Completed
Branch BUG-10381-asset-loading (0adce1)
by
unknown
25:08 queued 13:30
created
strategies/normalization/EE_Normalization_Strategy_Base.strategy.php 2 patches
Indentation   +47 added lines, -47 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
 
@@ -14,60 +14,60 @@  discard block
 block discarded – undo
14 14
 abstract class EE_Normalization_Strategy_Base extends EE_Form_Input_Strategy_Base
15 15
 {
16 16
 
17
-    /**
18
-     * Takes the sanitized value for the input and casts it into the correct PHP type.
19
-     * Eg, turns it into an int, float, string, boolean, datetime, etc. The validation
20
-     * strategy should be able to depend on the normalized value being of the correct type.
21
-     * If the normalized value passes validation, the normalized value is what other code
22
-     * will operate on. If the sanitized value cannot be normalized, this method should either
23
-     * add a validation error onto the input, or wrangle the input into a format that can be normalized
24
-     * (eg, for a date input, if the user enters "2014/100/100", you can either add an error stating
25
-     * "hey! 2014/100/100 is not a valid date!", or simply convert it into a valid date like "2014/12/31".
26
-     * For this case, I'd prefer the former. But there may be cases where you'd just rather correct it for them)
27
-     *
28
-     * @param string $value_to_normalize it should always be a string. If the input receives an array, then the
29
-     *                                   validation strategy should be called on array elements, not on the entire array
30
-     * @return mixed the normalized value
31
-     */
32
-    abstract public function normalize($value_to_normalize);
17
+	/**
18
+	 * Takes the sanitized value for the input and casts it into the correct PHP type.
19
+	 * Eg, turns it into an int, float, string, boolean, datetime, etc. The validation
20
+	 * strategy should be able to depend on the normalized value being of the correct type.
21
+	 * If the normalized value passes validation, the normalized value is what other code
22
+	 * will operate on. If the sanitized value cannot be normalized, this method should either
23
+	 * add a validation error onto the input, or wrangle the input into a format that can be normalized
24
+	 * (eg, for a date input, if the user enters "2014/100/100", you can either add an error stating
25
+	 * "hey! 2014/100/100 is not a valid date!", or simply convert it into a valid date like "2014/12/31".
26
+	 * For this case, I'd prefer the former. But there may be cases where you'd just rather correct it for them)
27
+	 *
28
+	 * @param string $value_to_normalize it should always be a string. If the input receives an array, then the
29
+	 *                                   validation strategy should be called on array elements, not on the entire array
30
+	 * @return mixed the normalized value
31
+	 */
32
+	abstract public function normalize($value_to_normalize);
33 33
 
34 34
 
35 35
 
36
-    /**
37
-     * Identical to normalize, except normalize_one() CANNOT be passed an array and
38
-     * never returns an array. Useful if the normalization strategy converts between arrays
39
-     *
40
-     * @param string $individual_item_to_normalize
41
-     * @return mixed
42
-     */
43
-    public function normalize_one($individual_item_to_normalize)
44
-    {
45
-        return $this->normalize($individual_item_to_normalize);
46
-    }
36
+	/**
37
+	 * Identical to normalize, except normalize_one() CANNOT be passed an array and
38
+	 * never returns an array. Useful if the normalization strategy converts between arrays
39
+	 *
40
+	 * @param string $individual_item_to_normalize
41
+	 * @return mixed
42
+	 */
43
+	public function normalize_one($individual_item_to_normalize)
44
+	{
45
+		return $this->normalize($individual_item_to_normalize);
46
+	}
47 47
 
48 48
 
49 49
 
50
-    /**
51
-     * Takes the normalized value (for an Yes_No_Input this could be TRUE or FALSE), and converts it into
52
-     * the value you would use in the html form (for a Yes_No_Input this could be '1' or '0').
53
-     *
54
-     * @param $normalized_value
55
-     * @return array|string the 'raw' value as used in the form, usually a string or array of strings.
56
-     */
57
-    abstract public function unnormalize($normalized_value);
50
+	/**
51
+	 * Takes the normalized value (for an Yes_No_Input this could be TRUE or FALSE), and converts it into
52
+	 * the value you would use in the html form (for a Yes_No_Input this could be '1' or '0').
53
+	 *
54
+	 * @param $normalized_value
55
+	 * @return array|string the 'raw' value as used in the form, usually a string or array of strings.
56
+	 */
57
+	abstract public function unnormalize($normalized_value);
58 58
 
59 59
 
60 60
 
61
-    /**
62
-     * Normally the same as unnormalize, except it CANNOT be passed an array and
63
-     * ALWAYS returns a string
64
-     *
65
-     * @param mixed $individual_item_to_unnormalize NOT an array
66
-     * @return string
67
-     */
68
-    public function unnormalize_one($individual_item_to_unnormalize)
69
-    {
70
-        return $this->unnormalize($individual_item_to_unnormalize);
71
-    }
61
+	/**
62
+	 * Normally the same as unnormalize, except it CANNOT be passed an array and
63
+	 * ALWAYS returns a string
64
+	 *
65
+	 * @param mixed $individual_item_to_unnormalize NOT an array
66
+	 * @return string
67
+	 */
68
+	public function unnormalize_one($individual_item_to_unnormalize)
69
+	{
70
+		return $this->unnormalize($individual_item_to_unnormalize);
71
+	}
72 72
 }
73 73
 // End of file EE_Normalization_Strategy_Base.strategy.php
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 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 4
 
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Int_Normalization.strategy.php 1 patch
Indentation   +75 added lines, -75 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
 
@@ -15,89 +15,89 @@  discard block
 block discarded – undo
15 15
 class EE_Int_Normalization extends EE_Normalization_Strategy_Base
16 16
 {
17 17
 
18
-    /*
18
+	/*
19 19
      * regex pattern that matches for the following:
20 20
      *      * optional negative sign
21 21
      *      * one or more digits
22 22
      */
23
-    const REGEX = '/^(-?)(\d+)(?:\.0+)?$/';
23
+	const REGEX = '/^(-?)(\d+)(?:\.0+)?$/';
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * @param string $value_to_normalize
29
-     * @return int|mixed|string
30
-     * @throws \EE_Validation_Error
31
-     */
32
-    public function normalize($value_to_normalize)
33
-    {
34
-        if ($value_to_normalize === null) {
35
-            return null;
36
-        }
37
-        if (is_int($value_to_normalize) || is_float($value_to_normalize)) {
38
-            return (int)$value_to_normalize;
39
-        }
40
-        if (! is_string($value_to_normalize)) {
41
-            throw new EE_Validation_Error(
42
-                sprintf(
43
-                    __('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
44
-                    print_r($value_to_normalize, true),
45
-                    gettype($value_to_normalize)
46
-                )
47
-            );
48
-        }
49
-        $value_to_normalize = filter_var(
50
-            $value_to_normalize,
51
-            FILTER_SANITIZE_NUMBER_FLOAT,
52
-            FILTER_FLAG_ALLOW_FRACTION
53
-        );
54
-        if ($value_to_normalize === '') {
55
-            return null;
56
-        }
57
-        $matches = array();
58
-        if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $matches)) {
59
-            if (count($matches) === 3) {
60
-                // if first match is the negative sign,
61
-                // then the number needs to be multiplied by -1 to remain negative
62
-                return $matches[1] === '-'
63
-                    ? (int)$matches[2] * -1
64
-                    : (int)$matches[2];
65
-            }
66
-        }
67
-        //find if this input has a int validation strategy
68
-        //in which case, use its message
69
-        $validation_error_message = null;
70
-        foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
71
-            if ($validation_strategy instanceof EE_Int_Validation_Strategy) {
72
-                $validation_error_message = $validation_strategy->get_validation_error_message();
73
-            }
74
-        }
75
-        //this really shouldn't ever happen because fields with a int normalization strategy
76
-        //should also have a int validation strategy, but in case it doesn't use the default
77
-        if (! $validation_error_message) {
78
-            $default_validation_strategy = new EE_Int_Validation_Strategy();
79
-            $validation_error_message = $default_validation_strategy->get_validation_error_message();
80
-        }
81
-        throw new EE_Validation_Error($validation_error_message, 'numeric_only');
82
-    }
27
+	/**
28
+	 * @param string $value_to_normalize
29
+	 * @return int|mixed|string
30
+	 * @throws \EE_Validation_Error
31
+	 */
32
+	public function normalize($value_to_normalize)
33
+	{
34
+		if ($value_to_normalize === null) {
35
+			return null;
36
+		}
37
+		if (is_int($value_to_normalize) || is_float($value_to_normalize)) {
38
+			return (int)$value_to_normalize;
39
+		}
40
+		if (! is_string($value_to_normalize)) {
41
+			throw new EE_Validation_Error(
42
+				sprintf(
43
+					__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
44
+					print_r($value_to_normalize, true),
45
+					gettype($value_to_normalize)
46
+				)
47
+			);
48
+		}
49
+		$value_to_normalize = filter_var(
50
+			$value_to_normalize,
51
+			FILTER_SANITIZE_NUMBER_FLOAT,
52
+			FILTER_FLAG_ALLOW_FRACTION
53
+		);
54
+		if ($value_to_normalize === '') {
55
+			return null;
56
+		}
57
+		$matches = array();
58
+		if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $matches)) {
59
+			if (count($matches) === 3) {
60
+				// if first match is the negative sign,
61
+				// then the number needs to be multiplied by -1 to remain negative
62
+				return $matches[1] === '-'
63
+					? (int)$matches[2] * -1
64
+					: (int)$matches[2];
65
+			}
66
+		}
67
+		//find if this input has a int validation strategy
68
+		//in which case, use its message
69
+		$validation_error_message = null;
70
+		foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
71
+			if ($validation_strategy instanceof EE_Int_Validation_Strategy) {
72
+				$validation_error_message = $validation_strategy->get_validation_error_message();
73
+			}
74
+		}
75
+		//this really shouldn't ever happen because fields with a int normalization strategy
76
+		//should also have a int validation strategy, but in case it doesn't use the default
77
+		if (! $validation_error_message) {
78
+			$default_validation_strategy = new EE_Int_Validation_Strategy();
79
+			$validation_error_message = $default_validation_strategy->get_validation_error_message();
80
+		}
81
+		throw new EE_Validation_Error($validation_error_message, 'numeric_only');
82
+	}
83 83
 
84 84
 
85 85
 
86
-    /**
87
-     * Converts the int into a string for use in teh html form
88
-     *
89
-     * @param int $normalized_value
90
-     * @return string
91
-     */
92
-    public function unnormalize($normalized_value)
93
-    {
94
-        if ($normalized_value === null || $normalized_value === '') {
95
-            return '';
96
-        }
97
-        if (empty($normalized_value)) {
98
-            return '0';
99
-        }
100
-        return "$normalized_value";
101
-    }
86
+	/**
87
+	 * Converts the int into a string for use in teh html form
88
+	 *
89
+	 * @param int $normalized_value
90
+	 * @return string
91
+	 */
92
+	public function unnormalize($normalized_value)
93
+	{
94
+		if ($normalized_value === null || $normalized_value === '') {
95
+			return '';
96
+		}
97
+		if (empty($normalized_value)) {
98
+			return '0';
99
+		}
100
+		return "$normalized_value";
101
+	}
102 102
 }
103 103
 // End of file EE_Int_Normalization.strategy.php
Please login to merge, or discard this patch.
core/db_models/fields/EE_Post_Content_Field.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -7,133 +7,133 @@
 block discarded – undo
7 7
  */
8 8
 class EE_Post_Content_Field extends EE_Text_Field_Base
9 9
 {
10
-    static protected $_added_the_content_basic_filters = false;
10
+	static protected $_added_the_content_basic_filters = false;
11 11
 
12
-    /**
13
-     * @param string $table_column
14
-     * @param string $nicename
15
-     * @param bool   $nullable
16
-     * @param null   $default_value
17
-     */
18
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
19
-    {
20
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
21
-        $this->setSchemaType('object');
22
-    }
12
+	/**
13
+	 * @param string $table_column
14
+	 * @param string $nicename
15
+	 * @param bool   $nullable
16
+	 * @param null   $default_value
17
+	 */
18
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
19
+	{
20
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
21
+		$this->setSchemaType('object');
22
+	}
23 23
 
24 24
 
25
-    /**
26
-     * removes all tags which a WP Post wouldn't allow in its content normally
27
-     *
28
-     * @param string $value
29
-     * @return string
30
-     */
31
-    function prepare_for_set($value)
32
-    {
33
-        if (! current_user_can('unfiltered_html')) {
34
-            $value = wp_kses("$value", wp_kses_allowed_html('post'));
35
-        }
36
-        return parent::prepare_for_set($value);
37
-    }
25
+	/**
26
+	 * removes all tags which a WP Post wouldn't allow in its content normally
27
+	 *
28
+	 * @param string $value
29
+	 * @return string
30
+	 */
31
+	function prepare_for_set($value)
32
+	{
33
+		if (! current_user_can('unfiltered_html')) {
34
+			$value = wp_kses("$value", wp_kses_allowed_html('post'));
35
+		}
36
+		return parent::prepare_for_set($value);
37
+	}
38 38
 
39
-    function prepare_for_set_from_db($value_found_in_db_for_model_object)
40
-    {
41
-        return $value_found_in_db_for_model_object;
42
-    }
39
+	function prepare_for_set_from_db($value_found_in_db_for_model_object)
40
+	{
41
+		return $value_found_in_db_for_model_object;
42
+	}
43 43
 
44 44
 
45 45
 
46
-    /**
47
-     * Runs the content through `the_content`, or if prepares the content for placing in a form input
48
-     * @param string $value_on_field_to_be_outputted
49
-     * @param string   $schema possible values: 'form_input' or null (if null, will run through 'the_content')
50
-     * @return string
51
-     * @throws EE_Error when WP_DEBUG is on and recursive calling is detected
52
-     */
53
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
54
-    {
55
-        switch($schema){
56
-            case 'form_input':
57
-                return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
58
-            case 'the_content':
46
+	/**
47
+	 * Runs the content through `the_content`, or if prepares the content for placing in a form input
48
+	 * @param string $value_on_field_to_be_outputted
49
+	 * @param string   $schema possible values: 'form_input' or null (if null, will run through 'the_content')
50
+	 * @return string
51
+	 * @throws EE_Error when WP_DEBUG is on and recursive calling is detected
52
+	 */
53
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
54
+	{
55
+		switch($schema){
56
+			case 'form_input':
57
+				return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
58
+			case 'the_content':
59 59
 
60
-                if(doing_filter( 'the_content')){
61
-                    if( defined('WP_DEBUG') && WP_DEBUG){
62
-                        throw new EE_Error(
63
-                            sprintf(
64
-                                esc_html__('You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.', 'event_espresso'),
65
-                                'EE_Post_Content_Field::prepare_for_pretty_echoing',
66
-                                '$schema',
67
-                                'the_content',
68
-                                'the_content_wp_core_only'
69
-                            )
70
-                        );
71
-                    } else {
72
-                        return $this->prepare_for_pretty_echoing($value_on_field_to_be_outputted, 'the_content_wp_core_only');
73
-                    }
74
-                }
75
-                return apply_filters(
76
-                    'the_content',
77
-                    parent::prepare_for_pretty_echoing(
78
-                        $value_on_field_to_be_outputted,
79
-                        $schema
80
-                    )
81
-                );
82
-            case 'the_content_wp_core_only':
83
-            default:
84
-                self::_ensure_filters_setup();
85
-                return apply_filters(
86
-                    'the_content_wp_core_only',
87
-                    parent::prepare_for_pretty_echoing(
88
-                        $value_on_field_to_be_outputted,
89
-                        $schema
90
-                    )
91
-                );
92
-        }
93
-    }
60
+				if(doing_filter( 'the_content')){
61
+					if( defined('WP_DEBUG') && WP_DEBUG){
62
+						throw new EE_Error(
63
+							sprintf(
64
+								esc_html__('You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.', 'event_espresso'),
65
+								'EE_Post_Content_Field::prepare_for_pretty_echoing',
66
+								'$schema',
67
+								'the_content',
68
+								'the_content_wp_core_only'
69
+							)
70
+						);
71
+					} else {
72
+						return $this->prepare_for_pretty_echoing($value_on_field_to_be_outputted, 'the_content_wp_core_only');
73
+					}
74
+				}
75
+				return apply_filters(
76
+					'the_content',
77
+					parent::prepare_for_pretty_echoing(
78
+						$value_on_field_to_be_outputted,
79
+						$schema
80
+					)
81
+				);
82
+			case 'the_content_wp_core_only':
83
+			default:
84
+				self::_ensure_filters_setup();
85
+				return apply_filters(
86
+					'the_content_wp_core_only',
87
+					parent::prepare_for_pretty_echoing(
88
+						$value_on_field_to_be_outputted,
89
+						$schema
90
+					)
91
+				);
92
+		}
93
+	}
94 94
 
95 95
 
96 96
 
97
-    /**
98
-     * Verifies we've setup the standard WP core filters on  'the_content_wp_core_only' filter
99
-     */
100
-    protected static function _ensure_filters_setup()
101
-    {
102
-        if( !self::$_added_the_content_basic_filters){
103
-            add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8);
104
-            add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8);
105
-            add_filter('the_content_wp_core_only', 'wptexturize', 10);
106
-            add_filter('the_content_wp_core_only', 'wpautop', 10);
107
-            add_filter('the_content_wp_core_only', 'shortcode_unautop', 10);
108
-            add_filter('the_content_wp_core_only', 'prepend_attachment', 10);
109
-            if(function_exists('wp_make_content_images_responsive')) {
110
-                add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10);
111
-            }
112
-            add_filter('the_content_wp_core_only', 'do_shortcode', 11);
113
-            add_filter('the_content_wp_core_only', 'convert_smilies', 20);
114
-            self::$_added_the_content_basic_filters = true;
115
-        }
116
-    }
97
+	/**
98
+	 * Verifies we've setup the standard WP core filters on  'the_content_wp_core_only' filter
99
+	 */
100
+	protected static function _ensure_filters_setup()
101
+	{
102
+		if( !self::$_added_the_content_basic_filters){
103
+			add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8);
104
+			add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8);
105
+			add_filter('the_content_wp_core_only', 'wptexturize', 10);
106
+			add_filter('the_content_wp_core_only', 'wpautop', 10);
107
+			add_filter('the_content_wp_core_only', 'shortcode_unautop', 10);
108
+			add_filter('the_content_wp_core_only', 'prepend_attachment', 10);
109
+			if(function_exists('wp_make_content_images_responsive')) {
110
+				add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10);
111
+			}
112
+			add_filter('the_content_wp_core_only', 'do_shortcode', 11);
113
+			add_filter('the_content_wp_core_only', 'convert_smilies', 20);
114
+			self::$_added_the_content_basic_filters = true;
115
+		}
116
+	}
117 117
 
118 118
 
119 119
 
120
-    public function getSchemaProperties()
121
-    {
122
-        return array(
123
-            'raw' => array(
124
-                'description' =>  sprintf(
125
-                    __('%s - the content as it exists in the database.', 'event_espresso'),
126
-                    $this->get_nicename()
127
-                ),
128
-                'type' => 'string'
129
-            ),
130
-            'rendered' => array(
131
-                'description' =>  sprintf(
132
-                    __('%s - the content rendered for display.', 'event_espresso'),
133
-                    $this->get_nicename()
134
-                ),
135
-                'type' => 'string'
136
-            )
137
-        );
138
-    }
120
+	public function getSchemaProperties()
121
+	{
122
+		return array(
123
+			'raw' => array(
124
+				'description' =>  sprintf(
125
+					__('%s - the content as it exists in the database.', 'event_espresso'),
126
+					$this->get_nicename()
127
+				),
128
+				'type' => 'string'
129
+			),
130
+			'rendered' => array(
131
+				'description' =>  sprintf(
132
+					__('%s - the content rendered for display.', 'event_espresso'),
133
+					$this->get_nicename()
134
+				),
135
+				'type' => 'string'
136
+			)
137
+		);
138
+	}
139 139
 }
140 140
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     function prepare_for_set($value)
32 32
     {
33
-        if (! current_user_can('unfiltered_html')) {
33
+        if ( ! current_user_can('unfiltered_html')) {
34 34
             $value = wp_kses("$value", wp_kses_allowed_html('post'));
35 35
         }
36 36
         return parent::prepare_for_set($value);
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
54 54
     {
55
-        switch($schema){
55
+        switch ($schema) {
56 56
             case 'form_input':
57 57
                 return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
58 58
             case 'the_content':
59 59
 
60
-                if(doing_filter( 'the_content')){
61
-                    if( defined('WP_DEBUG') && WP_DEBUG){
60
+                if (doing_filter('the_content')) {
61
+                    if (defined('WP_DEBUG') && WP_DEBUG) {
62 62
                         throw new EE_Error(
63 63
                             sprintf(
64 64
                                 esc_html__('You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.', 'event_espresso'),
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
      */
100 100
     protected static function _ensure_filters_setup()
101 101
     {
102
-        if( !self::$_added_the_content_basic_filters){
103
-            add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8);
104
-            add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8);
102
+        if ( ! self::$_added_the_content_basic_filters) {
103
+            add_filter('the_content_wp_core_only', array($GLOBALS['wp_embed'], 'run_shortcode'), 8);
104
+            add_filter('the_content_wp_core_only', array($GLOBALS['wp_embed'], 'autoembed'), 8);
105 105
             add_filter('the_content_wp_core_only', 'wptexturize', 10);
106 106
             add_filter('the_content_wp_core_only', 'wpautop', 10);
107 107
             add_filter('the_content_wp_core_only', 'shortcode_unautop', 10);
108 108
             add_filter('the_content_wp_core_only', 'prepend_attachment', 10);
109
-            if(function_exists('wp_make_content_images_responsive')) {
109
+            if (function_exists('wp_make_content_images_responsive')) {
110 110
                 add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10);
111 111
             }
112 112
             add_filter('the_content_wp_core_only', 'do_shortcode', 11);
Please login to merge, or discard this patch.
admin/extend/general_settings/Extend_General_Settings_Admin_Page.core.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -21,62 +21,62 @@  discard block
 block discarded – undo
21 21
 {
22 22
     
23 23
     
24
-    public function __construct($routing = true)
25
-    {
26
-        parent::__construct($routing);
27
-        define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/');
28
-    }
24
+	public function __construct($routing = true)
25
+	{
26
+		parent::__construct($routing);
27
+		define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/');
28
+	}
29 29
     
30 30
     
31
-    protected function _extend_page_config()
32
-    {
31
+	protected function _extend_page_config()
32
+	{
33 33
         
34
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings';
34
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings';
35 35
         
36
-        //filters and action hooks here
37
-        add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9);
38
-        add_filter('FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
39
-            array($this, 'update_debug_logging_options'), 10, 1);
36
+		//filters and action hooks here
37
+		add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9);
38
+		add_filter('FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
39
+			array($this, 'update_debug_logging_options'), 10, 1);
40 40
         
41
-    }
41
+	}
42 42
     
43 43
     
44 44
     
45
-    /*************        Logging Settings        *************/
45
+	/*************        Logging Settings        *************/
46 46
     
47
-    /**
48
-     * debug_logging_options
49
-     *
50
-     * @param array $template_args
51
-     *
52
-     * @return void
53
-     */
54
-    public function debug_logging_options($template_args = array())
55
-    {
56
-        $template_args['use_full_logging']   = EE_Registry::instance()->CFG->admin->use_full_logging;
57
-        $template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint(EE_Registry::instance()->CFG->admin->use_remote_logging) : false;
58
-        $template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url) && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url) ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : '';
59
-        $template                            = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php';
60
-        EEH_Template::display_template($template, $template_args);
61
-    }
47
+	/**
48
+	 * debug_logging_options
49
+	 *
50
+	 * @param array $template_args
51
+	 *
52
+	 * @return void
53
+	 */
54
+	public function debug_logging_options($template_args = array())
55
+	{
56
+		$template_args['use_full_logging']   = EE_Registry::instance()->CFG->admin->use_full_logging;
57
+		$template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint(EE_Registry::instance()->CFG->admin->use_remote_logging) : false;
58
+		$template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url) && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url) ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : '';
59
+		$template                            = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php';
60
+		EEH_Template::display_template($template, $template_args);
61
+	}
62 62
     
63 63
     
64
-    /**
65
-     * update_debug_logging_options
66
-     *
67
-     * @param array $admin_options
68
-     *
69
-     * @return array
70
-     */
71
-    public function update_debug_logging_options($admin_options = array())
72
-    {
73
-        $use_full_logging                = isset($this->_req_data['use_full_logging']) ? (bool)absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging;
74
-        $admin_options->use_full_logging = $use_full_logging;
75
-        $admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint($this->_req_data['use_remote_logging']) : $admin_options->use_remote_logging;
76
-        $admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw($this->_req_data['remote_logging_url']) : $admin_options->remote_logging_url;
64
+	/**
65
+	 * update_debug_logging_options
66
+	 *
67
+	 * @param array $admin_options
68
+	 *
69
+	 * @return array
70
+	 */
71
+	public function update_debug_logging_options($admin_options = array())
72
+	{
73
+		$use_full_logging                = isset($this->_req_data['use_full_logging']) ? (bool)absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging;
74
+		$admin_options->use_full_logging = $use_full_logging;
75
+		$admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint($this->_req_data['use_remote_logging']) : $admin_options->use_remote_logging;
76
+		$admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw($this->_req_data['remote_logging_url']) : $admin_options->remote_logging_url;
77 77
         
78
-        return $admin_options;
79
-    }
78
+		return $admin_options;
79
+	}
80 80
     
81 81
     
82 82
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
     public function __construct($routing = true)
25 25
     {
26 26
         parent::__construct($routing);
27
-        define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/');
27
+        define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'general_settings/templates/');
28 28
     }
29 29
     
30 30
     
31 31
     protected function _extend_page_config()
32 32
     {
33 33
         
34
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings';
34
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'general_settings';
35 35
         
36 36
         //filters and action hooks here
37 37
         add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         $template_args['use_full_logging']   = EE_Registry::instance()->CFG->admin->use_full_logging;
57 57
         $template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint(EE_Registry::instance()->CFG->admin->use_remote_logging) : false;
58 58
         $template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url) && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url) ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : '';
59
-        $template                            = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php';
59
+        $template                            = GEN_SET_CAF_TEMPLATE_PATH.'debug_log_settings.template.php';
60 60
         EEH_Template::display_template($template, $template_args);
61 61
     }
62 62
     
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function update_debug_logging_options($admin_options = array())
72 72
     {
73
-        $use_full_logging                = isset($this->_req_data['use_full_logging']) ? (bool)absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging;
73
+        $use_full_logging                = isset($this->_req_data['use_full_logging']) ? (bool) absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging;
74 74
         $admin_options->use_full_logging = $use_full_logging;
75 75
         $admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint($this->_req_data['use_remote_logging']) : $admin_options->use_remote_logging;
76 76
         $admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw($this->_req_data['remote_logging_url']) : $admin_options->remote_logging_url;
Please login to merge, or discard this patch.
core/services/collections/LooseCollection.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\exceptions\InvalidEntityException;
5 5
 
6 6
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('No direct script access allowed');
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -22,40 +22,40 @@  discard block
 block discarded – undo
22 22
 
23 23
 
24 24
 
25
-    /**
26
-     * setCollectionInterface
27
-     *
28
-     * @access protected
29
-     * @param  string $collection_interface
30
-     */
31
-    protected function setCollectionInterface($collection_interface )
32
-    {
33
-        $this->collection_interface = '';
34
-    }
25
+	/**
26
+	 * setCollectionInterface
27
+	 *
28
+	 * @access protected
29
+	 * @param  string $collection_interface
30
+	 */
31
+	protected function setCollectionInterface($collection_interface )
32
+	{
33
+		$this->collection_interface = '';
34
+	}
35 35
 
36 36
 
37 37
 
38
-    /**
39
-     * add
40
-     * attaches an object to the Collection
41
-     * and sets any supplied data associated with the current iterator entry
42
-     * by calling EE_Object_Collection::set_identifier()
43
-     *
44
-     * @access public
45
-     * @param  mixed $object
46
-     * @param  mixed $identifier
47
-     * @return bool
48
-     * @throws InvalidEntityException
49
-     */
50
-    public function add($object, $identifier = null)
51
-    {
52
-        if (! is_object($object)) {
53
-            throw new InvalidEntityException($object, 'object');
54
-        }
55
-        $this->attach($object);
56
-        $this->setIdentifier($object, $identifier);
57
-        return $this->contains($object);
58
-    }
38
+	/**
39
+	 * add
40
+	 * attaches an object to the Collection
41
+	 * and sets any supplied data associated with the current iterator entry
42
+	 * by calling EE_Object_Collection::set_identifier()
43
+	 *
44
+	 * @access public
45
+	 * @param  mixed $object
46
+	 * @param  mixed $identifier
47
+	 * @return bool
48
+	 * @throws InvalidEntityException
49
+	 */
50
+	public function add($object, $identifier = null)
51
+	{
52
+		if (! is_object($object)) {
53
+			throw new InvalidEntityException($object, 'object');
54
+		}
55
+		$this->attach($object);
56
+		$this->setIdentifier($object, $identifier);
57
+		return $this->contains($object);
58
+	}
59 59
 
60 60
 
61 61
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      * @access protected
29 29
      * @param  string $collection_interface
30 30
      */
31
-    protected function setCollectionInterface($collection_interface )
31
+    protected function setCollectionInterface($collection_interface)
32 32
     {
33 33
         $this->collection_interface = '';
34 34
     }
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function add($object, $identifier = null)
51 51
     {
52
-        if (! is_object($object)) {
52
+        if ( ! is_object($object)) {
53 53
             throw new InvalidEntityException($object, 'object');
54 54
         }
55 55
         $this->attach($object);
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 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,243 +40,243 @@  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.39.rc.007');
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.39.rc.007');
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
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
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
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.
core/services/shortcodes/EspressoShortcode.php 1 patch
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -20,198 +20,198 @@
 block discarded – undo
20 20
 abstract class EspressoShortcode implements ShortcodeInterface
21 21
 {
22 22
 
23
-    /**
24
-     * transient prefix
25
-     *
26
-     * @type string
27
-     */
28
-    const CACHE_TRANSIENT_PREFIX = 'ee_sc_';
29
-
30
-    /**
31
-     * @var PostRelatedCacheManager $cache_manager
32
-     */
33
-    private $cache_manager;
34
-
35
-
36
-
37
-    /**
38
-     * EspressoShortcode constructor
39
-     *
40
-     * @param PostRelatedCacheManager $cache_manager
41
-     */
42
-    public function __construct(PostRelatedCacheManager $cache_manager)
43
-    {
44
-        $this->cache_manager = $cache_manager;
45
-    }
46
-
47
-
48
-
49
-    /**
50
-     * enqueues scripts then processes the shortcode
51
-     *
52
-     * @param array $attributes
53
-     * @return string
54
-     * @throws \EE_Error
55
-     */
56
-    final public function processShortcodeCallback($attributes = array())
57
-    {
58
-        if ($this instanceof EnqueueAssetsInterface) {
59
-            if (is_admin()) {
60
-                $this->enqueueAdminScripts();
61
-            } else {
62
-                $this->enqueueScripts();
63
-            }
64
-        }
65
-        return $this->shortcodeContent(
66
-            $this->sanitizeAttributes((array)$attributes)
67
-        );
68
-    }
69
-
70
-
71
-
72
-    /**
73
-     * If shortcode caching is enabled for the shortcode,
74
-     * and cached results exist, then that will be returned
75
-     * else new content will be generated.
76
-     * If caching is enabled, then the new content will be cached for later.
77
-     *
78
-     * @param array $attributes
79
-     * @return mixed|string
80
-     * @throws \EE_Error
81
-     */
82
-    private function shortcodeContent(array $attributes)
83
-    {
84
-        $shortcode = $this;
85
-        $post_ID = $this->currentPostID();
86
-        // something like "SC_EVENTS-123"
87
-        $cache_ID = $this->shortcodeCacheID($post_ID);
88
-        $this->cache_manager->clearPostRelatedCacheOnUpdate($post_ID, $cache_ID);
89
-        return $this->cache_manager->get(
90
-            $cache_ID,
91
-            // serialized attributes
92
-            wp_json_encode($attributes),
93
-            // Closure for generating content if cache is expired
94
-            function () use ($shortcode, $attributes) {
95
-                return $shortcode->processShortcode($attributes);
96
-            },
97
-            // filterable cache expiration set by each shortcode
98
-            apply_filters(
99
-                'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration',
100
-                $this->cacheExpiration(),
101
-                $this->getTag(),
102
-                $this
103
-            )
104
-        );
105
-    }
106
-
107
-
108
-
109
-    /**
110
-     * @return int
111
-     * @throws \EE_Error
112
-     */
113
-    private function currentPostID()
114
-    {
115
-        // try to get EE_Event any way we can
116
-        $event = EEH_Event_View::get_event();
117
-        // then get some kind of ID
118
-        if ($event instanceof \EE_Event) {
119
-            $post_ID = $event->ID();
120
-        } else {
121
-            global $post;
122
-            $post_ID = $post->ID;
123
-        }
124
-        return $post_ID;
125
-    }
126
-
127
-
128
-
129
-    /**
130
-     * @param int $post_ID
131
-     * @return string
132
-     * @throws \EE_Error
133
-     */
134
-    private function shortcodeCacheID($post_ID)
135
-    {
136
-        $tag = str_replace('ESPRESSO_', '', $this->getTag());
137
-        return "SC_{$tag}-{$post_ID}";
138
-    }
139
-
140
-
141
-
142
-    /**
143
-     * array for defining custom attribute sanitization callbacks,
144
-     * where keys match keys in your attributes array,
145
-     * and values represent the sanitization function you wish to be applied to that attribute.
146
-     * So for example, if you had an integer attribute named "event_id"
147
-     * that you wanted to be sanitized using absint(),
148
-     * then you would return the following:
149
-     *      array('event_id' => 'absint')
150
-     * Entering 'skip_sanitization' for the callback value
151
-     * means that no sanitization will be applied
152
-     * on the assumption that the attribute
153
-     * will be sanitized at some point... right?
154
-     * You wouldn't pass around unsanitized attributes would you?
155
-     * That would be very Tom Foolery of you!!!
156
-     *
157
-     * @return array
158
-     */
159
-    protected function customAttributeSanitizationMap()
160
-    {
161
-        return array();
162
-    }
163
-
164
-
165
-
166
-    /**
167
-     * Performs basic sanitization on shortcode attributes
168
-     * Since incoming attributes from the shortcode usage in the WP editor will all be strings,
169
-     * most attributes will by default be sanitized using the sanitize_text_field() function.
170
-     * This can be overridden using the customAttributeSanitizationMap() method (see above),
171
-     * all other attributes would be sanitized using the defaults in the switch statement below
172
-     *
173
-     * @param array $attributes
174
-     * @return array
175
-     */
176
-    private function sanitizeAttributes(array $attributes)
177
-    {
178
-        $custom_sanitization = $this->customAttributeSanitizationMap();
179
-        foreach ($attributes as $key => $value) {
180
-            // is a custom sanitization callback specified ?
181
-            if (isset($custom_sanitization[$key])) {
182
-                $callback = $custom_sanitization[$key];
183
-                if ($callback === 'skip_sanitization') {
184
-                    $attributes[$key] = $value;
185
-                    continue;
186
-                }
187
-                if (function_exists($callback)) {
188
-                    $attributes[$key] = $callback($value);
189
-                    continue;
190
-                }
191
-            }
192
-            switch (true) {
193
-                case $value === null :
194
-                case is_int($value) :
195
-                case is_float($value) :
196
-                    // typical booleans
197
-                case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) :
198
-                    $attributes[$key] = $value;
199
-                    break;
200
-                case is_string($value) :
201
-                    $attributes[$key] = sanitize_text_field($value);
202
-                    break;
203
-                case is_array($value) :
204
-                    $attributes[$key] = $this->sanitizeAttributes($value);
205
-                    break;
206
-                default :
207
-                    // only remaining data types are Object and Resource
208
-                    // which are not allowed as shortcode attributes
209
-                    $attributes[$key] = null;
210
-                    break;
211
-            }
212
-        }
213
-        return $attributes;
214
-    }
23
+	/**
24
+	 * transient prefix
25
+	 *
26
+	 * @type string
27
+	 */
28
+	const CACHE_TRANSIENT_PREFIX = 'ee_sc_';
29
+
30
+	/**
31
+	 * @var PostRelatedCacheManager $cache_manager
32
+	 */
33
+	private $cache_manager;
34
+
35
+
36
+
37
+	/**
38
+	 * EspressoShortcode constructor
39
+	 *
40
+	 * @param PostRelatedCacheManager $cache_manager
41
+	 */
42
+	public function __construct(PostRelatedCacheManager $cache_manager)
43
+	{
44
+		$this->cache_manager = $cache_manager;
45
+	}
46
+
47
+
48
+
49
+	/**
50
+	 * enqueues scripts then processes the shortcode
51
+	 *
52
+	 * @param array $attributes
53
+	 * @return string
54
+	 * @throws \EE_Error
55
+	 */
56
+	final public function processShortcodeCallback($attributes = array())
57
+	{
58
+		if ($this instanceof EnqueueAssetsInterface) {
59
+			if (is_admin()) {
60
+				$this->enqueueAdminScripts();
61
+			} else {
62
+				$this->enqueueScripts();
63
+			}
64
+		}
65
+		return $this->shortcodeContent(
66
+			$this->sanitizeAttributes((array)$attributes)
67
+		);
68
+	}
69
+
70
+
71
+
72
+	/**
73
+	 * If shortcode caching is enabled for the shortcode,
74
+	 * and cached results exist, then that will be returned
75
+	 * else new content will be generated.
76
+	 * If caching is enabled, then the new content will be cached for later.
77
+	 *
78
+	 * @param array $attributes
79
+	 * @return mixed|string
80
+	 * @throws \EE_Error
81
+	 */
82
+	private function shortcodeContent(array $attributes)
83
+	{
84
+		$shortcode = $this;
85
+		$post_ID = $this->currentPostID();
86
+		// something like "SC_EVENTS-123"
87
+		$cache_ID = $this->shortcodeCacheID($post_ID);
88
+		$this->cache_manager->clearPostRelatedCacheOnUpdate($post_ID, $cache_ID);
89
+		return $this->cache_manager->get(
90
+			$cache_ID,
91
+			// serialized attributes
92
+			wp_json_encode($attributes),
93
+			// Closure for generating content if cache is expired
94
+			function () use ($shortcode, $attributes) {
95
+				return $shortcode->processShortcode($attributes);
96
+			},
97
+			// filterable cache expiration set by each shortcode
98
+			apply_filters(
99
+				'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration',
100
+				$this->cacheExpiration(),
101
+				$this->getTag(),
102
+				$this
103
+			)
104
+		);
105
+	}
106
+
107
+
108
+
109
+	/**
110
+	 * @return int
111
+	 * @throws \EE_Error
112
+	 */
113
+	private function currentPostID()
114
+	{
115
+		// try to get EE_Event any way we can
116
+		$event = EEH_Event_View::get_event();
117
+		// then get some kind of ID
118
+		if ($event instanceof \EE_Event) {
119
+			$post_ID = $event->ID();
120
+		} else {
121
+			global $post;
122
+			$post_ID = $post->ID;
123
+		}
124
+		return $post_ID;
125
+	}
126
+
127
+
128
+
129
+	/**
130
+	 * @param int $post_ID
131
+	 * @return string
132
+	 * @throws \EE_Error
133
+	 */
134
+	private function shortcodeCacheID($post_ID)
135
+	{
136
+		$tag = str_replace('ESPRESSO_', '', $this->getTag());
137
+		return "SC_{$tag}-{$post_ID}";
138
+	}
139
+
140
+
141
+
142
+	/**
143
+	 * array for defining custom attribute sanitization callbacks,
144
+	 * where keys match keys in your attributes array,
145
+	 * and values represent the sanitization function you wish to be applied to that attribute.
146
+	 * So for example, if you had an integer attribute named "event_id"
147
+	 * that you wanted to be sanitized using absint(),
148
+	 * then you would return the following:
149
+	 *      array('event_id' => 'absint')
150
+	 * Entering 'skip_sanitization' for the callback value
151
+	 * means that no sanitization will be applied
152
+	 * on the assumption that the attribute
153
+	 * will be sanitized at some point... right?
154
+	 * You wouldn't pass around unsanitized attributes would you?
155
+	 * That would be very Tom Foolery of you!!!
156
+	 *
157
+	 * @return array
158
+	 */
159
+	protected function customAttributeSanitizationMap()
160
+	{
161
+		return array();
162
+	}
163
+
164
+
165
+
166
+	/**
167
+	 * Performs basic sanitization on shortcode attributes
168
+	 * Since incoming attributes from the shortcode usage in the WP editor will all be strings,
169
+	 * most attributes will by default be sanitized using the sanitize_text_field() function.
170
+	 * This can be overridden using the customAttributeSanitizationMap() method (see above),
171
+	 * all other attributes would be sanitized using the defaults in the switch statement below
172
+	 *
173
+	 * @param array $attributes
174
+	 * @return array
175
+	 */
176
+	private function sanitizeAttributes(array $attributes)
177
+	{
178
+		$custom_sanitization = $this->customAttributeSanitizationMap();
179
+		foreach ($attributes as $key => $value) {
180
+			// is a custom sanitization callback specified ?
181
+			if (isset($custom_sanitization[$key])) {
182
+				$callback = $custom_sanitization[$key];
183
+				if ($callback === 'skip_sanitization') {
184
+					$attributes[$key] = $value;
185
+					continue;
186
+				}
187
+				if (function_exists($callback)) {
188
+					$attributes[$key] = $callback($value);
189
+					continue;
190
+				}
191
+			}
192
+			switch (true) {
193
+				case $value === null :
194
+				case is_int($value) :
195
+				case is_float($value) :
196
+					// typical booleans
197
+				case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) :
198
+					$attributes[$key] = $value;
199
+					break;
200
+				case is_string($value) :
201
+					$attributes[$key] = sanitize_text_field($value);
202
+					break;
203
+				case is_array($value) :
204
+					$attributes[$key] = $this->sanitizeAttributes($value);
205
+					break;
206
+				default :
207
+					// only remaining data types are Object and Resource
208
+					// which are not allowed as shortcode attributes
209
+					$attributes[$key] = null;
210
+					break;
211
+			}
212
+		}
213
+		return $attributes;
214
+	}
215 215
 
216 216
 
217 217
 
Please login to merge, or discard this patch.
core/services/shortcodes/ShortcodesManager.php 2 patches
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -33,210 +33,210 @@
 block discarded – undo
33 33
 class ShortcodesManager
34 34
 {
35 35
 
36
-    /**
37
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
38
-     */
39
-    private $legacy_shortcodes_manager;
40
-
41
-    /**
42
-     * @var ShortcodeInterface[] $shortcodes
43
-     */
44
-    private $shortcodes;
45
-
46
-
47
-
48
-    /**
49
-     * ShortcodesManager constructor
50
-     *
51
-     * @param LegacyShortcodesManager $legacy_shortcodes_manager
52
-     */
53
-    public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager) {
54
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
55
-        // assemble a list of installed and active shortcodes
56
-        add_action(
57
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
58
-            array($this, 'registerShortcodes'),
59
-            999
60
-        );
61
-        //  call add_shortcode() for all installed shortcodes
62
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes'));
63
-        // check content for shortcodes, the old way, and the more efficient new way
64
-        add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5);
65
-        add_action('get_header', array($this, 'getHeader'));
66
-    }
67
-
68
-
69
-
70
-    /**
71
-     * @return CollectionInterface|ShortcodeInterface[]
72
-     * @throws InvalidIdentifierException
73
-     * @throws InvalidInterfaceException
74
-     * @throws InvalidFilePathException
75
-     * @throws InvalidEntityException
76
-     * @throws InvalidDataTypeException
77
-     * @throws InvalidClassException
78
-     */
79
-    public function getShortcodes()
80
-    {
81
-        if ( ! $this->shortcodes instanceof CollectionInterface) {
82
-            $this->shortcodes = $this->loadShortcodesCollection();
83
-        }
84
-        return $this->shortcodes;
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     * @return CollectionInterface|ShortcodeInterface[]
91
-     * @throws InvalidIdentifierException
92
-     * @throws InvalidInterfaceException
93
-     * @throws InvalidFilePathException
94
-     * @throws InvalidEntityException
95
-     * @throws InvalidDataTypeException
96
-     * @throws InvalidClassException
97
-     */
98
-    protected function loadShortcodesCollection()
99
-    {
100
-        $loader = new CollectionLoader(
101
-            new CollectionDetails(
102
-            // collection name
103
-                'shortcodes',
104
-                // collection interface
105
-                'EventEspresso\core\services\shortcodes\ShortcodeInterface',
106
-                // FQCNs for classes to add (all classes within that namespace will be loaded)
107
-                array('EventEspresso\core\domain\entities\shortcodes'),
108
-                // filepaths to classes to add
109
-                array(),
110
-                // filemask to use if parsing folder for files to add
111
-                '',
112
-                // what to use as identifier for collection entities
113
-                // using CLASS NAME prevents duplicates (works like a singleton)
114
-                CollectionDetails::ID_CLASS_NAME
115
-            )
116
-        );
117
-        return $loader->getCollection();
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * @return void
124
-     * @throws DomainException
125
-     * @throws InvalidInterfaceException
126
-     * @throws InvalidIdentifierException
127
-     * @throws InvalidFilePathException
128
-     * @throws InvalidEntityException
129
-     * @throws InvalidDataTypeException
130
-     * @throws InvalidClassException
131
-     */
132
-    public function registerShortcodes()
133
-    {
134
-        try {
135
-            $this->shortcodes = apply_filters(
136
-                'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
137
-                $this->getShortcodes()
138
-            );
139
-            if (! $this->shortcodes instanceof CollectionInterface) {
140
-                throw new InvalidEntityException(
141
-                    $this->shortcodes,
142
-                    'CollectionInterface',
143
-                    sprintf(
144
-                        esc_html__(
145
-                            'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
146
-                            'event_espresso'
147
-                        ),
148
-                        is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
149
-                    )
150
-                );
151
-            }
152
-            $this->legacy_shortcodes_manager->registerShortcodes();
153
-        } catch (Exception $exception) {
154
-            new ExceptionStackTraceDisplay($exception);
155
-        }
156
-    }
157
-
158
-
159
-
160
-    /**
161
-     * @return void
162
-     */
163
-    public function addShortcodes()
164
-    {
165
-        try {
166
-            // cycle thru shortcode folders
167
-            foreach ($this->shortcodes as $shortcode) {
168
-                /** @var ShortcodeInterface $shortcode */
169
-                if ( $shortcode instanceof EnqueueAssetsInterface) {
170
-                    add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10);
171
-                    add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11);
172
-                }
173
-                // add_shortcode() if it has not already been added
174
-                if ( ! shortcode_exists($shortcode->getTag())) {
175
-                    add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback'));
176
-                }
177
-            }
178
-            $this->legacy_shortcodes_manager->addShortcodes();
179
-        } catch (Exception $exception) {
180
-            new ExceptionStackTraceDisplay($exception);
181
-        }
182
-    }
183
-
184
-
185
-
186
-    /**
187
-     * callback for the WP "get_header" hook point
188
-     * checks posts for EE shortcodes, and initializes them,
189
-     * then toggles filter switch that loads core default assets
190
-     *
191
-     * @return void
192
-     */
193
-    public function getHeader()
194
-    {
195
-        global $wp_query;
196
-        if (empty($wp_query->posts)) {
197
-            return;
198
-        }
199
-        $load_assets = false;
200
-        // array of posts displayed in current request
201
-        $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts);
202
-        foreach ($posts as $post) {
203
-            // now check post content and excerpt for EE shortcodes
204
-            $load_assets = $this->parseContentForShortcodes($post->post_content)
205
-                ? true
206
-                : $load_assets;
207
-        }
208
-        if ($load_assets) {
209
-            $this->legacy_shortcodes_manager->registry()->REQ->set_espresso_page(true);
210
-            add_filter('FHEE_load_css', '__return_true');
211
-            add_filter('FHEE_load_js', '__return_true');
212
-        }
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     * checks supplied content against list of shortcodes,
219
-     * then initializes any found shortcodes, and returns true.
220
-     * returns false if no shortcodes found.
221
-     *
222
-     * @param string $content
223
-     * @return bool
224
-     */
225
-    public function parseContentForShortcodes($content)
226
-    {
227
-        $has_shortcode = false;
228
-        if(empty($this->shortcodes)){
229
-            return $has_shortcode;
230
-        }
231
-        foreach ($this->shortcodes as $shortcode) {
232
-            /** @var ShortcodeInterface $shortcode */
233
-            if (has_shortcode($content, $shortcode->getTag())) {
234
-                $shortcode->initializeShortcode();
235
-                $has_shortcode = true;
236
-            }
237
-        }
238
-        return $has_shortcode;
239
-    }
36
+	/**
37
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
38
+	 */
39
+	private $legacy_shortcodes_manager;
40
+
41
+	/**
42
+	 * @var ShortcodeInterface[] $shortcodes
43
+	 */
44
+	private $shortcodes;
45
+
46
+
47
+
48
+	/**
49
+	 * ShortcodesManager constructor
50
+	 *
51
+	 * @param LegacyShortcodesManager $legacy_shortcodes_manager
52
+	 */
53
+	public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager) {
54
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
55
+		// assemble a list of installed and active shortcodes
56
+		add_action(
57
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
58
+			array($this, 'registerShortcodes'),
59
+			999
60
+		);
61
+		//  call add_shortcode() for all installed shortcodes
62
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes'));
63
+		// check content for shortcodes, the old way, and the more efficient new way
64
+		add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5);
65
+		add_action('get_header', array($this, 'getHeader'));
66
+	}
67
+
68
+
69
+
70
+	/**
71
+	 * @return CollectionInterface|ShortcodeInterface[]
72
+	 * @throws InvalidIdentifierException
73
+	 * @throws InvalidInterfaceException
74
+	 * @throws InvalidFilePathException
75
+	 * @throws InvalidEntityException
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws InvalidClassException
78
+	 */
79
+	public function getShortcodes()
80
+	{
81
+		if ( ! $this->shortcodes instanceof CollectionInterface) {
82
+			$this->shortcodes = $this->loadShortcodesCollection();
83
+		}
84
+		return $this->shortcodes;
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 * @return CollectionInterface|ShortcodeInterface[]
91
+	 * @throws InvalidIdentifierException
92
+	 * @throws InvalidInterfaceException
93
+	 * @throws InvalidFilePathException
94
+	 * @throws InvalidEntityException
95
+	 * @throws InvalidDataTypeException
96
+	 * @throws InvalidClassException
97
+	 */
98
+	protected function loadShortcodesCollection()
99
+	{
100
+		$loader = new CollectionLoader(
101
+			new CollectionDetails(
102
+			// collection name
103
+				'shortcodes',
104
+				// collection interface
105
+				'EventEspresso\core\services\shortcodes\ShortcodeInterface',
106
+				// FQCNs for classes to add (all classes within that namespace will be loaded)
107
+				array('EventEspresso\core\domain\entities\shortcodes'),
108
+				// filepaths to classes to add
109
+				array(),
110
+				// filemask to use if parsing folder for files to add
111
+				'',
112
+				// what to use as identifier for collection entities
113
+				// using CLASS NAME prevents duplicates (works like a singleton)
114
+				CollectionDetails::ID_CLASS_NAME
115
+			)
116
+		);
117
+		return $loader->getCollection();
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * @return void
124
+	 * @throws DomainException
125
+	 * @throws InvalidInterfaceException
126
+	 * @throws InvalidIdentifierException
127
+	 * @throws InvalidFilePathException
128
+	 * @throws InvalidEntityException
129
+	 * @throws InvalidDataTypeException
130
+	 * @throws InvalidClassException
131
+	 */
132
+	public function registerShortcodes()
133
+	{
134
+		try {
135
+			$this->shortcodes = apply_filters(
136
+				'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
137
+				$this->getShortcodes()
138
+			);
139
+			if (! $this->shortcodes instanceof CollectionInterface) {
140
+				throw new InvalidEntityException(
141
+					$this->shortcodes,
142
+					'CollectionInterface',
143
+					sprintf(
144
+						esc_html__(
145
+							'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
146
+							'event_espresso'
147
+						),
148
+						is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
149
+					)
150
+				);
151
+			}
152
+			$this->legacy_shortcodes_manager->registerShortcodes();
153
+		} catch (Exception $exception) {
154
+			new ExceptionStackTraceDisplay($exception);
155
+		}
156
+	}
157
+
158
+
159
+
160
+	/**
161
+	 * @return void
162
+	 */
163
+	public function addShortcodes()
164
+	{
165
+		try {
166
+			// cycle thru shortcode folders
167
+			foreach ($this->shortcodes as $shortcode) {
168
+				/** @var ShortcodeInterface $shortcode */
169
+				if ( $shortcode instanceof EnqueueAssetsInterface) {
170
+					add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10);
171
+					add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11);
172
+				}
173
+				// add_shortcode() if it has not already been added
174
+				if ( ! shortcode_exists($shortcode->getTag())) {
175
+					add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback'));
176
+				}
177
+			}
178
+			$this->legacy_shortcodes_manager->addShortcodes();
179
+		} catch (Exception $exception) {
180
+			new ExceptionStackTraceDisplay($exception);
181
+		}
182
+	}
183
+
184
+
185
+
186
+	/**
187
+	 * callback for the WP "get_header" hook point
188
+	 * checks posts for EE shortcodes, and initializes them,
189
+	 * then toggles filter switch that loads core default assets
190
+	 *
191
+	 * @return void
192
+	 */
193
+	public function getHeader()
194
+	{
195
+		global $wp_query;
196
+		if (empty($wp_query->posts)) {
197
+			return;
198
+		}
199
+		$load_assets = false;
200
+		// array of posts displayed in current request
201
+		$posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts);
202
+		foreach ($posts as $post) {
203
+			// now check post content and excerpt for EE shortcodes
204
+			$load_assets = $this->parseContentForShortcodes($post->post_content)
205
+				? true
206
+				: $load_assets;
207
+		}
208
+		if ($load_assets) {
209
+			$this->legacy_shortcodes_manager->registry()->REQ->set_espresso_page(true);
210
+			add_filter('FHEE_load_css', '__return_true');
211
+			add_filter('FHEE_load_js', '__return_true');
212
+		}
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 * checks supplied content against list of shortcodes,
219
+	 * then initializes any found shortcodes, and returns true.
220
+	 * returns false if no shortcodes found.
221
+	 *
222
+	 * @param string $content
223
+	 * @return bool
224
+	 */
225
+	public function parseContentForShortcodes($content)
226
+	{
227
+		$has_shortcode = false;
228
+		if(empty($this->shortcodes)){
229
+			return $has_shortcode;
230
+		}
231
+		foreach ($this->shortcodes as $shortcode) {
232
+			/** @var ShortcodeInterface $shortcode */
233
+			if (has_shortcode($content, $shortcode->getTag())) {
234
+				$shortcode->initializeShortcode();
235
+				$has_shortcode = true;
236
+			}
237
+		}
238
+		return $has_shortcode;
239
+	}
240 240
 
241 241
 }
242 242
 // End of file ShortcodesManager.php
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
137 137
                 $this->getShortcodes()
138 138
             );
139
-            if (! $this->shortcodes instanceof CollectionInterface) {
139
+            if ( ! $this->shortcodes instanceof CollectionInterface) {
140 140
                 throw new InvalidEntityException(
141 141
                     $this->shortcodes,
142 142
                     'CollectionInterface',
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
             // cycle thru shortcode folders
167 167
             foreach ($this->shortcodes as $shortcode) {
168 168
                 /** @var ShortcodeInterface $shortcode */
169
-                if ( $shortcode instanceof EnqueueAssetsInterface) {
169
+                if ($shortcode instanceof EnqueueAssetsInterface) {
170 170
                     add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10);
171 171
                     add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11);
172 172
                 }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     public function parseContentForShortcodes($content)
226 226
     {
227 227
         $has_shortcode = false;
228
-        if(empty($this->shortcodes)){
228
+        if (empty($this->shortcodes)) {
229 229
             return $has_shortcode;
230 230
         }
231 231
         foreach ($this->shortcodes as $shortcode) {
Please login to merge, or discard this patch.