WP_Widget_Pages::form() WordPress Method
The WP_Widget_Pages::form() method is used to display a form for a widget. This form is used to configure the widget's settings. The form is displayed in the WordPress admin interface.
WP_Widget_Pages::form( array $instance ) #
Outputs the settings form for the Pages widget.
Parameters
- $instance
(array)(Required)Current settings.
Source
File: wp-includes/widgets/class-wp-widget-pages.php
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | public function form( $instance ) { // Defaults. $instance = wp_parse_args( ( array ) $instance , array ( 'sortby' => 'post_title' , 'title' => '' , 'exclude' => '' , ) ); ?> <p> <label for = "<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" ><?php _e( 'Title:' ); ?></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( $instance['title'] ); ?>" /> </p> <p> <label for = "<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>" ><?php _e( 'Sort by:' ); ?></label> <select name= "<?php echo esc_attr( $this->get_field_name( 'sortby' ) ); ?>" id= "<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>" class = "widefat" > <option value= "post_title" <?php selected( $instance [ 'sortby' ], 'post_title' ); ?>><?php _e( 'Page title' ); ?></option> <option value= "menu_order" <?php selected( $instance [ 'sortby' ], 'menu_order' ); ?>><?php _e( 'Page order' ); ?></option> <option value= "ID" <?php selected( $instance [ 'sortby' ], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option> </select> </p> <p> <label for = "<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>" ><?php _e( 'Exclude:' ); ?></label> <input type= "text" value= "<?php echo esc_attr( $instance['exclude'] ); ?>" name= "<?php echo esc_attr( $this->get_field_name( 'exclude' ) ); ?>" id= "<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>" class = "widefat" /> <br /> <small><?php _e( 'Page IDs, separated by commas.' ); ?></small> </p> <?php } |
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |