PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.7.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.7.0
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
← All changes | compatibility/class-wpo-kd-submissions-compatibility.php +60 -4 4.6.1 → 4.7.0 View file →
@@ -31,8 +31,9 @@
31 31 * Constructor
32 32 */
33 33 private function __construct() {
34 34 add_filter('wp_optimize_get_tables', array($this, 'check_kd_submissions_tables'));
35 + add_filter('wp_optimize_get_table', array($this, 'check_kd_submissions_table'));
35 36 }
36 37
37 38 /**
38 39 * Associates KD Submissions tables with Elementor Pro when it is present.
@@ -40,22 +41,38 @@
40 41 * @param array<int, stdClass> $tables List of database table objects.
41 42 * @return array<int, stdClass> Updated list with corrected plugin associations.
42 43 */
43 44 public function check_kd_submissions_tables($tables) {
45 + $kd_submissions_status = $this->get_kd_submissions_status();
44 46 $elementor_pro_status = $this->get_elementor_pro_status();
45 47 $is_elementor_pro_available = $elementor_pro_status['installed'] || $elementor_pro_status['active'];
46 48
47 49 foreach ($tables as $key => $table) {
48 - if (!$this->is_kd_submissions_table($table)) {
50 + if (!$this->is_kd_submissions_table($table) && !$this->is_elementor_pro_table($table)) {
49 51 continue;
50 52 }
51 53
52 - if ($is_elementor_pro_available && !$this->has_plugin_in_list(self::ELEMENTOR_PRO_PLUGIN, $table->plugin_status)) {
54 + if (($is_elementor_pro_available || $this->is_elementor_pro_table($table)) && !$this->has_plugin_in_list(self::ELEMENTOR_PRO_PLUGIN, $table->plugin_status)) {
53 55 $tables[$key]->plugin_status[] = array(
54 56 'plugin' => self::ELEMENTOR_PRO_PLUGIN,
55 57 'status' => $elementor_pro_status,
56 58 );
59 +
60 + // Allow to remove the table when Elementor Pro and KD Submissions are inactive.
61 + $tables[$key]->can_be_removed = !$elementor_pro_status['active'] && !$kd_submissions_status['active'];
62 + } else {
63 + // If Elementor Pro is not available, ensure KD Submissions is associated
64 + if (!$this->has_plugin_in_list(self::KD_SUBMISSIONS_PLUGIN, $table->plugin_status)) {
65 + $tables[$key]->plugin_status[] = array(
66 + 'plugin' => self::KD_SUBMISSIONS_PLUGIN,
67 + 'status' => $kd_submissions_status,
68 + );
69 +
70 + // Allow to remove the table when KD Submissions is inactive.
71 + $tables[$key]->can_be_removed = !$kd_submissions_status['active'];
72 + }
57 73 }
74 +
58 75 }
59 76
60 77 return $tables;
61 78 }
@@ -60,8 +77,27 @@
60 77 return $tables;
61 78 }
62 79
63 80 /**
81 + * Associates a single KD Submissions table with Elementor Pro, if present.
82 + * If the provided table is not a KD Submissions table, it is returned unchanged.
83 + *
84 + * @param stdClass $table A database table object with a Name property and plugin_status array.
85 + * @return stdClass
86 + */
87 + public function check_kd_submissions_table($table) {
88 + if (!property_exists($table, 'Name')) return $table;
89 +
90 + $tables = array(
91 + $table->Name => $table,
92 + );
93 +
94 + $tables = $this->check_kd_submissions_tables($tables);
95 +
96 + return $tables[$table->Name];
97 + }
98 +
99 + /**
64 100 * Determines whether the given table belongs to KD Submissions.
65 101 *
66 102 * A table is identified as a KD Submissions table if its name matches
67 103 * the Elementor submissions actions log pattern, or if it contains the
@@ -70,14 +106,24 @@
70 106 * @param stdClass $table A database table object with a Name property and plugin_status array.
71 107 * @return bool
72 108 */
73 109 private function is_kd_submissions_table($table) {
110 + return false !== strpos($table->Name, '_e_')
111 + && $this->has_plugin_in_list(self::KD_SUBMISSIONS_PLUGIN, $table->plugin_status);
112 + }
113 +
114 + /**
115 + * Determines whether the given table belongs to Elementor Pro
116 + *
117 + * @param stdClass $table A database table object with a Name property and plugin_status array.
118 + * @return boolean
119 + */
120 + private function is_elementor_pro_table($table) {
74 121 if (preg_match('/e_submissions_actions_log$/', $table->Name)) {
75 122 return true;
76 123 }
77 124
78 - return false !== strpos($table->Name, '_e_')
79 - && $this->has_plugin_in_list(self::KD_SUBMISSIONS_PLUGIN, $table->plugin_status);
125 + return false;
80 126 }
81 127
82 128 /**
83 129 * Checks whether a given plugin is already present in the plugin status list.
@@ -101,8 +147,18 @@
101 147 */
102 148 private function get_elementor_pro_status() {
103 149 return WP_Optimize()->get_db_info()->get_plugin_status(self::ELEMENTOR_PRO_PLUGIN);
104 150 }
151 +
152 + /**
153 + * Retrieves the installation and activation status of KD Submissions.
154 + *
155 + * @return array{installed: bool, active: bool}
156 + */
157 + private function get_kd_submissions_status() {
158 + return WP_Optimize()->get_db_info()->get_plugin_status(self::KD_SUBMISSIONS_PLUGIN);
159 + }
160 +
105 161
106 162 /**
107 163 * Returns the singleton instance of this class.
108 164 *