diff --git a/readme.txt b/readme.txt index a27abb3..6cf43ac 100644 --- a/readme.txt +++ b/readme.txt @@ -2,9 +2,9 @@ Contributors: hxii Tags: yotpo, shortcode, shortcodes, yotpo add-on, yotpo shortcodes, shortcodes for yotpo Requires at least: 4.6 -Requires PHP: 5.6 +Requires PHP: 7.0 Tested up to: 5.3 -Stable tag: 1.1.6 +Stable tag: 1.2.1 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -47,6 +47,12 @@ Get in touch, and I'll see what can be done. == Screenshots == 1. Example usage of the shortcodes. == Changelog == += 1.2.1 = +* Code cleanup. +* Added review highlights widget `[yotpo_highlights]` with optional `product_id` argument. +* Added Q&A widget `[yotpo_questions]` with optional `product_id` argument. += 1.2.0 = +* Now using Yotpo Reviews for WooCommerce (YRFW) as requirement. = 1.1.6 = * Showing notice to warn users prior to updating to 1.2.X versions. * Checked with latest version of WP. diff --git a/wc_yotpo_shortcodes.php b/wc_yotpo_shortcodes.php index 88ebbf6..fb83b34 100644 --- a/wc_yotpo_shortcodes.php +++ b/wc_yotpo_shortcodes.php @@ -2,7 +2,7 @@ /* * Plugin Name: Shortcodes for Yotpo * Description: This plugin adds the ability to use shortcodes to control the placement of Yotpo widgets. -* Version: 1.1.6 +* Version: 1.2.1 * Author: Paul Glushak * Author URI: http://paulglushak.com/ * Plugin URI: http://paulglushak.com/shortcodes-for-yotpo/ @@ -12,81 +12,113 @@ /* * This plugin allows using shortcodes to display Yotpo widgets inside and oustide (applicable widgets only) of product pages e.g. page builders, sidebars, widgets etc. - * See example usage at the bottom. */ -// if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly -defined( 'ABSPATH' ) or die(); +defined( 'ABSPATH' ) || die(); /** * Shortcodes! */ -class Yotpo_Shortcodes -{ +class Yotpo_Shortcodes { - function __construct() - { - $this->init_shortcodes(); + /** + * Run the init function on construction via action + * + * @since 1.2.0 + */ + public function __construct() { + add_action( 'plugins_loaded', array( $this, 'init_shortcodes' ) ); } - function init_shortcodes() { - add_shortcode( 'yotpo_widget', array( $this, 'yotpo_widget' ) ); - add_shortcode( 'yotpo_bottomline', array( $this, 'yotpo_bottomline' ) ); - add_shortcode( 'yotpo_product_gallery', array( $this, 'yotpo_product_gallery' ) ); - add_shortcode( 'yotpo_product_reviews_carousel', array( $this, 'yotpo_product_reviews_carousel' ) ); - add_shortcode( 'yotpo_badge', array( $this, 'yotpo_badge' ) ); - add_shortcode( 'yotpo_testimonials', array( $this, 'yotpo_testimonials' ) ); - add_action( 'admin_notices', array( $this, 'show_upgrade_message' ) ); + /** + * Set short transient for thank-you message + * + * @return void + * @since 1.2.1 + */ + public function activate() { + set_transient( 'yotpo_shortcodes_message', true, 5 ); } + /** - * Basic dependency check, to be replaced with class requirement + * Registers all the shortcodes in WP * * @return void - **/ - private function basic_check() { - if ( !class_exists( 'woocommerce' ) ) { - return; - } elseif ( !function_exists( 'wc_yotpo_get_product_data' ) ) { - $plugins = get_option( 'active_plugins', array() ); - if ( array_search('wc_yotpo.php', $plugins) ) { - require_once( ABSPATH . 'wp-content/plugins/yotpo-social-reviews-for-woocommerce/wc_yotpo.php' ); - } else { - die(); + * @since 1.2.0 + */ + public function init_shortcodes() { + if ( class_exists( 'YRFW_Reviews' ) ) { + if ( get_transient( 'yotpo_shortcodes_message' ) ) { + new YRFW_Messages( 'Thank you for installing Shortcodes for Yotpo! Please consider leaving a review, it really helps!', 'success', true, true ); } + add_shortcode( 'yotpo_widget', array( $this, 'yotpo_widget' ) ); + add_shortcode( 'yotpo_bottomline', array( $this, 'yotpo_bottomline' ) ); + add_shortcode( 'yotpo_questions', array( $this, 'yotpo_questions' ) ); + add_shortcode( 'yotpo_product_gallery', array( $this, 'yotpo_product_gallery' ) ); + add_shortcode( 'yotpo_product_reviews_carousel', array( $this, 'yotpo_product_reviews_carousel' ) ); + add_shortcode( 'yotpo_badge', array( $this, 'yotpo_badge' ) ); + add_shortcode( 'yotpo_testimonials', array( $this, 'yotpo_testimonials' ) ); + add_shortcode( 'yotpo_highlights', array( $this, 'yotpo_highlights' ) ); + } else { + add_action( + 'admin_notices', + function() { + ?> +
Please install and/or activate Yotpo Reviews for WooCommerce in order for Shortcodes for Yotpo to work.
+Shortcodes for Yotpo - Please note that the next update of Shortcodes for Yotpo (version 1.2.1) will require Yotpo Reviews for WooCommerce (YRFW) to function.
-
Please make sure you install and configure YRFW when updating Shortcodes for Yotpo. For more information, please see here.