From 0361a2f0cb1082ea51ca47405a9876316789e909 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 27 Nov 2012 15:37:01 +0000 Subject: [PATCH] Settings API tweaks. Uses same names as the settings API for gateways which Closes #1848. Allows a single level of array based IDs for options which Closes #1826. Related to #1826 this is now used for image size settings. --- admin/settings/settings-init.php | 372 +++++++++++----------- admin/settings/settings-save.php | 86 +++-- admin/woocommerce-admin-install.php | 10 +- admin/woocommerce-admin-settings.php | 117 ++++--- classes/abstracts/abstract-wc-product.php | 2 +- classes/class-wc-product-variation.php | 2 +- widgets/widget-best_sellers.php | 7 +- widgets/widget-onsale.php | 7 +- widgets/widget-random_products.php | 12 +- widgets/widget-recent_products.php | 7 +- widgets/widget-recently_viewed.php | 7 +- woocommerce-core-functions.php | 17 +- woocommerce-template.php | 21 +- woocommerce.php | 35 +- 14 files changed, 407 insertions(+), 295 deletions(-) diff --git a/admin/settings/settings-init.php b/admin/settings/settings-init.php index 95cac01254f..b8f5629e700 100644 --- a/admin/settings/settings-init.php +++ b/admin/settings/settings-init.php @@ -13,33 +13,33 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly $localisation_setting = ( defined('WPLANG') ) ? array( - 'name' => __( 'Localisation', 'woocommerce' ), + 'title' => __( 'Localisation', 'woocommerce' ), 'desc' => __( 'Use informal localisation file if it exists', 'woocommerce' ), 'id' => 'woocommerce_informal_localisation_type', 'type' => 'checkbox', - 'std' => 'no', + 'default' => 'no', ) : array(); $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', array( - array( 'name' => __( 'General Options', 'woocommerce' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ), + array( 'title' => __( 'General Options', 'woocommerce' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ), array( - 'name' => __( 'Base Country/Region', 'woocommerce' ), + 'title' => __( 'Base Country/Region', 'woocommerce' ), 'desc' => __( 'This is the base country for your business. Tax rates will be based on this country.', 'woocommerce' ), 'id' => 'woocommerce_default_country', 'css' => 'min-width:300px;', - 'std' => 'GB', + 'default' => 'GB', 'type' => 'single_select_country', 'desc_tip' => true, ), array( - 'name' => __( 'Currency', 'woocommerce' ), + 'title' => __( 'Currency', 'woocommerce' ), 'desc' => __("This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.", 'woocommerce' ), 'id' => 'woocommerce_currency', 'css' => 'min-width:300px;', - 'std' => 'GBP', + 'default' => 'GBP', 'type' => 'select', 'class' => 'chosen_select', 'desc_tip' => true, @@ -76,10 +76,10 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', ), array( - 'name' => __( 'Allowed Countries', 'woocommerce' ), + 'title' => __( 'Allowed Countries', 'woocommerce' ), 'desc' => __( 'These are countries that you are willing to ship to.', 'woocommerce' ), 'id' => 'woocommerce_allowed_countries', - 'std' => 'all', + 'default' => 'all', 'type' => 'select', 'class' => 'chosen_select', 'css' => 'min-width:300px;', @@ -91,11 +91,11 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', ), array( - 'name' => __( 'Specific Countries', 'woocommerce' ), + 'title' => __( 'Specific Countries', 'woocommerce' ), 'desc' => '', 'id' => 'woocommerce_specific_allowed_countries', 'css' => '', - 'std' => '', + 'default' => '', 'type' => 'multi_select_countries' ), @@ -103,13 +103,13 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', array( 'type' => 'sectionend', 'id' => 'general_options'), - array( 'name' => __( 'Checkout and Accounts', 'woocommerce' ), 'type' => 'title','desc' => __( 'The following options control the behaviour of the checkout process and customer accounts.', 'woocommerce' ), 'id' => 'checkout_account_options' ), + array( 'title' => __( 'Checkout and Accounts', 'woocommerce' ), 'type' => 'title','desc' => __( 'The following options control the behaviour of the checkout process and customer accounts.', 'woocommerce' ), 'id' => 'checkout_account_options' ), array( - 'name' => __( 'Checkout', 'woocommerce' ), + 'title' => __( 'Checkout', 'woocommerce' ), 'desc' => __( 'Enable guest checkout (no account required)', 'woocommerce' ), 'id' => 'woocommerce_enable_guest_checkout', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'start' ), @@ -117,16 +117,16 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', array( 'desc' => __( 'Show order comments section', 'woocommerce' ), 'id' => 'woocommerce_enable_order_comments', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'end' ), array( - 'name' => __( 'Security', 'woocommerce' ), + 'title' => __( 'Security', 'woocommerce' ), 'desc' => __( 'Force secure checkout', 'woocommerce' ), 'id' => 'woocommerce_force_ssl_checkout', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'start', 'show_if_checked' => 'option', @@ -136,17 +136,17 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', array( 'desc' => __( 'Un-force HTTPS when leaving the checkout', 'woocommerce' ), 'id' => 'woocommerce_unforce_ssl_checkout', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'end', 'show_if_checked' => 'yes', ), array( - 'name' => __( 'Coupons', 'woocommerce' ), + 'title' => __( 'Coupons', 'woocommerce' ), 'desc' => __( 'Enable coupons', 'woocommerce' ), 'id' => 'woocommerce_enable_coupons', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'start', 'show_if_checked' => 'option' @@ -155,7 +155,7 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', array( 'desc' => __( 'Enable coupon form on cart', 'woocommerce' ), 'id' => 'woocommerce_enable_coupon_form_on_cart', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => '', 'show_if_checked' => 'yes' @@ -164,17 +164,17 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', array( 'desc' => __( 'Enable coupon form on checkout', 'woocommerce' ), 'id' => 'woocommerce_enable_coupon_form_on_checkout', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'end', 'show_if_checked' => 'yes' ), array( - 'name' => __( 'Registration', 'woocommerce' ), + 'title' => __( 'Registration', 'woocommerce' ), 'desc' => __( 'Allow registration on the checkout page', 'woocommerce' ), 'id' => 'woocommerce_enable_signup_and_login_from_checkout', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'start' ), @@ -182,7 +182,7 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', array( 'desc' => __( 'Allow registration on the "My Account" page', 'woocommerce' ), 'id' => 'woocommerce_enable_myaccount_registration', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => '' ), @@ -190,16 +190,16 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', array( 'desc' => __( 'Register using the email address for the username', 'woocommerce' ), 'id' => 'woocommerce_registration_email_for_username', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'end' ), array( - 'name' => __( 'Customer Accounts', 'woocommerce' ), + 'title' => __( 'Customer Accounts', 'woocommerce' ), 'desc' => __( 'Prevent customers from accessing WordPress admin', 'woocommerce' ), 'id' => 'woocommerce_lock_down_admin', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'start' ), @@ -207,7 +207,7 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', array( 'desc' => __( 'Clear cart when logging out', 'woocommerce' ), 'id' => 'woocommerce_clear_cart_on_logout', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => '' ), @@ -215,20 +215,20 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', array( 'desc' => __( 'Allow customers to repurchase past orders', 'woocommerce' ), 'id' => 'woocommerce_allow_customers_to_reorder', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'end' ), array( 'type' => 'sectionend', 'id' => 'checkout_account_options'), - array( 'name' => __( 'Styles and Scripts', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect the styling of your store, as well as how certain features behave.', 'woocommerce' ), 'id' => 'script_styling_options' ), + array( 'title' => __( 'Styles and Scripts', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect the styling of your store, as well as how certain features behave.', 'woocommerce' ), 'id' => 'script_styling_options' ), array( - 'name' => __( 'Styling', 'woocommerce' ), + 'title' => __( 'Styling', 'woocommerce' ), 'desc' => __( 'Enable WooCommerce CSS styles', 'woocommerce' ), 'id' => 'woocommerce_frontend_css', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox' ), @@ -237,27 +237,27 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', ), array( - 'name' => __( 'Store Notice', 'woocommerce' ), + 'title' => __( 'Store Notice', 'woocommerce' ), 'desc' => __( 'Enable the "Demo Store" notice on your site', 'woocommerce' ), 'id' => 'woocommerce_demo_store', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox' ), array( - 'name' => __( 'Store Notice Text', 'woocommerce' ), + 'title' => __( 'Store Notice Text', 'woocommerce' ), 'desc' => '', 'id' => 'woocommerce_demo_store_notice', - 'std' => __( 'This is a demo store for testing purposes — no orders shall be fulfilled.', 'woocommerce' ), + 'default' => __( 'This is a demo store for testing purposes — no orders shall be fulfilled.', 'woocommerce' ), 'type' => 'text', 'css' => 'min-width:300px;', ), array( - 'name' => __( 'Scripts', 'woocommerce' ), + 'title' => __( 'Scripts', 'woocommerce' ), 'desc' => __( 'Enable AJAX add to cart buttons on product archives', 'woocommerce' ), 'id' => 'woocommerce_enable_ajax_add_to_cart', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'start' ), @@ -265,7 +265,7 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', array( 'desc' => __( 'Enable WooCommerce lightbox on the product page', 'woocommerce' ), 'id' => 'woocommerce_enable_lightbox', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => '' ), @@ -273,23 +273,23 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', array( 'desc' => __( 'Enable enhanced country select boxes', 'woocommerce' ), 'id' => 'woocommerce_enable_chosen', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'end' ), array( 'type' => 'sectionend', 'id' => 'script_styling_options'), - array( 'name' => __( 'Digital Downloads', 'woocommerce' ), 'type' => 'title','desc' => __( 'The following options are specific to downloadable products.', 'woocommerce' ), 'id' => 'digital_download_options' ), + array( 'title' => __( 'Digital Downloads', 'woocommerce' ), 'type' => 'title','desc' => __( 'The following options are specific to downloadable products.', 'woocommerce' ), 'id' => 'digital_download_options' ), array( - 'name' => __( 'File Download Method', 'woocommerce' ), + 'title' => __( 'File Download Method', 'woocommerce' ), 'desc' => __( 'Forcing downloads will keep URLs hidden, but some servers may serve large files unreliably. If supported, X-Accel-Redirect/ X-Sendfile can be used to serve downloads instead (server requires mod_xsendfile).', 'woocommerce' ), 'id' => 'woocommerce_file_download_method', 'type' => 'select', 'class' => 'chosen_select', 'css' => 'min-width:300px;', - 'std' => 'force', + 'default' => 'force', 'desc_tip' => true, 'options' => array( 'force' => __( 'Force Downloads', 'woocommerce' ), @@ -299,11 +299,11 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', ), array( - 'name' => __( 'Access Restrictions', 'woocommerce' ), + 'title' => __( 'Access Restrictions', 'woocommerce' ), 'desc' => __( 'Must be logged in to download files', 'woocommerce' ), 'id' => 'woocommerce_downloads_require_login', 'type' => 'checkbox', - 'std' => 'no', + 'default' => 'no', 'desc_tip' => __( 'This setting does not apply to guest downloads.', 'woocommerce' ), 'checkboxgroup' => 'start' ), @@ -312,16 +312,16 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', 'desc' => __( 'Grant access to downloadable products after payment', 'woocommerce' ), 'id' => 'woocommerce_downloads_grant_access_after_payment', 'type' => 'checkbox', - 'std' => 'yes', + 'default' => 'yes', 'desc_tip' => __( 'Turn this option off to only grant access when an order is "complete", rather than "processing"', 'woocommerce' ), 'checkboxgroup' => 'end' ), array( - 'name' => __( 'Limit Quantity', 'woocommerce' ), + 'title' => __( 'Limit Quantity', 'woocommerce' ), 'desc' => __( 'Limit the purchasable quantity of downloadable-virtual items to 1', 'woocommerce' ), 'id' => 'woocommerce_limit_downloadable_product_qty', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox' ), @@ -342,38 +342,38 @@ if ( $shop_page_id > 0 && sizeof(get_pages("child_of=$shop_page_id")) > 0 ) $woocommerce_settings['pages'] = apply_filters('woocommerce_page_settings', array( array( - 'name' => __( 'Page Setup', 'woocommerce' ), + 'title' => __( 'Page Setup', 'woocommerce' ), 'type' => 'title', 'desc' => sprintf( __( 'Set up core WooCommerce pages here, for example the base page. The base page can also be used in your %sproduct permalinks%s.', 'woocommerce' ), '', '' ), 'id' => 'page_options' ), array( - 'name' => __( 'Shop Base Page', 'woocommerce' ), + 'title' => __( 'Shop Base Page', 'woocommerce' ), 'desc' => __( 'This sets the base page of your shop - this is where your product archive will be.', 'woocommerce' ), 'id' => 'woocommerce_shop_page_id', 'type' => 'single_select_page', - 'std' => '', + 'default' => '', 'class' => 'chosen_select_nostd', 'css' => 'min-width:300px;', 'desc_tip' => true ), array( - 'name' => __( 'Base Page Title', 'woocommerce' ), + 'title' => __( 'Base Page Title', 'woocommerce' ), 'desc' => __( 'This title to show on the shop base page. Leave blank to use the page title.', 'woocommerce' ), 'id' => 'woocommerce_shop_page_title', 'type' => 'text', 'css' => 'min-width:300px;', - 'std' => 'All Products', // Default value for the page title - changed in settings + 'default' => 'All Products', // Default value for the page title - changed in settings 'desc_tip' => true, ), array( - 'name' => __( 'Terms Page ID', 'woocommerce' ), + 'title' => __( 'Terms Page ID', 'woocommerce' ), 'desc' => __( 'If you define a "Terms" page the customer will be asked if they accept them when checking out.', 'woocommerce' ), 'id' => 'woocommerce_terms_page_id', - 'std' => '', + 'default' => '', 'class' => 'chosen_select_nostd', 'css' => 'min-width:300px;', 'type' => 'single_select_page', @@ -381,111 +381,111 @@ $woocommerce_settings['pages'] = apply_filters('woocommerce_page_settings', arra ), array( - 'name' => __( 'Logout link', 'woocommerce' ), + 'title' => __( 'Logout link', 'woocommerce' ), 'desc' => sprintf(__( 'Append a logout link to menus containing "My Account"', 'woocommerce' ), $base_slug), 'id' => 'woocommerce_menu_logout_link', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', ), array( 'type' => 'sectionend', 'id' => 'page_options' ), - array( 'name' => __( 'Shop Pages', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following pages need selecting so that WooCommerce knows where they are. These pages should have been created upon installation of the plugin, if not you will need to create them.', 'woocommerce' ) ), + array( 'title' => __( 'Shop Pages', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following pages need selecting so that WooCommerce knows where they are. These pages should have been created upon installation of the plugin, if not you will need to create them.', 'woocommerce' ) ), array( - 'name' => __( 'Cart Page', 'woocommerce' ), + 'title' => __( 'Cart Page', 'woocommerce' ), 'desc' => __( 'Page contents: [woocommerce_cart]', 'woocommerce' ), 'id' => 'woocommerce_cart_page_id', 'type' => 'single_select_page', - 'std' => '', + 'default' => '', 'class' => 'chosen_select_nostd', 'css' => 'min-width:300px;', 'desc_tip' => true, ), array( - 'name' => __( 'Checkout Page', 'woocommerce' ), + 'title' => __( 'Checkout Page', 'woocommerce' ), 'desc' => __( 'Page contents: [woocommerce_checkout]', 'woocommerce' ), 'id' => 'woocommerce_checkout_page_id', 'type' => 'single_select_page', - 'std' => '', + 'default' => '', 'class' => 'chosen_select_nostd', 'css' => 'min-width:300px;', 'desc_tip' => true, ), array( - 'name' => __( 'Pay Page', 'woocommerce' ), + 'title' => __( 'Pay Page', 'woocommerce' ), 'desc' => __( 'Page contents: [woocommerce_pay] Parent: "Checkout"', 'woocommerce' ), 'id' => 'woocommerce_pay_page_id', 'type' => 'single_select_page', - 'std' => '', + 'default' => '', 'class' => 'chosen_select_nostd', 'css' => 'min-width:300px;', 'desc_tip' => true, ), array( - 'name' => __( 'Thanks Page', 'woocommerce' ), + 'title' => __( 'Thanks Page', 'woocommerce' ), 'desc' => __( 'Page contents: [woocommerce_thankyou] Parent: "Checkout"', 'woocommerce' ), 'id' => 'woocommerce_thanks_page_id', 'type' => 'single_select_page', - 'std' => '', + 'default' => '', 'class' => 'chosen_select_nostd', 'css' => 'min-width:300px;', 'desc_tip' => true, ), array( - 'name' => __( 'My Account Page', 'woocommerce' ), + 'title' => __( 'My Account Page', 'woocommerce' ), 'desc' => __( 'Page contents: [woocommerce_my_account]', 'woocommerce' ), 'id' => 'woocommerce_myaccount_page_id', 'type' => 'single_select_page', - 'std' => '', + 'default' => '', 'class' => 'chosen_select_nostd', 'css' => 'min-width:300px;', 'desc_tip' => true, ), array( - 'name' => __( 'Edit Address Page', 'woocommerce' ), + 'title' => __( 'Edit Address Page', 'woocommerce' ), 'desc' => __( 'Page contents: [woocommerce_edit_address] Parent: "My Account"', 'woocommerce' ), 'id' => 'woocommerce_edit_address_page_id', 'type' => 'single_select_page', - 'std' => '', + 'default' => '', 'class' => 'chosen_select_nostd', 'css' => 'min-width:300px;', 'desc_tip' => true, ), array( - 'name' => __( 'View Order Page', 'woocommerce' ), + 'title' => __( 'View Order Page', 'woocommerce' ), 'desc' => __( 'Page contents: [woocommerce_view_order] Parent: "My Account"', 'woocommerce' ), 'id' => 'woocommerce_view_order_page_id', 'type' => 'single_select_page', - 'std' => '', + 'default' => '', 'class' => 'chosen_select_nostd', 'css' => 'min-width:300px;', 'desc_tip' => true, ), array( - 'name' => __( 'Change Password Page', 'woocommerce' ), + 'title' => __( 'Change Password Page', 'woocommerce' ), 'desc' => __( 'Page contents: [woocommerce_change_password] Parent: "My Account"', 'woocommerce' ), 'id' => 'woocommerce_change_password_page_id', 'type' => 'single_select_page', - 'std' => '', + 'default' => '', 'class' => 'chosen_select_nostd', 'css' => 'min-width:300px;', 'desc_tip' => true, ), array( - 'name' => __( 'Lost Password Page', 'woocommerce' ), + 'title' => __( 'Lost Password Page', 'woocommerce' ), 'desc' => __( 'Page contents: [woocommerce_lost_password] Parent: "My Account"', 'woocommerce' ), 'id' => 'woocommerce_lost_password_page_id', 'type' => 'single_select_page', - 'std' => '', + 'default' => '', 'class' => 'chosen_select_nostd', 'css' => 'min-width:300px;', 'desc_tip' => true, @@ -498,14 +498,14 @@ $woocommerce_settings['pages'] = apply_filters('woocommerce_page_settings', arra $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', array( - array( 'name' => __( 'Catalog Options', 'woocommerce' ), 'type' => 'title','desc' => '', 'id' => 'catalog_options' ), + array( 'title' => __( 'Catalog Options', 'woocommerce' ), 'type' => 'title','desc' => '', 'id' => 'catalog_options' ), array( - 'name' => __( 'Default Product Sorting', 'woocommerce' ), + 'title' => __( 'Default Product Sorting', 'woocommerce' ), 'desc' => __( 'This controls the default sort order of the catalog.', 'woocommerce' ), 'id' => 'woocommerce_default_catalog_orderby', 'css' => 'min-width:150px;', - 'std' => 'title', + 'default' => 'title', 'type' => 'select', 'options' => apply_filters('woocommerce_default_catalog_orderby_options', array( 'menu_order' => __( 'Default sorting', 'woocommerce' ), @@ -517,11 +517,11 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', ), array( - 'name' => __( 'Shop Page Display', 'woocommerce' ), + 'title' => __( 'Shop Page Display', 'woocommerce' ), 'desc' => __( 'This controls what is shown on the product archive.', 'woocommerce' ), 'id' => 'woocommerce_shop_page_display', 'css' => 'min-width:150px;', - 'std' => '', + 'default' => '', 'type' => 'select', 'options' => array( '' => __( 'Show products', 'woocommerce' ), @@ -532,11 +532,11 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', ), array( - 'name' => __( 'Default Category Display', 'woocommerce' ), + 'title' => __( 'Default Category Display', 'woocommerce' ), 'desc' => __( 'This controls what is shown on category archives.', 'woocommerce' ), 'id' => 'woocommerce_category_archive_display', 'css' => 'min-width:150px;', - 'std' => '', + 'default' => '', 'type' => 'select', 'options' => array( '' => __( 'Show products', 'woocommerce' ), @@ -547,10 +547,10 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', ), array( - 'name' => __( 'Redirects', 'woocommerce' ), + 'title' => __( 'Redirects', 'woocommerce' ), 'desc' => __( 'Redirect to cart after adding a product to the cart (on single product pages)', 'woocommerce' ), 'id' => 'woocommerce_cart_redirect_after_add', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'start' ), @@ -558,20 +558,20 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', array( 'desc' => __( 'Redirect to the product page on a single matching search result', 'woocommerce' ), 'id' => 'woocommerce_redirect_on_single_search_result', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'end' ), array( 'type' => 'sectionend', 'id' => 'catalog_options' ), - array( 'name' => __( 'Product Data', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect the fields available on the edit product page.', 'woocommerce' ), 'id' => 'product_data_options' ), + array( 'title' => __( 'Product Data', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect the fields available on the edit product page.', 'woocommerce' ), 'id' => 'product_data_options' ), array( - 'name' => __( 'Product Fields', 'woocommerce' ), + 'title' => __( 'Product Fields', 'woocommerce' ), 'desc' => __( 'Enable the SKU field for products', 'woocommerce' ), 'id' => 'woocommerce_enable_sku', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'start' ), @@ -579,7 +579,7 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', array( 'desc' => __( 'Enable the weight field for products', 'woocommerce' ), 'id' => 'woocommerce_enable_weight', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => '' ), @@ -587,7 +587,7 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', array( 'desc' => __( 'Enable the dimension fields for products', 'woocommerce' ), 'id' => 'woocommerce_enable_dimensions', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => '' ), @@ -595,17 +595,17 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', array( 'desc' => __( 'Show weight and dimension fields in product attributes tab', 'woocommerce' ), 'id' => 'woocommerce_enable_dimension_product_attributes', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'end' ), array( - 'name' => __( 'Weight Unit', 'woocommerce' ), + 'title' => __( 'Weight Unit', 'woocommerce' ), 'desc' => __( 'This controls what unit you will define weights in.', 'woocommerce' ), 'id' => 'woocommerce_weight_unit', 'css' => 'min-width:150px;', - 'std' => 'kg', + 'default' => 'kg', 'type' => 'select', 'options' => array( 'kg' => __( 'kg', 'woocommerce' ), @@ -617,11 +617,11 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', ), array( - 'name' => __( 'Dimensions Unit', 'woocommerce' ), + 'title' => __( 'Dimensions Unit', 'woocommerce' ), 'desc' => __( 'This controls what unit you will define lengths in.', 'woocommerce' ), 'id' => 'woocommerce_dimension_unit', 'css' => 'min-width:150px;', - 'std' => 'cm', + 'default' => 'cm', 'type' => 'select', 'options' => array( 'm' => __( 'm', 'woocommerce' ), @@ -634,10 +634,10 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', ), array( - 'name' => __( 'Product Ratings', 'woocommerce' ), + 'title' => __( 'Product Ratings', 'woocommerce' ), 'desc' => __( 'Enable the rating field on the review form', 'woocommerce' ), 'id' => 'woocommerce_enable_review_rating', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'start', 'show_if_checked' => 'option', @@ -646,7 +646,7 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', array( 'desc' => __( 'Ratings are required to leave a review', 'woocommerce' ), 'id' => 'woocommerce_review_rating_required', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => '', 'show_if_checked' => 'yes', @@ -655,7 +655,7 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', array( 'desc' => __( 'Show "verified owner" label for customer reviews', 'woocommerce' ), 'id' => 'woocommerce_review_rating_verification_label', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'end', 'show_if_checked' => 'yes', @@ -663,14 +663,14 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', array( 'type' => 'sectionend', 'id' => 'product_review_options' ), - array( 'name' => __( 'Pricing Options', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect how prices are displayed on the frontend.', 'woocommerce' ), 'id' => 'pricing_options' ), + array( 'title' => __( 'Pricing Options', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect how prices are displayed on the frontend.', 'woocommerce' ), 'id' => 'pricing_options' ), array( - 'name' => __( 'Currency Position', 'woocommerce' ), + 'title' => __( 'Currency Position', 'woocommerce' ), 'desc' => __( 'This controls the position of the currency symbol.', 'woocommerce' ), 'id' => 'woocommerce_currency_pos', 'css' => 'min-width:150px;', - 'std' => 'left', + 'default' => 'left', 'type' => 'select', 'options' => array( 'left' => __( 'Left', 'woocommerce' ), @@ -682,31 +682,31 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', ), array( - 'name' => __( 'Thousand Separator', 'woocommerce' ), + 'title' => __( 'Thousand Separator', 'woocommerce' ), 'desc' => __( 'This sets the thousand separator of displayed prices.', 'woocommerce' ), 'id' => 'woocommerce_price_thousand_sep', 'css' => 'width:50px;', - 'std' => ',', + 'default' => ',', 'type' => 'text', 'desc_tip' => true, ), array( - 'name' => __( 'Decimal Separator', 'woocommerce' ), + 'title' => __( 'Decimal Separator', 'woocommerce' ), 'desc' => __( 'This sets the decimal separator of displayed prices.', 'woocommerce' ), 'id' => 'woocommerce_price_decimal_sep', 'css' => 'width:50px;', - 'std' => '.', + 'default' => '.', 'type' => 'text', 'desc_tip' => true, ), array( - 'name' => __( 'Number of Decimals', 'woocommerce' ), + 'title' => __( 'Number of Decimals', 'woocommerce' ), 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'woocommerce' ), 'id' => 'woocommerce_price_num_decimals', 'css' => 'width:50px;', - 'std' => '2', + 'default' => '2', 'desc_tip' => true, 'type' => 'number', 'custom_attributes' => array( @@ -716,44 +716,56 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', ), array( - 'name' => __( 'Trailing Zeros', 'woocommerce' ), + 'title' => __( 'Trailing Zeros', 'woocommerce' ), 'desc' => __( 'Remove zeros after the decimal point. e.g. $10.00 becomes $10', 'woocommerce' ), 'id' => 'woocommerce_price_trim_zeros', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox' ), array( 'type' => 'sectionend', 'id' => 'pricing_options' ), - array( 'name' => __( 'Image Options', 'woocommerce' ), 'type' => 'title','desc' => sprintf(__( 'These settings affect the actual dimensions of images in your catalog - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to regenerate your thumbnails.', 'woocommerce' ), 'http://wordpress.org/extend/plugins/regenerate-thumbnails/'), 'id' => 'image_options' ), + array( 'title' => __( 'Image Options', 'woocommerce' ), 'type' => 'title','desc' => sprintf(__( 'These settings affect the actual dimensions of images in your catalog - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to regenerate your thumbnails.', 'woocommerce' ), 'http://wordpress.org/extend/plugins/regenerate-thumbnails/'), 'id' => 'image_options' ), array( - 'name' => __( 'Catalog Images', 'woocommerce' ), + 'title' => __( 'Catalog Images', 'woocommerce' ), 'desc' => __( 'This size is usually used in product listings', 'woocommerce' ), 'id' => 'woocommerce_catalog_image', 'css' => '', 'type' => 'image_width', - 'std' => '150', + 'default' => array( + 'width' => '150', + 'height' => '150', + 'crop' => true + ), 'desc_tip' => true, ), array( - 'name' => __( 'Single Product Image', 'woocommerce' ), + 'title' => __( 'Single Product Image', 'woocommerce' ), 'desc' => __( 'This is the size used by the main image on the product page.', 'woocommerce' ), 'id' => 'woocommerce_single_image', 'css' => '', 'type' => 'image_width', - 'std' => '300', + 'default' => array( + 'width' => '300', + 'height' => '300', + 'crop' => 1 + ), 'desc_tip' => true, ), array( - 'name' => __( 'Product Thumbnails', 'woocommerce' ), + 'title' => __( 'Product Thumbnails', 'woocommerce' ), 'desc' => __( 'This size is usually used for the gallery of images on the product page.', 'woocommerce' ), 'id' => 'woocommerce_thumbnail_image', 'css' => '', 'type' => 'image_width', - 'std' => '90', + 'default' => array( + 'width' => '90', + 'height' => '90', + 'crop' => 1 + ), 'desc_tip' => true, ), @@ -764,21 +776,21 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings', $woocommerce_settings['inventory'] = apply_filters('woocommerce_inventory_settings', array( - array( 'name' => __( 'Inventory Options', 'woocommerce' ), 'type' => 'title','desc' => '', 'id' => 'inventory_options' ), + array( 'title' => __( 'Inventory Options', 'woocommerce' ), 'type' => 'title','desc' => '', 'id' => 'inventory_options' ), array( - 'name' => __( 'Manage Stock', 'woocommerce' ), + 'title' => __( 'Manage Stock', 'woocommerce' ), 'desc' => __( 'Enable stock management', 'woocommerce' ), 'id' => 'woocommerce_manage_stock', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox' ), array( - 'name' => __( 'Notifications', 'woocommerce' ), + 'title' => __( 'Notifications', 'woocommerce' ), 'desc' => __( 'Enable low stock notifications', 'woocommerce' ), 'id' => 'woocommerce_notify_low_stock', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'start' ), @@ -786,13 +798,13 @@ $woocommerce_settings['inventory'] = apply_filters('woocommerce_inventory_settin array( 'desc' => __( 'Enable out of stock notifications', 'woocommerce' ), 'id' => 'woocommerce_notify_no_stock', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'end' ), array( - 'name' => __( 'Low Stock Threshold', 'woocommerce' ), + 'title' => __( 'Low Stock Threshold', 'woocommerce' ), 'desc' => '', 'id' => 'woocommerce_notify_low_stock_amount', 'css' => 'width:50px;', @@ -801,11 +813,11 @@ $woocommerce_settings['inventory'] = apply_filters('woocommerce_inventory_settin 'min' => 0, 'step' => 1 ), - 'std' => '2' + 'default' => '2' ), array( - 'name' => __( 'Out Of Stock Threshold', 'woocommerce' ), + 'title' => __( 'Out Of Stock Threshold', 'woocommerce' ), 'desc' => '', 'id' => 'woocommerce_notify_no_stock_amount', 'css' => 'width:50px;', @@ -814,23 +826,23 @@ $woocommerce_settings['inventory'] = apply_filters('woocommerce_inventory_settin 'min' => 0, 'step' => 1 ), - 'std' => '0' + 'default' => '0' ), array( - 'name' => __( 'Out Of Stock Visibility', 'woocommerce' ), + 'title' => __( 'Out Of Stock Visibility', 'woocommerce' ), 'desc' => __( 'Hide out of stock items from the catalog', 'woocommerce' ), 'id' => 'woocommerce_hide_out_of_stock_items', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox' ), array( - 'name' => __( 'Stock Display Format', 'woocommerce' ), + 'title' => __( 'Stock Display Format', 'woocommerce' ), 'desc' => __( 'This controls how stock is displayed on the frontend.', 'woocommerce' ), 'id' => 'woocommerce_stock_format', 'css' => 'min-width:150px;', - 'std' => '', + 'default' => '', 'type' => 'select', 'options' => array( '' => __( 'Always show stock e.g. "12 in stock"', 'woocommerce' ), @@ -847,13 +859,13 @@ $woocommerce_settings['inventory'] = apply_filters('woocommerce_inventory_settin $woocommerce_settings['shipping'] = apply_filters('woocommerce_shipping_settings', array( - array( 'name' => __( 'Shipping Options', 'woocommerce' ), 'type' => 'title', 'id' => 'shipping_options' ), + array( 'title' => __( 'Shipping Options', 'woocommerce' ), 'type' => 'title', 'id' => 'shipping_options' ), array( - 'name' => __( 'Shipping Calculations', 'woocommerce' ), + 'title' => __( 'Shipping Calculations', 'woocommerce' ), 'desc' => __( 'Enable shipping', 'woocommerce' ), 'id' => 'woocommerce_calc_shipping', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'start' ), @@ -861,7 +873,7 @@ $woocommerce_settings['shipping'] = apply_filters('woocommerce_shipping_settings array( 'desc' => __( 'Enable the shipping calculator on the cart page', 'woocommerce' ), 'id' => 'woocommerce_enable_shipping_calc', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => '' ), @@ -869,17 +881,17 @@ $woocommerce_settings['shipping'] = apply_filters('woocommerce_shipping_settings array( 'desc' => __( 'Hide shipping costs until an address is entered', 'woocommerce' ), 'id' => 'woocommerce_shipping_cost_requires_address', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'end' ), array( - 'name' => __( 'Shipping Method Display', 'woocommerce' ), + 'title' => __( 'Shipping Method Display', 'woocommerce' ), 'desc' => __( 'This controls how multiple shipping methods are displayed on the frontend.', 'woocommerce' ), 'id' => 'woocommerce_shipping_method_format', 'css' => 'min-width:150px;', - 'std' => '', + 'default' => '', 'type' => 'select', 'options' => array( '' => __( 'Radio buttons', 'woocommerce' ), @@ -889,10 +901,10 @@ $woocommerce_settings['shipping'] = apply_filters('woocommerce_shipping_settings ), array( - 'name' => __( 'Shipping Destination', 'woocommerce' ), + 'title' => __( 'Shipping Destination', 'woocommerce' ), 'desc' => __( 'Only ship to the users billing address', 'woocommerce' ), 'id' => 'woocommerce_ship_to_billing_address_only', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'start' ), @@ -900,7 +912,7 @@ $woocommerce_settings['shipping'] = apply_filters('woocommerce_shipping_settings array( 'desc' => __( 'Ship to billing address by default', 'woocommerce' ), 'id' => 'woocommerce_ship_to_same_address', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => '' ), @@ -908,7 +920,7 @@ $woocommerce_settings['shipping'] = apply_filters('woocommerce_shipping_settings array( 'desc' => __( 'Collect shipping address even when not required', 'woocommerce' ), 'id' => 'woocommerce_require_shipping_address', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'end' ), @@ -924,7 +936,7 @@ $woocommerce_settings['shipping'] = apply_filters('woocommerce_shipping_settings $woocommerce_settings['payment_gateways'] = apply_filters('woocommerce_payment_gateways_settings', array( - array( 'name' => __( 'Payment Gateways', 'woocommerce' ), 'desc' => __( 'Installed payment gateways are displayed below. Drag and drop payment gateways to control their display order on the checkout.', 'woocommerce' ), 'type' => 'title', 'id' => 'payment_gateways_options' ), + array( 'title' => __( 'Payment Gateways', 'woocommerce' ), 'desc' => __( 'Installed payment gateways are displayed below. Drag and drop payment gateways to control their display order on the checkout.', 'woocommerce' ), 'type' => 'title', 'id' => 'payment_gateways_options' ), array( 'type' => 'payment_gateways', @@ -942,21 +954,21 @@ if ( $tax_classes ) $woocommerce_settings['tax'] = apply_filters('woocommerce_tax_settings', array( - array( 'name' => __( 'Tax Options', 'woocommerce' ), 'type' => 'title','desc' => '', 'id' => 'tax_options' ), + array( 'title' => __( 'Tax Options', 'woocommerce' ), 'type' => 'title','desc' => '', 'id' => 'tax_options' ), array( - 'name' => __( 'Tax Calculations', 'woocommerce' ), + 'title' => __( 'Tax Calculations', 'woocommerce' ), 'desc' => __( 'Enable taxes and tax calculations', 'woocommerce' ), 'id' => 'woocommerce_calc_taxes', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox' ), array( - 'name' => __( 'Calculation Settings', 'woocommerce' ), + 'title' => __( 'Calculation Settings', 'woocommerce' ), 'desc' => __( 'Calculate tax based on the customer shipping address', 'woocommerce' ), 'id' => 'woocommerce_tax_shipping_address', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'start' ), @@ -964,7 +976,7 @@ $woocommerce_settings['tax'] = apply_filters('woocommerce_tax_settings', array( array( 'desc' => __( 'Round tax at subtotal level, instead of rounding per line', 'woocommerce' ), 'id' => 'woocommerce_tax_round_at_subtotal', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => '' ), @@ -972,16 +984,16 @@ $woocommerce_settings['tax'] = apply_filters('woocommerce_tax_settings', array( array( 'desc' => sprintf( __( 'Display the tax total when tax is %s', 'woocommerce' ), woocommerce_price( 0 ) ), 'id' => 'woocommerce_display_cart_taxes_if_zero', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'end', ), array( - 'name' => __( 'Catalog Prices', 'woocommerce' ), + 'title' => __( 'Catalog Prices', 'woocommerce' ), 'desc' => __( 'Prices include tax', 'woocommerce' ), 'id' => 'woocommerce_prices_include_tax', - 'std' => 'no', + 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'start', 'show_if_checked' => 'option', @@ -990,7 +1002,7 @@ $woocommerce_settings['tax'] = apply_filters('woocommerce_tax_settings', array( array( 'desc' => __( 'Display cart items excluding tax', 'woocommerce' ), 'id' => 'woocommerce_display_cart_prices_excluding_tax', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => '', 'show_if_checked' => 'yes', @@ -999,38 +1011,38 @@ $woocommerce_settings['tax'] = apply_filters('woocommerce_tax_settings', array( array( 'desc' => __( 'Display cart totals excluding tax', 'woocommerce' ), 'id' => 'woocommerce_display_totals_excluding_tax', - 'std' => 'yes', + 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'end', 'show_if_checked' => 'yes', ), array( - 'name' => __( 'Shipping Tax Class', 'woocommerce' ), + 'title' => __( 'Shipping Tax Class', 'woocommerce' ), 'desc' => __( 'Optionally control which tax class shipping gets, or leave it so shipping tax is based on the cart items themselves.', 'woocommerce' ), 'id' => 'woocommerce_shipping_tax_class', 'css' => 'min-width:150px;', - 'std' => 'title', + 'default' => 'title', 'type' => 'select', 'options' => array( '' => 'Shipping tax class based on cart items', 'standard' => __( 'Standard', 'woocommerce' ) ) + $classes_options, 'desc_tip' => true, ), array( - 'name' => __( 'Additional Tax classes', 'woocommerce' ), + 'title' => __( 'Additional Tax classes', 'woocommerce' ), 'desc' => __( 'List additonal tax classes below (1 per line). This is in addition to the default Standard Rate.', 'woocommerce' ), 'id' => 'woocommerce_tax_classes', 'css' => 'width:100%; height: 65px;', 'type' => 'textarea', - 'std' => sprintf( __( 'Reduced Rate%sZero Rate', 'woocommerce' ), PHP_EOL ) + 'default' => sprintf( __( 'Reduced Rate%sZero Rate', 'woocommerce' ), PHP_EOL ) ), array( - 'name' => __( 'Tax Rates', 'woocommerce' ), + 'title' => __( 'Tax Rates', 'woocommerce' ), 'id' => 'woocommerce_tax_rates', 'css' => 'min-width:50px;', 'type' => 'tax_rates', - 'std' => '' + 'default' => '' ), array( 'type' => 'sectionend', 'id' => 'tax_options' ), @@ -1041,19 +1053,19 @@ $woocommerce_settings['email'] = apply_filters('woocommerce_email_settings', arr array( 'type' => 'sectionend', 'id' => 'email_recipient_options' ), - array( 'name' => __( 'Email Sender Options', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect the sender (email address and name) used in WooCommerce emails.', 'woocommerce' ), 'id' => 'email_options' ), + array( 'title' => __( 'Email Sender Options', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect the sender (email address and name) used in WooCommerce emails.', 'woocommerce' ), 'id' => 'email_options' ), array( - 'name' => __( '"From" Name', 'woocommerce' ), + 'title' => __( '"From" Name', 'woocommerce' ), 'desc' => '', 'id' => 'woocommerce_email_from_name', 'type' => 'text', 'css' => 'min-width:300px;', - 'std' => esc_attr(get_bloginfo('name')) + 'default' => esc_attr(get_bloginfo('title')) ), array( - 'name' => __( '"From" Email Address', 'woocommerce' ), + 'title' => __( '"From" Email Address', 'woocommerce' ), 'desc' => '', 'id' => 'woocommerce_email_from_address', 'type' => 'email', @@ -1061,65 +1073,65 @@ $woocommerce_settings['email'] = apply_filters('woocommerce_email_settings', arr 'multiple' => 'multiple' ), 'css' => 'min-width:300px;', - 'std' => get_option('admin_email') + 'default' => get_option('admin_email') ), array( 'type' => 'sectionend', 'id' => 'email_options' ), - array( 'name' => __( 'Email Template', 'woocommerce' ), 'type' => 'title', 'desc' => sprintf(__( 'This section lets you customise the WooCommerce emails. Click here to preview your email template. For more advanced control copy woocommerce/templates/emails/ to yourtheme/woocommerce/emails/.', 'woocommerce' ), wp_nonce_url(admin_url('?preview_woocommerce_mail=true'), 'preview-mail')), 'id' => 'email_template_options' ), + array( 'title' => __( 'Email Template', 'woocommerce' ), 'type' => 'title', 'desc' => sprintf(__( 'This section lets you customise the WooCommerce emails. Click here to preview your email template. For more advanced control copy woocommerce/templates/emails/ to yourtheme/woocommerce/emails/.', 'woocommerce' ), wp_nonce_url(admin_url('?preview_woocommerce_mail=true'), 'preview-mail')), 'id' => 'email_template_options' ), array( - 'name' => __( 'Header Image', 'woocommerce' ), + 'title' => __( 'Header Image', 'woocommerce' ), 'desc' => sprintf(__( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the media uploader.', 'woocommerce' ), admin_url('media-new.php')), 'id' => 'woocommerce_email_header_image', 'type' => 'text', 'css' => 'min-width:300px;', - 'std' => '' + 'default' => '' ), array( - 'name' => __( 'Email Footer Text', 'woocommerce' ), + 'title' => __( 'Email Footer Text', 'woocommerce' ), 'desc' => __( 'The text to appear in the footer of WooCommerce emails.', 'woocommerce' ), 'id' => 'woocommerce_email_footer_text', 'css' => 'width:100%; height: 75px;', 'type' => 'textarea', - 'std' => get_bloginfo('name') . ' - ' . __( 'Powered by WooCommerce', 'woocommerce' ) + 'default' => get_bloginfo('title') . ' - ' . __( 'Powered by WooCommerce', 'woocommerce' ) ), array( - 'name' => __( 'Base Colour', 'woocommerce' ), + 'title' => __( 'Base Colour', 'woocommerce' ), 'desc' => __( 'The base colour for WooCommerce email templates. Default #557da1.', 'woocommerce' ), 'id' => 'woocommerce_email_base_color', 'type' => 'color', 'css' => 'width:6em;', - 'std' => '#557da1' + 'default' => '#557da1' ), array( - 'name' => __( 'Background Colour', 'woocommerce' ), + 'title' => __( 'Background Colour', 'woocommerce' ), 'desc' => __( 'The background colour for WooCommerce email templates. Default #f5f5f5.', 'woocommerce' ), 'id' => 'woocommerce_email_background_color', 'type' => 'color', 'css' => 'width:6em;', - 'std' => '#f5f5f5' + 'default' => '#f5f5f5' ), array( - 'name' => __( 'Email Body Background Colour', 'woocommerce' ), + 'title' => __( 'Email Body Background Colour', 'woocommerce' ), 'desc' => __( 'The main body background colour. Default #fdfdfd.', 'woocommerce' ), 'id' => 'woocommerce_email_body_background_color', 'type' => 'color', 'css' => 'width:6em;', - 'std' => '#fdfdfd' + 'default' => '#fdfdfd' ), array( - 'name' => __( 'Email Body Text Colour', 'woocommerce' ), + 'title' => __( 'Email Body Text Colour', 'woocommerce' ), 'desc' => __( 'The main body text colour. Default #505050.', 'woocommerce' ), 'id' => 'woocommerce_email_text_color', 'type' => 'color', 'css' => 'width:6em;', - 'std' => '#505050' + 'default' => '#505050' ), array( 'type' => 'sectionend', 'id' => 'email_template_options' ), diff --git a/admin/settings/settings-save.php b/admin/settings/settings-save.php index 5c085f53aae..f0044a4cd8c 100644 --- a/admin/settings/settings-save.php +++ b/admin/settings/settings-save.php @@ -23,13 +23,20 @@ function woocommerce_update_options( $options ) { if ( empty( $_POST ) ) return false; - + + // Options to update will be stored here + $update_options = array(); + + // Loop options and get values to save foreach ( $options as $value ) { if ( ! isset( $value['id'] ) ) continue; $type = isset( $value['type'] ) ? sanitize_title( $value['type'] ) : ''; + + // Get the option name + $option_value = null; switch ( $type ) { @@ -37,9 +44,9 @@ function woocommerce_update_options( $options ) { case "checkbox" : if ( isset( $_POST[$value['id']] ) ) { - update_option( $value['id'], 'yes' ); + $option_value = 'yes'; } else { - update_option( $value['id'], 'no' ); + $option_value = 'no'; } break; @@ -47,9 +54,9 @@ function woocommerce_update_options( $options ) { case "textarea" : if ( isset( $_POST[$value['id']] ) ) { - update_option( $value['id'], wp_kses_post( $_POST[ $value['id'] ] ) ); + $option_value = wp_kses_post( $_POST[ $value['id'] ] ); } else { - delete_option( $value['id'] ); + $option_value = ''; } break; @@ -67,17 +74,17 @@ function woocommerce_update_options( $options ) { // price separators get a special treatment as they should allow a spaces (don't trim) if ( isset( $_POST[ $value['id'] ] ) ) { - update_option( $value['id'], esc_attr( $_POST[ $value['id'] ] ) ); + $option_value = esc_attr( $_POST[ $value['id'] ] ); } else { - delete_option( $value['id'] ); + $option_value = ''; } } else { if ( isset( $_POST[$value['id']] ) ) { - update_option( $value['id'], woocommerce_clean( $_POST[ $value['id'] ] ) ); + $option_value = woocommerce_clean( $_POST[ $value['id'] ] ); } else { - delete_option( $value['id'] ); + $option_value = ''; } } @@ -137,8 +144,8 @@ function woocommerce_update_options( $options ) { ); } } - - update_option( 'woocommerce_tax_rates', $tax_rates ); + + $update_options[ 'woocommerce_tax_rates' ] = $tax_rates; // Local tax rates saving $local_tax_rates = array(); @@ -196,8 +203,8 @@ function woocommerce_update_options( $options ) { ); } } - - update_option( 'woocommerce_local_tax_rates', $local_tax_rates ); + + $update_options[ 'woocommerce_local_tax_rates' ] = $local_tax_rates; break; @@ -209,26 +216,26 @@ function woocommerce_update_options( $options ) { else $selected_countries = array(); - update_option( $value['id'], $selected_countries ); + $option_value = $selected_countries; break; case "image_width" : - if ( isset( $_POST[$value['id'] . '_width'] ) ) { + if ( isset( $_POST[$value['id'] ]['width'] ) ) { - update_option( $value['id'] . '_width', woocommerce_clean( $_POST[ $value['id'] . '_width'] ) ); - update_option( $value['id'] . '_height', woocommerce_clean( $_POST[ $value['id'] . '_height'] ) ); + $update_options[ $value['id'] ]['width'] = woocommerce_clean( $_POST[$value['id'] ]['width'] ); + $update_options[ $value['id'] ]['height'] = woocommerce_clean( $_POST[$value['id'] ]['height'] ); - if ( isset( $_POST[ $value['id'] . '_crop'] ) ) - update_option( $value['id'] . '_crop', 1 ); + if ( isset( $_POST[ $value['id'] ]['crop'] ) ) + $update_options[ $value['id'] ]['crop'] = 1; else - update_option( $value['id'].'_crop', 0 ); + $update_options[ $value['id'] ]['crop'] = 0; } else { - update_option( $value['id'] . '_width', $value['std'] ); - update_option( $value['id'] . '_height', $value['std'] ); - update_option( $value['id'] . '_crop', 1 ); + $update_options[ $value['id'] ]['width'] = $value['default']['width']; + $update_options[ $value['id'] ]['height'] = $value['default']['height']; + $update_options[ $value['id'] ]['crop'] = $value['default']['crop']; } break; @@ -242,9 +249,40 @@ function woocommerce_update_options( $options ) { } + if ( ! is_null( $option_value ) ) { + // Check if option is an array + if ( strstr( $value['id'], '[' ) ) { + + parse_str( $value['id'], $option_array ); + + // Option name is first key + $option_name = current( array_keys( $option_array ) ); + + // Get old option value + 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(); + + // Set keys and value + $key = key( $option_array[ $option_name ] ); + + $update_options[ $option_name ][ $key ] = $option_value; + + // Single value + } else { + $update_options[ $value['id'] ] = $option_value; + } + } + // Custom handling do_action( 'woocommerce_update_option', $value ); - } + + // Now save the options + foreach( $update_options as $name => $value ) + update_option( $name, $value, true ); + return true; } \ No newline at end of file diff --git a/admin/woocommerce-admin-install.php b/admin/woocommerce-admin-install.php index 520a672a96e..6d077d8b16c 100644 --- a/admin/woocommerce-admin-install.php +++ b/admin/woocommerce-admin-install.php @@ -111,14 +111,8 @@ function woocommerce_default_options() { foreach ( $woocommerce_settings as $section ) { foreach ( $section as $value ) { - if ( isset( $value['std'] ) && isset( $value['id'] ) ) { - if ( $value['type'] == 'image_width' ) { - add_option( $value['id'] . '_width', $value['std'] ); - add_option( $value['id'] . '_height', $value['std'] ); - add_option( $value['id'] . '_crop', 1 ); - } else { - add_option( $value['id'], $value['std'] ); - } + if ( isset( $value['default'] ) && isset( $value['id'] ) ) { + add_option( $value['id'], $value['default'] ); } } } diff --git a/admin/woocommerce-admin-settings.php b/admin/woocommerce-admin-settings.php index 9b2c16994b7..c757759f3fd 100644 --- a/admin/woocommerce-admin-settings.php +++ b/admin/woocommerce-admin-settings.php @@ -490,6 +490,45 @@ if ( ! function_exists( 'woocommerce_settings' ) ) { } +/** + * Get a setting from the settings API. + * + * @access public + * @param mixed $option + * @return void + */ +function woocommerce_settings_get_option( $option_name, $default = '' ) { + // Array value + if ( strstr( $option_name, '[' ) ) { + + parse_str( $option_name, $option_array ); + + // Option name is first key + $option_name = current( array_keys( $option_array ) ); + + // Get value + $option_values = get_option( $option_name, '' ); + + $key = key( $option_array[ $option_name ] ); + + if ( isset( $option_values[ $key ] ) ) + $option_value = $option_values[ $key ]; + else + $option_value = null; + + // Single value + } else { + $option_value = get_option( $option_name, null ); + } + + if ( is_array( $option_value ) ) + $option_value = array_map( 'stripslashes', $option_value ); + elseif ( $option_value ) + $option_value = stripslashes( $option_value ); + + return $option_value == null ? $default : $option_value; +} + /** * Output admin fields. * @@ -505,10 +544,10 @@ function woocommerce_admin_fields( $options ) { foreach ( $options as $value ) { if ( ! isset( $value['type'] ) ) continue; if ( ! isset( $value['id'] ) ) $value['id'] = ''; - if ( ! isset( $value['name'] ) ) $value['name'] = ''; + if ( ! isset( $value['title'] ) ) $value['title'] = ''; if ( ! isset( $value['class'] ) ) $value['class'] = ''; if ( ! isset( $value['css'] ) ) $value['css'] = ''; - if ( ! isset( $value['std'] ) ) $value['std'] = ''; + if ( ! isset( $value['default'] ) ) $value['default'] = ''; if ( ! isset( $value['desc'] ) ) $value['desc'] = ''; if ( ! isset( $value['desc_tip'] ) ) $value['desc_tip'] = false; @@ -550,7 +589,7 @@ function woocommerce_admin_fields( $options ) { // Section Titles case 'title': - if ( ! empty( $value['name'] ) ) echo '

' . esc_html( $value['name'] ) . '

'; + if ( ! empty( $value['title'] ) ) echo '

' . esc_html( $value['title'] ) . '

'; if ( ! empty( $value['desc'] ) ) echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); echo ''. "\n\n"; if ( ! empty( $value['id'] ) ) do_action( 'woocommerce_settings_' . sanitize_title( $value['id'] ) ); @@ -571,7 +610,7 @@ function woocommerce_admin_fields( $options ) { $type = $value['type']; $class = ''; - $option_value = get_option( $value['id'], null ) !== null ? esc_attr( stripslashes( get_option($value['id'] ) ) ) : esc_attr( $value['std'] ); + $option_value = woocommerce_settings_get_option( $value['id'], $value['default'] ); if ( $value['type'] == 'color' ) { $type = 'text'; @@ -581,7 +620,7 @@ function woocommerce_admin_fields( $options ) { ?> + - + $value['id'], + + $args = array( 'title' => $value['id'], 'id' => $value['id'], 'sort_column' => 'menu_order', 'sort_order' => 'ASC', 'show_option_none' => ' ', 'class' => $value['class'], 'echo' => false, - 'selected' => absint( get_option( $value['id'] ) ) + 'selected' => absint( woocommerce_settings_get_option( $value['id'] ) ) ); if( isset( $value['args'] ) ) $args = wp_parse_args( $value['args'], $args ); ?> - + @@ -806,8 +841,10 @@ function woocommerce_admin_fields( $options ) { // Single country selects case 'single_select_country' : + + $country_setting = (string) woocommerce_settings_get_option( $value['id'] ); + $countries = $woocommerce->countries->countries; - $country_setting = (string) get_option($value['id']); if (strstr($country_setting, ':')) : $country = current(explode(':', $country_setting)); $state = end(explode(':', $country_setting)); @@ -817,7 +854,7 @@ function woocommerce_admin_fields( $options ) { endif; ?>
- + @@ -590,7 +629,7 @@ function woocommerce_admin_fields( $options ) { id="" type="" style="" - value="" + value="" class="" /> @@ -600,9 +639,12 @@ function woocommerce_admin_fields( $options ) { // Textarea case 'textarea': + + $option_value = woocommerce_settings_get_option( $value['id'], $value['default'] ); + ?>
- + @@ -614,12 +656,7 @@ function woocommerce_admin_fields( $options ) { style="" class="" - > + >
- + @@ -668,13 +703,11 @@ function woocommerce_admin_fields( $options ) { // Radio inputs case 'radio' : - $option_value = get_option( $value['id'] ); - if ( ! $option_value ) - $option_value = $value['std']; + $option_value = woocommerce_settings_get_option( $value['id'], $value['default'] ); ?>
- + @@ -706,6 +739,8 @@ function woocommerce_admin_fields( $options ) { // Checkbox input case 'checkbox' : + + $option_value = woocommerce_settings_get_option( $value['id'], $value['default'] ); if ( ! isset( $value['hide_if_checked'] ) ) $value['hide_if_checked'] = false; if ( ! isset( $value['show_if_checked'] ) ) $value['show_if_checked'] = false; @@ -717,7 +752,7 @@ function woocommerce_admin_fields( $options ) { if ( $value['hide_if_checked'] == 'option' ) echo 'hide_options_if_checked'; if ( $value['show_if_checked'] == 'option' ) echo 'show_options_if_checked'; ?>"> -
- +
- + - + - +
- +
- + diff --git a/classes/abstracts/abstract-wc-product.php b/classes/abstracts/abstract-wc-product.php index 7db9d3af9fd..25d41bf408e 100644 --- a/classes/abstracts/abstract-wc-product.php +++ b/classes/abstracts/abstract-wc-product.php @@ -1184,7 +1184,7 @@ abstract class WC_Product { } elseif ( ( $parent_id = wp_get_post_parent_id( $this->id ) ) && has_post_thumbnail( $parent_id ) ) { $image = get_the_post_thumbnail( $parent_id, $size ); } else { - $image = 'Placeholder'; + $image = woocommerce_placeholder_img( $size ); } return $image; diff --git a/classes/class-wc-product-variation.php b/classes/class-wc-product-variation.php index cd8508ca106..c15331365e0 100644 --- a/classes/class-wc-product-variation.php +++ b/classes/class-wc-product-variation.php @@ -297,7 +297,7 @@ class WC_Product_Variation extends WC_Product { } elseif ( $parent_id = wp_get_post_parent_id( $this->id ) && has_post_thumbnail( $parent_id ) ) { $image = get_the_post_thumbnail( $parent_id, $size ); } else { - $image = 'Placeholder'; + $image = woocommerce_placeholder_img( $size ); } return $image; diff --git a/widgets/widget-best_sellers.php b/widgets/widget-best_sellers.php index 6a1b71c1b81..4d0ae9c7fb7 100644 --- a/widgets/widget-best_sellers.php +++ b/widgets/widget-best_sellers.php @@ -108,7 +108,12 @@ class WooCommerce_Widget_Best_Sellers extends WP_Widget {
    have_posts()) : $r->the_post(); global $product; ?>
  • - get_image_size('shop_thumbnail_image_width').'" height="'.$woocommerce->get_image_size('shop_thumbnail_image_height').'" />'; ?> + get_price_html(); ?>
  • diff --git a/widgets/widget-onsale.php b/widgets/widget-onsale.php index a9a548e920a..ec08b0dad9c 100644 --- a/widgets/widget-onsale.php +++ b/widgets/widget-onsale.php @@ -135,7 +135,12 @@ class WooCommerce_Widget_On_Sale extends WP_Widget {
      have_posts()) : $r->the_post(); global $product; ?>
    • - get_image_size('shop_thumbnail_image_width').'" height="'.$woocommerce->get_image_size('shop_thumbnail_image_height').'" />'; ?> + get_price_html(); ?>
    • diff --git a/widgets/widget-random_products.php b/widgets/widget-random_products.php index db65655181d..7989ac4691a 100644 --- a/widgets/widget-random_products.php +++ b/widgets/widget-random_products.php @@ -77,12 +77,12 @@ class WooCommerce_Widget_Random_Products extends WP_Widget { have_posts()) : $query->the_post(); global $product; ?>
    • - get_image_size( 'shop_thumbnail_image_width' ).'" height="'.$woocommerce->get_image_size( 'shop_thumbnail_image_height' ).'" />'; - } ?> + get_price_html() ?> diff --git a/widgets/widget-recent_products.php b/widgets/widget-recent_products.php index cacd408893e..4749f308434 100644 --- a/widgets/widget-recent_products.php +++ b/widgets/widget-recent_products.php @@ -97,7 +97,12 @@ class WooCommerce_Widget_Recent_Products extends WP_Widget {
        have_posts()) : $r->the_post(); global $product; ?>
      • - get_image_size('shop_thumbnail_image_width').'" height="'.$woocommerce->get_image_size('shop_thumbnail_image_height').'" />'; ?> + get_price_html(); ?>
      • diff --git a/widgets/widget-recently_viewed.php b/widgets/widget-recently_viewed.php index 27f2fbdf8c8..b5f96bdc098 100644 --- a/widgets/widget-recently_viewed.php +++ b/widgets/widget-recently_viewed.php @@ -92,7 +92,12 @@ class WooCommerce_Widget_Recently_Viewed extends WP_Widget {
          have_posts()) : $r->the_post(); global $product; ?>
        • - get_image_size('shop_thumbnail_image_width').'" height="'.$woocommerce->get_image_size('shop_thumbnail_image_height').'" />'; ?> + get_price_html(); ?>
        • diff --git a/woocommerce-core-functions.php b/woocommerce-core-functions.php index ce4a1b63525..724e3d48da2 100644 --- a/woocommerce-core-functions.php +++ b/woocommerce-core-functions.php @@ -137,7 +137,7 @@ function woocommerce_get_weight( $weight, $to_unit ) { /** - * Get the placeholder for products etc + * Get the placeholder image URL for products etc * * @access public * @return string @@ -149,6 +149,21 @@ function woocommerce_placeholder_img_src() { } +/** + * Get the placeholder image + * + * @access public + * @return string + */ +function woocommerce_placeholder_img( $size = 'shop_thumbnail' ) { + global $woocommerce; + + $dimensions = $woocommerce->get_image_size( $size ); + + return apply_filters('woocommerce_placeholder_img', 'Placeholder' ); +} + + /** * Send HTML emails from WooCommerce * diff --git a/woocommerce-template.php b/woocommerce-template.php index 7f556f51fac..7ef08e29c88 100644 --- a/woocommerce-template.php +++ b/woocommerce-template.php @@ -394,17 +394,12 @@ if ( ! function_exists( 'woocommerce_get_product_thumbnail' ) ) { * @return string */ function woocommerce_get_product_thumbnail( $size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0 ) { - global $post, $woocommerce; - - if ( ! $placeholder_width ) - $placeholder_width = $woocommerce->get_image_size( 'shop_catalog_image_width' ); - if ( ! $placeholder_height ) - $placeholder_height = $woocommerce->get_image_size( 'shop_catalog_image_height' ); + global $post; if ( has_post_thumbnail() ) return get_the_post_thumbnail( $post->ID, $size ); elseif ( woocommerce_placeholder_img_src() ) - return 'Placeholder'; + return woocommerce_placeholder_img( $size ); } } @@ -1176,14 +1171,12 @@ if ( ! function_exists( 'woocommerce_subcategory_thumbnail' ) ) { * @subpackage Loop * @return void */ - function woocommerce_subcategory_thumbnail( $category ) { + function woocommerce_subcategory_thumbnail( $category ) { global $woocommerce; - $small_thumbnail_size = apply_filters( 'single_product_small_thumbnail_size', 'shop_catalog' ); - $image_width = $woocommerce->get_image_size( 'shop_catalog_image_width' ); - $image_height = $woocommerce->get_image_size( 'shop_catalog_image_height' ); - - $thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true ); + $small_thumbnail_size = apply_filters( 'single_product_small_thumbnail_size', 'shop_catalog' ); + $dimensions = $woocommerce->get_image_size( $small_thumbnail_size ); + $thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true ); if ( $thumbnail_id ) { $image = wp_get_attachment_image_src( $thumbnail_id, $small_thumbnail_size ); @@ -1193,7 +1186,7 @@ if ( ! function_exists( 'woocommerce_subcategory_thumbnail' ) ) { } if ( $image ) - echo '' . $category->name . ''; + echo '' . $category->name . ''; } } diff --git a/woocommerce.php b/woocommerce.php index 6665453949e..755dad6e07f 100644 --- a/woocommerce.php +++ b/woocommerce.php @@ -1002,14 +1002,13 @@ class Woocommerce { * @return void */ function init_image_sizes() { - // Image sizes - $shop_thumbnail_crop = get_option('woocommerce_thumbnail_image_crop') == 1 ? true : false; - $shop_catalog_crop = get_option('woocommerce_catalog_image_crop') == 1 ? true : false; - $shop_single_crop = get_option('woocommerce_single_image_crop') == 1 ? true : false; + $shop_thumbnail = $this->get_image_size( 'shop_thumbnail' ); + $shop_catalog = $this->get_image_size( 'shop_catalog' ); + $shop_single = $this->get_image_size( 'shop_single' ); - add_image_size( 'shop_thumbnail', $this->get_image_size('shop_thumbnail_image_width'), $this->get_image_size('shop_thumbnail_image_height'), $shop_thumbnail_crop ); - add_image_size( 'shop_catalog', $this->get_image_size('shop_catalog_image_width'), $this->get_image_size('shop_catalog_image_height'), $shop_catalog_crop ); - add_image_size( 'shop_single', $this->get_image_size('shop_single_image_width'), $this->get_image_size('shop_single_image_height'), $shop_single_crop ); + add_image_size( 'shop_thumbnail', $shop_thumbnail['width'], $shop_thumbnail['height'], $shop_thumbnail['crop'] ); + add_image_size( 'shop_catalog', $shop_catalog['width'], $shop_catalog['height'], $shop_catalog['crop'] ); + add_image_size( 'shop_single', $shop_single['width'], $shop_single['height'], $shop_single['crop'] ); } @@ -1276,16 +1275,18 @@ class Woocommerce { * @return string */ function get_image_size( $image_size ) { - $return = ''; - switch ( $image_size ) { - case "shop_thumbnail_image_width" : $return = get_option('woocommerce_thumbnail_image_width'); break; - case "shop_thumbnail_image_height" : $return = get_option('woocommerce_thumbnail_image_height'); break; - case "shop_catalog_image_width" : $return = get_option('woocommerce_catalog_image_width'); break; - case "shop_catalog_image_height" : $return = get_option('woocommerce_catalog_image_height'); break; - case "shop_single_image_width" : $return = get_option('woocommerce_single_image_width'); break; - case "shop_single_image_height" : $return = get_option('woocommerce_single_image_height'); break; - } - return apply_filters( 'woocommerce_get_image_size_' . $image_size, $return ); + + // Only return sizes we define in settings + if ( ! in_array( $image_size, array( 'shop_thumbnail', 'shop_catalog', 'shop_single' ) ) ) + return apply_filters( 'woocommerce_get_image_size_' . $image_size, '' ); + + $size = get_option( $image_size . '_image', array() ); + + $size['width'] = isset( $size['width'] ) ? $size['width'] : '300'; + $size['height'] = isset( $size['height'] ) ? $size['height'] : '300'; + $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 1; + + return apply_filters( 'woocommerce_get_image_size_' . $image_size, $size ); } /** Messages ****************************************************************/