PluginProbe
Ever Compare – Products Compare Plugin for WooCommerce / trunk
Ever Compare – Products Compare Plugin for WooCommerce vtrunk
1.3.7 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 trunk 1.0.0 1.0.1 1.0.2 All 31 releases
← All changes | ever-compare.php +59 -16 1.0.2trunk View file →
@@ -4,18 +4,17 @@
4 4 * Description: WooCommerce Product compare plugin
5 5 * Plugin URI: https://hasthemes.com/plugins/
6 6 * Author: HasTheme
7 7 * Author URI: https://hasthemes.com/
8 - * Version: 1.0.2
8 + * Version: 1.3.7
9 9 * License: GPL2 or later
10 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
11 11 * Text Domain: ever-compare
12 12 * Domain Path: /languages
13 - * WC tested up to: 5.1.0
13 + * WC tested up to: 10.0.2
14 14 */
15 15
16 16 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
17 -require_once __DIR__ . '/vendor/autoload.php';
18 17
19 18 /**
20 19 * Plugin Main Class
21 20 */
@@ -25,9 +24,9 @@
25 24 * Plugin version
26 25 *
27 26 * @var string
28 27 */
29 - const version = '1.0.2';
28 + const version = '1.3.7';
30 29
31 30 /**
32 31 * [$_instance]
33 32 * @var null
@@ -50,8 +49,9 @@
50 49 */
51 50 private function __construct(){
52 51
53 52 $this->define_constants();
53 + add_action( 'plugins_loaded', [ $this, 'includes' ] );
54 54
55 55 register_activation_hook( EVERCOMPARE_FILE, [ $this, 'activate' ] );
56 56
57 57 add_action( 'init', [ $this, 'i18n' ] );
@@ -56,8 +56,16 @@
56 56
57 57 add_action( 'init', [ $this, 'i18n' ] );
58 58 add_action( 'plugins_loaded', [ $this, 'init_plugin' ] );
59 59
60 + // Compatible With WooCommerce Features
61 + add_action( 'before_woocommerce_init', function() {
62 + if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
63 + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', EVERCOMPARE_FILE, true );
64 + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', EVERCOMPARE_FILE, true );
65 + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'product_block_editor', EVERCOMPARE_FILE, true );
66 + }
67 + } );
60 68 }
61 69
62 70 /**
63 71 * Define the required plugin constants
@@ -74,8 +82,17 @@
74 82 define( 'EVERCOMPARE_BASE', plugin_basename( EVERCOMPARE_FILE ) );
75 83 }
76 84
77 85 /**
86 + * [includes] Load file
87 + * @return [void]
88 + */
89 + public function includes(){
90 + require_once EVERCOMPARE_PATH . '/vendor/autoload.php';
91 + if ( ! function_exists('is_plugin_active') ){ include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); }
92 + }
93 +
94 + /**
78 95 * [i18n] Load text domain
79 96 * @return [void]
80 97 */
81 98 public function i18n() {
@@ -87,20 +104,25 @@
87 104 *
88 105 * @return void
89 106 */
90 107 public function init_plugin() {
91 - if ( ! function_exists('is_plugin_active') ){ include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); }
92 108
93 109 EverCompare\Assets::instance();
94 110
111 + if ( is_admin() ) {
112 + $this->admin_notices();
113 + EverCompare\Admin::instance();
114 + new EverCompare\Admin\Dashboard_Widget();
115 + }
116 +
117 + if ( ! ever_compare_woocommerce_installed() ) {
118 + return;
119 + }
120 +
95 121 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
96 122 EverCompare\Ajax::instance();
97 123 }
98 124
99 - if ( is_admin() ) {
100 - $this->admin_notices();
101 - EverCompare\Admin::instance();
102 - }
103 125 EverCompare\Frontend::instance();
104 126
105 127 // add image size
106 128 $this->set_image_size();
@@ -107,8 +129,21 @@
107 129
108 130 // let's filter the woocommerce image size
109 131 add_filter( 'woocommerce_get_image_size_ever-compare-image', [ $this, 'wc_image_filter_size' ], 10, 1 );
110 132
133 + // let's filter the speculation rules
134 + add_filter( 'wp_speculation_rules_href_exclude_paths', function( $exclude_paths ) {
135 + $compare_page_id = ever_compare_get_option( 'compare_page', 'ever_compare_table_settings_tabs' );
136 + if ( $compare_page_id ) {
137 + $compare_page_url = get_permalink( $compare_page_id );
138 + $compare_path = parse_url( $compare_page_url, PHP_URL_PATH );
139 + if ( $compare_path ) {
140 + $compare_path = trailingslashit( $compare_path );
141 + $exclude_paths[] = "{$compare_path}*";
142 + }
143 + }
144 + return $exclude_paths;
145 + });
111 146 }
112 147
113 148 /**
114 149 * Do stuff upon plugin activation
@@ -115,8 +150,9 @@
115 150 *
116 151 * @return void
117 152 */
118 153 public function activate() {
154 + $this->includes();
119 155 $installer = new EverCompare\Installer();
120 156 $installer->run();
121 157 }
122 158
@@ -133,9 +169,9 @@
133 169 * [set_image_size] Set Image Size
134 170 */
135 171 public function set_image_size(){
136 172
137 - $image_dimention = ever_compare_get_option( 'image_size', 'ever_compare_table_settings_tabs' );
173 + $image_dimention = ever_compare_get_option( 'image_size', 'ever_compare_table_settings_tabs', array( 'width'=>300, 'height'=>300 ) );
138 174 if( isset( $image_dimention ) && is_array( $image_dimention ) ){
139 175 $hard_crop = !empty( ever_compare_get_option( 'hard_crop', 'ever_compare_table_settings_tabs' ) ) ? true : false;
140 176 add_image_size( 'ever-compare-image', $image_dimention['width'], $image_dimention['height'], $hard_crop );
141 177 }
@@ -147,19 +183,24 @@
147 183 * @return [array]
148 184 */
149 185 public function wc_image_filter_size(){
150 186
151 - $image_dimention = ever_compare_get_option( 'image_size', 'ever_compare_table_settings_tabs' );
187 + $image_dimention = ever_compare_get_option( 'image_size', 'ever_compare_table_settings_tabs', array('width'=>300,'height'=>300) );
152 188 $hard_crop = !empty( ever_compare_get_option( 'hard_crop', 'ever_compare_table_settings_tabs' ) ) ? true : false;
153 189
154 190 if( isset( $image_dimention ) && is_array( $image_dimention ) ){
155 191 return array(
156 - 'width' => isset( $image_dimention['width'] ) ? absint( $image_dimention['width'] ) : 600,
157 - 'height' => isset( $image_dimention['height'] ) ? absint( $image_dimention['height'] ) : 600,
192 + 'width' => isset( $image_dimention['width'] ) ? absint( $image_dimention['width'] ) : 300,
193 + 'height' => isset( $image_dimention['height'] ) ? absint( $image_dimention['height'] ) : 300,
158 194 'crop' => isset( $hard_crop ) ? 1 : 0,
159 195 );
160 196 }
161 -
197 +
198 + return array(
199 + 'width' => 300,
200 + 'height' => 300,
201 + 'crop' => 0,
202 + );
162 203 }
163 204
164 205 }
165 206
@@ -168,9 +209,11 @@
168 209 *
169 210 * @return ever_compare
170 211 */
171 212 function ever_compare() {
172 - return Ever_Compare::instance();
213 + if( ! class_exists('Woolentor_Ever_Compare') ){
214 + return Ever_Compare::instance();
215 + }
173 216 }
174 217
175 218 // Start Our journey
176 -ever_compare();
219 +ever_compare();