@@ -7,129 +7,129 @@ |
||
7 | 7 | class EE_Post_Content_Field extends EE_Text_Field_Base |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * @param string $table_column |
|
12 | - * @param string $nicename |
|
13 | - * @param bool $nullable |
|
14 | - * @param null $default_value |
|
15 | - */ |
|
16 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
17 | - { |
|
18 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
19 | - $this->setSchemaType('object'); |
|
20 | - } |
|
10 | + /** |
|
11 | + * @param string $table_column |
|
12 | + * @param string $nicename |
|
13 | + * @param bool $nullable |
|
14 | + * @param null $default_value |
|
15 | + */ |
|
16 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
17 | + { |
|
18 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
19 | + $this->setSchemaType('object'); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * removes all tags which a WP Post wouldn't allow in its content normally |
|
25 | - * |
|
26 | - * @param string $value |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function prepare_for_set($value) |
|
30 | - { |
|
31 | - if (! current_user_can('unfiltered_html')) { |
|
32 | - $value = wp_kses("$value", wp_kses_allowed_html('post')); |
|
33 | - } |
|
34 | - return parent::prepare_for_set($value); |
|
35 | - } |
|
23 | + /** |
|
24 | + * removes all tags which a WP Post wouldn't allow in its content normally |
|
25 | + * |
|
26 | + * @param string $value |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function prepare_for_set($value) |
|
30 | + { |
|
31 | + if (! current_user_can('unfiltered_html')) { |
|
32 | + $value = wp_kses("$value", wp_kses_allowed_html('post')); |
|
33 | + } |
|
34 | + return parent::prepare_for_set($value); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Runs the content through `the_content`, or if prepares the content for placing in a form input |
|
41 | - * @param string $value_on_field_to_be_outputted |
|
42 | - * @param string $schema possible values: 'form_input' or null (if null, will run through 'the_content') |
|
43 | - * @return string |
|
44 | - * @throws EE_Error when WP_DEBUG is on and recursive calling is detected |
|
45 | - */ |
|
46 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
47 | - { |
|
48 | - switch ($schema) { |
|
49 | - case 'form_input': |
|
50 | - return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
51 | - case 'the_content': |
|
52 | - if (doing_filter('the_content')) { |
|
53 | - if (defined('WP_DEBUG') && WP_DEBUG) { |
|
54 | - throw new EE_Error( |
|
55 | - sprintf( |
|
56 | - 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'), |
|
57 | - 'EE_Post_Content_Field::prepare_for_pretty_echoing', |
|
58 | - '$schema', |
|
59 | - 'the_content', |
|
60 | - 'the_content_wp_core_only' |
|
61 | - ) |
|
62 | - ); |
|
63 | - } else { |
|
64 | - return $this->prepare_for_pretty_echoing($value_on_field_to_be_outputted, 'the_content_wp_core_only'); |
|
65 | - } |
|
66 | - } |
|
67 | - return apply_filters( |
|
68 | - 'the_content', |
|
69 | - parent::prepare_for_pretty_echoing( |
|
70 | - $value_on_field_to_be_outputted, |
|
71 | - $schema |
|
72 | - ) |
|
73 | - ); |
|
74 | - case 'the_content_wp_core_only': |
|
75 | - default: |
|
76 | - self::_setup_the_content_wp_core_only_filters(); |
|
77 | - $return_value = apply_filters( |
|
78 | - 'the_content_wp_core_only', |
|
79 | - parent::prepare_for_pretty_echoing( |
|
80 | - $value_on_field_to_be_outputted, |
|
81 | - $schema |
|
82 | - ) |
|
83 | - ); |
|
84 | - // ya know what? adding these filters is super fast. Let's just |
|
85 | - // avoid needing to maintain global state and set this up as-needed |
|
86 | - remove_all_filters('the_content_wp_core_only'); |
|
87 | - do_action('AHEE__EE_Post_Content_Field__prepare_for_pretty_echoing__the_content_wp_core_only__done'); |
|
88 | - return $return_value; |
|
89 | - } |
|
90 | - } |
|
39 | + /** |
|
40 | + * Runs the content through `the_content`, or if prepares the content for placing in a form input |
|
41 | + * @param string $value_on_field_to_be_outputted |
|
42 | + * @param string $schema possible values: 'form_input' or null (if null, will run through 'the_content') |
|
43 | + * @return string |
|
44 | + * @throws EE_Error when WP_DEBUG is on and recursive calling is detected |
|
45 | + */ |
|
46 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
47 | + { |
|
48 | + switch ($schema) { |
|
49 | + case 'form_input': |
|
50 | + return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
51 | + case 'the_content': |
|
52 | + if (doing_filter('the_content')) { |
|
53 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
54 | + throw new EE_Error( |
|
55 | + sprintf( |
|
56 | + 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'), |
|
57 | + 'EE_Post_Content_Field::prepare_for_pretty_echoing', |
|
58 | + '$schema', |
|
59 | + 'the_content', |
|
60 | + 'the_content_wp_core_only' |
|
61 | + ) |
|
62 | + ); |
|
63 | + } else { |
|
64 | + return $this->prepare_for_pretty_echoing($value_on_field_to_be_outputted, 'the_content_wp_core_only'); |
|
65 | + } |
|
66 | + } |
|
67 | + return apply_filters( |
|
68 | + 'the_content', |
|
69 | + parent::prepare_for_pretty_echoing( |
|
70 | + $value_on_field_to_be_outputted, |
|
71 | + $schema |
|
72 | + ) |
|
73 | + ); |
|
74 | + case 'the_content_wp_core_only': |
|
75 | + default: |
|
76 | + self::_setup_the_content_wp_core_only_filters(); |
|
77 | + $return_value = apply_filters( |
|
78 | + 'the_content_wp_core_only', |
|
79 | + parent::prepare_for_pretty_echoing( |
|
80 | + $value_on_field_to_be_outputted, |
|
81 | + $schema |
|
82 | + ) |
|
83 | + ); |
|
84 | + // ya know what? adding these filters is super fast. Let's just |
|
85 | + // avoid needing to maintain global state and set this up as-needed |
|
86 | + remove_all_filters('the_content_wp_core_only'); |
|
87 | + do_action('AHEE__EE_Post_Content_Field__prepare_for_pretty_echoing__the_content_wp_core_only__done'); |
|
88 | + return $return_value; |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * Verifies we've setup the standard WP core filters on 'the_content_wp_core_only' filter |
|
96 | - */ |
|
97 | - protected static function _setup_the_content_wp_core_only_filters() |
|
98 | - { |
|
99 | - add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8); |
|
100 | - add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8); |
|
101 | - add_filter('the_content_wp_core_only', 'wptexturize', 10); |
|
102 | - add_filter('the_content_wp_core_only', 'wpautop', 10); |
|
103 | - add_filter('the_content_wp_core_only', 'shortcode_unautop', 10); |
|
104 | - add_filter('the_content_wp_core_only', 'prepend_attachment', 10); |
|
105 | - if (function_exists('wp_filter_content_tags')) { |
|
106 | - add_filter('the_content_wp_core_only', 'wp_filter_content_tags', 10); |
|
107 | - } elseif (function_exists('wp_make_content_images_responsive')) { |
|
108 | - add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10); |
|
109 | - } |
|
110 | - add_filter('the_content_wp_core_only', 'do_shortcode', 11); |
|
111 | - add_filter('the_content_wp_core_only', 'convert_smilies', 20); |
|
112 | - } |
|
94 | + /** |
|
95 | + * Verifies we've setup the standard WP core filters on 'the_content_wp_core_only' filter |
|
96 | + */ |
|
97 | + protected static function _setup_the_content_wp_core_only_filters() |
|
98 | + { |
|
99 | + add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8); |
|
100 | + add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8); |
|
101 | + add_filter('the_content_wp_core_only', 'wptexturize', 10); |
|
102 | + add_filter('the_content_wp_core_only', 'wpautop', 10); |
|
103 | + add_filter('the_content_wp_core_only', 'shortcode_unautop', 10); |
|
104 | + add_filter('the_content_wp_core_only', 'prepend_attachment', 10); |
|
105 | + if (function_exists('wp_filter_content_tags')) { |
|
106 | + add_filter('the_content_wp_core_only', 'wp_filter_content_tags', 10); |
|
107 | + } elseif (function_exists('wp_make_content_images_responsive')) { |
|
108 | + add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10); |
|
109 | + } |
|
110 | + add_filter('the_content_wp_core_only', 'do_shortcode', 11); |
|
111 | + add_filter('the_content_wp_core_only', 'convert_smilies', 20); |
|
112 | + } |
|
113 | 113 | |
114 | 114 | |
115 | 115 | |
116 | - public function getSchemaProperties() |
|
117 | - { |
|
118 | - return array( |
|
119 | - 'raw' => array( |
|
120 | - 'description' => sprintf( |
|
121 | - __('%s - the content as it exists in the database.', 'event_espresso'), |
|
122 | - $this->get_nicename() |
|
123 | - ), |
|
124 | - 'type' => 'string' |
|
125 | - ), |
|
126 | - 'rendered' => array( |
|
127 | - 'description' => sprintf( |
|
128 | - __('%s - the content rendered for display.', 'event_espresso'), |
|
129 | - $this->get_nicename() |
|
130 | - ), |
|
131 | - 'type' => 'string' |
|
132 | - ) |
|
133 | - ); |
|
134 | - } |
|
116 | + public function getSchemaProperties() |
|
117 | + { |
|
118 | + return array( |
|
119 | + 'raw' => array( |
|
120 | + 'description' => sprintf( |
|
121 | + __('%s - the content as it exists in the database.', 'event_espresso'), |
|
122 | + $this->get_nicename() |
|
123 | + ), |
|
124 | + 'type' => 'string' |
|
125 | + ), |
|
126 | + 'rendered' => array( |
|
127 | + 'description' => sprintf( |
|
128 | + __('%s - the content rendered for display.', 'event_espresso'), |
|
129 | + $this->get_nicename() |
|
130 | + ), |
|
131 | + 'type' => 'string' |
|
132 | + ) |
|
133 | + ); |
|
134 | + } |
|
135 | 135 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - 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 | - ); ?> |
|
52 | + 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 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
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.6.2'); |
|
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 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.7.rc.036'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.7.rc.036'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
41 | + if ( ! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | 42 | /** |
43 | 43 | * espresso_duplicate_plugin_error |
44 | 44 | * displays if more than one version of EE is activated at the same time |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
63 | 63 | } else { |
64 | 64 | define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | 66 | /** |
67 | 67 | * espresso_minimum_php_version_error |
68 | 68 | * |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | |
117 | 117 | register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
119 | + require_once __DIR__.'/core/bootstrap_espresso.php'; |
|
120 | 120 | bootstrap_espresso(); |
121 | 121 | } |
122 | 122 | } |
123 | -if (! function_exists('espresso_deactivate_plugin')) { |
|
123 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
124 | 124 | /** |
125 | 125 | * deactivate_plugin |
126 | 126 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | */ |
132 | 132 | function espresso_deactivate_plugin($plugin_basename = '') |
133 | 133 | { |
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
134 | + if ( ! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
136 | 136 | } |
137 | 137 | unset($_GET['activate'], $_REQUEST['activate']); |
138 | 138 | deactivate_plugins($plugin_basename); |