Commit Graph

93 Commits

Author SHA1 Message Date
Sergey Biryukov
7932193708 Coding Standards: Use strict comparison where static strings are involved.
This reduces the number of `WordPress.PHP.StrictComparisons.LooseComparison` issues in half, from 1897 to 890.

Includes minor code layout fixes for better readability.

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47808


git-svn-id: http://core.svn.wordpress.org/trunk@47584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-16 18:42:12 +00:00
Sergey Biryukov
38676936ba Coding Standards: Use strict type check for in_array() and array_search() where strings are involved.
This reduces the number of `WordPress.PHP.StrictInArray.MissingTrueStrict` issues from 486 to 50.

Includes minor code layout fixes for better readability.

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47550


git-svn-id: http://core.svn.wordpress.org/trunk@47325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-04-05 03:02:11 +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
Sergey Biryukov
9967a3e030 Docs: Add missing description for $post global.
Props immeet94.
Fixes #46503. See #47110.
Built from https://develop.svn.wordpress.org/trunk@45742


git-svn-id: http://core.svn.wordpress.org/trunk@45553 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-04 12:28:56 +00:00
desrosj
f807a098b1 Administration: Improve the accuracy of is_block_editor().
Currently, there are a number of scenarios where `is_block_editor()` (and `WP_Screen::is_block_editor`) would incorrectly indicate block editor support at different points of the loading process. Most notably, checking `is_block_editor` when hooking into the `current_screen` action will always result in `false`, even when the block editor is being loaded. This is because `is_block_editor` is not set to `true` until `edit-form-blocks.php` is included.

This change adds logic to `WP_Screen` to ensure the accuracy of `is_block_editor` on block editor pages earlier in the load process.

While edit screens will now be accurate 100% of the time from `current_screen` on, there are still a few edge cases where `is_block_editor` could contain an incorrect value when creating a new post.

Because a `WP_Post` object is a required parameter for the `replace_editor` filter and `use_block_editor_for_post()` function, `WP_Screen` will fall back to the value returned by `use_block_editor_for_post_type()` for the post being created. To eliminate these edge cases, the `use_block_editor_for_post_type` filter can be used to return the appropriate boolean value to indicate support.

Props Chouby, desrosj, aduth, johnbillion.
Fixes #46195.
Built from https://develop.svn.wordpress.org/trunk@45224


git-svn-id: http://core.svn.wordpress.org/trunk@45033 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-17 01:56:52 +00:00
Gary Pendergast
8464097ea4 Editor: Merge some minor bug fixes.
There were some tweaks made to the post editor in WordPress 5.0 that hadn't been merged to `trunk`, this commit rectifies that.

Merges [43815,43816] from the 5.0 branch to trunk.

Props birgire, jorbin, abdullahramzan, adamsilverstein, mrahmadawais, airathalitov, ajitbohra, schlessera, albertomedina, aldavigdis, alexsanford1, xyfi, nitrajka, afercia, andreiglingeanu, euthelup, aduth, sumobi, anevins, azaozz, androb, andrewserong, kallehauge, nosolosw, apeatling, atimmer, arnaudban, asvinballoo, b-07, benlk, blowery, caxco93, benjamin_zekavica, kau-boy, bernhard-reiter, bcolumbia, bph, boblinthorst, bradyvercher, bpayton, brentswisher, bronsonquick, burhandodhy, icaleb, chouby, ehg, chrisvanpatten, butimnoexpert, christophherr, chriskmnds, claudiosanches, danielbachhuber, mrmadhat, danielhw, danieltj, goldsounds, dfangstrom, daniloercoli, dannycooper, nerrad, dsawardekar, davemoran118, davidherrera, dryanpress, davidsword, davisshaver, dmsnell, dlocc, diegoreymendez, dd32, dency, ocean90, donnapep, chopinbach, electricfeet, eliorivero, sewmyheadon, ericnmurphy, foobar4u, circlecube, fabs_pim, flixos90, floriansimeth, gma992, garrett-eclipse, garyj, pento, doomwaxer, revgeorge, gziolo, bordoni, hardeepasrani, helen, luehrsen, herbmiller, toro_unit, ianbelanger, iandunn, igorsch, ipstenu, ireneyoast, israelshmueli, sisanu, jd55, copons, jnylen0, jamestryon, ephoxjames, jamiehalvorson, jsnajdr, jagnew, dciso, octalmage, vengisss, jhoffm34, shenkj, audrasjb, jblz, jeremyfelt, motleydev, jipmoors, sephsekla, joemaller, joemcgill, joen, johndyer, johnjamesjacoby, joshuawold, johnny5, desrosj, jonsurrell, belcherj, sirjonathan, koke, jorgefilipecosta, shelob9, jvisick77, julienmelissas, kopepasah, kadamwhite, codebykat, ryelle, gwwar, kevinwhoffman, coderkevin, ixkaito, kjellr, obenland, lancewillett, postphotos, loicblascos, lucasstark, luigipulcini, lucaskowalski, lukepettway, mahdiyazdani, mahmoudsaeed, mkaz, tyxla, markjaquith, mapk, vindl, m-e-h, mboynes, mattheu, lonelyvegan, mtias, napy84, maurobringolf, maximebj, mayukojpn, woodent, michaelhull, mmtr86, stubgo, simison, mihai2u, mike-haydon-swo, mnelson4, mpheasant, mikeschroder, idpokute, mikeyarce, dimadin, gonzomir, milesdelliott, warmarks, munirkamal, nfmohit, nateconley, greatislander, njpanderson, notnownikki, nielslange, nikschavan, potbot, nshki, webmandesign, oskosk, pglewis, pareshradadiya-1, swissspidy, pbearne, pauldechov, psealock, paulstonier, paulwilde, pedromendonca, ptasker, peterwilsoncc, tyrannous, strategio, piersb, delawski, prtksxna, presskopp, rachelbaker, rachelmcr, rakshans1, rahmon, lamosty, youknowriad, riddhiehta02, noisysocks, deviodigital, sanchothefat, robertsky, _dorsvenabili, rohittm, magicroundabout, rmccue, welcher, ryo511, sagarprajapati, samikeijonen, scottmweaver, kluny, sharaz, giventofly76, designsimply, sstoqnov, hypest, netweb, stevehenty, stuartfeldt, sergioestevao, soean, tammie_l, karmatosed, thrijith, timgardner, timmydcrawford, tjnowell, mirucon, travislopes, truongwp, tjfunke001, vishalkakadiya, vtrpldn, walterebert, westonruter, skorasaurus, somtijds, earnjam, williampatton, willybahuaud, yoavf, zebulan, ziyaddin, abhijitrakas, andreamiddleton, csabotta, dixitadusara, etoledom, faishal, hideokamoto, imath, iseulde, j-falk, jaswrks, johnwatkins0, jomurgel, notlaura, leahkoerper, mcsf, meetjey, 0mirka00, mitogh, ephoxmogran, tacrapo, mzorz, nagayama, omarreiss, ramonopoly, rileybrook, tinkerbelly, shaileesheth, sikander, ssousa, tfrommen, yahil.

Fixes #45037.


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


git-svn-id: http://core.svn.wordpress.org/trunk@43995 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-14 05:12:52 +00:00
Andrew Ozz
06725cf28d Move scheduling of old auto-draft posts deletion to get_default_post_to_edit() (where auto-drafts are created).
Fixes #44337.
Built from https://develop.svn.wordpress.org/trunk@43338


git-svn-id: http://core.svn.wordpress.org/trunk@43166 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-06-28 02:26:22 +00:00
Peter Wilson
e6ccdf161f General: Further improve error messages following [42648].
Props kristastevens, melchoyce.
Fixes #38332 for trunk.


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


git-svn-id: http://core.svn.wordpress.org/trunk@42547 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-19 02:13:32 +00:00
Peter Wilson
0d39b35c11 General: Replace Cheatin’ uh? with friendlier error messages.
While intended as a playful error message, `Cheatin’ uh?` can be interpreted as insulting or accusatory in an already stressful situation. This replaces Cheatin’ with more meaningful error messages, depending on the error that occurs.

Props ElectricFeet, EricMeyer, karmatosed, dd32, BandonRandon, melchoyce for language; dmsnell for original patch; peterwilsoncc.
Fixes #38332.


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


git-svn-id: http://core.svn.wordpress.org/trunk@42477 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-05 02:30:34 +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
Gary Pendergast
a72be13ec0 Editor: Add the replace_editor filter.
This filter allows the Core editor to be replaced by an entirely different editor (coughcoughGUTENBERGcough).

Props azaozz, who is supposed to be on sabbatical right now.
Fixes #42119.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-11 12:06:48 +00:00
Sergey Biryukov
866bd39813 I18N: Combine two duplicate "Invalid post type" strings.
Props @ramiy.
See #18218.
Built from https://develop.svn.wordpress.org/trunk@38076


git-svn-id: http://core.svn.wordpress.org/trunk@38017 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-17 16:05:31 +00:00
Dominik Schilling
25e66e4f1e Text Changes: Unify permission error messages.
The new format looks like "Sorry, you are not allowed to <action>.". This provides a consistent experience for all error messages related to missing permissions. It also reduces the number of similar strings and allows translators to provide a consistent style in their language.

Props ramiy, Presskopp.
Fixes #34521.
Built from https://develop.svn.wordpress.org/trunk@37914


git-svn-id: http://core.svn.wordpress.org/trunk@37855 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-29 15:16:29 +00:00
Sergey Biryukov
d5ac2bc41e Provide more helpful feedback than just "Cheatin' uh?" for permission errors in wp-admin/post-new.php.
props ericlewis, kraftbj, lukecarbis, mrmist.
fixes #33675. see #14530.
Built from https://develop.svn.wordpress.org/trunk@33864


git-svn-id: http://core.svn.wordpress.org/trunk@33832 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-02 18:36:22 +00:00
Scott Taylor
b56b9b3e5c Add @global annotations for wp-admin/*.
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-28 21:41:30 +00:00
Scott Taylor
84867b3e9c Admin globals:
* Declare `$wp_importers` as a global in `admin.php`
* Declare `$post_type`, `$post_type_object`, and  `$post` as globals where applicable

See #30799.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-10 05:29:22 +00:00
John Blackbourn
d88ed475b0 Switch to a 403 response code in places where it is more appropriate than a 500 due to permissions errors.
Fixes #10551
Props nacin

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


git-svn-id: http://core.svn.wordpress.org/trunk@30355 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-16 06:16:22 +00:00
Helen Hou-Sandí
6513808db0 When adding a post of a post type whose menu item is in a submenu, highlight the correct menu item. props mordauk, markjaquith. fixes #24137.
Built from https://develop.svn.wordpress.org/trunk@29300


git-svn-id: http://core.svn.wordpress.org/trunk@29082 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-25 15:26:18 +00:00
Andrew Nacin
fd57b239d2 Don't rely on include_path to include files.
Always use dirname() or, once available, ABSPATH.

props ketwaroo, hakre.
fixes #17092.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25533 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-25 00:18:11 +00:00
Andrew Nacin
5f9a631983 Let the wp_redirect to media-new.php from post-new.php?post_type=attachment be canceled using the wp_redirect filter.
props DrewAPicture.
fixes #25216.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-16 17:52:10 +00:00
Andrew Ozz
504c10dbba Post locks: load the post locked dialog html in post-new.php too, see #23697.
git-svn-id: http://core.svn.wordpress.org/trunk@24543 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-03 01:50:39 +00:00
Andrew Nacin
902314ad3c No AYS or autosave for attachments on post.php. Reverts part of [22725]. fixes #22491.
git-svn-id: http://core.svn.wordpress.org/trunk@22858 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-27 02:02:32 +00:00
Andrew Nacin
f26102a248 Redirect post-new.php?post_type=attachment to media-new.php. see #22491, #22083, #21391.
git-svn-id: http://core.svn.wordpress.org/trunk@22777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-21 17:40:53 +00:00
Andrew Ozz
0e38402629 Don't load autosave.js on the attachment editing screen, add simple AYS on unload if there are changes, props helenyhou, fixes #22491
git-svn-id: http://core.svn.wordpress.org/trunk@22725 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-20 19:46:38 +00:00
Ryan Boren
a550a6d489 Use the create_posts capability in more places.
In get_post_type_capabilities(), make sure create_posts reflects customizations to the edit_posts capability when create_posts is not specifically set.


git-svn-id: http://core.svn.wordpress.org/trunk@22291 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-24 22:15:43 +00:00
ryan
27630a4286 Schedule auto-draft deletion from post-new.php instead of from admin.php. This provides better throttling for large multisite installs and reduces the risk of a delete avalanche.
fixes #19663


git-svn-id: http://svn.automattic.com/wordpress/trunk@20453 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-04-12 18:49:48 +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
974108d57c Select the submenu item for post-new.php when using show_in_menu = 'some-parent-file' for post types. Continue to select the post-new.php submenu item if it has been separately added with add_submenu_page(). fixes #19125.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19425 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-11-23 20:45:23 +00:00
nacin
5e69bd0caf Set $parent_file for post-new.php when show_in_menu is a file. Provides for correct top-level highlighting. $submenu_file remains set to expect a post-new.php menu. see #19125.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-11-21 15:35:57 +00:00
nacin
9cb6e158fc Switch from Panel/SubPanel to Screen in inline documentation and Codex links. props michaelh, fixes #17265.
git-svn-id: http://svn.automattic.com/wordpress/trunk@17748 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 15:24:49 +00:00
ryan
de0188c661 Die if user doesn't have caps for the post type. Props duck_. fixes #15259
git-svn-id: http://svn.automattic.com/wordpress/trunk@16135 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-11-01 16:28:35 +00:00
ryan
f0076eed1c Set show_ui to true for post and page. Exclude _builtin = true from areas where we need to special case builtin types. fixes #13403
git-svn-id: http://svn.automattic.com/wordpress/trunk@14713 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-05-17 16:39:36 +00:00
nacin
6d6532bfa1 Use show_ui instead of public flag to check whether the post type uses post-new and edit.php. see #13403.
git-svn-id: http://svn.automattic.com/wordpress/trunk@14674 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-05-15 20:49:28 +00:00
nacin
7734a07cb2 Move post type object capabilities to a 'cap' object. Allow them to be initialized via the 'capabilities' key (an array) when registering support for the post type. Caps are now referred to by the name of the cap as if it was a post, i.e. ->cap->edit_post. see #13358.
git-svn-id: http://svn.automattic.com/wordpress/trunk@14585 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-05-12 20:45:18 +00:00
nbachiyski
46afe7c285 I18n for custom post type labels. Props demetris, dimadin. Fixes #12968
git-svn-id: http://svn.automattic.com/wordpress/trunk@14571 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-05-11 19:52:50 +00:00
nacin
340acf8263 Don't enqueue unnecessary scripts when the post type doesn't support the editor. fixes #12590, props scribu, _duck.
git-svn-id: http://svn.automattic.com/wordpress/trunk@14107 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-04-16 14:03:48 +00:00
ryan
9f0db9355a Die if invalid post type is passed. see #9674
git-svn-id: http://svn.automattic.com/wordpress/trunk@13537 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-03-01 20:33:03 +00:00
dd32
8136de990c Introduce 'singular_label' for Post Types. Props scribu. See #12214
git-svn-id: http://svn.automattic.com/wordpress/trunk@13101 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-02-13 08:56:38 +00:00
ryan
9de60f3644 Add a separate show_ui flag for post types. see #9674
git-svn-id: http://svn.automattic.com/wordpress/trunk@12993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-02-06 17:27:30 +00:00
markjaquith
0f924eee99 Create post_status=auto-draft when creating a new post item. status changes to draft on first auto-save. now we always have a real post ID to work with. see #11889. fixes #11145. fixes #11990
git-svn-id: http://svn.automattic.com/wordpress/trunk@12987 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-02-06 10:07:57 +00:00
ryan
5922f7e2c4 Allow customizing capabilities for custom post types. Always check caps against those in the post type object instead of contructing them manually. see #9674
git-svn-id: http://svn.automattic.com/wordpress/trunk@12927 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-02-02 17:37:03 +00:00
ryan
05bf7382ff Merge edit-pages.php into edit.php. see #9674
git-svn-id: http://svn.automattic.com/wordpress/trunk@12728 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-01-15 16:58:36 +00:00
ryan
5316b4fc2d Merge page-new.php into post-new.php. Start abstracting column headers and prefs. see #9674
git-svn-id: http://svn.automattic.com/wordpress/trunk@12702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-01-12 00:14:27 +00:00
ryan
da89de4958 More custom post type support. Props scribu. see #9674
git-svn-id: http://svn.automattic.com/wordpress/trunk@12597 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-01-04 16:58:43 +00:00
azaozz
7927c2f6c6 Pull thumbnail scripts out of Posts screens too. see #10928
git-svn-id: http://svn.automattic.com/wordpress/trunk@12065 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-10-19 21:51:16 +00:00
markjaquith
d7a30e235f First pass on canonical post thumbanils. Admin-side GUI only. Theme functions to follow. see #10928
git-svn-id: http://svn.automattic.com/wordpress/trunk@12007 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-10-07 22:18:09 +00:00
ryan
cc7c443f62 Move screen_meta() to admin header. Add all meta boxes before requiring admin-header.
git-svn-id: http://svn.automattic.com/wordpress/trunk@9620 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2008-11-11 22:40:16 +00:00
ryan
d457e3d181 Bring back h2 for add/edit post
git-svn-id: http://svn.automattic.com/wordpress/trunk@9221 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2008-10-17 00:36:18 +00:00