Inventory_Presser_Order_By_Widget::form( array $instance )
form
Contents
Description Description
Outputs the widget settings form that is shown in the dashboard.
Parameters Parameters
- $instance
-
(array) (Required) The widget options
Return Return
(void)
Source Source
File: includes/widget/class-widget-order-by.php
public function form( $instance ) { $title = ( isset( $instance['title'] ) ? $instance['title'] : '' ); ?> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'inventory-presser' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /> </p> <?php $args = array( 'public' => true, ); $already_turned_on_keys = array(); if ( isset( $instance['post-meta-keys'] ) ) { $already_turned_on_keys = explode( '|', $instance['post-meta-keys'] ); } echo '<p>Which fields should users be allowed to use as sort fields?</p>' . '<dl>'; foreach ( $this->get_post_meta_keys_and_labels( $instance ) as $key => $label ) { // output checkbox for each one echo '<dt>'; $title = 'Allow users to order by ' . $key; // title attribute for checkbox and label echo '<input type="checkbox" id="' . $this->get_field_id( 'obpm-key-' . $key ) . '" name="obpm-key-' . $key . '"'; if ( in_array( $key, $already_turned_on_keys ) ) { echo ' checked="checked"'; } echo ' title="' . $title . '"/>' . '<label for="' . $this->get_field_id( 'obpm-key-' . $key ) . '" title="' . $title . '">' . $this->prettify_meta_key( $key ) . '</label>' . '</dt>' // and a text box for a label . '<dd>' . '<label for="' . $this->get_field_id( 'obpm-label-' . $key ) . '">Label</label> ' . '<input type="text" id="' . $this->get_field_id( 'obpm-label-' . $key ) . '"' . ' name="obpm-label-' . $key . '" ' . 'value="' . $label . '" title="Label for ' . $key . '" />' . '</dd>'; } echo '</dl>'; }
Expand full source code Collapse full source code View on Github