wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
the_block_editor_meta_box_post_form_hidden_fields › WordPress Function
Seit5.0.0
Veraltetn/v
› the_block_editor_meta_box_post_form_hidden_fields ( $post )
Parameter: |
|
Definiert in: |
|
Codex: |
Renders the hidden form required for the meta boxes form.
Quellcode
function the_block_editor_meta_box_post_form_hidden_fields( $post ) { $form_extra = ''; if ( 'auto-draft' === $post->post_status ) { $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />"; } $form_action = 'editpost'; $nonce_action = 'update-post_' . $post->ID; $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post->ID ) . "' />"; $referer = wp_get_referer(); $current_user = wp_get_current_user(); $user_id = $current_user->ID; wp_nonce_field( $nonce_action ); /* * Some meta boxes hook into these actions to add hidden input fields in the classic post form. * For backward compatibility, we can capture the output from these actions, * and extract the hidden input fields. */ ob_start(); /** This filter is documented in wp-admin/edit-form-advanced.php */ do_action( 'edit_form_after_title', $post ); /** This filter is documented in wp-admin/edit-form-advanced.php */ do_action( 'edit_form_advanced', $post ); $classic_output = ob_get_clean(); $classic_elements = wp_html_split( $classic_output ); $hidden_inputs = ''; foreach ( $classic_elements as $element ) { if ( ! str_starts_with( $element, '<input ' ) ) { continue; } if ( preg_match( '/\stype=[\'"]hidden[\'"]\s/', $element ) ) { echo $element; } } ?> <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_id; ?>" /> <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr( $form_action ); ?>" /> <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ); ?>" /> <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post->post_type ); ?>" /> <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status ); ?>" /> <input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" /> <?php if ( 'draft' !== get_post_status( $post ) ) { wp_original_referer_field( true, 'previous' ); } echo $form_extra; wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); // Permalink title nonce. wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); /** * Adds hidden input fields to the meta box save form. * * Hook into this action to print `<input type="hidden" ... />` fields, which will be POSTed back to * the server when meta boxes are saved. * * @since 5.0.0 * * @param WP_Post $post The post that is being edited. */ do_action( 'block_editor_meta_box_hidden_fields', $post ); }