Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes
CustomMetaBox::render_meta_form()
Reimplementation of WP core's meta_form function. Renders meta form box.
Метод класса: CustomMetaBox{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$CustomMetaBox = new CustomMetaBox(); $CustomMetaBox->render_meta_form( $order ) : void;
- $order(\WC_Order) (обязательный)
- WC_Order object.
Код CustomMetaBox::render_meta_form() CustomMetaBox::render meta form WC 9.3.3
<?php public function render_meta_form( \WC_Order $order ) : void { $meta_key_input_id = 'metakeyselect'; $keys = $this->order_meta_keys_autofill( null, $order ); ?> <p><strong><?php esc_html_e( 'Add New Custom Field:', 'woocommerce' ); ?></strong></p> <table id="newmeta"> <thead> <tr> <th class="left"><label for="<?php echo esc_attr( $meta_key_input_id ); ?>"><?php esc_html_e( 'Name', 'woocommerce' ); ?></label></th> <th><label for="metavalue"><?php esc_html_e( 'Value', 'woocommerce' ); ?></label></th> </tr> </thead> <tbody> <tr> <td id="newmetaleft" class="left"> <?php if ( $keys ) { ?> <select id="metakeyselect" name="metakeyselect"> <option value="#NONE#"><?php esc_html_e( '— Select —', 'woocommerce' ); ?></option> <?php foreach ( $keys as $key ) { if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'edit_others_shop_orders' ) ) { continue; } echo "\n<option value='" . esc_attr( $key ) . "'>" . esc_html( $key ) . '</option>'; } ?> </select> <input class="hidden" type="text" id="metakeyinput" name="metakeyinput" value="" aria-label="<?php esc_attr_e( 'New custom field name', 'woocommerce' ); ?>" /> <button type="button" id="newmeta-button" class="button button-small hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggleClass('hidden');jQuery('#metakeyinput, #metakeyselect').filter(':visible').trigger('focus');"> <span id="enternew"><?php esc_html_e( 'Enter new', 'woocommerce' ); ?></span> <span id="cancelnew" class="hidden"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></span> <?php } else { ?> <input type="text" id="metakeyinput" name="metakeyinput" value="" /> <?php } ?> </td> <td><textarea id="metavalue" name="metavalue" rows="2" cols="25"></textarea> <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?> </td> </tr> </tbody> </table> <div class="submit add-custom-field"> <?php submit_button( __( 'Add Custom Field', 'woocommerce' ), '', 'addmeta', false, array( 'id' => 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta', ) ); ?> </div> <?php }