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.6.7.1 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / classes / class-activation.php
admin-site-enhancements / classes Last commit date
class-activation.php 2 weeks ago class-admin-menu-organizer.php 2 weeks ago class-admin-menu-svg-icon-mask.php 2 weeks ago class-auto-publish-posts-with-missed-schedule.php 2 weeks ago class-avif-upload.php 2 weeks ago class-captcha-protection.php 2 weeks ago class-change-login-url.php 2 weeks ago class-cleanup-admin-bar.php 2 weeks ago class-common-methods.php 2 weeks ago class-content-duplication.php 2 weeks ago class-content-order.php 2 weeks ago class-custom-admin-footer-text.php 2 weeks ago class-custom-body-class.php 2 weeks ago class-custom-css.php 2 weeks ago class-custom-nav-menu-items-in-new-tab.php 2 weeks ago class-deactivation.php 2 weeks ago class-disable-author-archives.php 2 weeks ago class-disable-comments.php 2 weeks ago class-disable-dashboard-widgets.php 2 weeks ago class-disable-embeds.php 2 weeks ago class-disable-feeds.php 2 weeks ago class-disable-gutenberg.php 2 weeks ago class-disable-rest-api.php 2 weeks ago class-disable-smaller-components.php 2 weeks ago class-disable-updates.php 2 weeks ago class-disable-user-account.php 2 weeks ago class-disable-xml-rpc.php 2 weeks ago class-display-system-summary.php 2 weeks ago class-email-address-obfuscator.php 2 weeks ago class-email-delivery.php 2 weeks ago class-enhance-list-tables.php 2 weeks ago class-external-permalinks.php 2 weeks ago class-heartbeat-control.php 2 weeks ago class-hide-admin-bar.php 2 weeks ago class-hide-admin-notices.php 2 weeks ago class-image-sizes-panel.php 2 weeks ago class-image-upload-control.php 2 weeks ago class-insert-head-body-footer-code.php 2 weeks ago class-last-login-column.php 2 weeks ago class-limit-login-attempts.php 2 weeks ago class-login-id-type.php 2 weeks ago class-login-logout-menu.php 2 weeks ago class-maintenance-mode.php 2 weeks ago class-manage-ads-appads-txt.php 2 weeks ago class-manage-robots-txt.php 2 weeks ago class-media-files-visibility-control.php 2 weeks ago class-media-replacement.php 2 weeks ago class-multiple-user-roles.php 2 weeks ago class-navigation-menu-duplicator.php 2 weeks ago class-obfuscate-author-slugs.php 2 weeks ago class-open-external-links-in-new-tab.php 2 weeks ago class-password-protection.php 2 weeks ago class-redirect-after-login.php 2 weeks ago class-redirect-after-logout.php 2 weeks ago class-redirect-fourofour.php 2 weeks ago class-registration-date-column.php 2 weeks ago class-revisions-control.php 2 weeks ago class-search-engines-visibility.php 2 weeks ago class-settings-fields-render.php 2 weeks ago class-settings-sanitization.php 2 weeks ago class-settings-sections-fields.php 2 weeks ago class-show-custom-taxonomy-filters.php 2 weeks ago class-site-identity-on-login-page.php 2 weeks ago class-svg-upload.php 2 weeks ago class-third-party-compat.php 2 weeks ago class-various-admin-ui-enhancements.php 2 weeks ago class-view-admin-as-role.php 2 weeks ago class-wider-admin-menu.php 2 weeks ago class-wp-config-transformer.php 2 weeks ago
class-activation.php
351 lines
1 <?php
2
3 namespace ASENHA\Classes;
4
5 /**
6 * Plugin Activation
7 *
8 * @since 1.0.0
9 */
10 class Activation {
11
12 /**
13 * Target schema version for the failed logins log table.
14 *
15 * @since 9.0.2
16 */
17 const FAILED_LOGINS_DB_VERSION = '1.1.0';
18
19 /**
20 * Create failed login log table for Limit Login Attempts feature
21 *
22 * @since 2.5.0
23 * @param bool $recreate When true, drop and recreate the table (plugin activation). When false, create only if missing.
24 */
25 public function create_failed_logins_log_table( $recreate = true ) {
26 global $wpdb;
27
28 // Limit Login Attempts Log Table
29
30 $table_name = $wpdb->prefix . 'asenha_failed_logins';
31
32 $charset_collation_sql = '';
33
34 if ( ! empty( $wpdb->charset ) ) {
35 $charset_collation_sql = "DEFAULT CHARACTER SET $wpdb->charset";
36 }
37
38 if ( ! empty( $wpdb->collate ) ) {
39 $charset_collation_sql .= " COLLATE $wpdb->collate";
40 }
41
42 if ( $recreate ) {
43 // Drop table if already exists
44 $wpdb->query( "DROP TABLE IF EXISTS `" . $table_name . "`" );
45 } else {
46 $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );
47
48 if ( $wpdb->get_var( $query ) === $table_name ) {
49 return true;
50 }
51 }
52
53 // Create database table. This procedure may also be called
54 $sql =
55 "CREATE TABLE {$table_name} (
56 id int(6) unsigned NOT NULL auto_increment,
57 ip_address varchar(40) NOT NULL DEFAULT '',
58 username varchar(255) NOT NULL DEFAULT '',
59 fail_count int(10) NOT NULL DEFAULT '0',
60 lockout_count int(10) NOT NULL DEFAULT '0',
61 request_uri varchar(255) NOT NULL DEFAULT '',
62 unixtime int(10) NOT NULL DEFAULT '0',
63 datetime_wp varchar(36) NOT NULL DEFAULT '',
64 info varchar(64) NOT NULL DEFAULT '',
65 UNIQUE (ip_address),
66 PRIMARY KEY (id)
67 ) {$charset_collation_sql}";
68
69 require_once ABSPATH . '/wp-admin/includes/upgrade.php';
70
71 dbDelta( $sql );
72
73 update_option( 'asenha_failed_logins_db_version', self::FAILED_LOGINS_DB_VERSION, false );
74
75 return true;
76 }
77
78 /**
79 * Upgrade failed logins log table schema for existing installs.
80 *
81 * @since 9.0.2
82 */
83 public function maybe_upgrade_failed_logins_log_table() {
84 global $wpdb;
85
86 $version_key = 'asenha_failed_logins_db_version';
87 $target = self::FAILED_LOGINS_DB_VERSION;
88 $current = get_option( $version_key, '' );
89 $table_name = $wpdb->prefix . 'asenha_failed_logins';
90 $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );
91 $table_exists = ( $wpdb->get_var( $query ) === $table_name );
92
93 if ( $current === $target && $table_exists ) {
94 return;
95 }
96
97 if ( ! $table_exists ) {
98 $this->create_failed_logins_log_table( false );
99 return;
100 }
101
102 $columns = $wpdb->get_results( "SHOW FULL COLUMNS FROM `{$table_name}`", ARRAY_A );
103
104 if ( empty( $columns ) ) {
105 return;
106 }
107
108 $column_lengths = array();
109
110 foreach ( $columns as $column ) {
111 if ( ! isset( $column['Field'], $column['Type'] ) ) {
112 continue;
113 }
114
115 if ( preg_match( '/varchar\((\d+)\)/i', $column['Type'], $matches ) ) {
116 $column_lengths[ $column['Field'] ] = (int) $matches[1];
117 }
118 }
119
120 if ( isset( $column_lengths['username'] ) && $column_lengths['username'] < 255 ) {
121 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
122 $wpdb->query( "ALTER TABLE `{$table_name}` MODIFY username varchar(255) NOT NULL DEFAULT ''" );
123 }
124
125 if ( isset( $column_lengths['request_uri'] ) && $column_lengths['request_uri'] < 255 ) {
126 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
127 $wpdb->query( "ALTER TABLE `{$table_name}` MODIFY request_uri varchar(255) NOT NULL DEFAULT ''" );
128 }
129
130 update_option( $version_key, $target, false );
131 }
132
133 /**
134 * Create email delivery log table for Email Delivery module
135 *
136 * @since 7.1.0
137 */
138 public function create_email_delivery_log_table() {
139 global $wpdb;
140 $table_name = $wpdb->prefix . 'asenha_email_delivery';
141
142 if ( ! empty( $wpdb->charset ) ) {
143 $charset_collation_sql = "DEFAULT CHARACTER SET $wpdb->charset";
144 }
145
146 if ( ! empty( $wpdb->collate ) ) {
147 $charset_collation_sql .= " COLLATE $wpdb->collate";
148 }
149
150 // Drop table if already exists
151 $wpdb->query("DROP TABLE IF EXISTS `". $table_name ."`");
152
153 // Create database table. This procedure may also be called
154 $sql =
155 "CREATE TABLE {$table_name} (
156 id int(6) unsigned NOT NULL auto_increment,
157 status enum('successful','failed','unknown') NOT NULL DEFAULT 'unknown',
158 error varchar(250) NOT NULL DEFAULT '',
159 subject varchar(250) NOT NULL DEFAULT '',
160 message longtext NOT NULL DEFAULT '',
161 send_to varchar(256) NOT NULL DEFAULT '',
162 sender varchar(256) NOT NULL DEFAULT '',
163 reply_to varchar(256) NOT NULL DEFAULT '',
164 headers text NOT NULL DEFAULT '',
165 content_type text NOT NULL DEFAULT '',
166 attachments text NOT NULL DEFAULT '',
167 backtrace text NOT NULL DEFAULT '',
168 processor text NOT NULL DEFAULT '',
169 sent_on datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
170 sent_on_unixtime int(10) NOT NULL DEFAULT '0',
171 extra longtext NOT NULL DEFAULT '',
172 PRIMARY KEY (id)
173 ) {$charset_collation_sql}";
174
175 require_once ABSPATH . '/wp-admin/includes/upgrade.php';
176
177 dbDelta( $sql );
178
179 return true;
180 }
181
182 /**
183 * Create tables for the Form Builder module
184 *
185 * @since 7.8.0
186 */
187 public function create_form_builder_tables() {
188 global $wpdb;
189
190 if ( ! empty( $wpdb->charset ) ) {
191 $charset_collation_sql = "DEFAULT CHARACTER SET $wpdb->charset";
192 }
193
194 if ( ! empty( $wpdb->collate ) ) {
195 $charset_collation_sql .= " COLLATE $wpdb->collate";
196 }
197
198 require_once ABSPATH . '/wp-admin/includes/upgrade.php';
199
200 $fields_table_name = $wpdb->prefix . 'asenha_formbuilder_fields';
201 $forms_table_name = $wpdb->prefix . 'asenha_formbuilder_forms';
202 $entries_table_name = $wpdb->prefix . 'asenha_formbuilder_entries';
203 $entry_meta_table_name = $wpdb->prefix . 'asenha_formbuilder_entry_meta';
204
205 $sql = "CREATE TABLE {$fields_table_name} (
206 id bigint(20) NOT NULL AUTO_INCREMENT,
207 field_key varchar(100) NULL,
208 name text NULL,
209 description longtext NULL,
210 type text NULL,
211 default_value longtext NULL,
212 options longtext NULL,
213 field_order int(11) DEFAULT 0,
214 required int(1) NULL,
215 field_options longtext NULL,
216 form_id int(11) NULL,
217 created_at datetime NOT NULL,
218 PRIMARY KEY (id),
219 KEY form_id (form_id),
220 UNIQUE KEY field_key (field_key)
221 ) {$charset_collation_sql}";
222
223 dbDelta( $sql );
224
225 $sql = "CREATE TABLE {$forms_table_name} (
226 id int(11) NOT NULL AUTO_INCREMENT,
227 form_key varchar(100) NULL,
228 name varchar(255) NULL,
229 description text NULL,
230 status varchar(255) NULL,
231 options longtext NULL,
232 settings longtext NULL,
233 styles longtext NULL,
234 created_at datetime NOT NULL,
235 PRIMARY KEY (id),
236 UNIQUE KEY form_key (form_key)
237 ) {$charset_collation_sql}";
238
239 dbDelta( $sql );
240
241 $sql = "CREATE TABLE {$entries_table_name} (
242 id bigint(20) NOT NULL AUTO_INCREMENT,
243 ip text NULL,
244 form_id bigint(20) NULL,
245 user_id bigint(20) NULL,
246 delivery_status tinyint(1) DEFAULT 0,
247 status varchar(255) NULL,
248 resume_key varchar(64) NULL,
249 updated_at datetime NULL,
250 created_at datetime NOT NULL,
251 PRIMARY KEY (id),
252 KEY form_id (form_id),
253 KEY user_id (user_id),
254 UNIQUE KEY resume_key (resume_key)
255 ) {$charset_collation_sql}";
256
257 dbDelta( $sql );
258
259 $sql = "CREATE TABLE {$entry_meta_table_name} (
260 id bigint(20) NOT NULL AUTO_INCREMENT,
261 meta_value longtext NULL,
262 field_id bigint(20) NOT NULL,
263 item_id bigint(20) NOT NULL,
264 created_at datetime NOT NULL,
265 PRIMARY KEY (id),
266 KEY field_id (field_id),
267 KEY item_id (item_id)
268 ) {$charset_collation_sql}";
269
270 dbDelta( $sql );
271
272 return true;
273 }
274
275 /**
276 * Create submissions table for the Contact Form module.
277 *
278 * @since 8.9.0
279 */
280 public function create_contact_form_submissions_table() {
281 global $wpdb;
282
283 $table_name = $wpdb->prefix . 'asenha_contact_form_submissions';
284
285 $charset_collation_sql = '';
286
287 if ( ! empty( $wpdb->charset ) ) {
288 $charset_collation_sql = "DEFAULT CHARACTER SET $wpdb->charset";
289 }
290
291 if ( ! empty( $wpdb->collate ) ) {
292 $charset_collation_sql .= " COLLATE $wpdb->collate";
293 }
294
295 $sql = "CREATE TABLE {$table_name} (
296 id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
297 subject varchar(255) NOT NULL DEFAULT '',
298 message longtext NOT NULL,
299 name varchar(255) NOT NULL DEFAULT '',
300 email varchar(255) NOT NULL DEFAULT '',
301 created_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
302 PRIMARY KEY (id),
303 KEY created_at (created_at)
304 ) {$charset_collation_sql}";
305
306 require_once ABSPATH . '/wp-admin/includes/upgrade.php';
307
308 dbDelta( $sql );
309
310 return true;
311 }
312
313 /**
314 * Part of Disable Embeds module
315 * Remove embeds rewrite rules on plugin activation.
316 *
317 * @link https://plugins.trac.wordpress.org/browser/disable-embeds/tags/1.5.0/disable-embeds.php#L101
318 * @since 8.0.0
319 */
320 public function disable_embeds_remove_rewrite_rules() {
321 $common_methods = new Common_Methods;
322 add_filter( 'rewrite_rules_array', [ $common_methods, 'disable_embeds_rewrites' ] );
323 flush_rewrite_rules( false );
324 }
325
326 /**
327 * Deferred flush for the Disable Embeds module.
328 * Runs on init (late priority) so all CPTs/taxonomies are already registered.
329 *
330 * @since 8.5.1
331 */
332 public function maybe_flush_disable_embeds_rewrite_rules() {
333 $options = get_option( ASENHA_SLUG_U );
334
335 if ( ! is_array( $options ) ) {
336 return;
337 }
338
339 if ( isset( $options['disable_embeds_flush_rewrite_rules_needed'] )
340 && true === $options['disable_embeds_flush_rewrite_rules_needed']
341 ) {
342 $common_methods = new Common_Methods;
343 add_filter( 'rewrite_rules_array', [ $common_methods, 'disable_embeds_rewrites' ] );
344 flush_rewrite_rules( false );
345
346 $options['disable_embeds_flush_rewrite_rules_needed'] = false;
347 update_option( ASENHA_SLUG_U, $options, true );
348 }
349 }
350
351 }