Support » Plugin: Enhanced Search Box » The placeholder appear only on focus

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jupitercow

    (@jcow)

    I couldn’t say for sure what is going on without seeing the code for theme.

    I imagine that the theme is already doing it’s own stuff to manage the searchbox and this plugin might be incompatible.

    the theme function for the place holder is this:

    function headway_get_search_form($placeholder = null) {
    
    	if ( !$placeholder )
    		$placeholder = __('Type to search, then press enter', 'headway');
    
    	$placeholder = apply_filters('headway_search_form_placeholder', $placeholder);
    	$search_query = get_search_query();
    	$search_input_attributes = array(
    		'type' => 'text',
    		'class' => 'field',
    		'name' => 's',
    		'id' => 's'
    	);
    
    	/* Handle the placeholder and value */
    		//$search_input_attributes['placeholder'] = $placeholder;
    
    		$search_input_attributes['value'] = $search_query ? $search_query : $placeholder;
    
    		$search_input_attributes['onclick'] = 'if(this.value==\'' . $placeholder . '\')this.value=\'\';';
    		$search_input_attributes['onblur'] = 'if(this.value==\'\')this.value=\'' . $placeholder . '\';';
    
    	/* Turn the array into real HTML attributes */
    		$search_input_attributes = apply_filters('headway_search_input_attributes', $search_input_attributes);
    		$search_input_attributes_string = '';
    
    		foreach ( $search_input_attributes as $attribute => $value )
    			$search_input_attributes_string .= $attribute . '="' . $value . '" ';
    
    	return '
    		<form method="get" id="searchform" action="' . esc_url(home_url('/')) . '">
    			<label for="s" class="assistive-text">' . __('Search', 'headway') . '</label>
    			<input ' . trim($search_input_attributes_string) .' />
    			<input type="submit" class="submit" name="submit" id="searchsubmit" value="' . esc_attr__('Search', 'headway') . '" />
    		</form>
    	';
    
    }

    I commented out the first two lines, the conditional to add the default theme placeholder, and enhanced search box works ok. See if you can fix the plugin so that there is no need to edit theme functions?

    Plugin Author Jupitercow

    (@jcow)

    Thanks for the update.

    This is a really basic plugin to add better placeholder functionality to the out-of-the-box searchbox. There really isn’t a way to compensate for every single theme out there. They are all different and it depends on how the theme developer has decided to modify the searchbox. Some themes just won’t be compatible with the plugin.

    I am glad you found a way to get it to work with your theme though.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘The placeholder appear only on focus’ is closed to new replies.