Inventory_Presser_Order_By_Widget::form( array $instance )
Outputs the widget settings form that is shown in the dashboard.
On This Page
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 esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'inventory-presser' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $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>' . esc_html__( 'Which fields should users be allowed to use as sort fields?', 'inventory-presser' )
. '</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="' . esc_attr( $this->get_field_id( 'obpm-key-' . $key ) )
. '" name="obpm-key-' . esc_attr( $key ) . '"'
. checked( in_array( $key, $already_turned_on_keys, true ), true, false )
. ' title="' . esc_attr( $title ) . '"/>'
. '<label for="' . esc_attr( $this->get_field_id( 'obpm-key-' . $key ) )
. '" title="' . esc_attr( $title ) . '">'
. esc_html( $this->prettify_meta_key( $key ) ) . '</label>'
. '</dt>' // and a text box for a label.
. '<dd>'
. '<label for="' . esc_attr( $this->get_field_id( 'obpm-label-' . $key ) )
. '">Label</label> '
. '<input type="text" id="' . esc_attr( $this->get_field_id( 'obpm-label-' . $key ) ) . '"'
. ' name="obpm-label-' . esc_attr( $key ) . '" '
. 'value="' . esc_attr( $label ) . '" title="Label for '
. esc_attr( $key ) . '" /></dd>';
}
echo '</dl>';
}
Expand full source codeCollapse full source codeView on Github