Removed more some unused code

This commit is contained in:
claudiosmweb 2014-11-19 22:43:09 -02:00
parent 45ddc1d26e
commit 8eeb6fc204
22 changed files with 136 additions and 161 deletions

View File

@ -14,9 +14,6 @@ class WC_Report_Taxes_By_Code extends WC_Admin_Report {
* @return array
*/
public function get_chart_legend() {
$legend = array();
return array();
}

View File

@ -14,9 +14,6 @@ class WC_Report_Taxes_By_Date extends WC_Admin_Report {
* @return array
*/
public function get_chart_legend() {
$legend = array();
return array();
}

View File

@ -201,10 +201,6 @@ class WC_Settings_Emails extends WC_Settings_Page {
WC_Admin_Settings::save_fields( $settings );
} else {
// Load mailer
$mailer = WC()->mailer();
if ( class_exists( $current_section ) ) {
$current_section_class = new $current_section();

View File

@ -79,15 +79,6 @@ class WC_Settings_Products extends WC_Settings_Page {
public function get_settings( $current_section = '' ) {
if ( 'display' == $current_section ) {
// Get shop page
$shop_page_id = wc_get_page_id( 'shop' );
$base_slug = ( $shop_page_id > 0 && get_post( $shop_page_id ) ) ? get_page_uri( $shop_page_id ) : 'shop';
$woocommerce_shop_page_children_warning = '';
if ( $shop_page_id > 0 && sizeof( get_pages( "child_of=$shop_page_id" ) ) > 0 ) {
$woocommerce_shop_page_children_warning = ' <mark class="notice">' . __( 'Note: The shop page has children - child pages will not work if you enable this option.', 'woocommerce' ) . '</mark>';
}
$settings = apply_filters( 'woocommerce_product_settings', array(
array(

View File

@ -62,8 +62,6 @@ function wc_create_page( $slug, $option = '', $page_title = '', $page_content =
return -1;
}
$page_found = null;
if ( strlen( $page_content ) > 0 ) {
// Search for an existing page with the specified page content (typically a shortcode)
$page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type='page' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );

View File

@ -150,7 +150,7 @@ class WC_API_Orders extends WC_API_Resource {
'status' => $order->get_status(),
'currency' => $order->get_order_currency(),
'total' => wc_format_decimal( $order->get_total(), 2 ),
'subtotal' => wc_format_decimal( $order->get_subtotal( $order ), 2 ),
'subtotal' => wc_format_decimal( $order->get_subtotal(), 2 ),
'total_line_items_quantity' => $order->get_item_count(),
'total_tax' => wc_format_decimal( $order->get_total_tax(), 2 ),
'total_shipping' => wc_format_decimal( $order->get_total_shipping(), 2 ),
@ -529,7 +529,7 @@ class WC_API_Orders extends WC_API_Resource {
$this->set_item( $order, $line_type, $item, 'create' );
} elseif ( $this->item_is_null( $item, $line_type ) ) {
} elseif ( $this->item_is_null( $item ) ) {
// delete item
wc_delete_order_item( $item['id'] );

View File

@ -1196,12 +1196,6 @@ class WC_API_Products extends WC_API_Resource {
if ( isset( $variation['in_stock'] ) ) {
$stock_status = ( true === $variation['in_stock'] ) ? 'instock' : 'outofstock';
wc_update_product_stock_status( $variation_id, $stock_status );
} else {
$stock_status = get_post_meta( $variation_id, '_stock_status', true );
if ( '' === $stock_status ) {
$stock_status = 'instock';
}
}
if ( 'yes' === $manage_stock ) {

View File

@ -458,18 +458,21 @@ class WC_API_Server {
$data = array();
$route = preg_replace( '#\(\?P(<\w+?>).*?\)#', '$1', $route );
$methods = array();
foreach ( self::$method_map as $name => $bitmask ) {
foreach ( $callbacks as $callback ) {
// Skip to the next route if any callback is hidden
if ( $callback[1] & self::HIDDEN_ENDPOINT )
if ( $callback[1] & self::HIDDEN_ENDPOINT ) {
continue 3;
}
if ( $callback[1] & $bitmask )
if ( $callback[1] & $bitmask ) {
$data['supports'][] = $name;
}
if ( $callback[1] & self::ACCEPT_DATA )
if ( $callback[1] & self::ACCEPT_DATA ) {
$data['accepts_data'] = true;
}
// For non-variable routes, generate links
if ( strpos( $route, '<' ) === false ) {
@ -479,8 +482,10 @@ class WC_API_Server {
}
}
}
$available['store']['routes'][ $route ] = apply_filters( 'woocommerce_api_endpoints_description', $data );
}
return apply_filters( 'woocommerce_api_index', $available );
}

View File

@ -265,9 +265,12 @@ class WC_Countries {
* @return string
*/
public function shipping_to_prefix() {
$return = '';
if (in_array(WC()->customer->get_shipping_country(), array( 'GB', 'US', 'AE', 'CZ', 'DO', 'NL', 'PH', 'USAF' ))) $return = __( 'to the', 'woocommerce' );
else $return = __( 'to', 'woocommerce' );
if ( in_array( WC()->customer->get_shipping_country(), array( 'GB', 'US', 'AE', 'CZ', 'DO', 'NL', 'PH', 'USAF' ) ) ) {
$return = __( 'to the', 'woocommerce' );
} else {
$return = __( 'to', 'woocommerce' );
}
return apply_filters('woocommerce_countries_shipping_to_prefix', $return, WC()->customer->get_shipping_country());
}

View File

@ -117,7 +117,6 @@ class WC_Install {
$this->create_files();
// Queue upgrades
$current_version = get_option( 'woocommerce_version', null );
$current_db_version = get_option( 'woocommerce_db_version', null );
if ( version_compare( $current_db_version, '2.2.0', '<' ) && null !== $current_db_version ) {

View File

@ -429,8 +429,6 @@ class WC_Query {
public function get_products_in_view() {
global $wp_the_query;
$unfiltered_product_ids = array();
// Get main query
$current_wp_query = $wp_the_query->query;

View File

@ -63,12 +63,10 @@ class WC_Webhook {
*
* @since 2.2
* @param string $key
* @return mixed|null|void value
* @return mixed value
*/
public function __get( $key ) {
$value = null;
if ( 'status' === $key ) {
$value = $this->get_status();
} else {

View File

@ -210,9 +210,8 @@ class WC_Gateway_Paypal_Request {
* @return string
*/
protected function get_order_item_name( $order, $item ) {
$product = $order->get_product_from_item( $item );
$item_name = $item['name'];
$item_meta = new WC_Order_Item_Meta( $item['item_meta'] );
$item_name = $item['name'];
$item_meta = new WC_Order_Item_Meta( $item['item_meta'] );
if ( $meta = $item_meta->display( true, true ) ) {
$item_name .= ' ( ' . $meta . ' )';

View File

@ -9,17 +9,16 @@ if ( ! defined( 'ABSPATH' ) ) {
*
* A simple shipping method for free shipping
*
* @class WC_Shipping_Free_Shipping
* @version 2.0.0
* @package WooCommerce/Classes/Shipping
* @author WooThemes
* @class WC_Shipping_Free_Shipping
* @version 2.3.0
* @package WooCommerce/Classes/Shipping
* @author WooThemes
*/
class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
/**
* __construct function.
*
* @access public
* @return void
*/
function __construct() {
@ -31,7 +30,6 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
/**
* init function.
*
* @access public
* @return void
*/
function init() {
@ -56,68 +54,66 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
/**
* Initialise Gateway Settings Form Fields
*
* @access public
* @return void
*/
function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Enable Free Shipping', 'woocommerce' ),
'default' => 'yes'
),
'title' => __( 'Enable/Disable', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Enable Free Shipping', 'woocommerce' ),
'default' => 'yes'
),
'title' => array(
'title' => __( 'Method Title', 'woocommerce' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Free Shipping', 'woocommerce' ),
'desc_tip' => true,
),
'title' => __( 'Method Title', 'woocommerce' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Free Shipping', 'woocommerce' ),
'desc_tip' => true,
),
'availability' => array(
'title' => __( 'Method availability', 'woocommerce' ),
'type' => 'select',
'default' => 'all',
'class' => 'availability',
'options' => array(
'all' => __( 'All allowed countries', 'woocommerce' ),
'specific' => __( 'Specific Countries', 'woocommerce' )
)
),
'title' => __( 'Method availability', 'woocommerce' ),
'type' => 'select',
'default' => 'all',
'class' => 'availability',
'options' => array(
'all' => __( 'All allowed countries', 'woocommerce' ),
'specific' => __( 'Specific Countries', 'woocommerce' )
)
),
'countries' => array(
'title' => __( 'Specific Countries', 'woocommerce' ),
'type' => 'multiselect',
'class' => 'chosen_select',
'css' => 'width: 450px;',
'default' => '',
'options' => WC()->countries->get_shipping_countries(),
'custom_attributes' => array(
'data-placeholder' => __( 'Select some countries', 'woocommerce' )
)
),
'title' => __( 'Specific Countries', 'woocommerce' ),
'type' => 'multiselect',
'class' => 'chosen_select',
'css' => 'width: 450px;',
'default' => '',
'options' => WC()->countries->get_shipping_countries(),
'custom_attributes' => array(
'data-placeholder' => __( 'Select some countries', 'woocommerce' )
)
),
'requires' => array(
'title' => __( 'Free Shipping Requires...', 'woocommerce' ),
'type' => 'select',
'default' => '',
'options' => array(
'' => __( 'N/A', 'woocommerce' ),
'coupon' => __( 'A valid free shipping coupon', 'woocommerce' ),
'min_amount' => __( 'A minimum order amount (defined below)', 'woocommerce' ),
'either' => __( 'A minimum order amount OR a coupon', 'woocommerce' ),
'both' => __( 'A minimum order amount AND a coupon', 'woocommerce' ),
)
),
'title' => __( 'Free Shipping Requires...', 'woocommerce' ),
'type' => 'select',
'default' => '',
'options' => array(
'' => __( 'N/A', 'woocommerce' ),
'coupon' => __( 'A valid free shipping coupon', 'woocommerce' ),
'min_amount' => __( 'A minimum order amount (defined below)', 'woocommerce' ),
'either' => __( 'A minimum order amount OR a coupon', 'woocommerce' ),
'both' => __( 'A minimum order amount AND a coupon', 'woocommerce' ),
)
),
'min_amount' => array(
'title' => __( 'Minimum Order Amount', 'woocommerce' ),
'type' => 'price',
'placeholder' => wc_format_localized_price( 0 ),
'description' => __( 'Users will need to spend this amount to get free shipping (if enabled above).', 'woocommerce' ),
'default' => '0',
'desc_tip' => true
)
);
'title' => __( 'Minimum Order Amount', 'woocommerce' ),
'type' => 'price',
'placeholder' => wc_format_localized_price( 0 ),
'description' => __( 'Users will need to spend this amount to get free shipping (if enabled above).', 'woocommerce' ),
'default' => '0',
'desc_tip' => true
)
);
}
@ -126,7 +122,6 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
* - Options for bits like 'title' and availability on a country-by-country basis
*
* @since 1.0.0
* @access public
* @return void
*/
public function admin_options() {
@ -146,63 +141,74 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
/**
* is_available function.
*
* @access public
* @param mixed $package
* @return bool
*/
function is_available( $package ) {
if ( $this->enabled == "no" ) return false;
if ( 'no' == $this->enabled ) {
return false;
}
$ship_to_countries = '';
if ( $this->availability == 'specific' )
if ( 'specific' == $this->availability ) {
$ship_to_countries = $this->countries;
else
} else {
$ship_to_countries = array_keys( WC()->countries->get_shipping_countries() );
}
if ( is_array( $ship_to_countries ) )
if ( ! in_array( $package['destination']['country'], $ship_to_countries ) )
return false;
if ( is_array( $ship_to_countries ) && ! in_array( $package['destination']['country'], $ship_to_countries ) ) {
return false;
}
// Enabled logic
$is_available = false;
$has_coupon = false;
$is_available = false;
$has_coupon = false;
$has_met_min_amount = false;
if ( in_array( $this->requires, array( 'coupon', 'either', 'both' ) ) ) {
if ( $coupons = WC()->cart->get_coupons() ) {
foreach ( $coupons as $code => $coupon ) {
if ( $coupon->is_valid() && $coupon->enable_free_shipping() )
if ( $coupon->is_valid() && $coupon->enable_free_shipping() ) {
$has_coupon = true;
}
}
}
}
if ( in_array( $this->requires, array( 'min_amount', 'either', 'both' ) ) && isset( WC()->cart->cart_contents_total ) ) {
if ( WC()->cart->prices_include_tax )
if ( WC()->cart->prices_include_tax ) {
$total = WC()->cart->cart_contents_total + array_sum( WC()->cart->taxes );
else
} else {
$total = WC()->cart->cart_contents_total;
}
if ( $total >= $this->min_amount )
if ( $total >= $this->min_amount ) {
$has_met_min_amount = true;
}
}
switch ( $this->requires ) {
case 'min_amount' :
if ( $has_met_min_amount ) $is_available = true;
if ( $has_met_min_amount ) {
$is_available = true;
}
break;
case 'coupon' :
if ( $has_coupon ) $is_available = true;
if ( $has_coupon ) {
$is_available = true;
}
break;
case 'both' :
if ( $has_met_min_amount && $has_coupon ) $is_available = true;
if ( $has_met_min_amount && $has_coupon ) {
$is_available = true;
}
break;
case 'either' :
if ( $has_met_min_amount || $has_coupon ) $is_available = true;
if ( $has_met_min_amount || $has_coupon ) {
$is_available = true;
}
break;
default :
$is_available = true;
@ -216,7 +222,6 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
/**
* calculate_shipping function.
*
* @access public
* @return array
*/
function calculate_shipping() {

View File

@ -45,20 +45,22 @@ function wc_empty_cart() {
/**
* Load the cart upon login
*
* @param mixed $user_login
* @param integer $user
* @return void
* @param string $user_login
* @param WP_User $user
*/
function wc_load_persistent_cart( $user_login, $user = 0 ) {
function wc_load_persistent_cart( $user_login, $user ) {
if ( ! $user )
if ( ! $user ) {
return;
}
$saved_cart = get_user_meta( $user->ID, '_woocommerce_persistent_cart', true );
if ( $saved_cart )
if ( empty( WC()->session->cart ) || ! is_array( WC()->session->cart ) || sizeof( WC()->session->cart ) == 0 )
if ( $saved_cart ) {
if ( empty( WC()->session->cart ) || ! is_array( WC()->session->cart ) || sizeof( WC()->session->cart ) == 0 ) {
WC()->session->cart = $saved_cart['cart'];
}
}
}
add_action( 'wp_login', 'wc_load_persistent_cart', 1, 2 );

View File

@ -569,8 +569,7 @@ function wc_get_log_file_path( $handle ) {
* Init for our rewrite rule fixes
*/
function wc_fix_rewrite_rules_init() {
$permalinks = get_option( 'woocommerce_permalinks' );
$product_permalink = empty( $permalinks['product_base'] ) ? _x( 'product', 'slug', 'woocommerce' ) : $permalinks['product_base'];
$permalinks = get_option( 'woocommerce_permalinks' );
if ( ! empty( $permalinks['use_verbose_page_rules'] ) ) {
$GLOBALS['wp_rewrite']->use_verbose_page_rules = true;

View File

@ -317,7 +317,6 @@ function wc_price( $price, $args = array() ) {
'ex_tax_label' => '0'
), $args ) );
$return = '';
$num_decimals = absint( get_option( 'woocommerce_price_num_decimals' ) );
$currency = isset( $args['currency'] ) ? $args['currency'] : '';
$currency_symbol = get_woocommerce_currency_symbol($currency);

View File

@ -116,36 +116,35 @@ function wc_customer_edit_account_url() {
* Hide menu items conditionally
*
* @param array $items
* @param mixed $args
* @return array
*/
function wc_nav_menu_items( $items, $args ) {
function wc_nav_menu_items( $items ) {
if ( ! is_user_logged_in() ) {
$hide_pages = array();
$hide_pages[] = (int) wc_get_page_id( 'logout' );
$hide_pages = apply_filters( 'woocommerce_logged_out_hidden_page_ids', $hide_pages );
$customer_logout = get_option( 'woocommerce_logout_endpoint', 'customer-logout' );
foreach ( $items as $key => $item ) {
if ( strstr( $item->url, 'customer-logout' ) )
if ( strstr( $item->url, $customer_logout ) ) {
unset( $items[ $key ] );
}
}
}
return $items;
}
add_filter( 'wp_nav_menu_objects', 'wc_nav_menu_items', 10, 2 );
add_filter( 'wp_nav_menu_objects', 'wc_nav_menu_items', 10 );
/**
* Fix active class in nav for shop page.
*
* @param array $menu_items
* @param array $args
* @return array
*/
function wc_nav_menu_item_classes( $menu_items, $args ) {
function wc_nav_menu_item_classes( $menu_items ) {
if ( ! is_woocommerce() ) return $menu_items;
if ( ! is_woocommerce() ) {
return $menu_items;
}
$shop_page = (int) wc_get_page_id('shop');
$page_for_posts = (int) get_option( 'page_for_posts' );
@ -158,15 +157,17 @@ function wc_nav_menu_item_classes( $menu_items, $args ) {
if ( $page_for_posts == $menu_item->object_id ) {
$menu_items[$key]->current = false;
if ( in_array( 'current_page_parent', $classes ) )
if ( in_array( 'current_page_parent', $classes ) ) {
unset( $classes[ array_search('current_page_parent', $classes) ] );
}
if ( in_array( 'current-menu-item', $classes ) )
if ( in_array( 'current-menu-item', $classes ) ) {
unset( $classes[ array_search('current-menu-item', $classes) ] );
}
// Set active state if this is the shop page link
} elseif ( is_shop() && $shop_page == $menu_item->object_id ) {
$menu_items[$key]->current = true;
$menu_items[ $key ]->current = true;
$classes[] = 'current-menu-item';
$classes[] = 'current_page_item';
@ -175,13 +176,13 @@ function wc_nav_menu_item_classes( $menu_items, $args ) {
$classes[] = 'current_page_parent';
}
$menu_items[$key]->classes = array_unique( $classes );
$menu_items[ $key ]->classes = array_unique( $classes );
}
return $menu_items;
}
add_filter( 'wp_nav_menu_objects', 'wc_nav_menu_item_classes', 2, 20 );
add_filter( 'wp_nav_menu_objects', 'wc_nav_menu_item_classes', 2 );
/**

View File

@ -614,10 +614,11 @@ if ( ! function_exists( 'woocommerce_get_product_thumbnail' ) ) {
function woocommerce_get_product_thumbnail( $size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0 ) {
global $post;
if ( has_post_thumbnail() )
if ( has_post_thumbnail() ) {
return get_the_post_thumbnail( $post->ID, $size );
elseif ( wc_placeholder_img_src() )
} elseif ( wc_placeholder_img_src() ) {
return wc_placeholder_img( $size );
}
}
}

View File

@ -542,11 +542,10 @@ add_action( 'woocommerce_product_set_stock_status', 'wc_recount_after_stock_chan
* that takes catalog visibility into account.
*
* @param array $terms
* @param mixed $taxonomies
* @param mixed $args
* @param string|array $taxonomies
* @return array
*/
function wc_change_term_counts( $terms, $taxonomies, $args ) {
function wc_change_term_counts( $terms, $taxonomies ) {
if ( is_admin() || is_ajax() ) {
return $terms;
}
@ -574,4 +573,4 @@ function wc_change_term_counts( $terms, $taxonomies, $args ) {
return $terms;
}
add_filter( 'get_terms', 'wc_change_term_counts', 10, 3 );
add_filter( 'get_terms', 'wc_change_term_counts', 10, 2 );

View File

@ -51,9 +51,6 @@ class WC_Widget_Layered_Nav_Filters extends WC_Widget {
return;
}
$current_term = is_tax() ? get_queried_object()->term_id : '';
$current_tax = is_tax() ? get_queried_object()->taxonomy : '';
// Price
$min_price = isset( $_GET['min_price'] ) ? esc_attr( $_GET['min_price'] ) : 0;
$max_price = isset( $_GET['max_price'] ) ? esc_attr( $_GET['max_price'] ) : 0;

View File

@ -97,9 +97,6 @@ class WC_Widget_Price_Filter extends WC_Widget {
}
}
$min = $max = 0;
$post_min = $post_max = '';
if ( 0 === sizeof( WC()->query->layered_nav_product_ids ) ) {
$min = floor( $wpdb->get_var(
$wpdb->prepare('