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

PHP wp_get_referer函数代码示例

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

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



在下文中一共展示了wp_get_referer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
 }
开发者ID:proj-2014,项目名称:vlan247-test-wp2,代码行数:7,代码来源:wd_quickshop.php


示例2: create_admin_menu_entry

 function create_admin_menu_entry()
 {
     if (@$_POST && isset($_POST['option_page'])) {
         $changed = false;
         if ('wdcab_options' == @$_POST['option_page']) {
             if (isset($_POST['wdcab']['links']['_last_'])) {
                 $last = $_POST['wdcab']['links']['_last_'];
                 unset($_POST['wdcab']['links']['_last_']);
                 if (@$last['url'] && @$last['title']) {
                     $_POST['wdcab']['links'][] = $last;
                 }
             }
             if (isset($_POST['wdcab']['links'])) {
                 $_POST['wdcab']['links'] = array_filter($_POST['wdcab']['links']);
             }
             ub_update_option('wdcab', $_POST['wdcab']);
             $changed = true;
         }
         if ($changed) {
             $goback = add_query_arg('settings-updated', 'true', wp_get_referer());
             wp_redirect($goback);
             die;
         }
     }
     $page = is_multisite() ? 'settings.php' : 'options-general.php';
     $perms = is_multisite() ? 'manage_network_options' : 'manage_options';
     add_submenu_page($page, __('Custom Admin Bar', 'ub'), __('Custom Admin Bar', 'ub'), $perms, 'wdcab', array($this, 'create_admin_page'));
 }
开发者ID:hscale,项目名称:webento,代码行数:28,代码来源:class_wdcab_admin_pages.php


示例3: is_password_protected

 static function is_password_protected()
 {
     global $post;
     $private_post = array('allowed' => false, 'error' => '');
     if (isset($_POST['submit_password'])) {
         // when we have a submision check the password and its submision
         if (isset($_POST['submit_password_nonce']) && wp_verify_nonce($_POST['submit_password_nonce'], 'password_protection')) {
             if (isset($_POST['post_password']) && !empty($_POST['post_password'])) {
                 // some simple checks on password
                 // finally test if the password submitted is correct
                 if ($post->post_password === $_POST['post_password']) {
                     $private_post['allowed'] = true;
                     // ok if we have a correct password we should inform wordpress too
                     // otherwise the mad dog will put the password form again in the_content() and other filters
                     global $wp_hasher;
                     if (empty($wp_hasher)) {
                         require_once ABSPATH . 'wp-includes/class-phpass.php';
                         $wp_hasher = new PasswordHash(8, true);
                     }
                     setcookie('wp-postpass_' . COOKIEHASH, $wp_hasher->HashPassword(stripslashes($_POST['post_password'])), 0, COOKIEPATH);
                 } else {
                     $private_post['error'] = '<h4 class="text--error">Wrong Password</h4>';
                 }
             }
         }
     }
     if (isset($_COOKIE['wp-postpass_' . COOKIEHASH]) && get_permalink() == wp_get_referer()) {
         $private_post['error'] = '<h4 class="text--error">Wrong Password</h4>';
     }
     return $private_post;
 }
开发者ID:qhuit,项目名称:Tournesol,代码行数:31,代码来源:rosa.php


示例4: filter_add_to_cart_url

 function filter_add_to_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 esc_url($ref_url);
 }
开发者ID:ericsoncardosoweb,项目名称:dallia,代码行数:7,代码来源:quickshop.php


示例5: pop_handle_save

 function pop_handle_save()
 {
     if (!isset($_POST[$this->id . '_options'])) {
         return;
     }
     if (!current_user_can($this->capability)) {
         return;
     }
     $options = explode(',', stripslashes($_POST['page_' . $this->id]));
     if ($options) {
         $existing_options = $this->get_options();
         foreach ($options as $option) {
             $option = trim($option);
             $value = null;
             if (isset($_POST[$option])) {
                 $value = $_POST[$option];
             }
             if (!is_array($value)) {
                 $value = trim($value);
             }
             $value = stripslashes_deep($value);
             $existing_options[$option] = $value;
         }
         update_option($this->options_varname, $existing_options);
     }
     do_action('pop_handle_save', $this);
     //------------------------------
     $goback = add_query_arg('updated', 'true', wp_get_referer());
     if (isset($_REQUEST['tabs_selected_tab']) && $_REQUEST['tabs_selected_tab'] != '') {
         $goback = add_query_arg('tabs_selected_tab', $_REQUEST['tabs_selected_tab'], $goback);
     }
     wp_redirect($goback);
 }
开发者ID:ashray-velapanur,项目名称:grind-members,代码行数:33,代码来源:class.PluginOptionsPanel.php


示例6: route_action

 function route_action()
 {
     $nonce_action = $_REQUEST['bpmod-action'];
     $action = $_REQUEST['bpmod-action'];
     if ('bulk_contents' == $_REQUEST['bpmod-action'] || 'bulk_users' == $_REQUEST['bpmod-action']) {
         $action .= '_' . $_REQUEST['bulk-action'];
     }
     $in_ajax = defined('DOING_AJAX');
     if ($in_ajax) {
         check_ajax_referer($nonce_action);
         $response_func = array(&$this, 'ajax_' . $action);
     } else {
         check_admin_referer($nonce_action);
         $response_func = array(&$this, 'action_' . $action);
         $this->redir = remove_query_arg(array('err_ids', 'marked_spammer', 'unmarked_spammer', 'content_ignored', 'content_moderated', 'content_deleted'), wp_get_referer());
     }
     $handle_func = array(&$this, 'handle_' . $action);
     $response_func = array(&$this, ($in_ajax ? 'ajax_' : 'action_') . $action);
     if (is_callable($handle_func)) {
         $result = (array) call_user_func($handle_func);
         if ($result && is_callable($response_func)) {
             call_user_func_array($response_func, $result);
         }
     }
     //fallback if nothing has been called
     if ($in_ajax) {
         die(-1);
     } else {
         bp_core_redirect($this->redir);
     }
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:31,代码来源:bpModBackendActions.php


示例7: redirect_post

/**
 * Redirect to previous page.
 *
 * @param int $post_id Optional. Post ID.
 */
function redirect_post($post_id = '')
{
    if (isset($_POST['save']) || isset($_POST['publish'])) {
        $status = get_post_status($post_id);
        if (isset($_POST['publish'])) {
            switch ($status) {
                case 'pending':
                    $message = 8;
                    break;
                case 'future':
                    $message = 9;
                    break;
                default:
                    $message = 6;
            }
        } else {
            $message = 'draft' == $status ? 10 : 1;
        }
        $location = add_query_arg('message', $message, get_edit_post_link($post_id, 'url'));
    } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) {
        $location = add_query_arg('message', 2, wp_get_referer());
        $location = explode('#', $location);
        $location = $location[0] . '#postcustom';
    } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) {
        $location = add_query_arg('message', 3, wp_get_referer());
        $location = explode('#', $location);
        $location = $location[0] . '#postcustom';
    } elseif ('post-quickpress-save-cont' == $_POST['action']) {
        $location = "post.php?action=edit&post={$post_id}&message=7";
    } else {
        $location = add_query_arg('message', 4, get_edit_post_link($post_id, 'url'));
    }
    wp_redirect(apply_filters('redirect_post_location', $location, $post_id));
    exit;
}
开发者ID:fka2004,项目名称:webkit,代码行数:40,代码来源:post.php


示例8: callback_login

 private function callback_login()
 {
     if (empty($_COOKIE[TEST_COOKIE])) {
         $this->message_collection->add(__("Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to log in to your account.", 'wp-e-commerce'), 'error');
     }
     $form_args = wpsc_get_login_form_args();
     $validation = wpsc_validate_form($form_args);
     if (is_wp_error($validation)) {
         wpsc_set_validation_errors($validation);
         return;
     }
     $user = wp_signon(array('user_login' => $_POST['username'], 'user_password' => $_POST['password'], 'rememberme' => !empty($_POST['rememberme'])));
     if (is_wp_error($user)) {
         $this->message_collection->add(__('We do not recognize the login information you entered. Please try again.', 'wp-e-commerce'), 'error');
         return;
     }
     $redirect_to = wp_get_referer();
     if (wpsc_get_customer_meta('checkout_after_login')) {
         $redirect_to = wpsc_get_checkout_url();
         wpsc_delete_customer_meta('checkout_after_login');
     }
     if (!$redirect_to || trim(str_replace(home_url(), '', $redirect_to), '/') == trim($_SERVER['REQUEST_URI'], '/')) {
         $redirect_to = wpsc_get_store_url();
     }
     wp_redirect($redirect_to);
     exit;
 }
开发者ID:ashik968,项目名称:digiplot,代码行数:27,代码来源:login.php


示例9: error

 /**
  * do the error
  * @author Lukas Juhas
  * @date   2016-02-05
  * @param  [type]     $message [description]
  * @return [type]              [description]
  */
 private function error($message = false)
 {
     // redirect back
     // TODO: probably add some error message - added attribute already
     wp_safe_redirect(wp_get_referer());
     exit;
 }
开发者ID:benchmarkstudios,项目名称:wc-category-locker,代码行数:14,代码来源:wc-category-locker.php


示例10: mdjm_pay_event_employees_action

/**
 * Pay event employees.
 *
 * @since	1.3
 * @param	arr		$data	Form data from the $_GET super global.
 * @return	void
 */
function mdjm_pay_event_employees_action($data)
{
    if (!wp_verify_nonce($data['mdjm_nonce'], 'pay_event_employees')) {
        $message = 'nonce_fail';
    } elseif (!isset($data['event_id'])) {
        $message = 'payment_event_missing';
    } else {
        // Process the payment action
        $employee_id = !empty($data['employee_id']) ? $data['employee_id'] : 0;
        $event_id = $data['event_id'];
        $payments = mdjm_pay_event_employees($event_id, $employee_id);
        if (!empty($employee_id) && $payments) {
            $message = 'pay_employee_success';
        } elseif (!empty($employee_id) && !$payments) {
            $message = 'pay_employee_failed';
        } elseif (empty($employee_id) && !empty($payments['success']) && empty($payments['failed'])) {
            $message = 'pay_all_employees_success';
        } elseif (empty($employee_id) && !empty($payments['success']) && !empty($payments['failed'])) {
            $message = 'pay_all_employees_some_success';
        } elseif (empty($employee_id) && empty($payments['success']) && !empty($payments['failed'])) {
            $message = 'pay_all_employees_failed';
        }
    }
    $url = remove_query_arg(array('mdjm_nonce', 'mdjm-action', 'employee_id', 'mdjm-message', 'event_id'), wp_get_referer());
    wp_redirect(add_query_arg(array('mdjm-message' => $message), $url));
    die;
}
开发者ID:mdjm,项目名称:mobile-dj-manager,代码行数:34,代码来源:txn-actions.php


示例11: process_request

 /**
  * Detect any GET/POST variables and determine what CRUD option to do based on that
  * @since 0.1
  */
 public function process_request()
 {
     // Set $this->_model->instance, the default is 0 which is the new instance form
     $this->_model->instance = isset($_GET['_instance']) ? (int) $_GET['_instance'] : 0;
     // if $this->_model->instance
     if (empty($this->_model->option[$this->_model->instance])) {
         wp_die("Oops, this page doesn't exist.", "Page does not exist", array('response' => 403));
     }
     // Check to see if the 'Delete' link was clicked
     if (isset($_GET['delete_instance']) && isset($_GET['_instance']) && check_admin_referer('delete_instance')) {
         PW_Alerts::add('updated', '<p><strong>' . $this->_model->singular_title . ' Instance Deleted</strong></p>');
         // make a copy of the option, then unsetting the index and update with the copy
         $option = $this->_model->option;
         unset($option[(int) $_GET['_instance']]);
         update_option($this->_model->name, $option);
         // redirect the page and remove _instance' and 'delete_instance' from the URL
         wp_redirect(remove_query_arg(array('_instance', 'delete_instance'), wp_get_referer()));
         exit;
     }
     // If the POST data is set and the nonce checks out, validate and save any submitted data
     if (isset($_POST[$this->_model->name]) && isset($_POST['_instance']) && check_admin_referer($this->_model->name . '-options')) {
         // get the options from $_POST
         $this->_model->input = stripslashes_deep($_POST[$this->_model->name]);
         // save the options
         if ($this->_model->save($this->_model->input, $_POST['_instance'])) {
             if ($_POST['_instance'] == 0) {
                 wp_redirect(add_query_arg('_instance', $this->_model->option['auto_id'] - 1, wp_get_referer()));
                 exit;
             }
         }
     }
 }
开发者ID:rspindel,项目名称:PW_Framework,代码行数:36,代码来源:PW_MultiModelController.php


示例12: handle_import

 function handle_import()
 {
     $handle_import = str_replace("-", "_", 'pop_import_file_' . $this->plugin_id);
     if (isset($_REQUEST[$handle_import]) && current_user_can($this->capability)) {
         if (isset($_FILES['pop_import_file']) && $_FILES['pop_import_file']['error'] == 0) {
             $data = unserialize(base64_decode(gzuncompress(file_get_contents($_FILES['pop_import_file']['tmp_name']))));
             //----
             if (property_exists($data, 'id') && property_exists($data, 'name') && property_exists($data, 'options')) {
                 if ($data->id == $this->plugin_id) {
                     $backup = isset($_REQUEST['pop-backup-on-import']) && $_REQUEST['pop-backup-on-import'] == '1' ? true : false;
                     if ($backup) {
                         $saved_options = $this->get_saved_options();
                         $saved_options[] = (object) array('name' => __('Automatic settings backup', 'pop'), 'date' => date('Y-m-d H:i:s'), 'options' => $this->get_options());
                         $var = $this->options_varname . '_saved';
                         if (update_option($var, $saved_options)) {
                         }
                     }
                     $new_options = $data->options;
                     $new_options = is_array($new_options) ? $new_options : array();
                     if ($this->import_option($new_options, true)) {
                     }
                 } else {
                 }
             } else {
             }
             //------
             $goback = add_query_arg('updated', 'true', wp_get_referer());
             $goback = add_query_arg('pop_open_tabs', isset($_REQUEST['pop_open_tabs']) ? $_REQUEST['pop_open_tabs'] : '', $goback);
             wp_redirect($goback);
         }
     }
 }
开发者ID:JDjimenezdelgado,项目名称:old-mmexperience,代码行数:32,代码来源:class.pop_import_export.php


示例13: handle_bulk_rename_form_submit

 function handle_bulk_rename_form_submit()
 {
     if (array_search('rename', $_REQUEST) !== FALSE || array_search('rename_retitle', $_REQUEST) !== FALSE) {
         wp_redirect(add_query_arg(array('renamed' => 1), wp_get_referer()));
         exit;
     }
 }
开发者ID:ryan2407,项目名称:Vision,代码行数:7,代码来源:class-media-rename.php


示例14: 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) {
        $products = array_fill_keys(array_values($products), 1);
    }
    foreach ($products as $product_id => $qty) {
        $titles[] = ($qty > 1 ? absint($qty) . ' &times; ' : '') . sprintf(_x('&ldquo;%s&rdquo;', '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_referer() ? wp_get_referer() : home_url());
        $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:unfulvio,项目名称:woocommerce,代码行数:33,代码来源:wc-cart-functions.php


示例15: bp_core_referrer

/**
 * Return the referrer URL without the http(s)://
 *
 * @deprecated 2.3.0
 *
 * @return string The referrer URL.
 */
function bp_core_referrer()
{
    _deprecated_function(__FUNCTION__, '2.3.0', 'bp_get_referer_path()');
    $referer = explode('/', wp_get_referer());
    unset($referer[0], $referer[1], $referer[2]);
    return implode('/', $referer);
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:14,代码来源:2.3.php


示例16: eventsList

function eventsList()
{
    $current_user = wp_get_current_user();
    if (isset($_GET['eventaction'])) {
        $event_action = (int) $_GET['eventaction'];
        if (is_numeric($_GET['eventid'])) {
            switch ($event_action) {
                case 0:
                    EventDatabaseManager::signIn($current_user->ID, $_GET['eventid']);
                    MailNotifications::sendSignInMail($current_user->user_email, EventDatabaseManager::getEvent($_GET['eventid']));
                    wp_redirect(wp_get_referer());
                    break;
                case 1:
                    break;
                case 2:
                    EventDatabaseManager::signOut($current_user->ID, $_GET['eventid']);
                    MailNotifications::sendSignOutMail($current_user->user_email, EventDatabaseManager::getEvent($_GET['eventid']));
                    wp_redirect(wp_get_referer());
                    break;
                default:
                    break;
            }
        }
        $events_custom = EventDatabaseManager::getAvailableEventsForUser($current_user->ID);
        return View::outputEventListForUser($_GET['page_id'], $_GET['page_id'], $current_user->ID, $events_custom);
    } elseif (isset($_GET['eventID'])) {
        $event = EventDatabaseManager::getEvent($_GET['eventID']);
        return eventsInfo($event);
    } else {
        $events_custom = EventDatabaseManager::getAvailableEventsForUser($current_user->ID);
        return View::outputEventListForUser($_GET['page_id'], $_GET['page_id'], $current_user->ID, $events_custom);
    }
}
开发者ID:umairriaz90,项目名称:Daschug1,代码行数:33,代码来源:user_functions.php


示例17: prepare_items

 public function prepare_items()
 {
     $columns = $this->get_columns();
     $hidden = $this->get_hidden_columns();
     $sortable = $this->get_sortable_columns();
     $table_class = $this->get_table_classes();
     $data = $this->table_data();
     if (isset($_REQUEST['s']) && '' != $_REQUEST['s'] && wp_get_referer()) {
         $s = sanitize_text_field($_REQUEST['s']);
         foreach ($data as $key => $value) {
             if (false === strpos($value->name, $s)) {
                 unset($data[$key]);
             }
         }
     }
     function usort_reorder($a, $b)
     {
         $orderby = isset($_REQUEST['orderby']) && '' != $_REQUEST['orderby'] ? sanitize_key($_REQUEST['orderby']) : 'term_id';
         $order = isset($_REQUEST['order']) && '' != $_REQUEST['order'] ? sanitize_key($_REQUEST['order']) : 'asc';
         $result = strcmp($a->{$orderby}, $b->{$orderby});
         if ('term_id' === $orderby || 'count' === $orderby) {
             $result = $b->{$orderby} - $a->{$orderby};
         }
         return 'asc' === $order ? $result : -$result;
     }
     uasort($data, 'usort_reorder');
     $per_page = $this->get_items_per_page('stt2extat_term_stats_per_page', 5);
     $current_page = $this->get_pagenum();
     $total_items = count($data);
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page), 'orderby' => isset($_REQUEST['orderby']) ? sanitize_key($_REQUEST['orderby']) : 'term_id', 'order' => isset($_REQUEST['order']) ? sanitize_key($_REQUEST['order']) : 'asc'));
     $data = array_slice($data, ($current_page - 1) * $per_page, $per_page);
     $this->_column_headers = array($columns, $hidden, $sortable, $table_class);
     $this->items = $data;
 }
开发者ID:Jevuska,项目名称:stt2-extension-add-terms,代码行数:34,代码来源:class-stt2extat-table.php


示例18: runCallbacks

 /**
  * Runs the appropriate callback handler
  *
  * @return void
  */
 private static function runCallbacks()
 {
     // 0. get the action
     $wp_list_table = _get_list_table('WP_Posts_List_Table');
     $action = $wp_list_table->current_action();
     // 1. Get the custom action object
     $bulkAction = self::getCustomBulkAction($action);
     if ($bulkAction === null) {
         return;
     }
     // 2. security check
     check_admin_referer('bulk-posts');
     // Get the post ids
     if (isset($_REQUEST['post'])) {
         $post_ids = array_map('intval', $_REQUEST['post']);
     }
     if (empty($post_ids)) {
         return;
     }
     // Run the callback
     $callback = $bulkAction->getCallback();
     $callback($post_ids);
     // Build the redirect url. Add all id's to the query args
     $sendback = remove_query_arg(array('untrashed', 'deleted', 'ids'), wp_get_referer());
     $sendback = add_query_arg(array('ids' => join(',', $post_ids)), $sendback);
     // 4. Redirect client
     wp_redirect($sendback);
     exit;
 }
开发者ID:sigurdsvela,项目名称:WP-CustomBulkAction,代码行数:34,代码来源:CustomBulkAction.php


示例19: multivars_admin_save

function multivars_admin_save()
{
    global $multivars_table_name, $multivars_variables, $wpdb;
    if ($_GET['page'] == 'multivars ') {
        if (!current_user_can('manage_network_options')) {
            wp_die(__('You do not have permission to access this page.'));
        }
        if ($_POST['action'] == 'multivars_save_variables') {
            $errors = array();
            foreach ($_POST['sitevariables'] as $id => $variable) {
                // validate the values
                if ($multivars_variables->valid($variable)) {
                    if (preg_match('/new/', $id)) {
                        $wpdb->insert($multivars_table_name, $variable);
                    } else {
                        $wpdb->update($multivars_table_name, $variable, array('id' => $id));
                    }
                } else {
                    array_push($errors, $variable);
                }
            }
            wp_redirect(add_query_arg(array('updated' => 'true'), wp_get_referer()));
            exit;
        }
    }
}
开发者ID:Ravenna-Interactive,项目名称:wp-site-variables,代码行数:26,代码来源:multivar.php


示例20: recalculate_profit_callback

 public function recalculate_profit_callback()
 {
     $redirect = wp_get_referer() ? wp_get_referer() : admin_url('admin.php?page=wc-reports&tab=profit');
     if (!isset($_REQUEST['token']) || !wp_verify_nonce($_REQUEST['token'], 'funkwoocost-recalculate-profit')) {
         wp_redirect(add_query_arg(array('status' => 'failed'), $redirect));
         die;
     }
     global $wpdb;
     $order_items = $wpdb->get_results("\n            SELECT order_items.order_item_id,\n                   meta_product_id.meta_value AS product_id,\n                   meta_variation_id.meta_value AS variation_id\n            FROM {$wpdb->prefix}woocommerce_order_items AS order_items\n            LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS meta_product_id ON order_items.order_item_id=meta_product_id.order_item_id AND meta_product_id.meta_key='_product_id'\n            LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS meta_variation_id ON order_items.order_item_id=meta_variation_id.order_item_id AND meta_variation_id.meta_key='_variation_id'\n            WHERE order_items.order_item_type='line_item'\n        ");
     // echo "<pre>";
     // print_r($order_items);
     // echo "</pre>";
     // exit();
     if (!empty($order_items)) {
         foreach ($order_items as $order_item) {
             $cost_of_good = !empty($order_item->variation_id) ? get_post_meta($order_item->variation_id, '_funkwoocost', true) : get_post_meta($order_item->product_id, '_funkwoocost', true);
             // echo $cost_of_good; exit();
             $order_item_qty = wc_get_order_item_meta($order_item->order_item_id, '_qty', true);
             wc_update_order_item_meta($order_item->order_item_id, '_line_funkwoocost_order', wc_format_decimal($cost_of_good * $order_item_qty));
         }
     }
     // clear transient
     delete_transient(strtolower('WooCost_Report_Profit_By_Date'));
     wp_redirect(add_query_arg(array('status' => 'success'), $redirect));
     die;
 }
开发者ID:qutek,项目名称:Woocommerce-Product-Costs,代码行数:26,代码来源:admin.class.php



注:本文中的wp_get_referer函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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