本文整理汇总了PHP中wp_get_raw_referer函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_raw_referer函数的具体用法?PHP wp_get_raw_referer怎么用?PHP wp_get_raw_referer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_raw_referer函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wc_add_to_cart_message
/**
* Add to cart messages.
*
* @access public
* @param int|array $products
* @param bool $show_qty Should qty's be shown? Added in 2.6.0
*/
function wc_add_to_cart_message($products, $show_qty = false)
{
$titles = array();
$count = 0;
if (!is_array($products)) {
$products = array($products);
$show_qty = false;
}
if (!$show_qty && !is_array($products)) {
$products = array_fill_keys(array_values($products), 1);
}
foreach ($products as $product_id => $qty) {
$titles[] = ($qty > 1 ? absint($qty) . ' × ' : '') . sprintf(_x('“%s”', 'Item name in quotes', 'woocommerce'), strip_tags(get_the_title($product_id)));
$count += $qty;
}
$titles = array_filter($titles);
$added_text = sprintf(_n('%s has been added to your cart.', '%s have been added to your cart.', $count, 'woocommerce'), wc_format_list_of_items($titles));
// Output success messages
if ('yes' === get_option('woocommerce_cart_redirect_after_add')) {
$return_to = apply_filters('woocommerce_continue_shopping_redirect', wp_get_raw_referer() ? wp_validate_redirect(wp_get_raw_referer(), false) : wc_get_page_permalink('shop'));
$message = sprintf('<a href="%s" class="button wc-forward">%s</a> %s', esc_url($return_to), esc_html__('Continue Shopping', 'woocommerce'), esc_html($added_text));
} else {
$message = sprintf('<a href="%s" class="button wc-forward">%s</a> %s', esc_url(wc_get_page_permalink('cart')), esc_html__('View Cart', 'woocommerce'), esc_html($added_text));
}
wc_add_notice(apply_filters('wc_add_to_cart_message', $message, $product_id));
}
开发者ID:coderkevin,项目名称:woocommerce,代码行数:33,代码来源:wc-cart-functions.php
示例2: wc_get_raw_referer
/**
* Retrieves unvalidated referer from '_wp_http_referer' or HTTP referer.
*
* Do not use for redirects, use {@see wp_get_referer()} instead.
*
* @since 2.6.1
* @return string|false Referer URL on success, false on failure.
*/
function wc_get_raw_referer()
{
if (function_exists('wp_get_raw_referer')) {
return wp_get_raw_referer();
}
if (!empty($_REQUEST['_wp_http_referer'])) {
return wp_unslash($_REQUEST['_wp_http_referer']);
} elseif (!empty($_SERVER['HTTP_REFERER'])) {
return wp_unslash($_SERVER['HTTP_REFERER']);
}
return false;
}
开发者ID:websideas,项目名称:Mondova,代码行数:20,代码来源:wc-cart-functions.php
示例3: wp_get_referer
/**
* Retrieve referer from '_wp_http_referer' or HTTP referer.
*
* If it's the same as the current request URL, will return false.
*
* @since 2.0.4
*
* @return false|string False on failure. Referer URL on success.
*/
function wp_get_referer()
{
if (!function_exists('wp_validate_redirect')) {
return false;
}
$ref = wp_get_raw_referer();
if ($ref && $ref !== wp_unslash($_SERVER['REQUEST_URI']) && $ref !== home_url() . wp_unslash($_SERVER['REQUEST_URI'])) {
return wp_validate_redirect($ref, false);
}
return false;
}
开发者ID:nissuk,项目名称:WordPress,代码行数:20,代码来源:functions.php
示例4: test_raw_referer_both
/**
* @ticket 27152
*/
public function test_raw_referer_both()
{
$_SERVER['HTTP_REFERER'] = addslashes('http://example.com/foo?bar');
$_REQUEST['_wp_http_referer'] = addslashes('http://foo.bar/baz');
$this->assertSame('http://foo.bar/baz', wp_get_raw_referer());
}
开发者ID:dd32,项目名称:wordpress.develop,代码行数:9,代码来源:referer.php
示例5: on_admin_init
/**
* Check if request is an create or enable/disable redirection
*/
function on_admin_init()
{
$referer = wp_get_raw_referer();
// We only continue if referer contains page=redirection.php
if (false === strpos($referer, "page=redirection.php")) {
return;
}
$referer_parsed = parse_url($referer);
error_log("-----");
// error_log( SimpleHistory::json_encode( $referer_parsed ) );
error_log(SimpleHistory::json_encode($_REQUEST));
/*
Create redirection
{
"source": "source yo",
"match": "url",
"red_action": "url",
"target": "dest yo",
"group_id": "1",
"add": "Add Redirection",
"group": "0",
"action": "red_redirect_add",
"_wpnonce": "cdadb5a4ca",
"_wp_http_referer": "\/wp-admin\/tools.php?page=redirection.php"
}
*/
if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "red_redirect_add") {
$this->log_redirection_add($_REQUEST);
return;
}
/*
Enable/disable single or multiple direction(s)
{
"page": "redirection.php",
"_wpnonce": "290f261024",
"_wp_http_referer": "\/wp-admin\/tools.php?page=redirection.php",
"action": "enable", or "disable"
"id": "0",
"paged": "1",
"item": [
"3",
"2",
"1"
],
"action2": "-1"
}
*/
if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "enable" && empty($_REQUEST["sub"])) {
$this->log_redirection_enable_or_disable($_REQUEST);
return;
} else {
if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "disable" && empty($_REQUEST["sub"])) {
$this->log_redirection_enable_or_disable($_REQUEST);
return;
}
}
/*
Delete item(s)
{
"page": "redirection.php",
"edit": "4",
"_wpnonce": "290f261024",
"_wp_http_referer": "\/wp-admin\/tools.php?page=redirection.php&edit=4",
"action": "delete",
"id": "0",
"paged": "1",
"item": [
"6"
],
"action2": "-1"
}
*/
if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "delete" && empty($_REQUEST["sub"])) {
$this->log_redirection_delete($_REQUEST);
return;
}
/*
Options
- delete all options and deactivate plugin
{
"page": "redirection.php",
"sub": "options",
"_wpnonce": "e2c008ca25",
"_wp_http_referer": "\/wp-admin\/tools.php?page=redirection.php&sub=options",
"delete": "Delete"
}
*/
if (isset($_REQUEST["sub"]) && $_REQUEST["sub"] == "options" && isset($_REQUEST["delete"]) && $_REQUEST["delete"] == "Delete") {
$this->log_options_delete_all($_REQUEST);
return;
}
/*
Save options {
"page": "redirection.php",
"sub": "options",
"_wpnonce": "8fe9b57662",
"_wp_http_referer": "\/wp-admin\/tools.php?page=redirection.php&sub=options",
//.........这里部分代码省略.........
开发者ID:bonny,项目名称:wordpress-simple-history,代码行数:101,代码来源:Plugin_Redirection.php
示例6: em_wp_get_referer
/**
* Since WP 4.5 em_wp_get_referer() returns false if URL is the same. We use it to get a safe referrer url, so we use the new wp_get_raw_referer() argument instead.
* @since 5.6.3
* @return string
*/
function em_wp_get_referer()
{
if (function_exists('wp_get_raw_referer')) {
//do essentially what em_wp_get_referer does, but potentially returning the same url as before
return wp_validate_redirect(wp_get_raw_referer(), false);
} else {
return wp_get_referer();
}
}
开发者ID:mjrobison,项目名称:FirstCareCPR,代码行数:14,代码来源:em-functions.php
注:本文中的wp_get_raw_referer函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论