• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_search_link函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_search_link函数的典型用法代码示例。如果您正苦于以下问题:PHP get_search_link函数的具体用法?PHP get_search_link怎么用?PHP get_search_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_search_link函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: webdados_fb_open_graph


//.........这里部分代码省略.........
            $term = $wp_query->get_queried_object();
            $fb_url = get_term_link($term, $term->taxonomy);
            $cat_desc = trim(esc_attr(strip_tags(stripslashes(category_description()))));
            if (trim($cat_desc) != '') {
                $fb_desc = $cat_desc;
            }
        } else {
            if (is_tag()) {
                $fb_title = esc_attr(strip_tags(stripslashes(single_tag_title('', false))));
                $term = $wp_query->get_queried_object();
                $fb_url = get_term_link($term, $term->taxonomy);
                $tag_desc = trim(esc_attr(strip_tags(stripslashes(tag_description()))));
                if (trim($tag_desc) != '') {
                    $fb_desc = $tag_desc;
                }
            } else {
                if (is_tax()) {
                    $fb_title = esc_attr(strip_tags(stripslashes(single_term_title('', false))));
                    $term = $wp_query->get_queried_object();
                    $fb_url = get_term_link($term, $term->taxonomy);
                    //WooCommerce
                    if (intval($fb_image_show) == 1 || intval($fb_image_show_schema) == 1 || intval($fb_image_show_twitter) == 1) {
                        if (class_exists('woocommerce') && $fb_wc_usecategthumb == 1 && is_product_category()) {
                            if ($thumbnail_id = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true)) {
                                if ($image = wp_get_attachment_url($thumbnail_id)) {
                                    $fb_image = $image;
                                }
                            }
                        }
                    }
                } else {
                    if (is_search()) {
                        $fb_title = esc_attr(strip_tags(stripslashes(__('Search for') . ' "' . get_search_query() . '"')));
                        $fb_url = get_search_link();
                    } else {
                        if (is_author()) {
                            $fb_title = esc_attr(strip_tags(stripslashes(get_the_author_meta('display_name', get_query_var('author')))));
                            $fb_url = get_author_posts_url(get_query_var('author'), get_query_var('author_name'));
                        } else {
                            if (is_archive()) {
                                if (is_day()) {
                                    $fb_title = esc_attr(strip_tags(stripslashes(get_query_var('day') . ' ' . single_month_title(' ', false) . ' ' . __('Archives'))));
                                    $fb_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day'));
                                } else {
                                    if (is_month()) {
                                        $fb_title = esc_attr(strip_tags(stripslashes(single_month_title(' ', false) . ' ' . __('Archives'))));
                                        $fb_url = get_month_link(get_query_var('year'), get_query_var('monthnum'));
                                    } else {
                                        if (is_year()) {
                                            $fb_title = esc_attr(strip_tags(stripslashes(get_query_var('year') . ' ' . __('Archives'))));
                                            $fb_url = get_year_link(get_query_var('year'));
                                        }
                                    }
                                }
                            } else {
                                if (is_front_page()) {
                                    $fb_url = get_option('home') . (intval($fb_url_add_trailing) == 1 ? '/' : '');
                                    $fb_type = trim($fb_type_homepage == '' ? 'website' : $fb_type_homepage);
                                } else {
                                    //Others... Defaults already set up there
                                }
                            }
                        }
                    }
                }
            }
开发者ID:BetterDigitalServices,项目名称:bluearrow,代码行数:67,代码来源:wonderm00n-open-graph.php


示例2: widget

        function widget($args, $instance)
        {
            extract($args);
            $title = apply_filters('widget_title', empty($instance['title']) ? __('Pages', 'wpdance') : $instance['title'], $instance, $this->id_base);
            echo $before_widget;
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>
			<div class="alphabet-products">
				<ul>
					<?php 
            for ($i = ord('A'); $i <= ord('Z'); $i++) {
                $_cur_char = chr($i);
                $_search_link = get_search_link(chr($i));
                $_search_link = esc_url(add_query_arg(array("post_type" => "product", "producta2z" => "1"), $_search_link));
                echo "<li><a class='bold-upper-small' href='{$_search_link}'>{$_cur_char}</a></li>";
            }
            for ($i = 1; $i <= 9; $i++) {
                $_search_link = get_search_link($i);
                $_search_link = esc_url(add_query_arg(array("post_type" => "product", "producta2z" => "1"), $_search_link));
                echo "<li><a class='bold-upper-small' href='{$_search_link}'>{$i}</a></li>";
            }
            ?>
				</ul>
			</div>
			<?php 
            echo $after_widget;
        }
开发者ID:mynein,项目名称:myne,代码行数:29,代码来源:productaz.php


示例3: permalink

 function permalink($terms)
 {
     if (is_array($terms)) {
         $terms = implode(' ', array_keys($terms));
     }
     return get_search_link($terms);
 }
开发者ID:nrporter,项目名称:scriblio,代码行数:7,代码来源:class-facet-searchword.php


示例4: redirect

function redirect()
{
    global $wp_rewrite;
    if (!is_search() || is_admin() || !isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->get_search_permastruct()) {
        return;
    }
    // Set the search base and query
    $search_base = $wp_rewrite->search_base;
    $search_query = get_query_var('s');
    // Skip the search results if there is exactly one result: http://wpglee.com/2011/04/redirect-when-search-query-only-returns-one-match/
    if (option('redirect_single') && $search_query) {
        global $wp_query;
        if ($wp_query->post_count == 1) {
            wp_redirect(esc_url(trailingslashit(get_permalink($wp_query->posts['0']->ID))));
            exit;
        }
    }
    // Return a random post when an empty search query is entered
    // Allows the random results to be filtered (e.g. to limit to a particular category, post types, or anything else accepted by `get_posts`)
    if (option('redirect_random') && $search_query === '') {
        $random = get_posts(apply_filters('ubik_search_redirect_random_args', ['numberposts' => 1, 'orderby' => 'rand']));
        wp_redirect(esc_url(trailingslashit(get_permalink($random[0]->ID))));
        exit;
    }
    // "Nice search" rewrite; full credit to Mark Jaquith for this functionality: https://wordpress.org/plugins/nice-search/
    if (strpos($_SERVER['REQUEST_URI'], "/{$search_base}/") === false && strpos($_SERVER['REQUEST_URI'], '&') === false) {
        //wp_redirect( esc_url( trailingslashit( home_url( "/{$search_base}/" . urlencode($search_query) ) ) ) );
        wp_redirect(get_search_link());
        exit;
    }
}
开发者ID:synapticism,项目名称:ubik,代码行数:31,代码来源:search.php


示例5: redirect

/**
 * Redirects search results from /?s=query to /search/query/, converts %20 to +.
 *
 * @link http://txfx.net/wordpress-plugins/nice-search/
 * @global \WP_Rewrite $wp_rewrite WordPress Rewrite Component.
 * @since 1.0.0
 */
function redirect()
{
    global $wp_rewrite;
    if (no_rewrite_set($wp_rewrite)) {
        return;
    }
    $search_base = $wp_rewrite->search_base;
    if (is_search_permalink($search_base)) {
        wp_redirect(get_search_link());
        exit;
    }
}
开发者ID:craigsimps,项目名称:simple-search-rewrite,代码行数:19,代码来源:simple-search-rewrite.php


示例6: redirect

/**
 * Redirects search results from /?s=query to /search/query/, converts %20 to +
 *
 * @link http://txfx.net/wordpress-plugins/nice-search/
 *
 * You can enable/disable this feature in functions.php (or lib/config.php if you're using Sage):
 * add_theme_support('soil-nice-search');
 */
function redirect()
{
    global $wp_rewrite;
    if (!isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->get_search_permastruct()) {
        return;
    }
    $search_base = $wp_rewrite->search_base;
    if (is_search() && !is_admin() && strpos($_SERVER['REQUEST_URI'], "/{$search_base}/") === false) {
        wp_redirect(get_search_link());
        exit;
    }
}
开发者ID:arobbins,项目名称:davis,代码行数:20,代码来源:nice-search.php


示例7: do_search

 /**
  * A Breadcrumb Trail Filling Function
  * 
  * This functions fills a breadcrumb for a search page.
  */
 protected function do_search()
 {
     //Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
     $breadcrumb = $this->add(new bcn_breadcrumb(get_search_query(), $this->opt['Hsearch_template_no_anchor'], array('search', 'current-item')));
     //If we're paged, or allowing the current item to be linked, let's link to the first page
     if ($this->opt['bcurrent_item_linked'] || is_paged() && $this->opt['bpaged_display']) {
         //Since we are paged and are linking the root breadcrumb, time to change to the regular template
         $breadcrumb->set_template($this->opt['Hsearch_template']);
         //Figure out the anchor for the search
         $breadcrumb->set_url(get_search_link());
     }
 }
开发者ID:wiratama,项目名称:gardenbal,代码行数:17,代码来源:class.bcn_breadcrumb_trail.php


示例8: loop_pagination

/**
 * Loop pagination function for paginating loops with multiple posts.  This should be used on archive, blog, and 
 * search pages.  It is not for singular views.
 *
 * @since 0.1.0
 * @access public
 * @uses paginate_links() Creates a string of paginated links based on the arguments given.
 * @param array $args Arguments to customize how the page links are output.
 * @return string $page_links
 */
function loop_pagination($args = array())
{
    global $wp_rewrite, $wp_query;
    /* If there's not more than one page, return nothing. */
    if (1 >= $wp_query->max_num_pages) {
        return;
    }
    /* Get the current page. */
    $current = get_query_var('paged') ? absint(get_query_var('paged')) : 1;
    /* Get the max number of pages. */
    $max_num_pages = intval($wp_query->max_num_pages);
    /* Set up some default arguments for the paginate_links() function. */
    $defaults = array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'total' => $max_num_pages, 'current' => $current, 'prev_next' => true, 'show_all' => false, 'end_size' => 1, 'mid_size' => 1, 'add_fragment' => '', 'type' => 'plain', 'before' => '<div class="pagination loop-pagination">', 'after' => '</div>', 'echo' => true);
    /* Add the $base argument to the array if the user is using permalinks. */
    if ($wp_rewrite->using_permalinks()) {
        $defaults['base'] = str_replace(2, '%#%', esc_url(get_pagenum_link(2)));
    }
    //$defaults['base'] = user_trailingslashit( trailingslashit( get_pagenum_link() ) . 'page/%#%' );
    /* If we're on a search results page, we need to change this up a bit. */
    if (is_search()) {
        $search_permastruct = $wp_rewrite->get_search_permastruct();
        if (!empty($search_permastruct)) {
            $defaults['base'] = user_trailingslashit(trailingslashit(get_search_link()) . 'page/%#%');
        }
    }
    /* Allow developers to overwrite the arguments with a filter. */
    $args = apply_filters('loop_pagination_args', $args);
    /* Merge the arguments input with the defaults. */
    $args = wp_parse_args($args, $defaults);
    /* Don't allow the user to set this to an array. */
    if ('array' == $args['type']) {
        $args['type'] = 'plain';
    }
    /* Get the paginated links. */
    $page_links = paginate_links($args);
    /* Remove 'page/1' from the entire output since it's not needed. */
    $page_links = str_replace(array('&#038;paged=1\'', '/page/1\'', '/page/1/\''), '\'', $page_links);
    /* Wrap the paginated links with the $before and $after elements. */
    $page_links = $args['before'] . $page_links . $args['after'];
    /* Allow devs to completely overwrite the output. */
    $page_links = apply_filters('loop_pagination', $page_links);
    /* Return the paginated links for use in themes. */
    if ($args['echo']) {
        echo $page_links;
    } else {
        return $page_links;
    }
}
开发者ID:jacko5,项目名称:bjj,代码行数:58,代码来源:loop-pagination.php


示例9: __construct

 public function __construct()
 {
     add_action('template_redirect', function () {
         global $wp_rewrite;
         if (!isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->get_search_permastruct()) {
             return;
         }
         if (is_search() && !is_admin() && strpos($_SERVER['REQUEST_URI'], '/' . $wp_rewrite->search_base . '/') === false && strpos($_SERVER['REQUEST_URI'], '&') === false) {
             wp_redirect(get_search_link());
             exit;
         }
     });
     add_filter('wpseo_json_ld_search_url', function () {
         return str_replace('/?s=', '/search/', $url);
     });
 }
开发者ID:tagmeo,项目名称:framework,代码行数:16,代码来源:Search.php


示例10: td_js_generator

function td_js_generator()
{
    td_js_buffer::add_variable('td_ajax_url', admin_url('admin-ajax.php'));
    td_js_buffer::add_variable('td_get_template_directory_uri', get_template_directory_uri());
    td_js_buffer::add_variable('tds_snap_menu', td_util::get_option('tds_snap_menu'));
    td_js_buffer::add_variable('tds_header_style', td_util::get_option('tds_header_style'));
    td_js_buffer::add_variable('tds_mobile_swipe', td_util::get_option('tds_mobile_swipe'));
    td_js_buffer::add_variable('td_search_url', get_search_link());
    td_js_buffer::add_variable('td_please_wait', str_replace(array('"', "'"), array('`'), __td("Please wait...")));
    td_js_buffer::add_variable('td_email_user_pass_incorrect', str_replace(array('"', "'"), array('`'), __td("User or password incorrect!")));
    td_js_buffer::add_variable('td_email_user_incorrect', str_replace(array('"', "'"), array('`'), __td("Email or username incorrect!")));
    td_js_buffer::add_variable('td_email_incorrect', str_replace(array('"', "'"), array('`'), __td("Email incorrect!")));
    //use for more articles on post pages
    td_js_buffer::add_variable('tds_more_articles_on_post_enable', td_util::get_option('tds_more_articles_on_post_pages_enable'));
    td_js_buffer::add_variable('tds_more_articles_on_post_time_to_wait', td_util::get_option('tds_more_articles_on_post_pages_time_to_wait'));
    td_js_buffer::add_variable('tds_more_articles_on_post_pages_distance_from_top', intval(td_util::get_option('tds_more_articles_on_post_pages_distance_from_top')));
    td_js_buffer::add("\nvar td_blocks = []; //here we store all the items for the current page\n\n//td_block class - each ajax block uses a object of this class for requests\nfunction td_block() {\n    this.id = '';\n    this.block_type = 1; //block type id (1-234 etc)\n    this.atts = '';\n    this.td_cur_cat = '';\n    this.td_column_number = '';\n    this.td_current_page = 1; //\n    this.post_count = 0; //from wp\n    this.found_posts = 0; //from wp\n    this.max_num_pages = 0; //from wp\n    this.is_ajax_running = false;\n    this.header_color = '';\n}\n\n    ");
}
开发者ID:Vatia13,项目名称:tofido,代码行数:18,代码来源:td_js_generator.php


示例11: swiftype_render_facets

/**
 * Echo a facet listing from the search results. This should only be used on
 * the search results page, because Swiftype search results must be present.
 *
 * You must modify the Swiftype query parameters to request facets.
 *
 * Facets are rendered inside a <div> with class st-facets.
 *
 * @param String $term_order Optional. Sort order for faceted terms. Default
 *                                     is 'count'; if 'alphabetical' faceted 
 *                                     terms will be sorted alphabetically.
 *
 * @return void
 */
function swiftype_render_facets($term_order = 'count')
{
    $results = swiftype_search_results();
    $facets = $results['info']['posts']['facets'];
    if (empty($facets)) {
        return '';
    }
    $html = '<div class="st-facets">';
    foreach ($facets as $facet_field => $facet_values) {
        if (empty($facet_values)) {
            continue;
        }
        $html .= '<h4 class="st-facet-field st-facet-field-' . sanitize_title_with_dashes($facet_field) . '">' . esc_html($facet_field) . '</h4>';
        $html .= '<ul>';
        $term_counts = array();
        foreach ($facet_values as $facet_term => $facet_count) {
            if (trim($facet_term) === '') {
                continue;
            }
            $facet_display = $facet_term;
            // special case for category since it's stored as an ID
            if ($facet_field == 'category') {
                $facet_display = get_cat_name($facet_term);
                if ($facet_display === '') {
                    continue;
                }
            }
            $term_counts[$facet_display] = array('term' => $facet_term, 'count' => $facet_count);
        }
        if ($term_order == 'alphabetical') {
            ksort($term_counts, SORT_FLAG_CASE | SORT_NATURAL);
        }
        foreach ($term_counts as $facet_display => $facet_details) {
            // apparently WordPress's add_query_arg does not properly handle & in a value; escape it with %26 beforehand.
            $escaped_facet_term = str_replace('&', '%26', $facet_details['term']);
            $url = add_query_arg(array('st-facet-field' => $facet_field, 'st-facet-term' => $escaped_facet_term), get_search_link());
            $html .= "<li><a href=\"" . esc_attr($url) . "\">" . esc_html($facet_display) . "</a> (" . esc_html($facet_details['count']) . ")</li>";
        }
        $html .= '</ul>';
    }
    $html .= '</div>';
    echo $html;
}
开发者ID:eberhardtsmith,项目名称:dinerporn,代码行数:57,代码来源:swiftype-theme-functions.php


示例12: vw_instant_search

 function vw_instant_search()
 {
     global $wpdb;
     if (isset($_GET['s'])) {
         $q = htmlspecialchars($_GET['s']);
         $q = mysql_real_escape_string($q);
         $q = esc_sql($q);
     } else {
         echo json_encode(apply_filters('instant_search_res', array()));
         die;
     }
     $query = array('suppress_filters' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'post_status' => 'publish', 'order' => 'DESC', 'orderby' => 'post_date', 'posts_per_page' => 6, 's' => $q);
     query_posts($query);
     // Check if any posts were found.
     if (!have_posts()) {
         $html = '<li class="vw-instant-search-no-result">';
         $html .= '<span class="vw-instant-search-result-title">No result was found</span>';
         $html .= '</li>';
         echo $html;
         die;
     }
     //Create an array with the results
     $html = '';
     while (have_posts()) {
         the_post();
         ob_start();
         get_template_part('templates/instant-search-result');
         $html .= ob_get_clean();
     }
     $html .= '<li class="vw-instant-search-all-result">';
     $html .= '<a href="' . get_search_link() . '"><span class="vw-instant-search-result-title">' . __('View all results &raquo;', 'envirra') . '</span></a>';
     $html .= '</li>';
     echo $html;
     wp_reset_query();
     die;
 }
开发者ID:mathewhtc,项目名称:cats-old,代码行数:36,代码来源:instant-search.php


示例13: canonical

 /**
  * This function normally outputs the canonical but is also used in other places to retrieve the canonical URL
  * for the current page.
  *
  * @param bool $echo    Whether or not to output the canonical element.
  * @param bool $unpaged Whether or not to return the canonical with or without pagination added to the URL.
  * @return string $canonical
  */
 function canonical($echo = true, $unpaged = false)
 {
     $options = get_wpseo_options();
     $canonical = false;
     // Set decent canonicals for homepage, singulars and taxonomy pages
     if (is_singular()) {
         if (wpseo_get_value('canonical') && wpseo_get_value('canonical') != '') {
             $canonical = wpseo_get_value('canonical');
         } else {
             $obj = get_queried_object();
             $canonical = get_permalink($obj->ID);
             // Fix paginated pages canonical, but only if the page is truly paginated.
             if (get_query_var('page') > 1) {
                 global $wp_rewrite;
                 $numpages = substr_count($obj->post_content, '<!--nextpage-->') + 1;
                 if ($numpages && get_query_var('page') < $numpages) {
                     if (!$wp_rewrite->using_permalinks()) {
                         $canonical = add_query_arg('page', get_query_var('page'), $canonical);
                     } else {
                         $canonical = user_trailingslashit(trailingslashit($canonical) . get_query_var('page'));
                     }
                 }
             }
         }
     } else {
         if (is_search()) {
             $canonical = get_search_link();
         } else {
             if (is_front_page()) {
                 $canonical = home_url('/');
             } else {
                 if ($this->is_posts_page()) {
                     $canonical = get_permalink(get_option('page_for_posts'));
                 } else {
                     if (is_tax() || is_tag() || is_category()) {
                         $term = get_queried_object();
                         $canonical = wpseo_get_term_meta($term, $term->taxonomy, 'canonical');
                         if (!$canonical) {
                             $canonical = get_term_link($term, $term->taxonomy);
                         }
                     } else {
                         if (function_exists('get_post_type_archive_link') && is_post_type_archive()) {
                             $canonical = get_post_type_archive_link(get_post_type());
                         } else {
                             if (is_author()) {
                                 $canonical = get_author_posts_url(get_query_var('author'), get_query_var('author_name'));
                             } else {
                                 if (is_archive()) {
                                     if (is_date()) {
                                         if (is_day()) {
                                             $canonical = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day'));
                                         } else {
                                             if (is_month()) {
                                                 $canonical = get_month_link(get_query_var('year'), get_query_var('monthnum'));
                                             } else {
                                                 if (is_year()) {
                                                     $canonical = get_year_link(get_query_var('year'));
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($canonical && $unpaged) {
             return $canonical;
         }
         if ($canonical && get_query_var('paged') > 1) {
             global $wp_rewrite;
             if (!$wp_rewrite->using_permalinks()) {
                 $canonical = add_query_arg('paged', get_query_var('paged'), $canonical);
             } else {
                 $canonical = user_trailingslashit(trailingslashit($canonical) . trailingslashit($wp_rewrite->pagination_base) . get_query_var('paged'));
             }
         }
     }
     if ($canonical && isset($options['force_transport']) && 'default' != $options['force_transport']) {
         $canonical = preg_replace('/https?/', $options['force_transport'], $canonical);
     }
     $canonical = apply_filters('wpseo_canonical', $canonical);
     if ($canonical && !is_wp_error($canonical)) {
         if ($echo) {
             echo '<link rel="canonical" href="' . esc_url($canonical, null, 'other') . '" />' . "\n";
         } else {
             return $canonical;
         }
     }
 }
开发者ID:robjcordes,项目名称:nexnewwp,代码行数:100,代码来源:class-frontend.php


示例14: tc_breadcrumb_trail_get_items


//.........这里部分代码省略.........
            /* If $front has been set, add it to the $path. */
            if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                $path .= trailingslashit($wp_rewrite->front);
            }
            /* If there's a slug, add it to the $path. */
            if (!empty($post_type_object->rewrite['slug'])) {
                $path .= $post_type_object->rewrite['slug'];
            }
            /* If there's a path, check for parents. */
            if (!empty($path)) {
                $trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
            }
            /* Add the post type [plural] name to the trail end. */
            if (is_paged()) {
                $trail[] = '<a href="' . esc_url(get_post_type_archive_link($post_type_object->name)) . '" title="' . esc_attr(post_type_archive_title('', false)) . '">' . post_type_archive_title('', false) . '</a>';
            } else {
                $trail[] = post_type_archive_title('', false);
            }
        } elseif (is_author()) {
            /* Get the user ID. */
            $user_id = get_query_var('author');
            /* If $front has been set, add it to $path. */
            if (!empty($wp_rewrite->front)) {
                $path .= trailingslashit($wp_rewrite->front);
            }
            /* If an $author_base exists, add it to $path. */
            if (!empty($wp_rewrite->author_base)) {
                $path .= $wp_rewrite->author_base;
            }
            /* If $path exists, check for parent pages. */
            if (!empty($path)) {
                $trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
            }
            /* Add the author's display name to the trail end. */
            if (is_paged()) {
                $trail[] = '<a href="' . esc_url(get_author_posts_url($user_id)) . '" title="' . esc_attr(get_the_author_meta('display_name', $user_id)) . '">' . get_the_author_meta('display_name', $user_id) . '</a>';
            } else {
                $trail[] = get_the_author_meta('display_name', $user_id);
            }
        } elseif (is_time()) {
            if (get_query_var('minute') && get_query_var('hour')) {
                $trail[] = get_the_time(__('g:i a', 'breadcrumb-trail'));
            } elseif (get_query_var('minute')) {
                $trail[] = sprintf(__('Minute %1$s', 'breadcrumb-trail'), get_the_time(__('i', 'breadcrumb-trail')));
            } elseif (get_query_var('hour')) {
                $trail[] = get_the_time(__('g a', 'breadcrumb-trail'));
            }
        } elseif (is_date()) {
            /* If $front has been set, check for parent pages. */
            if ($wp_rewrite->front) {
                $trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $wp_rewrite->front));
            }
            if (is_day()) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'breadcrumb-trail')) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
                $trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'breadcrumb-trail')) . '">' . get_the_time(__('F', 'breadcrumb-trail')) . '</a>';
                if (is_paged()) {
                    $trail[] = '<a href="' . get_day_link(get_the_time('Y'), get_the_time('m'), get_the_time('d')) . '" title="' . get_the_time(esc_attr__('d', 'breadcrumb-trail')) . '">' . get_the_time(__('d', 'breadcrumb-trail')) . '</a>';
                } else {
                    $trail[] = get_the_time(__('d', 'breadcrumb-trail'));
                }
            } elseif (get_query_var('w')) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'breadcrumb-trail')) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
                if (is_paged()) {
                    $trail[] = get_archives_link(add_query_arg(array('m' => get_the_time('Y'), 'w' => get_the_time('W')), esc_url(home_url())), sprintf(__('Week %1$s', 'breadcrumb-trail'), get_the_time(esc_attr__('W', 'breadcrumb-trail'))), false);
                } else {
                    $trail[] = sprintf(__('Week %1$s', 'breadcrumb-trail'), get_the_time(esc_attr__('W', 'breadcrumb-trail')));
                }
            } elseif (is_month()) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'breadcrumb-trail')) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
                if (is_paged()) {
                    $trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'breadcrumb-trail')) . '">' . get_the_time(__('F', 'breadcrumb-trail')) . '</a>';
                } else {
                    $trail[] = get_the_time(__('F', 'breadcrumb-trail'));
                }
            } elseif (is_year()) {
                if (is_paged()) {
                    $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . esc_attr(get_the_time(__('Y', 'breadcrumb-trail'))) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
                } else {
                    $trail[] = get_the_time(__('Y', 'breadcrumb-trail'));
                }
            }
        }
    } elseif (is_search()) {
        if (is_paged()) {
            $trail[] = '<a href="' . get_search_link() . '" title="' . sprintf(esc_attr__('Search results for &quot;%1$s&quot;', 'breadcrumb-trail'), esc_attr(get_search_query())) . '">' . sprintf(__('Search results for &quot;%1$s&quot;', 'breadcrumb-trail'), esc_attr(get_search_query())) . '</a>';
        } else {
            $trail[] = sprintf(__('Search results for &quot;%1$s&quot;', 'breadcrumb-trail'), esc_attr(get_search_query()));
        }
    } elseif (is_404()) {
        $trail[] = __('404 Not Found', 'breadcrumb-trail');
    }
    /* Check for pagination. */
    if (is_paged()) {
        $trail[] = sprintf(__('Page %d', 'breadcrumb-trail'), absint(get_query_var('paged')));
    } elseif (is_singular() && 1 < get_query_var('page')) {
        $trail[] = sprintf(__('Page %d', 'breadcrumb-trail'), absint(get_query_var('page')));
    }
    /* Allow devs to step in and filter the $trail array. */
    return apply_filters('breadcrumb_trail_items', $trail, $args);
}
开发者ID:keoniworld,项目名称:Customizr,代码行数:101,代码来源:tc_hot_crumble.php


示例15: testThemeTemplateIsCorrectForSearch

 public function testThemeTemplateIsCorrectForSearch()
 {
     $this->go_to_with_template(get_search_link('foo'));
     $this->assertTrue(is_search());
     $this->assertSame('search.php', self::get_theme_data('template_file'));
 }
开发者ID:johnbillion,项目名称:query-monitor,代码行数:6,代码来源:test-collector-theme.php


示例16: ktz_get_AGC_single

function ktz_get_AGC_single()
{
    if (ot_get_option('ktz_agc_activated') == "yes") {
        $orititle = get_the_title();
        $orititle = trim($orititle);
        $termstring = $orititle;
        if ($orititle != '') {
            echo '<div class="box-post single relpost">';
            echo '<h4 class="ktz-agc-title"><span class="ktz-blocktitle">' . __('Related Search', ktz_theme_textdomain) . '</span></h4>';
            echo '<ul class="ktz-agc-single">';
            $googleresults = perform_google_web_search_single($termstring);
            if (is_array($googleresults)) {
                $i = 0;
                foreach ($googleresults as $result) {
                    $link = urldecode(CleanFileNameBan(strip_tags($result['Oriurl'])));
                    $i++;
                    if ($i < 5) {
                        echo '<li class="clearfix">';
                        echo '<div class="content-related">';
                        echo '<a title="' . CleanFileNameBan(hilangkan_spesial_karakter($result['title'])) . '" href="' . get_search_link(CleanFileNameBan(hilangkan_spesial_karakter($result['title']))) . '">' . CleanFileNameBan(hilangkan_spesial_karakter($result['title'])) . '</a>';
                        echo '</div></li>';
                    }
                }
            }
            echo '</ul>';
            echo '</div>';
        }
    }
}
开发者ID:jjpango,项目名称:JJTeam,代码行数:29,代码来源:_agc_ktz.php


示例17: canonical

 /**
  * This function normally outputs the canonical but is also used in other places to retrieve
  * the canonical URL for the current page.
  *
  * @param bool $echo        Whether or not to output the canonical element.
  * @param bool $un_paged    Whether or not to return the canonical with or without pagination added to the URL.
  * @param bool $no_override Whether or not to return a manually overridden canonical
  *
  * @return string $canonical
  */
 public function canonical($echo = true, $un_paged = false, $no_override = false)
 {
     $canonical = false;
     $skip_pagination = false;
     // Set decent canonicals for homepage, singulars and taxonomy pages
     if (is_singular()) {
         $meta_canon = WPSEO_Meta::get_value('canonical');
         if ($no_override === false && $meta_canon !== '') {
             $canonical = $meta_canon;
             $skip_pagination = true;
         } else {
             $obj = get_queried_object();
             $canonical = get_permalink($obj->ID);
             // Fix paginated pages canonical, but only if the page is truly paginated.
             if (get_query_var('page') > 1) {
                 global $wp_rewrite;
                 $numpages = substr_count($obj->post_content, '<!--nextpage-->') + 1;
                 if ($numpages && get_query_var('page') <= $numpages) {
                     if (!$wp_rewrite->using_permalinks()) {
                         $canonical = add_query_arg('page', get_query_var('page'), $canonical);
                     } else {
                         $canonical = user_trailingslashit(trailingslashit($canonical) . get_query_var('page'));
                     }
                 }
             }
         }
         unset($meta_canon);
     } else {
         if (is_search()) {
             $canonical = get_search_link();
         } elseif (is_front_page()) {
             $canonical = home_url('/');
         } elseif ($this->is_posts_page()) {
             $canonical = get_permalink(get_option('page_for_posts'));
         } elseif (is_tax() || is_tag() || is_category()) {
             $term = get_queried_object();
             if ($no_override === false) {
                 $canonical = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'canonical');
                 if (is_string($canonical) && $canonical !== '') {
                     $skip_pagination = true;
                 }
             }
             if (!is_string($canonical) || $canonical === '') {
                 $canonical = get_term_link($term, $term->taxonomy);
             }
         } elseif (is_post_type_archive()) {
             $post_type = get_query_var('post_type');
             if (is_array($post_type)) {
                 $post_type = reset($post_type);
             }
             $canonical = get_post_type_archive_link($post_type);
         } elseif (is_author()) {
             $canonical = get_author_posts_url(get_query_var('author'), get_query_var('author_name'));
         } elseif (is_archive()) {
             if (is_date()) {
                 if (is_day()) {
                     $canonical = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day'));
                 } elseif (is_month()) {
                     $canonical = get_month_link(get_query_var('year'), get_query_var('monthnum'));
                 } elseif (is_year()) {
                     $canonical = get_year_link(get_query_var('year'));
                 }
             }
         }
     }
     if ($canonical && $un_paged) {
         return $canonical;
     }
     if ($canonical && !$skip_pagination && get_query_var('paged') > 1) {
         global $wp_rewrite;
         if (!$wp_rewrite->using_permalinks()) {
             $canonical = add_query_arg('paged', get_query_var('paged'), $canonical);
         } else {
             if (is_front_page()) {
                 $base = $wp_rewrite->using_index_permalinks() ? 'index.php/' : '/';
                 $canonical = home_url($base);
             }
             $canonical = user_trailingslashit(trailingslashit($canonical) . trailingslashit($wp_rewrite->pagination_base) . get_query_var('paged'));
         }
     }
     if ($canonical && 'default' !== $this->options['force_transport']) {
         $canonical = preg_replace('`^http[s]?`', $this->options['force_transport'], $canonical);
     }
     /**
      * Filter: 'wpseo_canonical' - Allow filtering of the canonical URL put out by WP SEO
      *
      * @api string $canonical The canonical URL
      */
     $canonical = apply_filters('wpseo_canonical', $canonical);
     if (is_string($canonical) && $canonical !== '') {
//.........这里部分代码省略.........
开发者ID:thabofletcher,项目名称:tc-site,代码行数:101,代码来源:class-frontend.php


示例18: get_search_feed_link

/**
 * Retrieve the permalink for the feed of the search results.
 *
 * @since 2.5.0
 *
 * @param string $search_query Optional. Search query.
 * @param string $feed Optional. Feed type.
 * @return string
 */
function get_search_feed_link($search_query = '', $feed = '')
{
    global $wp_rewrite;
    $link = get_search_link($search_query);
    if (empty($feed)) {
        $feed = get_default_feed();
    }
    $permastruct = $wp_rewrite->get_search_permastruct();
    if (empty($permastruct)) {
        $link = add_query_arg('feed', $feed, $link);
    } else {
        $link = trailingslashit($link);
        $link .= "feed/{$feed}/";
    }
    $link = apply_filters('search_feed_link', $link, $feed, 'posts');
    return $link;
}
开发者ID:vpatrinica,项目名称:jfdesign,代码行数:26,代码来源:link-template.php


示例19: generate_canonical

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_search_query函数代码示例发布时间:2022-05-15
下一篇:
PHP get_search_form函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap