本文整理汇总了PHP中wp_parse_str函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_parse_str函数的具体用法?PHP wp_parse_str怎么用?PHP wp_parse_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_parse_str函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: farmtoyou_paging_nav
/**
* Display navigation to next/previous set of posts when applicable.
*
* @since Farmtoyou 1.0
*
* @global WP_Query $wp_query WordPress Query object.
* @global WP_Rewrite $wp_rewrite WordPress Rewrite object.
*/
function farmtoyou_paging_nav()
{
global $wp_query, $wp_rewrite;
// Don't print empty markup if there's only one page.
if ($wp_query->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $wp_rewrite->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit($wp_rewrite->pagination_base . '/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $wp_query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'farmtoyou'), 'next_text' => __('Next →', 'farmtoyou')));
if ($links) {
?>
<nav class="navigation paging-navigation" role="navigation">
<div class="pagination loop-pagination">
<?php
echo $links;
?>
</div><!-- .pagination -->
</nav><!-- .navigation -->
<?php
}
}
示例2: abramoca_pagination
function abramoca_pagination($query = null)
{
global $wp_query;
if (empty($query)) {
$query = $wp_query;
}
if ($query->max_num_pages < 2) {
return;
}
if (is_front_page()) {
$paged = get_query_var('page') ? intval(get_query_var('page')) : 1;
} else {
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
}
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $query->max_num_pages, 'current' => $paged, 'mid_size' => 3, 'type' => 'array', 'add_args' => array_map('urlencode', $query_args), 'prev_next' => True, 'prev_text' => !is_rtl() ? __('← Previous ') : __(' → Previous'), 'next_text' => !is_rtl() ? __('Next →') : __('Next ←')));
if (is_array($links)) {
echo '<ul class="pagination">';
//Aquí se editaría la clase CSS de la paginación
foreach ($links as $page) {
echo "<li>{$page}</li>";
}
echo '</ul>';
}
}
示例3: add_lang_to_link
function add_lang_to_link($link)
{
global $sitepress;
$lang = '';
if (false !== ($index = strpos($link, '?'))) {
// We honor the ?lang argument from the link itself (if present).
$data = array();
wp_parse_str(substr($link, $index + 1), $data);
if (!empty($data['lang'])) {
$lang = $data['lang'];
}
} else {
$lang = $this->get_current_language();
}
if (!$lang) {
return $link;
}
$nego_type = absint($sitepress->get_setting('language_negotiation_type'));
if (1 == $nego_type) {
if ($trans_id = icl_object_id(wpbdp_get_page_id(), 'page', false, $lang)) {
$real_link = get_permalink($trans_id);
$used_link = _get_page_link($trans_id);
$link = str_replace($used_link, $real_link, $link);
return $link;
}
}
$link = add_query_arg('lang', $lang, $link);
return $link;
}
示例4: anciela_paging_nav
/**
* Display navigation to next/previous set of posts when applicable.
*
* @since Anciela 1.0
*/
function anciela_paging_nav($query = null)
{
// Don't print empty markup if there's only one page.
if ($query == null) {
$query = $GLOBALS['wp_query'];
}
if ($query->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Plus récents', 'anciela'), 'next_text' => __('Plus anciens →', 'anciela')));
if ($links) {
?>
<nav class="navigation paging-navigation" role="navigation">
<?php
echo $links;
?>
</nav><!-- .navigation -->
<?php
}
}
示例5: iva_pagination
/**
* Display navigation to next/previous set of posts when applicable.
*
* @since hopes 1.0
*/
function iva_pagination()
{
// Don't print empty markup if there's only one page.
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'iva_theme_front'), 'next_text' => __('Next →', 'iva_theme_front')));
if ($links) {
$out = '<nav class="navigation paging-navigation" role="navigation">';
$out .= '<div class="pagination loop-pagination">';
$out .= $links;
$out .= '</div>';
$out .= '</nav>';
}
return $out;
}
示例6: gazeta_the_posts_pagination
function gazeta_the_posts_pagination($query, $echo = true)
{
$pagination = '';
global $wp_query;
if (empty($query)) {
$query = $wp_query;
}
if ($query->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
$args = array('base' => $pagenum_link, 'format' => $format, 'total' => $query->max_num_pages, 'current' => $paged, 'mid_size' => 3, 'type' => 'list', 'add_args' => array_map('urlencode', $query_args), 'prev_text' => '<i class="fa fa-angle-double-left"></i>', 'next_text' => '<i class="fa fa-angle-double-right"></i>', 'before_page_number' => '<span>', 'after_page_number' => '</span>');
// Set up paginated links.
$pagination = paginate_links(apply_filters('gazeta_old_navigation_args', $args));
if ($pagination) {
if ($echo === false) {
return '<nav class="navigation pagination"><div class="nav-links">' . $pagination . '</div></nav>';
} else {
echo '<nav class="navigation pagination"><div class="nav-links">';
echo $pagination;
echo '</div></nav>';
}
}
}
示例7: pagination
function pagination($pages = '', $range = 4)
{
// Don't print empty markup if there's only one page.
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('<i class="fa fa-angle-left"></i>', 'crunchpress'), 'next_text' => __('<i class="fa fa-angle-right"></i>', 'crunchpress')));
if ($links) {
?>
<div class="pagination-all pagination" role="navigation">
<ul id='pagination'>
<li>
<?php
echo $links;
?>
</li>
</ul><!-- .pagination -->
</div><!-- .navigation -->
<?php
}
}
示例8: flat_paging_nav
function flat_paging_nav()
{
// Don't print empty markup if there's only one page.
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 4, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('<i class="fa fa-chevron-left"></i>', 'flat'), 'next_text' => __('<i class="fa fa-chevron-right"></i>', 'flat')));
$allowed_html = array('a' => array('href' => array(), 'class' => array()), 'span' => array('class' => array()), 'i' => array('class' => array()));
if ($links) {
?>
<nav class="navigation paging-navigation" role="navigation">
<div class="nav-links">
<?php
echo wp_kses($links, $allowed_html);
?>
</div>
</nav>
<?php
}
}
示例9: _ks_parse_arg
function _ks_parse_arg($func_get_args, $defaults = '')
{
$r = array();
$arg = $func_get_args[0];
if (is_object($arg)) {
$r = get_object_vars($arg);
if (is_array($defaults)) {
$r = array_merge($defaults, $r);
}
} elseif (is_array($arg)) {
if (is_array($defaults)) {
$r = array_merge($defaults, $arg);
}
} elseif (is_string($arg) && count($arg) == 1 && preg_match('/^\\w+=/', $arg) && strpos($arg, ' ') === false) {
// query striing
wp_parse_str($arg, $r);
if (is_array($defaults)) {
$r = array_merge($defaults, $r);
}
} elseif (is_array($defaults)) {
$func_get_args = (array) $func_get_args;
// force array for null arguments
$r = array();
foreach ($defaults as $key => $value) {
$a = array_shift($func_get_args);
$r[$key] = is_null($a) ? $value : $a;
}
}
return $r;
}
示例10: get_photos
/**
* Returns an array of photos on a WP_Error.
*/
private function get_photos($args = array())
{
$transient_key = md5('aquick-flickr-cache-' . print_r($args, true));
$cached = get_transient($transient_key);
if ($cached) {
return $cached;
}
$username = isset($args['username']) ? $args['username'] : '';
$tags = isset($args['tags']) ? $args['tags'] : '';
$count = isset($args['count']) ? absint($args['count']) : 10;
$query = array('tagmode' => 'any', 'tags' => $tags);
// If username is an RSS feed
if (preg_match('#^https?://api\\.flickr\\.com/services/feeds/photos_public\\.gne#', $username)) {
$url = parse_url($username);
$url_query = array();
wp_parse_str($url['query'], $url_query);
$query = array_merge($query, $url_query);
} else {
$user = $this->request('flickr.people.findByUsername', array('username' => $username));
if (is_wp_error($user)) {
return $user;
}
$user_id = $user->user->id;
$query['id'] = $user_id;
}
$photos = $this->request_feed('photos_public', $query);
if (!$photos) {
return new WP_Error('error', __('Could not fetch photos.', AZ_THEME_NAME));
}
$photos = array_slice($photos, 0, $count);
set_transient($transient_key, $photos, apply_filters('quick_flickr_widget_cache_timeout', 3600));
return $photos;
}
示例11: my_simone_paging_nav
/**
* Display navigation to next/previous set of posts when applicable.
*
* @return void
*/
function my_simone_paging_nav()
{
// Don't print empty markup if there's only one page.
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 2, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'my-simone'), 'next_text' => __('Next →', 'my-simone'), 'type' => 'list'));
if ($links) {
?>
<nav class="navigation paging-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
_e('Posts navigation', 'my-simone');
?>
</h1>
<?php
echo $links;
?>
</nav><!-- .navigation -->
<?php
}
}
示例12: learn_press_course_paging_nav
/**
* Display navigation to next/previous set of posts when applicable.
*/
function learn_press_course_paging_nav()
{
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('<', 'learn_press'), 'next_text' => __('>', 'learn_press'), 'type' => 'list'));
if ($links) {
?>
<div class="navigation pagination">
<?php
echo $links;
?>
</div>
<!-- .pagination -->
<?php
}
}
示例13: test_wp_parse_args_other
function test_wp_parse_args_other() {
$b = true;
wp_parse_str($b, $s);
$this->assertEquals($s, wp_parse_args($b));
$q = 'x=5&_baba=dudu&';
wp_parse_str($q, $ss);
$this->assertEquals($ss, wp_parse_args($q));
}
示例14: bp_activity_action_permalink_router
/**
* Catch and route requests for single activity item permalinks.
*
* @since 1.2.0
*
* @return bool False on failure.
*/
function bp_activity_action_permalink_router()
{
// Not viewing activity.
if (!bp_is_activity_component() || !bp_is_current_action('p')) {
return false;
}
// No activity to display.
if (!bp_action_variable(0) || !is_numeric(bp_action_variable(0))) {
return false;
}
// Get the activity details.
$activity = bp_activity_get_specific(array('activity_ids' => bp_action_variable(0), 'show_hidden' => true));
// 404 if activity does not exist
if (empty($activity['activities'][0])) {
bp_do_404();
return;
} else {
$activity = $activity['activities'][0];
}
// Do not redirect at default.
$redirect = false;
// Redirect based on the type of activity.
if (bp_is_active('groups') && $activity->component == buddypress()->groups->id) {
// Activity is a user update.
if (!empty($activity->user_id)) {
$redirect = bp_core_get_user_domain($activity->user_id, $activity->user_nicename, $activity->user_login) . bp_get_activity_slug() . '/' . $activity->id . '/';
// Activity is something else.
} else {
// Set redirect to group activity stream.
if ($group = groups_get_group($activity->item_id)) {
$redirect = bp_get_group_permalink($group) . bp_get_activity_slug() . '/' . $activity->id . '/';
}
}
// Set redirect to users' activity stream.
} elseif (!empty($activity->user_id)) {
$redirect = bp_core_get_user_domain($activity->user_id, $activity->user_nicename, $activity->user_login) . bp_get_activity_slug() . '/' . $activity->id . '/';
}
// If set, add the original query string back onto the redirect URL.
if (!empty($_SERVER['QUERY_STRING'])) {
$query_frags = array();
wp_parse_str($_SERVER['QUERY_STRING'], $query_frags);
$redirect = add_query_arg(urlencode_deep($query_frags), $redirect);
}
/**
* Filter the intended redirect url before the redirect occurs for the single activity item.
*
* @since 1.2.2
*
* @param array $value Array with url to redirect to and activity related to the redirect.
*/
if (!($redirect = apply_filters_ref_array('bp_activity_permalink_redirect_url', array($redirect, &$activity)))) {
bp_core_redirect(bp_get_root_domain());
}
// Redirect to the actual activity permalink page.
bp_core_redirect($redirect);
}
示例15: parse_query
/**
* Allow $atts to be just the post_query as a string or object
*
* @param string|array $qs
* @return array Properly formatted $atts
* @since 0.4.2
*/
public static function parse_query($qs)
{
if (is_string($qs)) {
$query = array();
wp_parse_str($qs, $query);
} else {
$query = $qs;
}
return $query;
}