/** * Enqueue styles. */ public function admin_styles() { global $wp_scripts; $screen = get_current_screen(); $screen_id = $screen ? $screen->id : ''; $jquery_version = isset($wp_scripts->registered['jquery-ui-core']->ver) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.11.4'; // Register admin styles wp_register_style('woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), WC_VERSION); wp_register_style('woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION); wp_register_style('jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.min.css', array(), $jquery_version); wp_register_style('woocommerce_admin_dashboard_styles', WC()->plugin_url() . '/assets/css/dashboard.css', array(), WC_VERSION); wp_register_style('woocommerce_admin_print_reports_styles', WC()->plugin_url() . '/assets/css/reports-print.css', array(), WC_VERSION, 'print'); // Sitewide menu CSS wp_enqueue_style('woocommerce_admin_menu_styles'); // Admin styles for WC pages only if (in_array($screen_id, wc_get_screen_ids())) { wp_enqueue_style('woocommerce_admin_styles'); wp_enqueue_style('jquery-ui-style'); wp_enqueue_style('wp-color-picker'); } if (in_array($screen_id, array('dashboard'))) { wp_enqueue_style('woocommerce_admin_dashboard_styles'); } if (in_array($screen_id, array('woocommerce_page_wc-reports', 'toplevel_page_wc-reports'))) { wp_enqueue_style('woocommerce_admin_print_reports_styles'); } /** * @deprecated 2.3 */ if (has_action('woocommerce_admin_css')) { do_action('woocommerce_admin_css'); wc_deprecated_function('The woocommerce_admin_css action', '2.3', 'admin_enqueue_scripts'); } }
/** * Return a products child ids - visible only. * * @since 2.7.0 * @param string $context * @return array Children ids */ public function get_visible_children($context = 'view') { if (has_filter('woocommerce_get_children')) { wc_deprecated_function('The woocommerce_get_children filter', '', 'woocommerce_product_get_children or woocommerce_product_get_visible_children'); } return apply_filters('woocommerce_get_children', $this->get_prop('visible_children', $context), $this, true); }
/** * Create a zone. * @deprecated 2.7.0 - Use ::save instead. */ public function create() { wc_deprecated_function('WC_Shipping_Zone::create', '2.7', 'Use ::save instead.'); $data_store = WC_Data_Store::load('shipping-zone'); try { $data_store->create($this); } catch (Exception $e) { return false; } }
/** * Create a token. * @deprecated 2.7.0 - Use ::save instead. */ public function create() { wc_deprecated_function('WC_Payment_Token::create', '2.7', 'Use ::save instead.'); $data_store = WC_Data_Store::load('payment-token'); try { $data_store->create($this); } catch (Exception $e) { return false; } }
/** * Output the shortcode. * * @param array $atts */ public static function output($atts) { global $wp; // Check cart class is loaded or abort if (is_null(WC()->cart)) { return; } if (!is_user_logged_in()) { $message = apply_filters('woocommerce_my_account_message', ''); if (!empty($message)) { wc_add_notice($message); } // After password reset, add confirmation message. if (!empty($_GET['password-reset'])) { wc_add_notice(__('Your password has been reset successfully.', 'woocommerce')); } if (isset($wp->query_vars['lost-password'])) { self::lost_password(); } else { wc_get_template('myaccount/form-login.php'); } } else { // Start output buffer since the html may need discarding for BW compatibility ob_start(); // Collect notices before output $notices = wc_get_notices(); // Output the new account page self::my_account($atts); /** * Deprecated my-account.php template handling. This code should be * removed in a future release. * * If woocommerce_account_content did not run, this is an old template * so we need to render the endpoint content again. */ if (!did_action('woocommerce_account_content')) { foreach ($wp->query_vars as $key => $value) { if ('pagename' === $key) { continue; } if (has_action('woocommerce_account_' . $key . '_endpoint')) { ob_clean(); // Clear previous buffer wc_set_notices($notices); wc_print_notices(); do_action('woocommerce_account_' . $key . '_endpoint', $value); break; } } wc_deprecated_function('Your theme version of my-account.php template', '2.6', 'the latest version, which supports multiple account pages and navigation, from WC 2.6.0'); } // Send output buffer ob_end_flush(); } }
/** * Save admin fields. * * Loops though the woocommerce options array and outputs each field. * * @param array $options Options array to output * @param array $data Optional. Data to use for saving. Defaults to $_POST. * @return bool */ public static function save_fields($options, $data = null) { if (is_null($data)) { $data = $_POST; } if (empty($data)) { return false; } // Options to update will be stored here and saved later. $update_options = array(); // Loop options and get values to save. foreach ($options as $option) { if (!isset($option['id']) || !isset($option['type'])) { continue; } // Get posted value. if (strstr($option['id'], '[')) { parse_str($option['id'], $option_name_array); $option_name = current(array_keys($option_name_array)); $setting_name = key($option_name_array[$option_name]); $raw_value = isset($data[$option_name][$setting_name]) ? wp_unslash($data[$option_name][$setting_name]) : null; } else { $option_name = $option['id']; $setting_name = ''; $raw_value = isset($data[$option['id']]) ? wp_unslash($data[$option['id']]) : null; } // Format the value based on option type. switch ($option['type']) { case 'checkbox': $value = '1' === $raw_value || 'yes' === $raw_value ? 'yes' : 'no'; break; case 'textarea': $value = wp_kses_post(trim($raw_value)); break; case 'multiselect': case 'multi_select_countries': $value = array_filter(array_map('wc_clean', (array) $raw_value)); break; case 'image_width': $value = array(); if (isset($raw_value['width'])) { $value['width'] = wc_clean($raw_value['width']); $value['height'] = wc_clean($raw_value['height']); $value['crop'] = isset($raw_value['crop']) ? 1 : 0; } else { $value['width'] = $option['default']['width']; $value['height'] = $option['default']['height']; $value['crop'] = $option['default']['crop']; } break; case 'select': $allowed_values = empty($option['options']) ? array() : array_keys($option['options']); if (empty($option['default']) && empty($allowed_values)) { $value = null; break; } $default = empty($option['default']) ? $allowed_values[0] : $option['default']; $value = in_array($raw_value, $allowed_values) ? $raw_value : $default; break; default: $value = wc_clean($raw_value); break; } /** * Fire an action when a certain 'type' of field is being saved. * @deprecated 2.4.0 - doesn't allow manipulation of values! */ if (has_action('woocommerce_update_option_' . sanitize_title($option['type']))) { wc_deprecated_function('The woocommerce_update_option_X action', '2.4.0', 'woocommerce_admin_settings_sanitize_option filter'); do_action('woocommerce_update_option_' . sanitize_title($option['type']), $option); continue; } /** * Sanitize the value of an option. * @since 2.4.0 */ $value = apply_filters('woocommerce_admin_settings_sanitize_option', $value, $option, $raw_value); /** * Sanitize the value of an option by option name. * @since 2.4.0 */ $value = apply_filters("woocommerce_admin_settings_sanitize_option_{$option_name}", $value, $option, $raw_value); if (is_null($value)) { continue; } // Check if option is an array and handle that differently to single values. if ($option_name && $setting_name) { if (!isset($update_options[$option_name])) { $update_options[$option_name] = get_option($option_name, array()); } if (!is_array($update_options[$option_name])) { $update_options[$option_name] = array(); } $update_options[$option_name][$setting_name] = $value; } else { $update_options[$option_name] = $value; } /** * Fire an action before saved. * @deprecated 2.4.0 - doesn't allow manipulation of values! */ do_action('woocommerce_update_option', $option); } // Save all options in our array. foreach ($update_options as $name => $value) { update_option($name, $value); } return true; }
/** * @deprecated 2.7.0 * @see WC_Structured_Data class * * @return string */ function woocommerce_get_product_schema() { wc_deprecated_function('woocommerce_get_product_schema', '2.7'); global $product; $schema = "Product"; // Downloadable product schema handling if ($product->is_downloadable()) { switch ($product->download_type) { case 'application': $schema = "SoftwareApplication"; break; case 'music': $schema = "MusicAlbum"; break; default: $schema = "Product"; break; } } return 'http://schema.org/' . $schema; }
/** * Adds Schema.org markup for order in JSON-LD format. * * @deprecated 2.7.0 * @see WC_Structured_Data::generate_order_data() * * @since 2.6.0 * @param mixed $order * @param bool $sent_to_admin (default: false) * @param bool $plain_text (default: false) */ public function order_schema_markup($order, $sent_to_admin = false, $plain_text = false) { wc_deprecated_function('WC_Emails::order_schema_markup', '2.7', 'WC_Structured_Data::generate_order_data'); WC()->structured_data->generate_order_data($order, $sent_to_admin, $plain_text); WC()->structured_data->output_structured_data(); }
/** * Backwards compat shim */ function register_api_field($object_type, $attributes, $args = array()) { wc_deprecated_function('register_api_field', 'WPAPI-2.0', 'register_rest_field'); register_rest_field($object_type, $attributes, $args); }
/** * @deprected 2.7.0 Sync is taken care of during save - no need to call this directly. */ public function grouped_product_sync() { wc_deprecated_function('WC_Product::grouped_product_sync', '2.7'); }
/** * @deprecated 2.6.0 Was previously used to determine sort order of methods, but this is now controlled by zones and thus unused. */ public function sort_shipping_methods() { wc_deprecated_function('sort_shipping_methods', '2.6'); return $this->shipping_methods; }
/** * Format settings if needed. * @deprecated 2.6.0 Unused * @param array $value * @return array */ public function format_settings($value) { wc_deprecated_function('format_settings', '2.6'); return $value; }
/** * Get currency. * @deprecated 2.7.0 */ public function get_order_currency() { wc_deprecated_function('get_order_currency', '2.7', 'get_currency'); return apply_filters('woocommerce_get_order_currency', $this->get_currency(), $this); }
/** * Return an array of formatted item meta in format e.g. * Handles @deprecated args. * @return array */ public function get_formatted_legacy($hideprefix = '_') { if (!is_ajax()) { wc_deprecated_function('get_formatted_legacy', '2.4', 'Item Meta Data is being called with legacy arguments'); } $formatted_meta = array(); foreach ($this->meta as $meta_key => $meta_values) { if (empty($meta_values) || !empty($hideprefix) && substr($meta_key, 0, 1) == $hideprefix) { continue; } foreach ((array) $meta_values as $meta_value) { // Skip serialised meta if (is_serialized($meta_value)) { continue; } $attribute_key = urldecode(str_replace('attribute_', '', $meta_key)); // If this is a term slug, get the term's nice name if (taxonomy_exists($attribute_key)) { $term = get_term_by('slug', $meta_value, $attribute_key); if (!is_wp_error($term) && is_object($term) && $term->name) { $meta_value = $term->name; } } // Unique key required $formatted_meta_key = $meta_key; $loop = 0; while (isset($formatted_meta[$formatted_meta_key])) { $loop++; $formatted_meta_key = $meta_key . '-' . $loop; } $formatted_meta[$formatted_meta_key] = array('key' => $meta_key, 'label' => wc_attribute_label($attribute_key, $this->product), 'value' => apply_filters('woocommerce_order_item_display_meta_value', $meta_value)); } } return $formatted_meta; }
/** * Get HTML to show product stock. * @since 2.7.0 * @param WC_Product $product * @return string */ function wc_get_stock_html($product) { ob_start(); wc_get_template('single-product/stock.php', array('product' => $product)); $html = ob_get_clean(); if (has_filter('woocommerce_stock_html')) { wc_deprecated_function('The woocommerce_stock_html filter', '', 'woocommerce_get_stock_html'); $html = apply_filters('woocommerce_stock_html', $html, $product->get_availability_text(), $product); } return apply_filters('woocommerce_get_stock_html', $html, $product); }
/** * Get refund reason. * @deprecated 2.7 * @return int|float */ public function get_refund_reason() { wc_deprecated_function('get_refund_reason', '2.7', 'get_reason'); return $this->get_reason(); }
/** * Check if a coupon excludes sale items. * * @return bool */ public function exclude_sale_items() { wc_deprecated_function('exclude_sale_items', '2.7', 'get_exclude_sale_items'); return $this->get_exclude_sale_items(); }
/** * Layered Nav post filter. * @deprecated 2.6.0 due to performance concerns */ public function layered_nav_query($filtered_posts) { wc_deprecated_function('layered_nav_query', '2.6'); }
/** * Legacy set address. */ function set_address_2($address) { wc_deprecated_function('WC_Customer::set_address_2', '2.7', 'WC_Customer::set_billing_address_2'); $this->set_billing_address_2($address); }
/** * Gets the order discount amount - these are applied after tax. * @deprecated Coupons can not be applied after tax */ public function get_discounts_after_tax() { wc_deprecated_function('get_discounts_after_tax', '2.3'); }
/** * Core credit card form which gateways can used if needed. Deprecated - inheirt WC_Payment_Gateway_CC instead. * @param array $args * @param array $fields */ public function credit_card_form($args = array(), $fields = array()) { wc_deprecated_function('credit_card_form', '2.6', 'WC_Payment_Gateway_CC->form'); $cc_form = new WC_Payment_Gateway_CC(); $cc_form->id = $this->id; $cc_form->supports = $this->supports; $cc_form->form(); }