PDA

View Full Version : مشکل فرم سرچ



kaajhost
شنبه 17 آذر 1397, 19:32 عصر
سلام
من از یک فرم سرچ واژه نامه استفاده میکنم اما وقتی هیچ کلمه ای هم در سرچ فیلد نمی زنم اما دکمه سرچ را فشار می دهم تمام مقادیر را بر می گرداند. میخواهم کاری کنم بدون وارد کردن کلمه هیچ مقداری نشان داده نشود لطفا راهنمایی بفرمایید:

/** * Function serves the shortcode: [glossary_search]
*/
public static function glossarySearchShortcode( $atts = array() ) {
global $post;


if ( !is_array( $atts ) ) {
$atts = array();
}


$default_atts = apply_filters( 'cmtt_glossary_search_shortcode_default_atts', array(
'glossary_page_link' => get_permalink( self::getGlossaryIndexPageId() ),
)
);


$shortcode_atts = apply_filters( 'cmtt_glossary_search_atts', array_merge( $default_atts, $atts ) );
do_action( 'cmtt_glossary_search_shortcode_before', $shortcode_atts );
$output = self::outputSearch( $shortcode_atts );
do_action( 'cmtt_glossary_search_shortcode_after', $atts );


return $output;
}


/**
* Displays the main glossary index
*
* @param type $shortcodeAtts
* @return string $content
*/
public static function outputSearch( $shortcodeAtts ) {
global $post;


$content = '';


if ( $post === NULL && $shortcodeAtts[ 'post_id' ] ) {
$post = get_post( $shortcodeAtts[ 'post_id' ] );
}


$content .= apply_filters( 'cmtt_glossary_search_before_content', '', $shortcodeAtts );
$content .= '<form method="post" action="' . esc_attr( $shortcodeAtts[ 'glossary_page_link' ] ) . '" target="_blank">';


$additionalClass = (!empty( $shortcodeAtts[ 'search_term' ] )) ? 'search' : '';


$searchLabel = __( get_option( 'cmtt_glossary_SearchLabel', 'Search:' ), 'cm-tooltip-glossary' );
$searchPlaceholder = __( get_option( 'cmtt_glossary_SearchPlaceholder', '' ), 'cm-tooltip-glossary' );
$searchButtonLabel = __( get_option( 'cmtt_glossary_SearchButtonLabel', 'Search' ), 'cm-tooltip-glossary' );
$searchTerm = isset( $shortcodeAtts[ 'search_term' ] ) ? $shortcodeAtts[ 'search_term' ] : '';
$searchHelp = __( get_option( 'cmtt_glossarySearchHelp', 'The search returns the partial search for the given query from both the term title and description. So it will return the results even if the given query is part of the word in the description.' ), 'cm-tooltip-glossary' );
ob_start();
?>
<?php if ( !empty( $searchHelp ) ) : ?>
<div class="cmtt_help glossary-search-helpitem" data-cmtooltip="<?php echo $searchHelp ?>"></div>
<?php endif; ?>
<span class="glossary-search-label"><?php echo $searchLabel ?></span>
<input type="search" value="<?php echo esc_attr( $searchTerm ) ?>" placeholder="<?php echo esc_attr( $searchPlaceholder ); ?>" class="glossary-search-term <?php echo esc_attr( $additionalClass ) ?>" name="search_term" id="glossary-search-term" />
<input type="submit" value="<?php echo esc_attr( $searchButtonLabel ) ?>" id="glossary-search" class="glossary-search button" />
<?php
$content .= ob_get_clean();
$content .= '</form>';
$content = apply_filters( 'cmtt_glossary_search_after_content', $content, $shortcodeAtts );


do_action( 'cmtt_after_glossary_search' );


return $content;
}