[ patch ] Uploaded Image as featured, and CT posts
-
I had the same problems as some of you and managed to make it work with little change
A/ to have my own custom post types updated in the form :
add_action( 'fu_after_create_post', 'fu_add_meta_post' ); function fu_add_meta_post( $post_id ) { global $scpt_known_custom_fields;//I use super-cpt extension foreach($scpt_known_custom_fields["mycpt"] as $cptkey=>$cpttype) add_post_meta( $post_id, $cptkey, sanitize_text_field($_POST[$cptkey]) ); //todo sanitize better ...
maybe it was already in the doc. anyway, it should.
B/ “make my image attachment automatically as featured image”
almost the same :
[ function fu_add_meta_post( $post_id ) ... continued ... ] $attached_image = get_children( "post_parent=$post_id&post_type=attachment&post_mime_type=image&numberposts=1" ); if ($attached_image) foreach ($attached_image as $attachment_id => $attachment) { set_post_thumbnail($post_id, $attachment_id)); break; } return $post_id; } // things about themes thumbnails add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 75, 50, true);//W,H,crop add_image_size( 'single-post-thumbnail', 300, 200 );
* “get_children” syntax is ugly, any nicer replacement?
* still wrong as “websta” noticed it,
the hook fu_after_create_post is done too early.
HEY! why not hook at a better timing ? :My changes in plugins/frontend-uploader/frontend-uploader.php : line 321, in _upload_post, comment hook //GK do_action( 'fu_after_create_post', $post_id ); line 419 in _handle_result, hook here // Account for successful uploads if ( isset( $result['success'] ) && $result['success'] ) { // If it's a post if ( isset( $result['post_id'] ) ){ $query_args['response'] = 'fu-post-sent'; do_action( 'fu_after_create_post', $result['post_id'] );//GK }
I am a bit new to WP, and to forum and github,
so maybe I need to be fixed too.Thanks Rinat Khaziev for this plugin, and for viewing my propositions
to improve the plugin.Guy
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘[ patch ] Uploaded Image as featured, and CT posts’ is closed to new replies.