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 / berocket / libraries / check_init.php
products-compare-for-woocommerce / berocket / libraries Last commit date
addons 2 months ago templates 2 months ago check_init.php 2 months ago feature_tab.php 2 months ago popup.php 2 months ago tippy.php 2 months ago tutorial.php 2 months ago wpml_compatibility.php 2 months ago
check_init.php
114 lines
1 <?php
2 if( ! class_exists('BeRocket_framework_check_init_lib') ) {
3 class BeRocket_framework_check_init_lib {
4 public $check_array = array();
5 public $notices = array();
6 public $check_result = array('exist' => false, 'result' => true);
7 function __construct($check_array = array()) {
8 $this->check_array = $check_array;
9 add_filter( 'berocket_display_additional_notices', array(
10 $this,
11 'framework_notice'
12 ) );
13 }
14 function check() {
15 $result = true;
16 if( ! empty($this->check_result['exist']) ) {
17 return $this->check_result['result'];
18 }
19 if( is_array($this->check_array) && count($this->check_array) ) {
20 $result = false;
21 foreach($this->check_array as $check_or) {
22 $break = false;
23 if( isset($check_or['check']) ) {
24 $check_or = $this->check_array;
25 $break = true;
26 }
27
28 if( is_array($check_or) ) {
29 $result_and = true;
30 foreach($check_or as $check_and) {
31 if( isset($check_and['check']) ) {
32 if( method_exists($this, 'check_'.$check_and['check']) ) {
33 $result_and = $result_and && $this->{'check_'.$check_and['check']}( (isset($check_and['data']) ? $check_and['data'] : array()) );
34 }
35 $result_and = apply_filters('BeRocket_framework_check_init_'.$check_and['check'], $result_and, $check_and);
36 }
37 }
38 $result = $result_and;
39 if( $result_and ) {
40 $break = true;
41 }
42 }
43
44 if( $break ) break;
45 }
46 }
47 $this->check_result = array('exist' => true, 'result' => $result);
48 return $result;
49 }
50 function check_woocommerce_version($data = array()) {
51 if( defined( 'WC_VERSION' ) ) {
52 $version = WC_VERSION;
53 $result = $this->version_compare($version, $data);
54 } elseif ( class_exists( 'WooCommerce' ) && function_exists('WC') ) {
55 $version = WC()->version;
56 $result = $this->version_compare($version, $data);
57 } else {
58 $result = ( is_plugin_active( 'woocommerce/woocommerce.php' ) || is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) );
59 $result = $result && $this->version_compare(br_get_woocommerce_version(), $data);
60 }
61 $this->show_notice($result, $data);
62 return $result;
63 }
64 function check_framework_version($data = array()) {
65 $framework_version = ( ( ! class_exists('BeRocket_Framework') || empty(BeRocket_Framework::$framework_version) ) ? '0' : BeRocket_Framework::$framework_version );
66 $result = $this->version_compare($framework_version, $data);
67 $this->show_notice($result, $data);
68 return $result;
69 }
70 function check_wordpress_version($data = array()) {
71 global $wp_version;
72 $result = $this->version_compare($wp_version, $data);
73 $this->show_notice($result, $data);
74 return $result;
75 }
76 function version_compare($version, $data) {
77 if( ! empty($data['version']) && ! empty($data['operator']) ) {
78 return version_compare($version, $data['version'], $data['operator']);
79 } else {
80 return true;
81 }
82 }
83 function show_notice($result, $data) {
84 if( ! $result && ! empty($data['notice']) ) {
85 $this->notices[] = array(
86 'start' => 0,
87 'end' => 0,
88 'name' => 'framework_init_check',
89 'html' => '<strong>'.$data['notice'].'</strong>',
90 'righthtml' => '',
91 'rightwidth' => 0,
92 'nothankswidth' => 0,
93 'contentwidth' => 1600,
94 'subscribe' => false,
95 'priority' => 10,
96 'height' => 50,
97 'repeat' => false,
98 'repeatcount' => 1,
99 'image' => array(
100 'local' => '',
101 'width' => 0,
102 'height' => 0,
103 'scale' => 1,
104 )
105 );
106 }
107 }
108 function framework_notice($notices) {
109 $notices = array_merge($this->notices, $notices);
110 return $notices;
111 }
112 }
113 }
114