Permalink
Browse files

Add filters for post content, title, and categories

Add filters to that plugins and themes can potentially change the post
title, content, and categories used when new posts are created by
Automatic Featured Image Posts.
  • Loading branch information...
1 parent 2ff4b53 commit 99e847704b6b2768fac02f160ff0b909e0d41c4e @jeremyfelt committed Apr 14, 2012
Showing with 34 additions and 7 deletions.
  1. +10 −3 automatic-featured-image-posts.php
  2. +9 −2 readme.md
  3. +15 −2 readme.wp
@@ -3,7 +3,7 @@
Plugin Name: Automatic Featured Image Posts
Plugin URI: http://www.jeremyfelt.com/wordpress/plugins/automatic-featured-image-posts/
Description: Automatically creates a new post with an assigned featured image from every image upload.
-Version: 0.5
+Version: 0.6
Author: Jeremy Felt
Author URI: http://www.jeremyfelt.com
License: GPL2
@@ -286,10 +286,17 @@ public function create_post_from_image( $post_id ) {
$new_post_date = date( 'Y-m-d H:i:s' );
$current_user = wp_get_current_user();
- $new_post_content = '';
+ /* Allow other functions or themes to change the post title before creation. */
+ $new_post_title = apply_filters( 'afip_new_post_title', get_the_title( $post_id ), $post_id );
+
+ /* Allow other functions or themes to change the post categories before creation. */
+ $new_post_category = apply_filters( 'afip_new_post_category', $new_post_category, $post_id );
+
+ /* Allow other functions or themes to change the post content before creation. */
+ $new_post_content = apply_filters( 'afip_new_post_content', '', $post_id );
$new_post_id = wp_insert_post( array(
- 'post_title' => get_the_title( $post_id ),
+ 'post_title' => $new_post_title,
'post_content' => $new_post_content,
'post_status' => $afip_options[ 'default_post_status' ],
'post_author' => $current_user->ID,
View
@@ -4,7 +4,7 @@
* Tags: featured image, media, photo, pictures, posts, photoblog, upload, automatic, custom post type, thumbnail, post thumbnails, post formats
* Requires at least: 3.2.1
* Tested up to: 3.4
-* Stable tag: 0.5
+* Stable tag: 0.6
> Automatic Featured Image Posts creates a new post with a Featured Image every time an image is uploaded.
@@ -40,13 +40,17 @@ That's it!
* A warning will appear on your Automatic Featured Image Posts settings screen if it is detected that featured images are not enabled.
###Can you put the images in post content instead of setting them as a featured image? =
-* At this time, no. I spent quite a bit of time exploring a good way to do this, and I'm definitely open to it in the future, but it doesn't appear to be realistic right now. There are so many options for placing an image in your content, I'd hate to think I'd pick the perfect default.
+* I can't, but you can with the included filters.
+ * Check out the [writeup on the new filters] (http://www.jeremyfelt.com/wordpress/2012/04/14/filters-in-aut…ed-image-posts "Filters in Automatic Featured Image Posts")
## Screenshots
1. An overview of the Automatic Featured Image Posts settings screen.
## Changelog
+### 0.6
+* Add filters to allow themes and plugins to change the post title, categories, and content before creation
+
### 0.5
* Add support for Post Formats. If your theme supports it, you can now select to publish as an image, aside, etc...
* Make sure the attachment is also adhering to core parent/inherit standards after media is uploaded.
@@ -70,6 +74,9 @@ That's it!
## Upgrade Notice
+###0.6
+* NEW - Filters added for post title, categories, and content.
+
### 0.5
* NEW - Option to assign automatically created posts to registered post formats.
View
@@ -5,7 +5,7 @@ Donate link: http://www.jeremyfelt.com/wordpress/plugins/automatic-featured-imag
Tags: featured image, media, photo, pictures, posts, photoblog, upload, automatic, custom post type, thumbnail, post thumbnails, post formats
Requires at least: 3.2.1
Tested up to: 3.4
-Stable tag: 0.5
+Stable tag: 0.6
Automatic Featured Image Posts creates a new post with a Featured Image every time an image is uploaded.
@@ -27,6 +27,12 @@ Settings are available for:
* Default is 'standard', which equates to none.
* Other options are provided if registered by your theme
+Filters are available for:
+
+* 'afip_new_post_title' = Allow other functions or themes to change the post title before creation.
+* 'afip_new_post_category' = Allow other functions or themes to change the post categories before creation.
+* 'afip_new_post_content' = Allow other functions or themes to change the post content before creation.
+
== Installation ==
1. Upload 'automatic-featured-image-posts' to your plugin directory, usually 'wp-content/plugins/', or install automatically via your WordPress admin page.
@@ -44,14 +50,18 @@ That's it!
= Can you put the images in post content instead of setting them as a featured image? =
-* At this time, no. I spent quite a bit of time exploring a good way to do this, and I'm definitely open to it in the future, but it doesn't appear to be realistic right now. There are so many options for placing an image in your content, I'd hate to think I'd pick the perfect default.
+* I can't, but you can with the included filters.
+ * Check out the [writeup on the new filters] (http://www.jeremyfelt.com/wordpress/2012/04/14/filters-in-aut…ed-image-posts "Filters in Automatic Featured Image Posts")
== Screenshots ==
1. An overview of the Automatic Featured Image Posts settings screen.
== Changelog ==
+= 0.6 =
+* Add filters to allow themes and plugins to change the post title, categories, and content before creation
+
= 0.5 =
* Add support for Post Formats. If your theme supports it, you can now select to publish as an image, aside, etc...
* Make sure the attachment is also adhering to core parent/inherit standards after media is uploaded.
@@ -76,6 +86,9 @@ That's it!
== Upgrade Notice ==
+= 0.6 =
+* NEW - Filters added for post title, categories, and content.
+
= 0.5 =
* NEW - Option to assign automatically created posts to registered post formats.

0 comments on commit 99e8477

Please sign in to comment.