+
+
' . __( 'Live Admin Nav Filter' ) . '
+
+
+
' . __( 'Usage' ) . '
+
+
+ -
+ Hitting
\'/\'
while not in a text area or input field will let you quickly begin searching.
+
+ -
+ While results are displayed, press the
up
and down
keys to cycle through your results.
+
+ -
+ When you\'re happy with your selection, hit the
enter
key to go to it.
+
+
+
+
+ Lovingly crafted by Rémy Bach.
+ Should you feel like throwing any
+ money my way, please do so below:
+
+
';
+ } // end display_page
+
+ /* Define all settings and their defaults */
+ public function get_settings() {
+ // Position Settings
+ $this->settings['position'] = array(
+ 'title' => __( 'Position' ),
+ 'desc' => __( 'Choose whether the filter field goes at the top, or the bottom of the menu.' ),
+ 'std' => 'bottom',
+ 'type' => 'select',
+ 'choices' => array( 'bottom'=>'Bottom', 'top'=>'Top' ),
+ 'section' => 'position'
+ );
+ $this->settings['hidden'] = array(
+ 'title' => __( 'Hidden' ),
+ 'desc' => __( 'Choose whether the filter field is hidden until a "/" is typed.' ),
+ 'std' => 0,
+ 'type' => 'select',
+ 'choices' => array( 0=>'No', 1=>'Yes' ),
+ 'section' => 'position'
+ );
+
+ // Colour Settings
+ $this->settings['border_colour'] = array(
+ 'title' => __( 'Border Colour' ),
+ 'desc' => __( 'Choose a colour for the border around navigation elements that contain matches.' ),
+ 'std' => '#FFED2B',
+ 'type' => 'text',
+ 'section' => 'colour'
+ );
+ $this->settings['highlight_colour'] = array(
+ 'title' => __( 'Highlight Colour' ),
+ 'desc' => __( 'Choose a colour that will highlight your matched search.' ),
+ 'std' => '#FFED2B',
+ 'type' => 'text',
+ 'section' => 'colour'
+ );
+ } // end get_settings
+
+ /* Initialize settings to their default values */
+ public function initialize_settings() {
+ $default_settings = array();
+ foreach ( $this->settings as $id => $setting ) {
+ if ( $setting['type'] != 'heading' )
+ $default_settings[$id] = $setting['std'];
+ }
+
+ update_option( 'lnf-options', $default_settings );
+ } // end initialize_settings
+
+ /* Register settings via the WP Settings API */
+ public function register_settings() {
+ register_setting( 'lnf-options', 'lnf-options', array ( &$this, 'validate_settings' ) );
+
+ foreach ( $this->sections as $slug => $title ) {
+ add_settings_section( $slug, $title, array( &$this, 'display_section' ), 'lnf-options' );
+ }
+
+ $this->get_settings();
+
+ foreach ( $this->settings as $id => $setting ) {
+ $setting['id'] = $id;
+ $this->create_setting( $setting );
+ }
+ } // end register_settings
+
+ /* Description for section */
+ public function display_section() {
+ // code
+ } // end display_section
+
+ public function create_setting( $args = array() ) {
+ $defaults = array(
+ 'id' => 'default_field',
+ 'title' => 'Default Field',
+ 'desc' => 'This is a default description.',
+ 'std' => '',
+ 'type' => 'text',
+ 'section' => 'general',
+ 'choices' => array(),
+ 'class' => ''
+ );
+
+ extract( wp_parse_args( $args, $defaults ) );
+
+ $field_args = array(
+ 'type' => $type,
+ 'id' => $id,
+ 'desc' => $desc,
+ 'std' => $std,
+ 'choices' => $choices,
+ 'label_for' => $id,
+ 'class' => $class
+ );
+
+ if ( $type == 'checkbox' ) {
+ $this->checkboxes[] = $id;
+ }
+
+ add_settings_field( $id, $title, array( $this, 'display_setting' ), 'lnf-options', $section, $field_args );
+ } // end create_setting
+
+ /* HTML output for individual settings */
+ public function display_setting( $args = array() ) {
+ extract( $args );
+
+ $options = get_option( 'lnf-options' );
+
+ if ( ! isset( $options[$id] ) && $type != 'checkbox' ) {
+ $options[$id] = $std;
+ } else if ( ! isset( $options[$id] ) ) {
+ $options[$id] = 0;
+ }
+
+ $field_class = '';
+ if ( $class != '' ) {
+ $field_class = ' ' . $class;
+ }
+
+ switch ( $type ) {
+
+ case 'heading':
+ echo '
' . $desc . '';
+ break;
+
+ case 'checkbox':
+
+ echo ' ';
+
+ break;
+
+ case 'select':
+ echo '';
+
+ if ( $desc != '' ) {
+ echo ' ' . $desc . '';
+ }
+
+ break;
+
+ case 'radio':
+ $i = 0;
+ foreach ( $choices as $value => $label ) {
+ echo ' ';
+ if ( $i < count( $options ) - 1 ) {
+ echo ' ';
+ }
+ $i++;
+ }
+
+ if ( $desc != '' ) {
+ echo ' ' . $desc . '';
+ }
+
+ break;
+
+ case 'textarea':
+ echo '';
+
+ if ( $desc != '' ) {
+ echo ' ' . $desc . '';
+ }
+
+ break;
+
+ case 'password':
+ echo '';
+
+ if ( $desc != '' ) {
+ echo ' ' . $desc . '';
+ }
+
+ break;
+
+ case 'text':
+ default:
+ echo '';
+
+ if ( $desc != '' ) {
+ echo ' ' . $desc . '';
+ }
+
+ break;
+ }
+ } // end display_setting
+
+ /**
+ * Validate our input fields
+ */
+ public function validate_settings( $input ) {
+ $options = get_option( 'lnf-options' );
+
+ foreach ( $this->checkboxes as $id ) {
+ if ( isset( $options[$id] ) && ! isset( $input[$id] ) )
+ unset( $options[$id] );
+ }
+
+ foreach ($input as $key => $val) {
+ // Match hex codes only.
+ if ( preg_match('/colour/', $key) && !preg_match( '/^#[a-zA-Z0-9]{6}$/', $val ) ) {
+ return false;
+ }
+ }
+
+ return $input;
+ } // end validate_settings
+
+} // end class
+
+new LiveAdminNavFilter();
\ No newline at end of file
diff --git a/screenshot-1.jpg b/screenshot-1.jpg
new file mode 100644
index 0000000..8579c92
Binary files /dev/null and b/screenshot-1.jpg differ
diff --git a/screenshot-2.jpg b/screenshot-2.jpg
new file mode 100644
index 0000000..6623740
Binary files /dev/null and b/screenshot-2.jpg differ
diff --git a/screenshot-3.jpg b/screenshot-3.jpg
new file mode 100644
index 0000000..9def042
Binary files /dev/null and b/screenshot-3.jpg differ
|