PluginProbe ʕ •ᴥ•ʔ
Products Compare for WooCommerce / 3.6.2.6
Products Compare for WooCommerce v3.6.2.6
3.6.2.8 3.6.2.7 trunk 1.0.1 1.0.10 1.0.10.1 1.0.11 1.0.11.1 1.0.12 1.0.13 1.0.13.1 1.0.2 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 3.5 3.5.0.1 3.5.0.2 3.5.1 3.5.1.1 3.5.1.2 3.5.1.3 3.5.1.4 3.5.1.5 3.5.1.6 3.5.1.7 3.5.2 3.5.2.1 3.5.2.2 3.5.2.3 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.7.1 3.5.7.2 3.5.7.3 3.5.7.4 3.5.7.5 3.5.7.6 3.5.7.7 3.5.7.8 3.5.7.9 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.6.2.1 3.6.2.2 3.6.2.3 3.6.2.4 3.6.2.5 3.6.2.6
products-compare-for-woocommerce / divi / includes / CompareExtension.php
products-compare-for-woocommerce / divi / includes Last commit date
modules 2 months ago CompareExtension.php 2 months ago loader.js 2 months ago loader.php 2 months ago
CompareExtension.php
88 lines
1 <?php
2
3 class BRCMP_CompareExtension extends DiviExtension {
4 public $gettext_domain = 'brcompare-my-extension';
5 public $name = 'brcompare-extension';
6 public $version = '1.0.0';
7 public function __construct( $name = 'brcompare-extension', $args = array() ) {
8 $this->plugin_dir = plugin_dir_path( __FILE__ );
9 $this->plugin_dir_url = plugin_dir_url( $this->plugin_dir );
10
11 parent::__construct( $name, $args );
12 add_action('wp_ajax_brcompare_compare_table', array($this, 'compare_table'));
13 add_action('wp_ajax_brcompare_compare_button', array($this, 'compare_button'));
14 add_action('wp_ajax_brcompare_compare_widget', array($this, 'compare_widget'));
15 }
16 public function compare_widget() {
17 if ( ! current_user_can( 'manage_options' ) ) {
18 wp_die();
19 }
20 $atts = berocket_sanitize_array($_POST);
21 $atts = self::convert_on_off($atts);
22 if( ! empty($atts['toolbar']) ) {
23 echo '<div style="height:50px;"></div>';
24 }
25 the_widget( 'berocket_compare_products_widget', $atts );
26 wp_die();
27 }
28 public function compare_table() {
29 if ( ! current_user_can( 'manage_options' ) ) {
30 wp_die();
31 }
32 $filter = do_shortcode('[br_compare_table]');
33 echo $filter;
34 wp_die();
35 }
36 public function compare_button() {
37 if ( ! current_user_can( 'manage_options' ) ) {
38 wp_die();
39 }
40 $atts = berocket_sanitize_array($_POST);
41 $atts = self::convert_on_off($atts) ;
42 if( ! empty($atts['product']) ) {
43 if( $atts['product'] == 'latest' ) {
44 global $wpdb;
45 $atts['product'] = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'product' AND post_status = 'publish' ORDER BY ID DESC LIMIT 1");
46 } elseif( $atts['product'] == 'current' ) {
47 $atts['product'] = '';
48 }
49 }
50 do_action('br_compare_button_options', $atts);
51 wp_die();
52 }
53 public function wp_hook_enqueue_scripts() {
54 if ( $this->_debug ) {
55 $this->_enqueue_debug_bundles();
56 } else {
57 $this->_enqueue_bundles();
58 }
59
60 if ( et_core_is_fb_enabled() && ! et_builder_bfb_enabled() ) {
61 $this->_enqueue_backend_styles();
62 }
63
64 // Normalize the extension name to get actual script name. For example from 'divi-custom-modules' to `DiviCustomModules`.
65 $extension_name = str_replace( ' ', '', ucwords( str_replace( '-', ' ', $this->name ) ) );
66
67 // Enqueue frontend bundle's data.
68 if ( ! empty( $this->_frontend_js_data ) ) {
69 wp_localize_script( "{$this->name}-frontend-bundle", "{$extension_name}FrontendData", $this->_frontend_js_data );
70 }
71
72 // Enqueue builder bundle's data.
73 if ( et_core_is_fb_enabled() && ! empty( $this->_builder_js_data ) ) {
74 wp_localize_script( "{$this->name}-builder-bundle", "{$extension_name}BuilderData", $this->_builder_js_data );
75 }
76 }
77 public static function convert_on_off($atts) {
78 foreach($atts as &$attr) {
79 if( $attr === 'on' || $attr === 'off' ) {
80 $attr = ( $attr === 'on' ? TRUE : FALSE );
81 }
82 }
83 return $atts;
84 }
85 }
86
87 new BRCMP_CompareExtension;
88