PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.5.2
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.5.2
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / compatibility / class-wpo-kd-submissions-compatibility.php

class-wpo-kd-submissions-compatibility.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 4.5.2, at compatibility/class-wpo-kd-submissions-compatibility.php

101 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) die('No direct access allowed');
4
5 if (!class_exists('WPO_KD_Submissions_Compatibility')) :
6
7 /**
8 * Class to handle compatibility with KD Submissions plugin
9 */
10 class WPO_KD_Submissions_Compatibility {
11
12 /**
13 * Constructor
14 */
15 private function __construct() {
16 add_filter('wp_optimize_get_tables', array($this, 'check_kd_submissions_tables'));
17 }
18
19 /**
20 * Checks if KD Submissions tables should be marked as Elementor tables. If Elementor Pro is installed or active and KD Submissions tables are not marked as Elementor tables, then mark them as Elementor tables. This is needed to make sure that if Elementor Pro is installed, then KD Submissions tables are optimized with Elementor tables.
21 *
22 * @param array $tables
23 * @return array
24 */
25 public function check_kd_submissions_tables($tables) {
26 $is_elementor_pro_installed_or_active = $this->is_elementor_pro_installed_or_active();
27 $elementor_pro_status = $this->get_elementor_pro_status();
28
29 foreach ($tables as $key => $table) {
30 if (preg_match('/e_submissions_actions_log$/', $table->Name) || (false !== strpos($table->Name, '_e_') && $this->has_plugin_in_list('kd-submissions', $table->plugin_status))) {
31 if ($is_elementor_pro_installed_or_active && !$this->has_plugin_in_list('elementor-pro', $table->plugin_status)) {
32 $tables[$key]->plugin_status[] = array(
33 'plugin' => 'elementor-pro',
34 'status' => $elementor_pro_status,
35 );
36 }
37 }
38 }
39
40 return $tables;
41 }
42
43 /**
44 * Checks plugin status array and checks if selected plugin is already in the list.
45 *
46 * @param string $plugin
47 * @param array $plugin_status
48 * [
49 * [
50 * [plugin] => woocommerce
51 * [status] => Array
52 * (
53 * [installed] => (bool)
54 * [active] => (bool)
55 * )
56 * @return bool
57 */
58 private function has_plugin_in_list($plugin, $plugin_status) {
59 foreach ($plugin_status as $plugin_info) {
60 if ($plugin === $plugin_info['plugin']) return true;
61 }
62
63 return false;
64 }
65
66 /**
67 * Checks if Elementor Pro is installed or active. This is needed to check if KD Submissions tables should be marked as Elementor tables.
68 *
69 * @return boolean
70 */
71 private function is_elementor_pro_installed_or_active() {
72 $status = $this->get_elementor_pro_status();
73
74 return $status['installed'] || $status['active'];
75 }
76
77 /**
78 * Get Elementor Pro status
79 *
80 * @return array
81 */
82 private function get_elementor_pro_status() {
83 return WP_Optimize_Database_Information::instance()->get_plugin_status('elementor-pro');
84 }
85
86 /**
87 * Returns singleton instance
88 *
89 * @return WPO_KD_Submissions_Compatibility
90 */
91 public static function instance() {
92 static $_instance = null;
93 if (null === $_instance) {
94 $_instance = new self();
95 }
96 return $_instance;
97 }
98 }
99
100 endif;
101