@@ -5,51 +5,51 @@ |
||
5 | 5 | * it does not override any existing definition of the function in WP. |
6 | 6 | */ |
7 | 7 | if ( ! function_exists( 'get_preview_post_link' ) ) { |
8 | - /** |
|
9 | - * Function was added in WordPress 4.4.0 |
|
10 | - * @param null $post |
|
11 | - * @param array $query_args |
|
12 | - * @param string $preview_link |
|
13 | - * @return mixed |
|
14 | - */ |
|
15 | - function get_preview_post_link($post = null, $query_args = array(), $preview_link = '') |
|
16 | - { |
|
17 | - $post = get_post($post); |
|
18 | - if (! $post) { |
|
19 | - return ''; |
|
20 | - } |
|
8 | + /** |
|
9 | + * Function was added in WordPress 4.4.0 |
|
10 | + * @param null $post |
|
11 | + * @param array $query_args |
|
12 | + * @param string $preview_link |
|
13 | + * @return mixed |
|
14 | + */ |
|
15 | + function get_preview_post_link($post = null, $query_args = array(), $preview_link = '') |
|
16 | + { |
|
17 | + $post = get_post($post); |
|
18 | + if (! $post) { |
|
19 | + return ''; |
|
20 | + } |
|
21 | 21 | |
22 | - $post_type_object = get_post_type_object($post->post_type); |
|
23 | - if (is_post_type_viewable($post_type_object)) { |
|
24 | - if (! $preview_link) { |
|
25 | - $preview_link = set_url_scheme(get_permalink($post)); |
|
26 | - } |
|
22 | + $post_type_object = get_post_type_object($post->post_type); |
|
23 | + if (is_post_type_viewable($post_type_object)) { |
|
24 | + if (! $preview_link) { |
|
25 | + $preview_link = set_url_scheme(get_permalink($post)); |
|
26 | + } |
|
27 | 27 | |
28 | - $query_args['preview'] = 'true'; |
|
29 | - $preview_link = add_query_arg($query_args, $preview_link); |
|
30 | - } |
|
28 | + $query_args['preview'] = 'true'; |
|
29 | + $preview_link = add_query_arg($query_args, $preview_link); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Filters the URL used for a post preview. |
|
34 | - * |
|
35 | - * @since 2.0.5 |
|
36 | - * @since 4.0.0 Added the `$post` parameter. |
|
37 | - * @param string $preview_link URL used for the post preview. |
|
38 | - * @param WP_Post $post Post object. |
|
39 | - */ |
|
40 | - return apply_filters('preview_post_link', $preview_link, $post); |
|
41 | - } |
|
32 | + /** |
|
33 | + * Filters the URL used for a post preview. |
|
34 | + * |
|
35 | + * @since 2.0.5 |
|
36 | + * @since 4.0.0 Added the `$post` parameter. |
|
37 | + * @param string $preview_link URL used for the post preview. |
|
38 | + * @param WP_Post $post Post object. |
|
39 | + */ |
|
40 | + return apply_filters('preview_post_link', $preview_link, $post); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | if ( ! function_exists( 'is_post_type_viewable' ) ) { |
45 | - function is_post_type_viewable( $post_type ) { |
|
46 | - if ( is_scalar( $post_type ) ) { |
|
47 | - $post_type = get_post_type_object( $post_type ); |
|
48 | - if ( ! $post_type ) { |
|
49 | - return false; |
|
50 | - } |
|
51 | - } |
|
45 | + function is_post_type_viewable( $post_type ) { |
|
46 | + if ( is_scalar( $post_type ) ) { |
|
47 | + $post_type = get_post_type_object( $post_type ); |
|
48 | + if ( ! $post_type ) { |
|
49 | + return false; |
|
50 | + } |
|
51 | + } |
|
52 | 52 | |
53 | - return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public ); |
|
54 | - } |
|
53 | + return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public ); |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * Note: this file should only be required right before calling the function the shim is for. This is to ensure that |
5 | 5 | * it does not override any existing definition of the function in WP. |
6 | 6 | */ |
7 | -if ( ! function_exists( 'get_preview_post_link' ) ) { |
|
7 | +if ( ! function_exists('get_preview_post_link')) { |
|
8 | 8 | /** |
9 | 9 | * Function was added in WordPress 4.4.0 |
10 | 10 | * @param null $post |
@@ -15,13 +15,13 @@ discard block |
||
15 | 15 | function get_preview_post_link($post = null, $query_args = array(), $preview_link = '') |
16 | 16 | { |
17 | 17 | $post = get_post($post); |
18 | - if (! $post) { |
|
18 | + if ( ! $post) { |
|
19 | 19 | return ''; |
20 | 20 | } |
21 | 21 | |
22 | 22 | $post_type_object = get_post_type_object($post->post_type); |
23 | 23 | if (is_post_type_viewable($post_type_object)) { |
24 | - if (! $preview_link) { |
|
24 | + if ( ! $preview_link) { |
|
25 | 25 | $preview_link = set_url_scheme(get_permalink($post)); |
26 | 26 | } |
27 | 27 | |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | -if ( ! function_exists( 'is_post_type_viewable' ) ) { |
|
45 | - function is_post_type_viewable( $post_type ) { |
|
46 | - if ( is_scalar( $post_type ) ) { |
|
47 | - $post_type = get_post_type_object( $post_type ); |
|
48 | - if ( ! $post_type ) { |
|
44 | +if ( ! function_exists('is_post_type_viewable')) { |
|
45 | + function is_post_type_viewable($post_type) { |
|
46 | + if (is_scalar($post_type)) { |
|
47 | + $post_type = get_post_type_object($post_type); |
|
48 | + if ( ! $post_type) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public ); |
|
53 | + return $post_type->publicly_queryable || ($post_type->_builtin && $post_type->public); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | \ No newline at end of file |
@@ -325,8 +325,8 @@ |
||
325 | 325 | //eg if given "/var/something/somewhere/", we want to get "somewhere"'s |
326 | 326 | //parent folder, "/var/something/" |
327 | 327 | $ds = strlen($file_or_folder_path) > 1 |
328 | - ? strrpos($file_or_folder_path, DS, -2) |
|
329 | - : strlen($file_or_folder_path); |
|
328 | + ? strrpos($file_or_folder_path, DS, -2) |
|
329 | + : strlen($file_or_folder_path); |
|
330 | 330 | return substr($file_or_folder_path, 0, $ds + 1); |
331 | 331 | } |
332 | 332 |
@@ -38,30 +38,30 @@ discard block |
||
38 | 38 | * @throws EE_Error if filesystem credentials are required |
39 | 39 | * @return WP_Filesystem_Base |
40 | 40 | */ |
41 | - private static function _get_wp_filesystem( $filepath = null) { |
|
42 | - if( apply_filters( |
|
41 | + private static function _get_wp_filesystem($filepath = null) { |
|
42 | + if (apply_filters( |
|
43 | 43 | 'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct', |
44 | - $filepath && EEH_File::is_in_uploads_folder( $filepath ), |
|
45 | - $filepath ) ) { |
|
46 | - if( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct ) { |
|
47 | - require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); |
|
44 | + $filepath && EEH_File::is_in_uploads_folder($filepath), |
|
45 | + $filepath )) { |
|
46 | + if ( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) { |
|
47 | + require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php'); |
|
48 | 48 | $method = 'direct'; |
49 | - $wp_filesystem_direct_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method ); |
|
49 | + $wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method); |
|
50 | 50 | //check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem() |
51 | - if ( ! defined('FS_CHMOD_DIR') ) { |
|
52 | - define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) ); |
|
51 | + if ( ! defined('FS_CHMOD_DIR')) { |
|
52 | + define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755)); |
|
53 | 53 | } |
54 | - if ( ! defined('FS_CHMOD_FILE') ) { |
|
55 | - define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) ); |
|
54 | + if ( ! defined('FS_CHMOD_FILE')) { |
|
55 | + define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644)); |
|
56 | 56 | } |
57 | - require_once( $wp_filesystem_direct_file ); |
|
58 | - EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct( array() ); |
|
57 | + require_once($wp_filesystem_direct_file); |
|
58 | + EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array()); |
|
59 | 59 | } |
60 | 60 | return EEH_File::$_wp_filesystem_direct; |
61 | 61 | } |
62 | 62 | global $wp_filesystem; |
63 | 63 | // no filesystem setup ??? |
64 | - if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) { |
|
64 | + if ( ! $wp_filesystem instanceof WP_Filesystem_Base) { |
|
65 | 65 | // if some eager beaver's just trying to get in there too early... |
66 | 66 | // let them do it, because we are one of those eager beavers! :P |
67 | 67 | /** |
@@ -74,34 +74,34 @@ discard block |
||
74 | 74 | * and there may be troubles if the WP files are owned by a different user |
75 | 75 | * than the server user. But both of these issues should exist in 4.4 and earlier too |
76 | 76 | */ |
77 | - if ( FALSE && ! did_action( 'wp_loaded' )) { |
|
77 | + if (FALSE && ! did_action('wp_loaded')) { |
|
78 | 78 | $msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'); |
79 | - if ( WP_DEBUG ) { |
|
80 | - $msg .= '<br />' . __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
79 | + if (WP_DEBUG) { |
|
80 | + $msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
81 | 81 | } |
82 | - throw new EE_Error( $msg ); |
|
82 | + throw new EE_Error($msg); |
|
83 | 83 | } else { |
84 | 84 | // should be loaded if we are past the wp_loaded hook... |
85 | - if ( ! function_exists( 'WP_Filesystem' )) { |
|
86 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
87 | - require_once( ABSPATH . 'wp-admin/includes/template.php' ); |
|
85 | + if ( ! function_exists('WP_Filesystem')) { |
|
86 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
87 | + require_once(ABSPATH.'wp-admin/includes/template.php'); |
|
88 | 88 | } |
89 | 89 | // turn on output buffering so that we can capture the credentials form |
90 | 90 | ob_start(); |
91 | - $credentials = request_filesystem_credentials( '' ); |
|
91 | + $credentials = request_filesystem_credentials(''); |
|
92 | 92 | // store credentials form for the time being |
93 | 93 | EEH_File::$_credentials_form = ob_get_clean(); |
94 | 94 | // basically check for direct or previously configured access |
95 | - if ( ! WP_Filesystem( $credentials ) ) { |
|
95 | + if ( ! WP_Filesystem($credentials)) { |
|
96 | 96 | // if credentials do NOT exist |
97 | - if ( $credentials === FALSE ) { |
|
98 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
99 | - throw new EE_Error( __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
100 | - } elseif( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { |
|
101 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
97 | + if ($credentials === FALSE) { |
|
98 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
99 | + throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
100 | + } elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
101 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
102 | 102 | throw new EE_Error( |
103 | 103 | sprintf( |
104 | - __( 'WP Filesystem Error: $1%s', 'event_espresso' ), |
|
104 | + __('WP Filesystem Error: $1%s', 'event_espresso'), |
|
105 | 105 | $wp_filesystem->errors->get_error_message() ) ); |
106 | 106 | } |
107 | 107 | } |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * display_request_filesystem_credentials_form |
115 | 115 | */ |
116 | 116 | public static function display_request_filesystem_credentials_form() { |
117 | - if ( ! empty( EEH_File::$_credentials_form )) { |
|
118 | - echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>'; |
|
117 | + if ( ! empty(EEH_File::$_credentials_form)) { |
|
118 | + echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>'; |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -133,29 +133,29 @@ discard block |
||
133 | 133 | * @throws EE_Error if filesystem credentials are required |
134 | 134 | * @return bool |
135 | 135 | */ |
136 | - public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) { |
|
136 | + public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') { |
|
137 | 137 | // load WP_Filesystem and set file permissions |
138 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
139 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
140 | - if ( ! $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) )) { |
|
141 | - $file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name; |
|
142 | - $file_name .= ! empty( $file_ext ) ? ' file' : ' folder'; |
|
138 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
139 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
140 | + if ( ! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
141 | + $file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name; |
|
142 | + $file_name .= ! empty($file_ext) ? ' file' : ' folder'; |
|
143 | 143 | $msg = sprintf( |
144 | - __( 'The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso' ), |
|
144 | + __('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'), |
|
145 | 145 | $file_name, |
146 | 146 | '<br />' |
147 | 147 | ); |
148 | - if ( EEH_File::exists( $full_file_path )) { |
|
149 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file ); |
|
148 | + if (EEH_File::exists($full_file_path)) { |
|
149 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file); |
|
150 | 150 | } else { |
151 | 151 | // no file permissions means the file was not found |
152 | 152 | $msg .= sprintf( |
153 | - __( 'Please ensure the following path is correct: "%s".', 'event_espresso' ), |
|
153 | + __('Please ensure the following path is correct: "%s".', 'event_espresso'), |
|
154 | 154 | $full_file_path |
155 | 155 | ); |
156 | 156 | } |
157 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
158 | - throw new EE_Error( $msg . '||' . $msg ); |
|
157 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
158 | + throw new EE_Error($msg.'||'.$msg); |
|
159 | 159 | } |
160 | 160 | return FALSE; |
161 | 161 | } |
@@ -173,24 +173,24 @@ discard block |
||
173 | 173 | * @throws EE_Error if filesystem credentials are required |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){ |
|
176 | + private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') { |
|
177 | 177 | // load WP_Filesystem and set file permissions |
178 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
178 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
179 | 179 | // check file permissions |
180 | - $perms = $wp_filesystem->getchmod( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ); |
|
181 | - if ( $perms ) { |
|
180 | + $perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)); |
|
181 | + if ($perms) { |
|
182 | 182 | // file permissions exist, but way be set incorrectly |
183 | - $type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : ''; |
|
184 | - $type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder'; |
|
183 | + $type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : ''; |
|
184 | + $type_of_file .= ! empty($type_of_file) ? 'file' : 'folder'; |
|
185 | 185 | return sprintf( |
186 | - __( 'File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso' ), |
|
186 | + __('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'), |
|
187 | 187 | $type_of_file, |
188 | 188 | $perms |
189 | 189 | ); |
190 | 190 | } else { |
191 | 191 | // file exists but file permissions could not be read ?!?! |
192 | 192 | return sprintf( |
193 | - __( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ), |
|
193 | + __('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'), |
|
194 | 194 | $full_file_path |
195 | 195 | ); |
196 | 196 | } |
@@ -208,35 +208,35 @@ discard block |
||
208 | 208 | * can't write to it |
209 | 209 | * @return bool false if folder isn't writable; true if it exists and is writeable, |
210 | 210 | */ |
211 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ){ |
|
212 | - if ( empty( $folder )) { |
|
211 | + public static function ensure_folder_exists_and_is_writable($folder = '') { |
|
212 | + if (empty($folder)) { |
|
213 | 213 | return false; |
214 | 214 | } |
215 | 215 | // remove ending DS |
216 | - $folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' )); |
|
217 | - $parent_folder = EEH_File::get_parent_folder( $folder ); |
|
216 | + $folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\')); |
|
217 | + $parent_folder = EEH_File::get_parent_folder($folder); |
|
218 | 218 | // add DS to folder |
219 | - $folder = EEH_File::end_with_directory_separator( $folder ); |
|
220 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $folder ); |
|
221 | - if ( ! $wp_filesystem->is_dir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) { |
|
219 | + $folder = EEH_File::end_with_directory_separator($folder); |
|
220 | + $wp_filesystem = EEH_File::_get_wp_filesystem($folder); |
|
221 | + if ( ! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) { |
|
222 | 222 | //ok so it doesn't exist. Does its parent? Can we write to it? |
223 | - if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) { |
|
223 | + if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) { |
|
224 | 224 | return false; |
225 | 225 | } |
226 | - if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) { |
|
226 | + if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) { |
|
227 | 227 | return false; |
228 | 228 | } else { |
229 | - if ( ! $wp_filesystem->mkdir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) { |
|
230 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
231 | - $msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder ); |
|
232 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder ); |
|
233 | - throw new EE_Error( $msg ); |
|
229 | + if ( ! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) { |
|
230 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
231 | + $msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder); |
|
232 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder); |
|
233 | + throw new EE_Error($msg); |
|
234 | 234 | } |
235 | 235 | return false; |
236 | 236 | } |
237 | - EEH_File::add_index_file( $folder ); |
|
237 | + EEH_File::add_index_file($folder); |
|
238 | 238 | } |
239 | - } elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
239 | + } elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
240 | 240 | return false; |
241 | 241 | } |
242 | 242 | return true; |
@@ -251,15 +251,15 @@ discard block |
||
251 | 251 | * @throws EE_Error if filesystem credentials are required |
252 | 252 | * @return bool |
253 | 253 | */ |
254 | - public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){ |
|
254 | + public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') { |
|
255 | 255 | // load WP_Filesystem and set file permissions |
256 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_path ); |
|
257 | - $full_path = EEH_File::standardise_directory_separators( $full_path ); |
|
258 | - if ( ! $wp_filesystem->is_writable( EEH_File::convert_local_filepath_to_remote_filepath( $full_path ) ) ) { |
|
259 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
260 | - $msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder ); |
|
261 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path ); |
|
262 | - throw new EE_Error( $msg ); |
|
256 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_path); |
|
257 | + $full_path = EEH_File::standardise_directory_separators($full_path); |
|
258 | + if ( ! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) { |
|
259 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
260 | + $msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder); |
|
261 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path); |
|
262 | + throw new EE_Error($msg); |
|
263 | 263 | } |
264 | 264 | return FALSE; |
265 | 265 | } |
@@ -276,25 +276,25 @@ discard block |
||
276 | 276 | * @throws EE_Error if filesystem credentials are required |
277 | 277 | * @return bool |
278 | 278 | */ |
279 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) { |
|
279 | + public static function ensure_file_exists_and_is_writable($full_file_path = '') { |
|
280 | 280 | // load WP_Filesystem and set file permissions |
281 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
282 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
283 | - $parent_folder = EEH_File::get_parent_folder( $full_file_path ); |
|
284 | - if ( ! EEH_File::exists( $full_file_path )) { |
|
285 | - if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) { |
|
281 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
282 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
283 | + $parent_folder = EEH_File::get_parent_folder($full_file_path); |
|
284 | + if ( ! EEH_File::exists($full_file_path)) { |
|
285 | + if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) { |
|
286 | 286 | return false; |
287 | 287 | } |
288 | - if ( ! $wp_filesystem->touch( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) { |
|
289 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
290 | - $msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path ); |
|
291 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
292 | - throw new EE_Error( $msg ); |
|
288 | + if ( ! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
289 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
290 | + $msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path); |
|
291 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
292 | + throw new EE_Error($msg); |
|
293 | 293 | } |
294 | 294 | return false; |
295 | 295 | } |
296 | 296 | } |
297 | - if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) { |
|
297 | + if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) { |
|
298 | 298 | return false; |
299 | 299 | } |
300 | 300 | return true; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @param string $file_or_folder_path |
307 | 307 | * @return string parent folder, ENDING with a directory separator |
308 | 308 | */ |
309 | - public static function get_parent_folder( $file_or_folder_path ) { |
|
309 | + public static function get_parent_folder($file_or_folder_path) { |
|
310 | 310 | //find the last DS, ignoring a DS on the very end |
311 | 311 | //eg if given "/var/something/somewhere/", we want to get "somewhere"'s |
312 | 312 | //parent folder, "/var/something/" |
@@ -328,12 +328,12 @@ discard block |
||
328 | 328 | * @throws EE_Error if filesystem credentials are required |
329 | 329 | * @return string |
330 | 330 | */ |
331 | - public static function get_file_contents( $full_file_path = '' ){ |
|
332 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
333 | - if ( EEH_File::verify_filepath_and_permissions( $full_file_path, EEH_File::get_filename_from_filepath( $full_file_path ) , EEH_File::get_file_extension( $full_file_path ))) { |
|
331 | + public static function get_file_contents($full_file_path = '') { |
|
332 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
333 | + if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) { |
|
334 | 334 | // load WP_Filesystem and set file permissions |
335 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
336 | - return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ); |
|
335 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
336 | + return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)); |
|
337 | 337 | } |
338 | 338 | return ''; |
339 | 339 | } |
@@ -348,26 +348,26 @@ discard block |
||
348 | 348 | * @throws EE_Error if filesystem credentials are required |
349 | 349 | * @return bool |
350 | 350 | */ |
351 | - public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){ |
|
352 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
353 | - $file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : ''; |
|
354 | - $folder = EEH_File::remove_filename_from_filepath( $full_file_path ); |
|
355 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
356 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
357 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path ); |
|
358 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
359 | - throw new EE_Error( $msg ); |
|
351 | + public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') { |
|
352 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
353 | + $file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : ''; |
|
354 | + $folder = EEH_File::remove_filename_from_filepath($full_file_path); |
|
355 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
356 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
357 | + $msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path); |
|
358 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
359 | + throw new EE_Error($msg); |
|
360 | 360 | } |
361 | 361 | return FALSE; |
362 | 362 | } |
363 | 363 | // load WP_Filesystem and set file permissions |
364 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
364 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
365 | 365 | // write the file |
366 | - if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ), $file_contents )) { |
|
367 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
368 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path ); |
|
369 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' ); |
|
370 | - throw new EE_Error( $msg ); |
|
366 | + if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) { |
|
367 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
368 | + $msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path); |
|
369 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f'); |
|
370 | + throw new EE_Error($msg); |
|
371 | 371 | } |
372 | 372 | return FALSE; |
373 | 373 | } |
@@ -383,9 +383,9 @@ discard block |
||
383 | 383 | * @throws EE_Error if filesystem credentials are required |
384 | 384 | * @return boolean |
385 | 385 | */ |
386 | - public static function delete( $filepath, $recursive = false, $type = false ) { |
|
386 | + public static function delete($filepath, $recursive = false, $type = false) { |
|
387 | 387 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
388 | - return $wp_filesystem->delete( $filepath, $recursive, $type ) ? TRUE : FALSE; |
|
388 | + return $wp_filesystem->delete($filepath, $recursive, $type) ? TRUE : FALSE; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | * @throws EE_Error if filesystem credentials are required |
398 | 398 | * @return bool |
399 | 399 | */ |
400 | - public static function exists( $full_file_path = '' ) { |
|
401 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
402 | - return $wp_filesystem->exists( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ? TRUE : FALSE; |
|
400 | + public static function exists($full_file_path = '') { |
|
401 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
402 | + return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? TRUE : FALSE; |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | * @throws EE_Error if filesystem credentials are required |
413 | 413 | * @return bool |
414 | 414 | */ |
415 | - public static function is_readable( $full_file_path = '' ) { |
|
416 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
417 | - if( $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) { |
|
415 | + public static function is_readable($full_file_path = '') { |
|
416 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
417 | + if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
418 | 418 | return true; |
419 | 419 | } else { |
420 | 420 | return false; |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | * @param string $full_file_path |
431 | 431 | * @return string |
432 | 432 | */ |
433 | - public static function remove_filename_from_filepath( $full_file_path = '' ) { |
|
434 | - return pathinfo( $full_file_path, PATHINFO_DIRNAME ); |
|
433 | + public static function remove_filename_from_filepath($full_file_path = '') { |
|
434 | + return pathinfo($full_file_path, PATHINFO_DIRNAME); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | * @param string $full_file_path |
442 | 442 | * @return string |
443 | 443 | */ |
444 | - public static function get_filename_from_filepath( $full_file_path = '' ) { |
|
445 | - return pathinfo( $full_file_path, PATHINFO_BASENAME ); |
|
444 | + public static function get_filename_from_filepath($full_file_path = '') { |
|
445 | + return pathinfo($full_file_path, PATHINFO_BASENAME); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -452,8 +452,8 @@ discard block |
||
452 | 452 | * @param string $full_file_path |
453 | 453 | * @return string |
454 | 454 | */ |
455 | - public static function get_file_extension( $full_file_path = '' ) { |
|
456 | - return pathinfo( $full_file_path, PATHINFO_EXTENSION ); |
|
455 | + public static function get_file_extension($full_file_path = '') { |
|
456 | + return pathinfo($full_file_path, PATHINFO_EXTENSION); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | |
@@ -464,10 +464,10 @@ discard block |
||
464 | 464 | * @throws EE_Error if filesystem credentials are required |
465 | 465 | * @return bool |
466 | 466 | */ |
467 | - public static function add_htaccess_deny_from_all( $folder = '' ) { |
|
468 | - $folder = EEH_File::standardise_and_end_with_directory_separator( $folder ); |
|
469 | - if ( ! EEH_File::exists( $folder . '.htaccess' ) ) { |
|
470 | - if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) { |
|
467 | + public static function add_htaccess_deny_from_all($folder = '') { |
|
468 | + $folder = EEH_File::standardise_and_end_with_directory_separator($folder); |
|
469 | + if ( ! EEH_File::exists($folder.'.htaccess')) { |
|
470 | + if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) { |
|
471 | 471 | return FALSE; |
472 | 472 | } |
473 | 473 | } |
@@ -481,10 +481,10 @@ discard block |
||
481 | 481 | * @throws EE_Error if filesystem credentials are required |
482 | 482 | * @return boolean |
483 | 483 | */ |
484 | - public static function add_index_file( $folder ) { |
|
485 | - $folder = EEH_File::standardise_and_end_with_directory_separator( $folder ); |
|
486 | - if ( ! EEH_File::exists( $folder . 'index.php' ) ) { |
|
487 | - if ( ! EEH_File::write_to_file( $folder . 'index.php', 'You are not permitted to read from this folder', '.php' )) { |
|
484 | + public static function add_index_file($folder) { |
|
485 | + $folder = EEH_File::standardise_and_end_with_directory_separator($folder); |
|
486 | + if ( ! EEH_File::exists($folder.'index.php')) { |
|
487 | + if ( ! EEH_File::write_to_file($folder.'index.php', 'You are not permitted to read from this folder', '.php')) { |
|
488 | 488 | return false; |
489 | 489 | } |
490 | 490 | } |
@@ -499,11 +499,11 @@ discard block |
||
499 | 499 | * @param string $file_path |
500 | 500 | * @return string |
501 | 501 | */ |
502 | - public static function get_classname_from_filepath_with_standard_filename( $file_path ){ |
|
502 | + public static function get_classname_from_filepath_with_standard_filename($file_path) { |
|
503 | 503 | //extract file from path |
504 | - $filename = basename( $file_path ); |
|
504 | + $filename = basename($file_path); |
|
505 | 505 | //now remove the first period and everything after |
506 | - $pos_of_first_period = strpos( $filename,'.' ); |
|
506 | + $pos_of_first_period = strpos($filename, '.'); |
|
507 | 507 | return substr($filename, 0, $pos_of_first_period); |
508 | 508 | } |
509 | 509 | |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * @param string $file_path |
516 | 516 | * @return string |
517 | 517 | */ |
518 | - public static function standardise_directory_separators( $file_path ){ |
|
519 | - return str_replace( array( '\\', '/' ), DS, $file_path ); |
|
518 | + public static function standardise_directory_separators($file_path) { |
|
519 | + return str_replace(array('\\', '/'), DS, $file_path); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -527,8 +527,8 @@ discard block |
||
527 | 527 | * @param string $file_path |
528 | 528 | * @return string |
529 | 529 | */ |
530 | - public static function end_with_directory_separator( $file_path ){ |
|
531 | - return rtrim( $file_path, '/\\' ) . DS; |
|
530 | + public static function end_with_directory_separator($file_path) { |
|
531 | + return rtrim($file_path, '/\\').DS; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | * @param $file_path |
539 | 539 | * @return string |
540 | 540 | */ |
541 | - public static function standardise_and_end_with_directory_separator( $file_path ){ |
|
542 | - return self::end_with_directory_separator( self::standardise_directory_separators( $file_path )); |
|
541 | + public static function standardise_and_end_with_directory_separator($file_path) { |
|
542 | + return self::end_with_directory_separator(self::standardise_directory_separators($file_path)); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | |
@@ -556,21 +556,21 @@ discard block |
||
556 | 556 | * if $index_numerically == FALSE (Default) keys are what the class names SHOULD be; |
557 | 557 | * and values are their filepaths |
558 | 558 | */ |
559 | - public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){ |
|
559 | + public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) { |
|
560 | 560 | $class_to_folder_path = array(); |
561 | - foreach( $folder_paths as $folder_path ){ |
|
562 | - $folder_path = self::standardise_and_end_with_directory_separator( $folder_path ); |
|
561 | + foreach ($folder_paths as $folder_path) { |
|
562 | + $folder_path = self::standardise_and_end_with_directory_separator($folder_path); |
|
563 | 563 | // load WP_Filesystem and set file permissions |
564 | - $files_in_folder = glob( $folder_path . '*' ); |
|
564 | + $files_in_folder = glob($folder_path.'*'); |
|
565 | 565 | $class_to_folder_path = array(); |
566 | - if ( $files_in_folder ) { |
|
567 | - foreach( $files_in_folder as $file_path ){ |
|
566 | + if ($files_in_folder) { |
|
567 | + foreach ($files_in_folder as $file_path) { |
|
568 | 568 | //only add files, not folders |
569 | - if ( ! is_dir( $file_path )) { |
|
570 | - if ( $index_numerically ) { |
|
569 | + if ( ! is_dir($file_path)) { |
|
570 | + if ($index_numerically) { |
|
571 | 571 | $class_to_folder_path[] = $file_path; |
572 | 572 | } else { |
573 | - $classname = self::get_classname_from_filepath_with_standard_filename( $file_path ); |
|
573 | + $classname = self::get_classname_from_filepath_with_standard_filename($file_path); |
|
574 | 574 | $class_to_folder_path[$classname] = $file_path; |
575 | 575 | } |
576 | 576 | } |
@@ -590,39 +590,39 @@ discard block |
||
590 | 590 | * @throws EE_Error if filesystem credentials are required |
591 | 591 | * @return boolean success |
592 | 592 | */ |
593 | - public static function copy( $source_file, $destination_file, $overwrite = FALSE ){ |
|
594 | - $full_source_path = EEH_File::standardise_directory_separators( $source_file ); |
|
595 | - if( ! EEH_File::exists( $full_source_path ) ){ |
|
596 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
597 | - $msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path ); |
|
598 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path ); |
|
599 | - throw new EE_Error( $msg ); |
|
593 | + public static function copy($source_file, $destination_file, $overwrite = FALSE) { |
|
594 | + $full_source_path = EEH_File::standardise_directory_separators($source_file); |
|
595 | + if ( ! EEH_File::exists($full_source_path)) { |
|
596 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
597 | + $msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path); |
|
598 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path); |
|
599 | + throw new EE_Error($msg); |
|
600 | 600 | } |
601 | 601 | return FALSE; |
602 | 602 | } |
603 | 603 | |
604 | - $full_dest_path = EEH_File::standardise_directory_separators( $destination_file ); |
|
605 | - $folder = EEH_File::remove_filename_from_filepath( $full_dest_path ); |
|
606 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
607 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
608 | - $msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path ); |
|
609 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path ); |
|
610 | - throw new EE_Error( $msg ); |
|
604 | + $full_dest_path = EEH_File::standardise_directory_separators($destination_file); |
|
605 | + $folder = EEH_File::remove_filename_from_filepath($full_dest_path); |
|
606 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
607 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
608 | + $msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path); |
|
609 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path); |
|
610 | + throw new EE_Error($msg); |
|
611 | 611 | } |
612 | 612 | return FALSE; |
613 | 613 | } |
614 | 614 | |
615 | 615 | // load WP_Filesystem and set file permissions |
616 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $destination_file ); |
|
616 | + $wp_filesystem = EEH_File::_get_wp_filesystem($destination_file); |
|
617 | 617 | // write the file |
618 | 618 | if ( ! $wp_filesystem->copy( |
619 | - EEH_File::convert_local_filepath_to_remote_filepath( $full_source_path ), |
|
620 | - EEH_File::convert_local_filepath_to_remote_filepath( $full_dest_path ), |
|
619 | + EEH_File::convert_local_filepath_to_remote_filepath($full_source_path), |
|
620 | + EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path), |
|
621 | 621 | $overwrite )) { |
622 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
623 | - $msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path ); |
|
624 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' ); |
|
625 | - throw new EE_Error( $msg ); |
|
622 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
623 | + $msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path); |
|
624 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f'); |
|
625 | + throw new EE_Error($msg); |
|
626 | 626 | } |
627 | 627 | return FALSE; |
628 | 628 | } |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * @param string $filepath |
635 | 635 | * @return boolean |
636 | 636 | */ |
637 | - public static function is_in_uploads_folder( $filepath ) { |
|
637 | + public static function is_in_uploads_folder($filepath) { |
|
638 | 638 | $uploads = wp_upload_dir(); |
639 | - return strpos( $filepath, $uploads[ 'basedir' ] ) === 0 ? true : false; |
|
639 | + return strpos($filepath, $uploads['basedir']) === 0 ? true : false; |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | /** |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | * @return string the remote filepath (eg the filepath the filesystem method, eg |
652 | 652 | * ftp or ssh, will use to access the folder |
653 | 653 | */ |
654 | - public static function convert_local_filepath_to_remote_filepath( $local_filepath ) { |
|
655 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $local_filepath ); |
|
656 | - return str_replace( WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath ); |
|
654 | + public static function convert_local_filepath_to_remote_filepath($local_filepath) { |
|
655 | + $wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath); |
|
656 | + return str_replace(WP_CONTENT_DIR.DS, $wp_filesystem->wp_content_dir(), $local_filepath); |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | // End of file EEH_File.helper.php |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | |
3 | 5 | /** |
4 | 6 | * |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -116,42 +116,42 @@ discard block |
||
116 | 116 | |
117 | 117 | |
118 | 118 | protected function _start() { |
119 | - $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>'; |
|
120 | - $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', 'event_espresso') . '</p>'; |
|
119 | + $content = '<h3>'.__('Questions Overview', 'event_espresso').'</h3>'; |
|
120 | + $content .= '<p>'.__('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', 'event_espresso').'</p>'; |
|
121 | 121 | |
122 | 122 | return $content; |
123 | 123 | } |
124 | 124 | |
125 | 125 | protected function _display_text_stop() { |
126 | - return '<p>' . __('View available questions.', 'event_espresso') . '</p>'; |
|
126 | + return '<p>'.__('View available questions.', 'event_espresso').'</p>'; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | protected function _admin_label_stop() { |
130 | - return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>'; |
|
130 | + return '<p>'.__('View the admin label for your questions.', 'event_espresso').'</p>'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | protected function _type_stop() { |
134 | - return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', 'event_espresso') . '</p>'; |
|
134 | + return '<p>'.__('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', 'event_espresso').'</p>'; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | protected function _values_stop() { |
138 | - return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', 'event_espresso') . '</p>'; |
|
138 | + return '<p>'.__('View stored values for checkboxes, radio buttons, and select boxes.', 'event_espresso').'</p>'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | protected function _required_stop() { |
142 | - return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>'; |
|
142 | + return '<p>'.__('View if a question is required.', 'event_espresso').'</p>'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | protected function _bulk_actions_stop() { |
146 | - return '<p>' . __('Perform bulk actions to multiple questions.', 'event_espresso') . '</p>'; |
|
146 | + return '<p>'.__('Perform bulk actions to multiple questions.', 'event_espresso').'</p>'; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | protected function _search_stop() { |
150 | - return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', 'event_espresso') . '</p>'; |
|
150 | + return '<p>'.__('Search through questions. The following sources will be searched: Name of Question (display text).', 'event_espresso').'</p>'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | protected function _add_new_question_stop() { |
154 | - return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>'; |
|
154 | + return '<p>'.__('Click here to add a new question.', 'event_espresso').'</p>'; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | } |
158 | 158 | \ No newline at end of file |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -1,6 +1,6 @@ discard block |
||
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 | /** |
@@ -18,64 +18,64 @@ discard block |
||
18 | 18 | class Registration_Form_Questions_Overview_Help_Tour extends EE_Help_Tour |
19 | 19 | { |
20 | 20 | |
21 | - protected function _set_tour_properties() |
|
22 | - { |
|
23 | - $this->_label = __('Questions Overview Tour', 'event_espresso'); |
|
24 | - $this->_slug = $this->_is_caf ? 'questions-overview-caf-joyride' : 'questions-overview-joyride'; |
|
25 | - } |
|
21 | + protected function _set_tour_properties() |
|
22 | + { |
|
23 | + $this->_label = __('Questions Overview Tour', 'event_espresso'); |
|
24 | + $this->_slug = $this->_is_caf ? 'questions-overview-caf-joyride' : 'questions-overview-joyride'; |
|
25 | + } |
|
26 | 26 | |
27 | - protected function _set_tour_stops() |
|
28 | - { |
|
29 | - $this->_stops = array( |
|
30 | - 10 => array( |
|
31 | - 'content' => $this->_start(), |
|
32 | - ), |
|
33 | - 30 => array( |
|
34 | - 'id' => 'display_text', |
|
35 | - 'content' => $this->_display_text_stop(), |
|
36 | - 'options' => array( |
|
37 | - 'tipLocation' => 'top', |
|
38 | - 'tipAdjustmentX' => -5, |
|
39 | - 'tipAdjustmentY' => -25 |
|
40 | - ) |
|
41 | - ), |
|
42 | - 40 => array( |
|
43 | - 'id' => 'admin_label', |
|
44 | - 'content' => $this->_admin_label_stop(), |
|
45 | - 'options' => array( |
|
46 | - 'tipLocation' => 'top', |
|
47 | - 'tipAdjustmentX' => 20, |
|
48 | - 'tipAdjustmentY' => -25 |
|
49 | - ) |
|
50 | - ), |
|
51 | - 50 => array( |
|
52 | - 'id' => 'type', |
|
53 | - 'content' => $this->_type_stop(), |
|
54 | - 'options' => array( |
|
55 | - 'tipLocation' => 'top', |
|
56 | - 'tipAdjustmentX' => -5, |
|
57 | - 'tipAdjustmentY' => -25 |
|
58 | - ) |
|
59 | - ), |
|
60 | - 60 => array( |
|
61 | - 'id' => 'values', |
|
62 | - 'content' => $this->_values_stop(), |
|
63 | - 'options' => array( |
|
64 | - 'tipLocation' => 'top', |
|
65 | - 'tipAdjustmentX' => -5, |
|
66 | - 'tipAdjustmentY' => -25 |
|
67 | - ) |
|
68 | - ), |
|
69 | - 70 => array( |
|
70 | - 'id' => 'required', |
|
71 | - 'content' => $this->_required_stop(), |
|
72 | - 'options' => array( |
|
73 | - 'tipLocation' => 'top', |
|
74 | - 'tipAdjustmentY' => -20, |
|
75 | - 'tipAdjustmentX' => -15 |
|
76 | - ) |
|
77 | - ), |
|
78 | - /*80 => array( |
|
27 | + protected function _set_tour_stops() |
|
28 | + { |
|
29 | + $this->_stops = array( |
|
30 | + 10 => array( |
|
31 | + 'content' => $this->_start(), |
|
32 | + ), |
|
33 | + 30 => array( |
|
34 | + 'id' => 'display_text', |
|
35 | + 'content' => $this->_display_text_stop(), |
|
36 | + 'options' => array( |
|
37 | + 'tipLocation' => 'top', |
|
38 | + 'tipAdjustmentX' => -5, |
|
39 | + 'tipAdjustmentY' => -25 |
|
40 | + ) |
|
41 | + ), |
|
42 | + 40 => array( |
|
43 | + 'id' => 'admin_label', |
|
44 | + 'content' => $this->_admin_label_stop(), |
|
45 | + 'options' => array( |
|
46 | + 'tipLocation' => 'top', |
|
47 | + 'tipAdjustmentX' => 20, |
|
48 | + 'tipAdjustmentY' => -25 |
|
49 | + ) |
|
50 | + ), |
|
51 | + 50 => array( |
|
52 | + 'id' => 'type', |
|
53 | + 'content' => $this->_type_stop(), |
|
54 | + 'options' => array( |
|
55 | + 'tipLocation' => 'top', |
|
56 | + 'tipAdjustmentX' => -5, |
|
57 | + 'tipAdjustmentY' => -25 |
|
58 | + ) |
|
59 | + ), |
|
60 | + 60 => array( |
|
61 | + 'id' => 'values', |
|
62 | + 'content' => $this->_values_stop(), |
|
63 | + 'options' => array( |
|
64 | + 'tipLocation' => 'top', |
|
65 | + 'tipAdjustmentX' => -5, |
|
66 | + 'tipAdjustmentY' => -25 |
|
67 | + ) |
|
68 | + ), |
|
69 | + 70 => array( |
|
70 | + 'id' => 'required', |
|
71 | + 'content' => $this->_required_stop(), |
|
72 | + 'options' => array( |
|
73 | + 'tipLocation' => 'top', |
|
74 | + 'tipAdjustmentY' => -20, |
|
75 | + 'tipAdjustmentX' => -15 |
|
76 | + ) |
|
77 | + ), |
|
78 | + /*80 => array( |
|
79 | 79 | 'class' => 'bulkactions', |
80 | 80 | 'content' => $this->_bulk_actions_stop(), |
81 | 81 | 'options' => array( |
@@ -84,77 +84,77 @@ discard block |
||
84 | 84 | 'tipAdjustmentX' => -15 |
85 | 85 | ) |
86 | 86 | ),*/ |
87 | - 90 => array( |
|
88 | - 'id' => 'event-espresso_page_espresso_registration_form-search-input', |
|
89 | - 'content' => $this->_search_stop(), |
|
90 | - 'options' => array( |
|
91 | - 'tipLocation' => 'left', |
|
92 | - 'tipAdjustmentY' => -50, |
|
93 | - 'tipAdjustmentX' => -15 |
|
94 | - ) |
|
95 | - ), |
|
96 | - 100 => array( |
|
97 | - 'id' => 'add-new-question', |
|
98 | - 'content' => $this->_add_new_question_stop(), |
|
99 | - 'options' => array( |
|
100 | - 'tipLocation' => 'right', |
|
101 | - 'tipAdjustmentY' => -50, |
|
102 | - 'tipAdjustmentX' => 15 |
|
103 | - ) |
|
104 | - ), |
|
105 | - ); |
|
106 | - } |
|
87 | + 90 => array( |
|
88 | + 'id' => 'event-espresso_page_espresso_registration_form-search-input', |
|
89 | + 'content' => $this->_search_stop(), |
|
90 | + 'options' => array( |
|
91 | + 'tipLocation' => 'left', |
|
92 | + 'tipAdjustmentY' => -50, |
|
93 | + 'tipAdjustmentX' => -15 |
|
94 | + ) |
|
95 | + ), |
|
96 | + 100 => array( |
|
97 | + 'id' => 'add-new-question', |
|
98 | + 'content' => $this->_add_new_question_stop(), |
|
99 | + 'options' => array( |
|
100 | + 'tipLocation' => 'right', |
|
101 | + 'tipAdjustmentY' => -50, |
|
102 | + 'tipAdjustmentX' => 15 |
|
103 | + ) |
|
104 | + ), |
|
105 | + ); |
|
106 | + } |
|
107 | 107 | |
108 | 108 | |
109 | - protected function _start() |
|
110 | - { |
|
111 | - $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>'; |
|
112 | - $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', |
|
113 | - 'event_espresso') . '</p>'; |
|
109 | + protected function _start() |
|
110 | + { |
|
111 | + $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>'; |
|
112 | + $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', |
|
113 | + 'event_espresso') . '</p>'; |
|
114 | 114 | |
115 | - return $content; |
|
116 | - } |
|
115 | + return $content; |
|
116 | + } |
|
117 | 117 | |
118 | - protected function _display_text_stop() |
|
119 | - { |
|
120 | - return '<p>' . __('View available questions.', 'event_espresso') . '</p>'; |
|
121 | - } |
|
118 | + protected function _display_text_stop() |
|
119 | + { |
|
120 | + return '<p>' . __('View available questions.', 'event_espresso') . '</p>'; |
|
121 | + } |
|
122 | 122 | |
123 | - protected function _admin_label_stop() |
|
124 | - { |
|
125 | - return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>'; |
|
126 | - } |
|
123 | + protected function _admin_label_stop() |
|
124 | + { |
|
125 | + return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>'; |
|
126 | + } |
|
127 | 127 | |
128 | - protected function _type_stop() |
|
129 | - { |
|
130 | - return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', |
|
131 | - 'event_espresso') . '</p>'; |
|
132 | - } |
|
128 | + protected function _type_stop() |
|
129 | + { |
|
130 | + return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', |
|
131 | + 'event_espresso') . '</p>'; |
|
132 | + } |
|
133 | 133 | |
134 | - protected function _values_stop() |
|
135 | - { |
|
136 | - return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', |
|
137 | - 'event_espresso') . '</p>'; |
|
138 | - } |
|
134 | + protected function _values_stop() |
|
135 | + { |
|
136 | + return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', |
|
137 | + 'event_espresso') . '</p>'; |
|
138 | + } |
|
139 | 139 | |
140 | - protected function _required_stop() |
|
141 | - { |
|
142 | - return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>'; |
|
143 | - } |
|
140 | + protected function _required_stop() |
|
141 | + { |
|
142 | + return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>'; |
|
143 | + } |
|
144 | 144 | |
145 | - /* protected function _bulk_actions_stop() { |
|
145 | + /* protected function _bulk_actions_stop() { |
|
146 | 146 | return '<p>' . __('Perform bulk actions to multiple questions.', 'event_espresso') . '</p>'; |
147 | 147 | } */ |
148 | 148 | |
149 | - protected function _search_stop() |
|
150 | - { |
|
151 | - return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', |
|
152 | - 'event_espresso') . '</p>'; |
|
153 | - } |
|
149 | + protected function _search_stop() |
|
150 | + { |
|
151 | + return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', |
|
152 | + 'event_espresso') . '</p>'; |
|
153 | + } |
|
154 | 154 | |
155 | - protected function _add_new_question_stop() |
|
156 | - { |
|
157 | - return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>'; |
|
158 | - } |
|
155 | + protected function _add_new_question_stop() |
|
156 | + { |
|
157 | + return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>'; |
|
158 | + } |
|
159 | 159 | |
160 | 160 | } |
161 | 161 | \ No newline at end of file |
@@ -108,38 +108,38 @@ discard block |
||
108 | 108 | |
109 | 109 | protected function _start() |
110 | 110 | { |
111 | - $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>'; |
|
112 | - $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', |
|
113 | - 'event_espresso') . '</p>'; |
|
111 | + $content = '<h3>'.__('Questions Overview', 'event_espresso').'</h3>'; |
|
112 | + $content .= '<p>'.__('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', |
|
113 | + 'event_espresso').'</p>'; |
|
114 | 114 | |
115 | 115 | return $content; |
116 | 116 | } |
117 | 117 | |
118 | 118 | protected function _display_text_stop() |
119 | 119 | { |
120 | - return '<p>' . __('View available questions.', 'event_espresso') . '</p>'; |
|
120 | + return '<p>'.__('View available questions.', 'event_espresso').'</p>'; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | protected function _admin_label_stop() |
124 | 124 | { |
125 | - return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>'; |
|
125 | + return '<p>'.__('View the admin label for your questions.', 'event_espresso').'</p>'; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | protected function _type_stop() |
129 | 129 | { |
130 | - return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', |
|
131 | - 'event_espresso') . '</p>'; |
|
130 | + return '<p>'.__('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', |
|
131 | + 'event_espresso').'</p>'; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | protected function _values_stop() |
135 | 135 | { |
136 | - return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', |
|
137 | - 'event_espresso') . '</p>'; |
|
136 | + return '<p>'.__('View stored values for checkboxes, radio buttons, and select boxes.', |
|
137 | + 'event_espresso').'</p>'; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | protected function _required_stop() |
141 | 141 | { |
142 | - return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>'; |
|
142 | + return '<p>'.__('View if a question is required.', 'event_espresso').'</p>'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /* protected function _bulk_actions_stop() { |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | |
149 | 149 | protected function _search_stop() |
150 | 150 | { |
151 | - return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', |
|
152 | - 'event_espresso') . '</p>'; |
|
151 | + return '<p>'.__('Search through questions. The following sources will be searched: Name of Question (display text).', |
|
152 | + 'event_espresso').'</p>'; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | protected function _add_new_question_stop() |
156 | 156 | { |
157 | - return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>'; |
|
157 | + return '<p>'.__('Click here to add a new question.', 'event_espresso').'</p>'; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } |
161 | 161 | \ No newline at end of file |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_Foreign_Key_Field_Base.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_Foreign_Key_Field_Base.php'); |
|
3 | 3 | |
4 | 4 | class EE_Foreign_Key_String_Field extends EE_Foreign_Key_Field_Base |
5 | 5 | { |
@@ -4,17 +4,17 @@ |
||
4 | 4 | class EE_Foreign_Key_String_Field extends EE_Foreign_Key_Field_Base |
5 | 5 | { |
6 | 6 | |
7 | - /** |
|
8 | - * removes all tags when setting |
|
9 | - * |
|
10 | - * @param string $value_inputted_for_field_on_model_object |
|
11 | - * @return string |
|
12 | - */ |
|
13 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
14 | - { |
|
15 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
16 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
17 | - } |
|
18 | - return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
|
19 | - } |
|
7 | + /** |
|
8 | + * removes all tags when setting |
|
9 | + * |
|
10 | + * @param string $value_inputted_for_field_on_model_object |
|
11 | + * @return string |
|
12 | + */ |
|
13 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
14 | + { |
|
15 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
16 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
17 | + } |
|
18 | + return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
|
19 | + } |
|
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -3,6 +3,6 @@ |
||
3 | 3 | |
4 | 4 | class EE_Trashed_Flag_Field extends EE_Boolean_Field |
5 | 5 | { |
6 | - //note: some client code simply checks if a field IS an EE_Trashed_Flag_Field |
|
7 | - //...otherwise, these fields are mostly the same as boolean fields |
|
6 | + //note: some client code simply checks if a field IS an EE_Trashed_Flag_Field |
|
7 | + //...otherwise, these fields are mostly the same as boolean fields |
|
8 | 8 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_Boolean_Field.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_Boolean_Field.php'); |
|
3 | 3 | |
4 | 4 | class EE_Trashed_Flag_Field extends EE_Boolean_Field |
5 | 5 | { |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_DB_Only_Field_Base.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Used by EE_Belongs_To_Any_Relations and EE_Has_Many_Any_Relations to identify the model the foreign key points to. |
@@ -2,24 +2,24 @@ |
||
2 | 2 | |
3 | 3 | abstract class EE_Primary_Key_Field_Base extends EE_Field_With_Model_Name |
4 | 4 | { |
5 | - /** |
|
6 | - * Overrides parent so it doesn't need to provide so many non-applicable fields |
|
7 | - * |
|
8 | - * @param string $table_column |
|
9 | - * @param string $nicename |
|
10 | - */ |
|
11 | - public function __construct($table_column, $nicename, $default) |
|
12 | - { |
|
13 | - parent::__construct($table_column, $nicename, false, $default, null); |
|
14 | - } |
|
5 | + /** |
|
6 | + * Overrides parent so it doesn't need to provide so many non-applicable fields |
|
7 | + * |
|
8 | + * @param string $table_column |
|
9 | + * @param string $nicename |
|
10 | + */ |
|
11 | + public function __construct($table_column, $nicename, $default) |
|
12 | + { |
|
13 | + parent::__construct($table_column, $nicename, false, $default, null); |
|
14 | + } |
|
15 | 15 | |
16 | - /** |
|
17 | - * @param $table_alias |
|
18 | - * @param $name |
|
19 | - */ |
|
20 | - function _construct_finalize($table_alias, $name, $model_name) |
|
21 | - { |
|
22 | - $this->_model_name_pointed_to = $model_name; |
|
23 | - parent::_construct_finalize($table_alias, $name, $model_name); |
|
24 | - } |
|
16 | + /** |
|
17 | + * @param $table_alias |
|
18 | + * @param $name |
|
19 | + */ |
|
20 | + function _construct_finalize($table_alias, $name, $model_name) |
|
21 | + { |
|
22 | + $this->_model_name_pointed_to = $model_name; |
|
23 | + parent::_construct_finalize($table_alias, $name, $model_name); |
|
24 | + } |
|
25 | 25 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -24,34 +24,34 @@ discard block |
||
24 | 24 | */ |
25 | 25 | class EE_WP_User_Field extends EE_Foreign_Key_Int_Field |
26 | 26 | { |
27 | - /** |
|
28 | - * No need to provide a default or the model pointed to- the default is |
|
29 | - * always get_current_user_id() and the model pointed to is always WP_User |
|
30 | - * |
|
31 | - * @param string $table_column name fo column for field |
|
32 | - * @param string $nicename should eb internationalized with __('blah','event_espresso') |
|
33 | - * @param boolean $nullable |
|
34 | - */ |
|
35 | - function __construct($table_column, $nicename, $nullable) |
|
36 | - { |
|
37 | - parent::__construct($table_column, $nicename, $nullable, null, 'WP_User'); |
|
38 | - } |
|
27 | + /** |
|
28 | + * No need to provide a default or the model pointed to- the default is |
|
29 | + * always get_current_user_id() and the model pointed to is always WP_User |
|
30 | + * |
|
31 | + * @param string $table_column name fo column for field |
|
32 | + * @param string $nicename should eb internationalized with __('blah','event_espresso') |
|
33 | + * @param boolean $nullable |
|
34 | + */ |
|
35 | + function __construct($table_column, $nicename, $nullable) |
|
36 | + { |
|
37 | + parent::__construct($table_column, $nicename, $nullable, null, 'WP_User'); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Gets the default which is always the current user. This can't be set when initially |
|
42 | - * constructing the model field because that's done before $current_user is set |
|
43 | - * |
|
44 | - * @return mixed |
|
45 | - */ |
|
46 | - function get_default_value() |
|
47 | - { |
|
48 | - if (did_action('init')) { |
|
49 | - return get_current_user_id(); |
|
50 | - } else { |
|
51 | - EE_Error::doing_it_wrong('EE_WP_User_Field::get_default_value', |
|
52 | - __('You cant get a default value for a wp_User_Field because the "init" action is called, because current_user global hasnt yet been setup. Consider doing your business logic on the "init" hook or later.', |
|
53 | - 'event_espresso'), '4.6.20'); |
|
54 | - return 1; |
|
55 | - } |
|
56 | - } |
|
40 | + /** |
|
41 | + * Gets the default which is always the current user. This can't be set when initially |
|
42 | + * constructing the model field because that's done before $current_user is set |
|
43 | + * |
|
44 | + * @return mixed |
|
45 | + */ |
|
46 | + function get_default_value() |
|
47 | + { |
|
48 | + if (did_action('init')) { |
|
49 | + return get_current_user_id(); |
|
50 | + } else { |
|
51 | + EE_Error::doing_it_wrong('EE_WP_User_Field::get_default_value', |
|
52 | + __('You cant get a default value for a wp_User_Field because the "init" action is called, because current_user global hasnt yet been setup. Consider doing your business logic on the "init" hook or later.', |
|
53 | + 'event_espresso'), '4.6.20'); |
|
54 | + return 1; |
|
55 | + } |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 |