Commit Graph

26 Commits

Author SHA1 Message Date
Sergey Biryukov
1ce5dc7444 Code Modernization: Replace usage of strpos() with str_contains().
`str_contains()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) contains the given substring (needle).

WordPress core includes a polyfill for `str_contains()` on PHP < 8.0 as of WordPress 5.9.

This commit replaces `false !== strpos( ... )` with `str_contains()` in core files, making the code more readable and consistent, as well as better aligned with modern development practices.

Follow-up to [52039], [52040], [52326], [55703], [55710], [55987].

Props Soean, spacedmonkey, costdev, dingo_d, azaozz, mikeschroder, flixos90, peterwilsoncc, SergeyBiryukov.
Fixes #58206.
Built from https://develop.svn.wordpress.org/trunk@55988


git-svn-id: http://core.svn.wordpress.org/trunk@55500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 14:36:26 +00:00
iandunn
8b025acd61 Multisite: Log error/warnings/notices from ms-files.php.
Previously errors were not displayed or logged, but the original intention was only to prevent them from being displayed. Hiding them from logs makes problems like #53492 much harder to debug.

This makes the handling of errors in `ms-files` consistent with the REST API, `admin-ajax`, and XML-RPC.

Props iandunn, johnjamesjacoby.
Fixes #53493.

Built from https://develop.svn.wordpress.org/trunk@51358


git-svn-id: http://core.svn.wordpress.org/trunk@50967 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-06 20:21:57 +00:00
Sergey Biryukov
641c632b0c Coding Standards: Use Yoda conditions where appropriate.
See #49222.
Built from https://develop.svn.wordpress.org/trunk@47219


git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-09 16:55:09 +00:00
Sergey Biryukov
47ed56f38f Code Modernization: Replace dirname( __FILE__ ) calls with __DIR__ magic constant.
This avoids the performance overhead of the function call every time `dirname( __FILE__ )` was used instead of `__DIR__`.

This commit also includes:

* Removing unnecessary parentheses from `include`/`require` statements. These are language constructs, not function calls.
* Replacing `include` statements for several files with `require_once`, for consistency:
 * `wp-admin/admin-header.php`
 * `wp-admin/admin-footer.php`
 * `wp-includes/version.php`

Props ayeshrajans, desrosj, valentinbora, jrf, joostdevalk, netweb.
Fixes #48082.
Built from https://develop.svn.wordpress.org/trunk@47198


git-svn-id: http://core.svn.wordpress.org/trunk@46998 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-06 06:33:11 +00:00
Sergey Biryukov
001ffe81fb Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47122


git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-29 00:45:18 +00:00
Gary Pendergast
aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


Built from https://develop.svn.wordpress.org/trunk@42343


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
Jeremy Felt
7d6c7b441d Multsite: Flush output buffer after readfile() in ms-files.php.
Props fuscata, MikeLittle for testing, iamfriendly for testing.
Fixes #14730.

Built from https://develop.svn.wordpress.org/trunk@38662


git-svn-id: http://core.svn.wordpress.org/trunk@38605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-27 20:05:28 +00:00
Scott Taylor
5c6b63d3a6 if is a statment, not a function.
See #32444.

Built from https://develop.svn.wordpress.org/trunk@32800


git-svn-id: http://core.svn.wordpress.org/trunk@32771 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 20:01:25 +00:00
Andrew Nacin
de0b1ffbf8 Use stripslashes() instead of wp_unslash() in ms-files.php to avoid formatting.php dependency. props devesine, fixes #24374.
git-svn-id: http://core.svn.wordpress.org/trunk@24305 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-05-20 20:20:22 +00:00
Ryan Boren
15a06a35ab Use wp_unslash() instead of stripslashes() and stripslashes_deep(). Use wp_slash() instead of add_magic_quotes().
see #WP21767


git-svn-id: http://core.svn.wordpress.org/trunk@23591 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-03 16:30:38 +00:00
Ryan Boren
43a7e695e9 Revert 23416, 23419, 23445 except for wp_reset_vars() changes. We are going a different direction with the slashing cleanup, so resetting to a clean slate. see #21767
git-svn-id: http://core.svn.wordpress.org/trunk@23554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-01 16:28:40 +00:00
Ryan Boren
cc5ed3a485 Change all core API to expect unslashed rather than slashed arguments.
The exceptions to this are update_post_meta() and add_post_meta() which are often used by plugins in POST handlers and will continue accepting slashed data for now.

Introduce wp_upate_post_meta() and wp_add_post_meta() as unslashed alternatives to update_post_meta() and add_post_meta(). These functions could become methods in WP_Post so don't use them too heavily yet.

Remove all escape() calls from wp_xmlrpc_server. Now that core expects unslashed data this is no longer needed.

Remove addslashes(), addslashes_gpc(), add_magic_quotes() calls on data being prepared for handoff to core functions that until now expected slashed data. Adding slashes in no longer necessary.

Introduce wp_unslash() and use to it remove slashes from GPCS data before using it in core API. Almost every instance of stripslashes() in core should now be wp_unslash(). In the future (a release or three) when GPCS is no longer slashed, wp_unslash() will stop stripping slashes and simply return what is passed. At this point wp_unslash() calls can be removed from core.

Introduce wp_slash() for slashing GPCS data. This will also turn into a noop once GPCS is no longer slashed. wp_slash() should almost never be used. It is mainly of use in unit tests.

Plugins should use wp_unslash() on data being passed to core API.

Plugins should no longer slash data being passed to core. So when you get_post() and then wp_insert_post() the post data from get_post() no longer needs addslashes(). Most plugins were not bothering with this. They will magically start doing the right thing. Unfortunately, those few souls who did it properly will now have to avoid calling addslashes() for 3.6 and newer.

Use wp_kses_post() and wp_kses_data(), which expect unslashed data, instead of wp_filter_post_kses() and wp_filter_kses(), which expect slashed data. Filters are no longer passed slashed data.

Remove many no longer necessary calls to $wpdb->escape() and esc_sql().

In wp_get_referer() and wp_get_original_referer(), return unslashed data.

Remove old stripslashes() calls from WP_Widget::update() handlers. These haven't been necessary since WP_Widget.

Switch several queries over to prepare().

Expect something to break.

Props alexkingorg
see #21767


git-svn-id: http://core.svn.wordpress.org/trunk@23416 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-14 22:51:06 +00:00
ryan
e3b46b25d3 Lose EOF ?>. Clean up EOF newlines. fixes #12307
git-svn-id: http://svn.automattic.com/wordpress/trunk@19712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-08 17:01:11 +00:00
nacin
f855a18bc1 trailingslashit isn't normally available in ms-files. props davecpage, fixes #18592.
git-svn-id: http://svn.automattic.com/wordpress/trunk@18642 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-09-06 15:41:57 +00:00
nacin
d6fe2825c9 Force a trailing slash on BLOGUPLOADDIR in ms-files.php. props wonderboymusic, see #18592.
git-svn-id: http://svn.automattic.com/wordpress/trunk@18638 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-09-05 16:55:05 +00:00
ryan
0a26ef9d38 s/Content-type/Content-Type/. Props dvwallin. fixes #17256
git-svn-id: http://svn.automattic.com/wordpress/trunk@17922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-05-13 19:31:36 +00:00
westi
7e5c6cb031 Ensure we don't generate incorrect content types when files are requested with query strings. Fixes #14450 props chrisbliss18.
git-svn-id: http://svn.automattic.com/wordpress/trunk@15749 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-10-07 21:00:45 +00:00
wpmuguru
24f2415b80 block ms-files.php when not multisite, see #11742
git-svn-id: http://svn.automattic.com/wordpress/trunk@14609 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-05-13 21:40:42 +00:00
westi
2906ded640 Remove blank data and lines after the closing ?> which can break image display for multisite.
git-svn-id: http://svn.automattic.com/wordpress/trunk@14078 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-04-13 17:13:28 +00:00
nacin
aa92bfad14 Remove conditionally declared wp_check_filetype() from ms-files.php. It will always be defined in functions.php. see #11644
git-svn-id: http://svn.automattic.com/wordpress/trunk@13682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-03-12 00:38:04 +00:00
nacin
01d4f4f18c Remove wp-content/blogs.php and add deprecated warning for MU admins. fixes #11742
git-svn-id: http://svn.automattic.com/wordpress/trunk@13514 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-02-28 20:29:24 +00:00
westi
b20c3c41d4 Improve the implementation of the default constant defining functions for multisite. See #11881.
git-svn-id: http://svn.automattic.com/wordpress/trunk@13065 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-02-12 08:22:34 +00:00
wpmuguru
26d0ba4c75 revert remove error_reporting from ms-files.php, remove _deprecated_file call from blogs.php, see #11742
git-svn-id: http://svn.automattic.com/wordpress/trunk@13040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-02-09 18:22:21 +00:00
wpmuguru
412aacfde1 remove error_reporting from ms-files.php, see #11742
git-svn-id: http://svn.automattic.com/wordpress/trunk@13038 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-02-09 16:44:40 +00:00
wpmuguru
f3cae9b9d9 restore shell wp-content/blogs.php & add deprecated warnings, props nacin, see #11742
git-svn-id: http://svn.automattic.com/wordpress/trunk@12977 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-02-05 21:40:22 +00:00
wpmuguru
d1069acd38 improvements to custom content dir support, props nacin, see #11742
git-svn-id: http://svn.automattic.com/wordpress/trunk@12936 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-02-03 18:19:56 +00:00