本文整理汇总了PHP中add_query_arg函数的典型用法代码示例。如果您正苦于以下问题:PHP add_query_arg函数的具体用法?PHP add_query_arg怎么用?PHP add_query_arg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_query_arg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_qs_add_to_cart_url
public function update_qs_add_to_cart_url($cart_url)
{
$ref_url = wp_get_referer();
$ref_url = remove_query_arg(array('added-to-cart', 'add-to-cart'), $ref_url);
$ref_url = add_query_arg(array('add-to-cart' => $this->id), $ref_url);
return $ref_url;
}
示例2: educator_theme_fonts_url
/**
* Get fonts URL.
*
* @return string
*/
function educator_theme_fonts_url()
{
$fonts = array();
$fonts[] = get_theme_mod('headings_font', 'Open Sans');
$fonts[] = get_theme_mod('body_font', 'Open Sans');
$font_families = array();
$available_fonts = apply_filters('ib_theme_get_fonts', array());
foreach ($fonts as $font_name) {
if (isset($font_families[$font_name])) {
continue;
}
if (isset($available_fonts[$font_name])) {
$font = $available_fonts[$font_name];
$font_families[$font_name] = urlencode($font_name);
if (!empty($font['font_styles'])) {
$font_families[$font_name] .= ':' . $font['font_styles'];
}
}
}
if (empty($font_families)) {
return false;
}
$query_args = array(array('family' => implode('|', $font_families)));
$charater_sets = get_theme_mod('charater_sets', 'latin,latin-ext');
if (!empty($charater_sets)) {
$query_args['subset'] = educator_sanitize_character_sets($charater_sets);
}
return add_query_arg($query_args, '//fonts.googleapis.com/css');
}
示例3: output
/**
* Output the settings
*/
public function output()
{
global $woocommerce, $woocommerce_settings, $current_section, $current_tab;
if (!current_user_can('manage_woocommerce')) {
wp_die(__('You do not have sufficient permissions to access this page.', MAILPOET_WOOCOMMERCE_TEXT_DOMAIN));
}
do_action('woocommerce_mailpoet_settings_start');
$mailpoet_settings = $this->get_settings();
// Get current section
$current_section = empty($_REQUEST['section']) ? 'general' : sanitize_text_field(urldecode($_REQUEST['section']));
$current = $current_section ? '' : ' class="current"';
// Creates each settings section.
$mailpoet_section = apply_filters('woocommerce_mailpoet_settings_sections', array('general' => __('General', MAILPOET_WOOCOMMERCE_TEXT_DOMAIN), 'lists' => __('Lists', MAILPOET_WOOCOMMERCE_TEXT_DOMAIN)));
foreach ($mailpoet_section as $section => $title) {
$title = ucwords($title);
$current = $section == $current_section ? ' class="current"' : '';
$links[] = '<a href="' . add_query_arg('section', $section, admin_url('admin.php?page=woocommerce_settings&tab=mailpoet')) . '"' . $current . '>' . esc_html($title) . '</a>';
}
echo '<ul class="subsubsub"><li>' . implode('| </li><li>', $links) . '</li></ul><br class="clear" />';
woocommerce_admin_fields($mailpoet_settings);
if ($current_section == 'lists') {
include_once MailPoet_WooCommerce_Add_on()->plugin_path() . '/includes/admin/settings/settings-newsletters.php';
$mailpoet_list = mailpoet_lists();
do_action('woocommerce_mailpoet_list_newsletters', $mailpoet_list);
}
}
示例4: mm_ux_log
function mm_ux_log($args = array())
{
$url = "https://ssl.google-analytics.com/collect";
global $title;
if (empty($_SERVER['REQUEST_URI'])) {
return;
}
$path = explode('wp-admin', $_SERVER['REQUEST_URI']);
if (empty($path) || empty($path[1])) {
$path = array("", " ");
}
$defaults = array('v' => '1', 'tid' => 'UA-39246514-3', 't' => 'pageview', 'cid' => md5(get_option('siteurl')), 'uid' => md5(get_option('siteurl') . get_current_user_id()), 'cn' => 'mojo_wp_plugin', 'cs' => 'mojo_wp_plugin', 'cm' => 'plugin_admin', 'ul' => get_locale(), 'dp' => $path[1], 'sc' => '', 'ua' => @$_SERVER['HTTP_USER_AGENT'], 'dl' => $path[1], 'dh' => get_option('siteurl'), 'dt' => $title, 'ec' => '', 'ea' => '', 'el' => '', 'ev' => '');
if (isset($_SERVER['REMOTE_ADDR'])) {
$defaults['uip'] = $_SERVER['REMOTE_ADDR'];
}
$params = wp_parse_args($args, $defaults);
$test = get_transient('mm_test', '');
if (isset($test['key']) && isset($test['name'])) {
$params['cm'] = $params['cm'] . "_" . $test['name'] . "_" . $test['key'];
}
//use test account for testing
if (defined('WP_DEBUG') && WP_DEBUG) {
$params['tid'] = 'UA-19617272-27';
}
$z = wp_rand(0, 1000000000);
$query = http_build_query(array_filter($params));
$args = array('body' => $query, 'method' => 'POST', 'blocking' => false);
$url = add_query_arg(array('z' => $z), $url);
wp_remote_post($url, $args);
}
示例5: igthemes_font_url
function igthemes_font_url()
{
$fonts_url = '';
$fonts = array();
$subsets = 'latin,latin-ext';
/*
* Translators: If there are characters in your language that are not supported,
* translate this to 'off'. Do not translate into your own language.
*/
if ('off' !== _x('on', 'Open Sans font: on or off', 'store-wp')) {
$fonts[] = 'Open Sans:300italic,400italic,700italic,300,400,700';
}
/*
* Translators: To add an additional character subset specific to your language,
* translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language.
*/
$subset = _x('no-subset', 'Add new subset (greek, cyrillic, vietnamese)', 'store-wp');
if ('cyrillic' == $subset) {
$subsets .= ',cyrillic,cyrillic-ext';
} elseif ('greek' == $subset) {
$subsets .= ',greek,greek-ext';
} elseif ('devanagari' == $subset) {
$subsets .= ',devanagari';
}
if ($fonts) {
$fonts_url = add_query_arg(array('family' => urlencode(implode('|', $fonts)), 'subset' => urlencode($subsets)), '//fonts.googleapis.com/css');
}
return $fonts_url;
}
示例6: twentyfourteen_contextual_help
/**
* Add contextual help to the Themes and Post edit screens.
*
* @since Twenty Fourteen 1.0
*/
function twentyfourteen_contextual_help()
{
if ('admin_head-edit.php' === current_filter() && 'post' !== $GLOBALS['typenow']) {
return;
}
get_current_screen()->add_help_tab(array('id' => 'twentyfourteen', 'title' => __('Twenty Fourteen', 'twentyfourteen'), 'content' => '<ul>' . '<li>' . sprintf(__('The home page features your choice of up to 6 posts prominently displayed in a grid or slider, controlled by a <a href="%1$s">tag</a>; you can change the tag and layout in <a href="%2$s">Appearance → Customize</a>. If no posts match the tag, <a href="%3$s">sticky posts</a> will be displayed instead.', 'twentyfourteen'), esc_url(add_query_arg('tag', _x('featured', 'featured content default tag slug', 'twentyfourteen'), admin_url('edit.php'))), admin_url('customize.php'), admin_url('edit.php?show_sticky=1')) . '</li>' . '<li>' . sprintf(__('Enhance your site design by using <a href="%s">Featured Images</a> for posts you’d like to stand out (also known as post thumbnails). This allows you to associate an image with your post without inserting it. Twenty Fourteen uses featured images for posts and pages—above the title—and in the Featured Content area on the home page.', 'twentyfourteen'), 'https://codex.wordpress.org/Post_Thumbnails#Setting_a_Post_Thumbnail') . '</li>' . '<li>' . sprintf(__('For an in-depth tutorial, and more tips and tricks, visit the <a href="%s">Twenty Fourteen documentation</a>.', 'twentyfourteen'), 'https://codex.wordpress.org/Twenty_Fourteen') . '</li>' . '</ul>'));
}
示例7: step_forward
public function step_forward($step = 1, $part = '')
{
$step++;
$redirect = add_query_arg(array('page' => 'affiliate-wp-migrate', 'type' => 'wp-affiliate', 'part' => $part, 'step' => $step), admin_url('index.php'));
wp_redirect($redirect);
exit;
}
示例8: get_actions
/**
* @see CPAC_Column_Actions::get_actions()
* @since 2.4.7
*/
public function get_actions($id)
{
$actions = array();
$user_object = new WP_User($id);
$screen = get_current_screen();
if ('site-users-network' == $screen->id) {
$url = "site-users.php?id={$this->site_id}&";
} else {
$url = 'users.php?';
}
if (get_current_user_id() == $user_object->ID) {
$edit_link = 'profile.php';
} else {
$edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), "user-edit.php?user_id={$user_object->ID}"));
}
if (current_user_can('edit_user', $user_object->ID)) {
$edit = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a></strong><br />";
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
} else {
$edit = "<strong>{$user_object->user_login}</strong><br />";
}
if (!is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('delete_user', $user_object->ID)) {
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user={$user_object->ID}", 'bulk-users') . "'>" . __('Delete') . "</a>";
}
if (is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('remove_user', $user_object->ID)) {
$actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url($url . "action=remove&user={$user_object->ID}", 'bulk-users') . "'>" . __('Remove') . "</a>";
}
return $actions;
}
示例9: edd_wl_render_admin_columns
/**
* Render Wish List Columns
*
* @since 1.0
* @param string $column_name Column name
* @param int $post_id Download (Post) ID
* @return void
*/
function edd_wl_render_admin_columns($column_name, $post_id)
{
if (get_post_type($post_id) == 'edd_wish_list') {
$items = get_post_meta(get_the_ID(), 'edd_wish_list', true);
switch ($column_name) {
case 'downloads':
if ($items) {
echo count($items);
} else {
echo 0;
}
break;
case 'total':
echo edd_wl_get_list_total(get_the_ID());
break;
case 'list_author':
$post = get_post();
if (0 == $post->post_author) {
echo __('Guest', 'edd-wish-lists');
} else {
printf('<a href="%s">%s</a>', esc_url(add_query_arg(array('post_type' => $post->post_type, 'author' => get_the_author_meta('ID')), 'edit.php')), get_the_author());
}
break;
}
}
}
示例10: jetpack_instagram_handler
function jetpack_instagram_handler($matches, $atts, $url)
{
global $content_width;
static $did_script;
// keep a copy of the passed-in URL since it's modified below
$passed_url = $url;
$max_width = 698;
$min_width = 320;
if (is_feed()) {
$media_url = sprintf('http://instagr.am/p/%s/media/?size=l', $matches[2]);
return sprintf('<a href="%s" title="%s"><img src="%s" alt="Instagram Photo" /></a>', esc_url($url), esc_attr__('View on Instagram', 'jetpack'), esc_url($media_url));
}
$atts = shortcode_atts(array('width' => isset($content_width) ? $content_width : $max_width, 'hidecaption' => false), $atts);
$atts['width'] = absint($atts['width']);
if ($atts['width'] > $max_width || $min_width > $atts['width']) {
$atts['width'] = $max_width;
}
// remove the modal param from the URL
$url = remove_query_arg('modal', $url);
// force .com instead of .am for https support
$url = str_replace('instagr.am', 'instagram.com', $url);
// The oembed endpoint expects HTTP, but HTTP requests 301 to HTTPS
$instagram_http_url = str_replace('https://', 'http://', $url);
$instagram_https_url = str_replace('http://', 'https://', $url);
$url_args = array('url' => $instagram_http_url, 'maxwidth' => $atts['width']);
if ($atts['hidecaption']) {
$url_args['hidecaption'] = 'true';
}
$url = esc_url_raw(add_query_arg($url_args, 'https://api.instagram.com/oembed/'));
// Don't use object caching here by default, but give themes ability to turn it on.
$response_body_use_cache = apply_filters('instagram_cache_oembed_api_response_body', false, $matches, $atts, $passed_url);
$response_body = false;
if ($response_body_use_cache) {
$cache_key = 'oembed_response_body_' . md5($url);
$response_body = wp_cache_get($cache_key, 'instagram_embeds');
}
if (!$response_body) {
// Not using cache (default case) or cache miss
$instagram_response = wp_remote_get($url, array('redirection' => 0));
if (is_wp_error($instagram_response) || 200 != $instagram_response['response']['code'] || empty($instagram_response['body'])) {
return "<!-- instagram error: invalid oratv resource -->";
}
$response_body = json_decode($instagram_response['body']);
if ($response_body_use_cache) {
// if caching it is short-lived since this is a "Cache-Control: no-cache" resource
wp_cache_set($cache_key, $response_body, 'instagram_embeds', HOUR_IN_SECONDS + mt_rand(0, HOUR_IN_SECONDS));
}
}
if (!empty($response_body->html)) {
if (!$did_script) {
$did_script = true;
add_action('wp_footer', 'jetpack_instagram_add_script');
}
// there's a script in the response, which we strip on purpose since it's added above
$ig_embed = preg_replace('@<(script)[^>]*?>.*?</\\1>@si', '', $response_body->html);
} else {
$ig_embed = jetpack_instagram_iframe_embed($instagram_https_url, $atts);
}
return $ig_embed;
}
示例11: get_event_avatar
/**
* Get HTML markup for the post's "avatar" image according conditional
* fallback model.
*
* Accepts an ordered array of named avatar $fallbacks. Also accepts a string
* of space-separated classes to add to the default classes.
* @param Ai1ec_Event $event The event to get the avatar for
* @param array|null $fallback_order Order of fallback in searching for
* images, or null to use default
* @param string $classes A space-separated list of CSS classes
* to apply to the outer <div> element.
* @param boolean $wrap_permalink Whether to wrap the element in a link
* to the event details page.
*
* @return string String of HTML if image is found
*/
public function get_event_avatar(Ai1ec_Event $event, $fallback_order = null, $classes = '', $wrap_permalink = true)
{
$source = $size = null;
$url = $this->get_event_avatar_url($event, $fallback_order, $source, $size);
if (empty($url)) {
return '';
}
$url = esc_attr($url);
$classes = esc_attr($classes);
// Set the alt tag (helpful for SEO).
$alt = $event->get('post')->post_title;
$location = $this->_registry->get('view.event.location')->get_short_location($event);
if (!empty($location)) {
$alt .= ' @ ' . $location;
}
$alt = esc_attr($alt);
$size_attr = $size[0] ? "width=\"{$size['0']}\" height=\"{$size['1']}\"" : "";
$html = '<img src="' . $url . '" alt="' . $alt . '" ' . $size_attr . ' />';
if ($wrap_permalink) {
$permalink = add_query_arg('instance_id', $event->get('instance_id'), get_permalink($event->get('post_id')));
$html = '<a href="' . $permalink . '">' . $html . '</a>';
}
$classes .= ' ai1ec-' . $source;
$classes .= $size[0] > $size[1] ? ' ai1ec-landscape' : ' ai1ec-portrait';
$html = '<div class="ai1ec-event-avatar timely ' . $classes . '">' . $html . '</div>';
return $html;
}
示例12: edd_admin_messages
/**
* Admin Messages
*
* @access private
* @since 1.0
* @return void
*/
function edd_admin_messages()
{
global $typenow;
if ('download' != $typenow) {
return;
}
$edd_access_level = edd_get_menu_access_level();
if (isset($_GET['edd-message']) && $_GET['edd-message'] == 'discount_updated' && current_user_can($edd_access_level)) {
add_settings_error('edd-notices', 'edd-discount-updated', __('Discount code updated.', 'edd'), 'updated');
}
if (isset($_GET['edd-message']) && $_GET['edd-message'] == 'discount_update_failed' && current_user_can($edd_access_level)) {
add_settings_error('edd-notices', 'edd-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'edd'), 'error');
}
if (isset($_GET['edd-message']) && $_GET['edd-message'] == 'payment_deleted' && current_user_can($edd_access_level)) {
add_settings_error('edd-notices', 'edd-payment-deleted', __('The payment has been deleted.', 'edd'), 'updated');
}
if (isset($_GET['edd-message']) && $_GET['edd-message'] == 'email_sent' && current_user_can($edd_access_level)) {
add_settings_error('edd-notices', 'edd-payment-sent', __('The purchase receipt has been resent.', 'edd'), 'updated');
}
if (!get_option('edd_payment_totals_upgraded')) {
// the payment history needs updated for version 1.1.9
$url = add_query_arg('edd-action', 'upgrade_payments');
$upgrade_notice = sprintf(__('The payment history needs updated. %s'), '<a href="' . wp_nonce_url($url, 'edd_upgrade_payments_nonce') . '">' . __('Click to Upgrade', 'edd') . '</a>');
add_settings_error('edd-notices', 'edd-payments-upgrade', $upgrade_notice, 'error');
}
settings_errors('edd-notices');
}
示例13: edd_process_gateway_select
/**
* Processes gateway select on checkout. Only for users without ajax / javascript
*
* @since 1.7
*
* @param $data
*/
function edd_process_gateway_select($data)
{
if (isset($_POST['gateway_submit'])) {
wp_redirect(add_query_arg('payment-mode', $_POST['payment-mode']));
exit;
}
}
示例14: oembed_query_args
/**
* Append additional parameters to the oEmbed URL
*
* @used-by Filter: 'oembed_fetch_url'
*
* @param string $provider URL of the oEmbed provider.
* @param string $url URL of the content to be embedded.
* @param array $args Optional arguments, usually passed from a shortcode.
*/
function oembed_query_args($provider, $url, $args = [])
{
if (isset($args['autoplay']) && (bool) $args['autoplay']) {
$provider = add_query_arg('autoplay', 1, $provider);
}
return $provider;
}
示例15: set_path
/**
* Set the path by type
* @uses add_query_arg()
* @return MslsAdminIcon
*/
public function set_path()
{
if ('post' != $this->type) {
$this->path = add_query_arg(array('post_type' => $this->type), $this->path);
}
return $this;
}