PluginProbe
Internal Link Juicer: SEO Auto Linker for WordPress / trunk
Internal Link Juicer: SEO Auto Linker for WordPress vtrunk
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.5.2 1.2.0 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.15.1 1.2.16 1.2.17 All 75 releases
internal-links / includes / install.php

install.php in Internal Link Juicer: SEO Auto Linker for WordPress trunk, at includes/install.php

85 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // @codingStandardsIgnoreStart
3 /**
4 * @package ILJ\Includes
5 */
6 // @codingStandardsIgnoreEnd
7 use ILJ\Database\Usermeta;
8 use ILJ\Database\Linkindex;
9 use ILJ\Database\Postmeta;
10 use ILJ\Backend\Environment;
11 use ILJ\Core\Options;
12 use ILJ\Database\DatabaseCollation;
13 use ILJ\Database\LinkindexTemp;
14
15 /**
16 * Responsible for creating the database tables
17 *
18 * @since 1.0.0
19 * @return void
20 */
21 function ilj_install_db() {
22 global $wpdb;
23
24 $charset_collate = DatabaseCollation::get_collation(true);
25 $query_linkindex = 'CREATE TABLE ' . $wpdb->prefix . Linkindex::ILJ_DATABASE_TABLE_LINKINDEX . ' (
26 `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
27 `link_from` BIGINT(20) NULL,
28 `link_to` BIGINT(20) NULL,
29 `type_from` VARCHAR(45) NULL,
30 `type_to` VARCHAR(45) NULL,
31 `anchor` TEXT NULL,
32 PRIMARY KEY (`id`),
33 INDEX `link_from` (`link_from` ASC),
34 INDEX `type_from` (`type_from` ASC),
35 INDEX `type_to` (`type_to` ASC),
36 INDEX `link_to` (`link_to` ASC)) ' . $charset_collate . ';';
37
38 include_once ABSPATH . 'wp-admin/includes/upgrade.php';
39
40 dbDelta($query_linkindex);
41
42 Environment::update('last_version', ILJ_VERSION);
43 }
44
45 /**
46 * This function performs tasks such as creating database tables,
47 * and any other activation-related procedures.
48 *
49 * @param mixed $network_wide
50 * @return void
51 */
52 function ilj_plugin_activate($network_wide) {
53 if (is_multisite()) {
54 if ($network_wide) {
55 $site_ids = get_sites(array('fields' => 'ids'));
56 foreach ($site_ids as $site_id) {
57 switch_to_blog($site_id);
58 ilj_install_db();
59 restore_current_blog();
60 }
61 return;
62 }
63 ilj_install_db();
64 return;
65 }
66 ilj_install_db();
67 }
68
69 /**
70 * Function for `wp_initialize_site` action-hook to install ilj database
71 *
72 * @param WP_Site $new_site New site object.
73 *
74 * @return void
75 */
76 function ilj_multisite_install_db($new_site) {
77 switch_to_blog($new_site->blog_id);
78 ilj_install_db();
79 restore_current_blog();
80 }
81
82 add_action('wp_initialize_site', 'ilj_multisite_install_db', 10, 1);
83 register_activation_hook(ILJ_FILE, '\\ilj_plugin_activate');
84 register_activation_hook(ILJ_FILE, array('ILJ\Core\Options', 'setOptionsDefault'));
85