Php Wordpress小部件仅在url大小写正确时才处于活动状态

Php Wordpress小部件仅在url大小写正确时才处于活动状态,php,wordpress,.htaccess,Php,Wordpress,.htaccess,我的wordpress站点上的小部件有问题。基本上,它是一个Ajax导航过滤器边栏,允许用户通过单击所需选项来过滤结果。我遇到的问题是,小部件似乎区分大小写,只有在url大小写正确时才会显示 e、 g 如果url如下所示,小部件将不会出现: mysite.com/product-category/mens 但如果url为大写字母M,则会出现: mysite.com/product-category/Mens 我已经尝试在我的服务器中激活mod_拼写,在.htaccess中也激活了CheckSpe

我的wordpress站点上的小部件有问题。基本上,它是一个Ajax导航过滤器边栏,允许用户通过单击所需选项来过滤结果。我遇到的问题是,小部件似乎区分大小写,只有在url大小写正确时才会显示

e、 g

如果url如下所示,小部件将不会出现:

mysite.com/product-category/mens

但如果url为大写字母M,则会出现:

mysite.com/product-category/Mens

我已经尝试在我的服务器中激活mod_拼写,在.htaccess中也激活了CheckSpelling,但这并没有起到任何作用。我必须手动输入URL才能让小部件显示出来

有人有什么想法吗

谢谢

克里斯

下面是我的小部件的代码:

    /* FIX TO WOOCOMMERCE 2.1 */

    if ( function_exists( 'wc_attribute_taxonomy_name' ) ) {

        $taxonomy = wc_attribute_taxonomy_name($instance['attribute']);

    } else {

        $taxonomy = $woocommerce->attribute_taxonomy_name($instance['attribute'] );

    }

    if ( ! taxonomy_exists( $taxonomy ) )

        return;

    $terms = yit_get_terms( $terms_type_list, $taxonomy );


    if ( count( $terms ) > 0 ) {

        ob_start();

        $found = false;

        echo $before_widget . $before_title . $title . $after_title;

        // Force found when option is selected - do not force found on taxonomy attributes

        if ( ! $_attributes_array || ! is_tax( $_attributes_array ) )


            if ( is_array( $_chosen_attributes ) && array_key_exists( $taxonomy, $_chosen_attributes ) )

                $found = true;

        if ( $display_type == 'list' ) {



            // List display

            echo "<ul class='yith-wcan-list yith-wcan'>";


            $topten = array_slice($terms,0,10);
            usort($topten,"cmp");
            $terms = array_slice($terms,10);
            usort($terms,"cmp");
            $terms = array_merge((array)$topten,(array)$terms);


            foreach ( $terms as $term ) {


                // Get count based on current view - uses transients

                $transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );

                if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {

                    $_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );

                    set_transient( $transient_name, $_products_in_term );

                }

                $option_is_set = ( isset( $_chosen_attributes[ $taxonomy ] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) );

                // If this is an AND query, only show options with count > 0

                if ( $query_type == 'and' ) {

                    $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->filtered_product_ids ) );

                    // skip the term for the current archive

                    if ( $current_term == $term->term_id )

                        continue;

                    if ( $count > 0 && $current_term !== $term->term_id )

                        $found = true;

                    if ( ( $terms_type_list != 'hierarchical' || ! yit_term_has_child($term, $taxonomy) ) && $count == 0 && ! $option_is_set ){

                        continue;

                    }

                // If this is an OR query, show all options so search can be expanded

                } else {

                    // skip the term for the current archive

                    if ( $current_term == $term->term_id )

                        continue;

                    $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->unfiltered_product_ids ) );

                    if ( $count > 0 )

                        $found = true;

                }

                $arg = 'filter_' . sanitize_title( $instance['attribute'] );

                $current_filter = ( isset( $_GET[ $arg ] ) ) ? explode( ',', $_GET[ $arg ] ) : array();

                if ( ! is_array( $current_filter ) )

                    $current_filter = array();

                $current_filter = array_map( 'esc_attr', $current_filter );

                if ( ! in_array( $term->term_id, $current_filter ) )

                    $current_filter[] = $term->term_id;

                // Base Link decided by current page

                if ( defined( 'SHOP_IS_ON_FRONT' ) ) {

                    $link = home_url();

                } elseif ( is_post_type_archive( 'product' ) || is_page( function_exists( 'wc_get_page_id' ) ? wc_get_page_id('shop') : woocommerce_get_page_id('shop') ) ) {

                    $link = get_post_type_archive_link( 'product' );

                } else {

                    $link = get_term_link( get_query_var('term'), get_query_var('taxonomy') );

                }

不确定你的代码是什么样子的 但是,如果您使用类似$_GET['key']的东西从url中获取男性,那么您可以先使用php函数ucfirst

对于javascript,您需要创建自己的函数。 我使用了从另一个stackoverflow问题中得到的函数:

function capitaliseFirstLetter(string)
{
    return string.charAt(0).toUpperCase() + string.slice(1);
}

小部件的代码是什么样子的?脚本很长,我将编辑我认为相关的原始帖子。你可以使用这样的插件实现类似的功能吗:?我实际上已经考虑过UCFirst,但我发现自己正在编辑wordpress核心文件,这是我想要避免的。谢谢你提供的信息。
function capitaliseFirstLetter(string)
{
    return string.charAt(0).toUpperCase() + string.slice(1);
}