Commit Graph

727 Commits

Author SHA1 Message Date
Andrew Nacin 8adec7a437 Do not save an initial revision for a post created through the auto-draft mechanism. Prevents a bogus revision, often with the title 'Auto Draft'. Restores pre-auto-draft behavior made obvious by XML-RPC's implementation of both auto-drafts and the subsequent wp.getRevisions method. fixes #22687. see #22686.
git-svn-id: https://develop.svn.wordpress.org/trunk@22989 602fd350-edb4-49c9-b593-d223f7449a82
2012-12-03 06:28:28 +00:00
Ryan Boren a26c25a8bc Map the create_posts post type cap to upload_files for attachments.
Props nacin
fixes #16714


git-svn-id: https://develop.svn.wordpress.org/trunk@22921 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-29 16:14:07 +00:00
Ryan Boren bf812ac283 Clear the object term relationships cache in wp_set_object_terms() rather than wp_set_post_terms(). This should be done lower in the stack than wp_set_post_terms().
Props batmoo
fixes #22560


git-svn-id: https://develop.svn.wordpress.org/trunk@22878 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-27 19:42:38 +00:00
Daryl Koopersmith 8e6aa60fa4 Media: Dynamically generate attachment filters using get_post_mime_types().
Moves `get_post_mime_types()` from `wp-admin/includes/post.php` to `wp-includes/post.php`.

fixes #22514, see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22743 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-21 10:18:59 +00:00
Ryan Boren e158d36f6e Don't bail from get_the_terms() if the post type is not registed for the taxonomy. This can break back compat when add_post_type_support( 'page', 'post-formats' ) is called but register_taxonomy_for_object_type( 'postr_-format', 'page' ) is not.
Props SergeyBiryukov
fixes #22473


git-svn-id: https://develop.svn.wordpress.org/trunk@22722 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-20 18:31:06 +00:00
Andrew Nacin 52cc02a9be This should be a cache add, not a cache set. see #22503.
git-svn-id: https://develop.svn.wordpress.org/trunk@22676 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-19 08:39:52 +00:00
Andrew Nacin 4cba7e30e0 Call wp_cache_set() with a group and then an expiration in wp_mime_type_icon(). fixes #22503. see #22186.
git-svn-id: https://develop.svn.wordpress.org/trunk@22674 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-19 08:31:43 +00:00
Ryan Boren 35576683fe Always return a raw filtered post object from WP_Post::get_instance().
Props kovshenin, scribu, ntm
fixes #22448


git-svn-id: https://develop.svn.wordpress.org/trunk@22635 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-17 15:14:48 +00:00
Andrew Nacin 6f8681b02d Revert [22445]. see #20376. fixes #22389.
git-svn-id: https://develop.svn.wordpress.org/trunk@22464 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-08 03:30:56 +00:00
Andrew Nacin d9bab22085 Fix meta value querying in wp_list_pages(). props SergeyBiryukov. fixes #20376.
git-svn-id: https://develop.svn.wordpress.org/trunk@22445 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-07 21:48:38 +00:00
Andrew Nacin 2a9536d817 Add a $public_only argument to count_many_users_posts() and get_posts_by_author_sql(). Defaults to false, and allows the counts to be returned for only public posts. props ryan, westi. fixes #21431.
git-svn-id: https://develop.svn.wordpress.org/trunk@22386 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-05 23:11:25 +00:00
Andrew Nacin a6a8321d7d clean_post_cache() no longer calls itself recursively. see #11399.
git-svn-id: https://develop.svn.wordpress.org/trunk@22357 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-02 16:13:53 +00:00
Ryan Boren 308c702183 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: https://develop.svn.wordpress.org/trunk@22291 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-24 22:15:43 +00:00
Ryan Boren 8bc27f2c58 Don't wp_cache_add() stdClass objects in get_post() to avoid polluting the cache with incomplete or otherwise compromised objects.
Declare the core properties of WP_Pist as proper public properties and provide them with defaults.

Props wonderboymusic
fixes #22223


git-svn-id: https://develop.svn.wordpress.org/trunk@22264 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-19 21:53:17 +00:00
Andrew Nacin 70c394fb79 Avoid queries in wp_unique_post_slug() for nav menu items. see #22189.
git-svn-id: https://develop.svn.wordpress.org/trunk@22232 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-15 14:13:57 +00:00
Andrew Nacin c29cae6fd4 Remove whitespace from around the WP_Post/get_post SQL string.
git-svn-id: https://develop.svn.wordpress.org/trunk@22230 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-15 03:08:43 +00:00
Andrew Nacin 000f9e6140 Use wp_update_post() rather than wp_insert_post() in wp_publish_post() to avoid stomping of values like categories. props ericmann, fixes #22167. see #21963.
git-svn-id: https://develop.svn.wordpress.org/trunk@22189 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-11 17:36:59 +00:00
Andrew Nacin caa32ba980 Add post_type_labels_{$post_type} filter. props scribu. fixes #21948.
git-svn-id: https://develop.svn.wordpress.org/trunk@22164 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 13:50:42 +00:00
Ryan Boren 594ef24dca Make sure cache bucket is an array to avoid warning. see #21309
git-svn-id: https://develop.svn.wordpress.org/trunk@22163 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 12:29:51 +00:00
Ryan Boren e22b981706 Avoid 'Only variables should be assigned by reference' warning. Props wonderboymusic. see #21865
git-svn-id: https://develop.svn.wordpress.org/trunk@22114 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-04 18:21:47 +00:00
Ryan Boren 48484428a2 Introduce create_posts meta capability. Props scribu, nacin, casben79. see #16714
git-svn-id: https://develop.svn.wordpress.org/trunk@22060 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-27 15:33:19 +00:00
Ryan Boren d9b4325db3 Fetch full terms for the post_category and tags_input queries and then wp_list_pluck() the desired fields. Fetching full terms primes the cache and reduces overall queries. Add cache invalidation to wp_set_post_terms(). Props scribu. see #21309
git-svn-id: https://develop.svn.wordpress.org/trunk@21981 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-24 20:35:56 +00:00
Ryan Boren 44cb6ddc16 Don't add empty _wp_attached_file, _wp_attachment_metadata, _thumbnail_id meta to posts. Delete these fields when set to empty. Props SergeyBiryukov, Caspie. fixes #16391
git-svn-id: https://develop.svn.wordpress.org/trunk@21967 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-24 13:07:34 +00:00
Andrew Nacin 3f051e73ef Properly indent after [21952]. see #11399.
git-svn-id: https://develop.svn.wordpress.org/trunk@21953 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-22 16:21:06 +00:00
Andrew Nacin b7198b85f8 Stop cleaning the cache of a post's children. Ancestors are no longer cached against the post object, which means this kind of walking is unnecessary. It is also prohibitively expensive with large hierarchies.
We need to remove post_ancestors non-persistent caching for this. get_post_ancestors() can simply rely on the caching of get_post() instead. Previously, it was a direct query, hence the extra layers of caching and clearing.

Child cache clearing stays in wp_delete_post() as children get a new parent.

fixes #11399.



git-svn-id: https://develop.svn.wordpress.org/trunk@21952 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-22 15:55:02 +00:00
Andrew Nacin 991be145a9 Use the regular post type UI for editing single media items (attachments).
* Attachments now go through post.php, edit_post(), the like, and have show_ui set to true.
 * Taxonomies attached to the media library now appear in the admin menu (if show_ui).
 * Editing, cropping, uploading, etc. is still very rough, but mostly functional.

API-wise:
 * New function: get_taxonomies_for_attachments(). Like get_taxonomies(), for taxonomies specifically registered against attachments.
 * Brings taxonomy support from the posts list table to the media list table. Expect them to converge soon.
 * wp_insert_attachment() now handles taxonomies like wp_insert_post(). Also expect them to converge soon.
 * New edit_form_after_title hook.

props helenyhou, ocean90. see #21391.



git-svn-id: https://develop.svn.wordpress.org/trunk@21948 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-21 22:52:54 +00:00
Andrew Nacin 2e6cb465b2 Call clean_post_cache() in wp_insert_post() after the manual query to change GUID. Remove the second call to clean_post_cache() previously done on the save_post hook. see #11399.
git-svn-id: https://develop.svn.wordpress.org/trunk@21943 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-21 18:52:15 +00:00
Andrew Nacin 35688ccb89 Have wp_publish_post() wrap wp_insert_post() directly. see #11399.
git-svn-id: https://develop.svn.wordpress.org/trunk@21942 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-21 18:49:45 +00:00
Peter Westwood d86f9f140f Posting: Improve the invalid date protection code based on feedback from nacin.
* Introduce a wp_checkdate() function with a single filter to centralise the code that validates dates.
 * Improve the error message
 * Correctly handle the return value of wp_insert_post which is not always a WP_Error on failure

Fixes #17180


git-svn-id: https://develop.svn.wordpress.org/trunk@21922 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-20 10:46:50 +00:00
Peter Westwood 59dd4b7d2b Posting: Make it much harder to create posts with invalid dates by enforcing the post date tests in the UI and the backend code.
Previously you could quite easily send a new post into the back of beyond by specifying an invalid date like the 30th Feb and this was very confusing.
Sometimes it would seem to work and sometimes the post would end up very far in the past - depending on the mysql version and other factors.

Fixes #17180 props jkudish.


git-svn-id: https://develop.svn.wordpress.org/trunk@21921 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-19 21:43:35 +00:00
Andrew Nacin 9a0d9562a2 Use wp_get_theme()->get_page_templates() rather than get_page_templates() in wp_insert_post(),
to allow page template setting on the frontend without a fatal error. fixes #21755.



git-svn-id: https://develop.svn.wordpress.org/trunk@21847 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-14 18:36:08 +00:00
Andrew Nacin 0ce7f85ca4 Remove unused show_in_admin_all and single_view_cap from register_post_status(). props duck_. fixes #18972.
git-svn-id: https://develop.svn.wordpress.org/trunk@21846 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-14 18:02:23 +00:00
Andrew Nacin 5b132e4c24 In get_page_by_path(), attempt to return an item that has the same post type before returning an attachment with the same name. props SergeyBiryukov. tests in [UT1021]. fixes #15665.
git-svn-id: https://develop.svn.wordpress.org/trunk@21845 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-14 17:19:25 +00:00
Andrew Nacin 6d2fc0af91 If update_post_caches() does not receive a post type, glean post types from the individual post objects, rather than assuming 'post'. fixes #20177.
git-svn-id: https://develop.svn.wordpress.org/trunk@21844 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-14 16:26:05 +00:00
Andrew Nacin cb682a8b61 Allow supports => false to be passed to register_post_type() to disable the default title and editor.
An empty array may also disable all default features in the future.
Do not rely on this behavior: always specify title and editor if you want them.

props sc0ttkclark.
fixes #21586.



git-svn-id: https://develop.svn.wordpress.org/trunk@21831 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-13 17:02:39 +00:00
Andrew Nacin c1eaaf31b8 Always return upload directory information from wp_upload_dir(), even if there is an error. Append the error to the array. see #19235.
git-svn-id: https://develop.svn.wordpress.org/trunk@21822 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-11 22:06:49 +00:00
Andrew Nacin dfac91464f Remove AtomPub from core.
* Will be replaced with http://wordpress.org/extend/plugins/atom-publishing-protocol/.
 * Introduces an action, xmlrpc_rsd_apis, to add APIs to xmlrpc.php?rsd.
 * Introduces support for 'error' being 403 and 50x in class-wp.php.
 * Removes 'Remote Publishing' from Writing Settings (see [21804]). Keeps the remote_publishing settings section.

DB version is bumped to generate the new wp-app rewrite rule and remove the old enable_app option.

props wonderboymusic.
fixes #21509.



git-svn-id: https://develop.svn.wordpress.org/trunk@21818 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-11 20:11:39 +00:00
Ryan Boren 879cb8231b Remove unnecessary return by refs. Props wonderboymusic. fixes #21839
git-svn-id: https://develop.svn.wordpress.org/trunk@21792 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-10 17:00:11 +00:00
Andrew Nacin b489c2b242 Use wp_cache_add() in wp_mime_type_icon(). fixes #21835.
git-svn-id: https://develop.svn.wordpress.org/trunk@21783 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-07 21:10:43 +00:00
Daryl Koopersmith d539c11a94 Ensure $post_id is defined in wp_mime_type_icon() to prevent notices when a valid mime type string is provided. see #21835.
git-svn-id: https://develop.svn.wordpress.org/trunk@21782 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-07 21:04:58 +00:00
Ryan Boren 31ec698423 Use get_post() instead of global $post.
Make the $post argument to get_post() optional, defaulting to the current post in The Loop.

Props nacin
see #21309


git-svn-id: https://develop.svn.wordpress.org/trunk@21735 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-04 16:29:28 +00:00
Ryan Boren 31ae2c631a Simplify return from WP_Post::__get() now that references are no longer returned. see #21309
git-svn-id: https://develop.svn.wordpress.org/trunk@21655 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-29 13:42:11 +00:00
Ryan Boren a8e913063a Lose return ref from WP_Post::__get(). see #21309
git-svn-id: https://develop.svn.wordpress.org/trunk@21654 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-29 13:23:54 +00:00
Ryan Boren 01527025c9 Add tags_input, page_template, and post_category get magic to WP_Post.
Deprecate get_post_to_edit() and wp_get_single_post().
Props scribu
see #21309


git-svn-id: https://develop.svn.wordpress.org/trunk@21651 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-28 19:08:28 +00:00
Ryan Boren a94b94504a Use switch_to_blog()/restore_current_blog() in get_blog_post() and get_blog_permalink(). Eliminate the duplicate caching in these functions. Return WP_Post from get_blog_post(). Update phpdoc. Remove global-posts cache invalidation. Props jondavidjohn fixes #21595
git-svn-id: https://develop.svn.wordpress.org/trunk@21628 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-27 16:22:45 +00:00
Ryan Boren 338d0a103a Remove typo in phpdoc. see #21309 Props TobiasBg
git-svn-id: https://develop.svn.wordpress.org/trunk@21601 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-23 21:15:40 +00:00
Ryan Boren 9905abe697 Update phpdoc for functions that return WP_Post. Soft deprecate get_page(). see #21309
git-svn-id: https://develop.svn.wordpress.org/trunk@21598 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-23 20:34:41 +00:00
Ryan Boren de06b81360 Remove return ref from all calls to get_post()
Return WP_Post from get_default_post_to_edit()
Replace all calls to get_page() with get_post()
see #21309


git-svn-id: https://develop.svn.wordpress.org/trunk@21597 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-23 20:01:10 +00:00
Ryan Boren 83ea8767a5 Remove references from get_post() and get_page().
Handle $GLOBALS['post'] containing stdClass instead of WP_Post.
Props nacin
see #21309


git-svn-id: https://develop.svn.wordpress.org/trunk@21572 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-21 15:42:28 +00:00
Andrew Nacin 9143e2c860 Return a variable reference from get_pages(). see [21559], see #21309, fixes #20756.
git-svn-id: https://develop.svn.wordpress.org/trunk@21567 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-20 23:43:04 +00:00