So erhalten und bearbeiten Sie benutzerdefinierte Felder, wenn Sie sich im Schnellbearbeitungsmodus befinden

Ich habe einige benutzerdefinierte Felder, die ein Benutzer in Quick Edit bearbeiten können soll. Ich kann die Spalten verwalten, aber ich kann sie nicht bearbeiten, wenn der aktuelle Code mit den benutzerdefinierten Feldern auf “Quick Edit” geklickt wird in der Lage sein zu bearbeiten:

/* custom columns */ add_filter("manage_edit-programmes_columns", "edit_columns" ); add_action("manage_posts_custom_column", "custom_columns"); function edit_columns($columns) { $columns = array( "cb" => "", "title" => "Schedule id", "programme" => "Programme", "channel" => "Channel", "onair" => "On Air", "catchup" => "Catchup", "popularity" => "Popularity", "onair" => "On Air", "date" => "Date" ); return $columns; } function custom_columns( $column ) { global $post; switch ( $column ) { case "programme": echo get_post_meta($post->ID, 'Programme Name', true); break; case "channel": echo get_the_term_list($post->ID, 'channelnames', '', ', ', ''); break; case "onair": echo get_post_meta($post->ID, 'Date Time Start', true); break; case "catchup": echo get_post_meta($post->ID, 'linktovideocatchup', true); break; case "popularity": echo get_post_meta($post->ID, 'popularityfig', true); break; } } 

Hilfe sehr geschätzt.

Solutions Collecting From Web of "So erhalten und bearbeiten Sie benutzerdefinierte Felder, wenn Sie sich im Schnellbearbeitungsmodus befinden"

Ein paar Dinge,

  1. save_post Sie sicher, dass Sie in Ihrem save_post Hook nach DOING_AJAX das zum Speichern in der Schnellbearbeitung verwendet wird.
  2. Überprüfen Sie meine andere Frage: Schnelle Bearbeitung Bildschirmanpassung . Die Antwort, die ich erhalten habe, hat funktioniert, aber ich habe es noch nicht wirklich in mein Plugin implementiert, da es noch keine Priorität von mir ist .

Hoffe, dass dir das hilft. 😉

Das Speichern von Daten aus Quick Edit und Bulk Edit benötigt JavaScript-Helfer.

Der folgende Code kommt aus einem Produktionssystem mit dem benutzerdefinierten video Post-Typ, bevor ich das WordPress Bulk-Edit-Plugin Custom Bulk / Quick Edit geschrieben habe .

Datei quick_edit.js

 // @ref http://rachelcarden.com/2012/03/manage-wordpress-posts-using-bulk-edit-and-quick-edit/ (function($) { // we create a copy of the WP inline edit post function var $wp_inline_edit = inlineEditPost.edit; // and then we overwrite the function with our own code inlineEditPost.edit = function( id ) { // "call" the original WP edit function // we don't want to leave WordPress hanging $wp_inline_edit.apply( this, arguments ); // now we take care of our business // get the post ID var $post_id = 0; if ( typeof( id ) == 'object' ) $post_id = parseInt( this.getId( id ) ); if ( $post_id > 0 ) { // define the edit row var $edit_row = $( '#edit-' + $post_id ); var $post_row = $( '#post-' + $post_id ); // get the data var $additional_copies = $( '.column-additional_copies', $post_row ).html(); var $main_credits = $( '.column-main_credits', $post_row ).html(); // populate the data $( ':input[name="additional_copies"]', $edit_row ).val( $additional_copies ); $( ':input[name="main_credits"]', $edit_row ).val( $main_credits ); } }; $( '#bulk_edit' ).live( 'click', function() { // define the bulk edit row var $bulk_row = $( '#bulk-edit' ); // get the selected post ids that are being edited var $post_ids = new Array(); $bulk_row.find( '#bulk-titles' ).children().each( function() { $post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) ); }); // get the data var $additional_copies = $bulk_row.find( 'textarea[name="additional_copies"]' ).val(); var $main_credits = $bulk_row.find( 'textarea[name="main_credits"]' ).val(); // save the data $.ajax({ url: ajaxurl, // this is a variable that WordPress has already defined for us type: 'POST', async: false, cache: false, data: { action: 'save_bulk_edit_video', // this is the name of our WP AJAX function that we'll set up next post_ids: $post_ids, // and these are the 2 parameters we're passing to our function additional_copies: $additional_copies, main_credits: $main_credits } }); }); })(jQuery); 

Datei video-quick-edit.php

 < ?php /** * Quick Edit and Bulk Edit helper for Media Burn video records * * @author Michael Cannon  * @ref http://rachelcarden.com/2012/03/manage-wordpress-posts-using-bulk-edit-and-quick-edit/ */ add_action( 'bulk_edit_custom_box', 'quick_edit_custom_box_video', 10, 2 ); add_action( 'quick_edit_custom_box', 'quick_edit_custom_box_video', 10, 2 ); function quick_edit_custom_box_video( $column_name, $post_type ) { $slug = 'video'; if ( $slug !== $post_type ) return; if ( ! in_array( $column_name, array( 'additional_copies', 'main_credits' ) ) ) return; static $printNonce = true; if ( $printNonce ) { $printNonce = false; wp_nonce_field( plugin_basename( __FILE__ ), 'video_edit_nonce' ); } ?> 
< ?php } add_action( 'save_post', 'save_video_meta' ); function save_video_meta( $post_id ) { // TODO make $slug static $slug = 'video'; if ( $slug !== $_POST['post_type'] ) return; if ( !current_user_can( 'edit_post', $post_id ) ) return; if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; if ( isset( $post->post_type ) && 'revision' == $post->post_type ) return; $_POST += array( "{$slug}_edit_nonce" => '' ); if ( !wp_verify_nonce( $_POST["{$slug}_edit_nonce"], plugin_basename( __FILE__ ) ) ) return; if ( isset( $_REQUEST['additional_copies'] ) ) update_post_meta( $post_id, 'additional_copies', wp_kses_post( $_REQUEST['additional_copies'] ) ); if ( isset( $_REQUEST['main_credits'] ) ) update_post_meta( $post_id, 'main_credits', wp_kses_post( $_REQUEST['main_credits'] ) ); } add_action( 'admin_print_scripts-edit.php', 'admin_edit_video_foot' ); function admin_edit_video_foot() { $slug = 'video'; // load only when editing a video if ( ( isset( $_GET['page'] ) && $slug == $_GET['page'] ) || ( isset( $_GET['post_type'] ) && $slug == $_GET['post_type'] ) ) { wp_enqueue_script( 'admin-quick-edit-video', get_template_directory_uri() . '/functions/user/custom/fitv/quick_edit.js', array( 'jquery', 'inline-edit-post' ), '', true ); } } add_action( 'wp_ajax_save_bulk_edit_video', 'save_bulk_edit_video' ); function save_bulk_edit_video() { $post_ids = ( ! empty( $_POST[ 'post_ids' ] ) ) ? $_POST[ 'post_ids' ] : array(); $additional_copies = ( ! empty( $_POST[ 'additional_copies' ] ) ) ? wp_kses_post( $_POST[ 'additional_copies' ] ) : null; $main_credits = ( ! empty( $_POST[ 'main_credits' ] ) ) ? wp_kses_post( $_POST[ 'main_credits' ] ) : null; if ( ! empty( $post_ids ) && is_array( $post_ids ) ) { foreach ( $post_ids as $post_id ) { update_post_meta( $post_id, 'additional_copies', $additional_copies ); update_post_meta( $post_id, 'main_credits', $main_credits ); } } die(); } ?>