From 947837904174aa58527e55063da112fbabcef634 Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Fri, 17 May 2013 08:55:55 +0200 Subject: [PATCH] Backwards compat for #3118 --- classes/class-wc-shortcodes.php | 15 +++++++++------ woocommerce-template.php | 20 +++++++++++++++++--- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/classes/class-wc-shortcodes.php b/classes/class-wc-shortcodes.php index f600683d498..9b83617c190 100644 --- a/classes/class-wc-shortcodes.php +++ b/classes/class-wc-shortcodes.php @@ -1028,13 +1028,16 @@ class WC_Shortcodes { function related_products_shortcode( $atts ) { $atts = shortcode_atts( array( - 'per_page' => '2', - 'columns' => '2', - 'orderby' => 'rand', + 'posts_per_page' => '2', + 'columns' => '2', + 'orderby' => 'rand', ), $atts); - $atts['posts_per_page'] = $atts['per_page']; - unset($atts['per_page']); + if ( isset( $atts['per_page'] ) ) { + _deprecated_argument( __CLASS__ . '->' . __FUNCTION__, '2.1', __( 'Use $args["posts_per_page"] instead. Deprecated argument will be removed in WC 2.1.', 'woocommerce' ) ); + $atts['posts_per_page'] = $atts['per_page']; + unset( $atts['per_page'] ); + } ob_start(); @@ -1042,4 +1045,4 @@ class WC_Shortcodes { return ob_get_clean(); } -} \ No newline at end of file +} diff --git a/woocommerce-template.php b/woocommerce-template.php index 7edef23557a..ccea8fcb6e9 100644 --- a/woocommerce-template.php +++ b/woocommerce-template.php @@ -840,14 +840,28 @@ if ( ! function_exists( 'woocommerce_related_products' ) ) { * Output the related products. * * @access public + * @param array Provided arguments + * @param bool Columns argument for backwards compat + * @param bool Order by argument for backwards compat * @return void */ - function woocommerce_related_products( $args = array() ) { + function woocommerce_related_products( $args = array(), $columns = false, $orderby = false ) { + if ( ! is_array( $args ) ) { + _deprecated_argument( __CLASS__ . '->' . __FUNCTION__, '2.1', __( 'Use $args argument as an array instead. Deprecated argument will be removed in WC 2.1.', 'woocommerce' ) ); + + $argsvalue = $args; + + $args = array( + 'posts_per_page' => $argsvalue, + 'columns' => $columns, + 'orderby' => $orderby, + ); + } $defaults = array( 'posts_per_page' => 2, - 'columns' => 2, - 'orderby' => 'rand' + 'columns' => 2, + 'orderby' => 'rand' ); $args = wp_parse_args( $args, $defaults );