| @@ -27,10 +27,19 @@ | ||
| 27 | 27 | global $wpdb; |
| 28 | 28 | |
| 29 | 29 | $pluginName = 'xyz-wp-insert-code-snippet/xyz-wp-insert-code-snippet.php'; |
| 30 | 30 | if (is_plugin_active($pluginName)) { |
| 31 | -wp_die( "The plugin Insert HTML Snippet cannot be activated unless the premium version of this plugin is deactivated. Back to <a href='".admin_url()."plugins.php'>Plugin Installation</a>." ); | |
| 31 | + wp_die( "The plugin Insert HTML Snippet cannot be activated unless the premium version of this plugin is deactivated. Back to <a href='".esc_url(admin_url())."plugins.php'>Plugin Installation</a>." ); | |
| 32 | 32 | } |
| 33 | + if ( version_compare( PHP_VERSION, '7.0.0', '<' ) ) { | |
| 34 | + wp_die( | |
| 35 | + sprintf( | |
| 36 | + 'This plugin requires PHP version 7.0 or higher. You are using PHP %s. <a href="%s">Go back to Plugins page</a>.', | |
| 37 | + PHP_VERSION, | |
| 38 | + esc_url( admin_url( 'plugins.php' ) ) | |
| 39 | + ) | |
| 40 | + ); | |
| 41 | +} | |
| 33 | 42 | if(get_option('xyz_ihs_sort_order')=='') |
| 34 | 43 | { |
| 35 | 44 | add_option('xyz_ihs_sort_order','desc'); |
| 36 | 45 | } |
| @@ -66,8 +75,9 @@ | ||
| 66 | 75 | $charset_collate = $wpdb->get_charset_collate(); |
| 67 | 76 | $queryInsertHtml = "CREATE TABLE IF NOT EXISTS ".$wpdb->prefix."xyz_ihs_short_code ( |
| 68 | 77 | `id` int NOT NULL AUTO_INCREMENT, |
| 69 | 78 | `title` varchar(1000) NOT NULL, |
| 79 | + `description` TEXT NULL , | |
| 70 | 80 | `content` longtext NOT NULL, |
| 71 | 81 | `short_code` varchar(2000) NOT NULL, |
| 72 | 82 | `status` int NOT NULL, |
| 73 | 83 | PRIMARY KEY (`id`) |
| @@ -79,7 +89,27 @@ | ||
| 79 | 89 | if(!(in_array("insertionLocation", $tblcolums))) |
| 80 | 90 | $wpdb->query("ALTER TABLE ".$wpdb->prefix."xyz_ihs_short_code ADD insertionLocation int NOT NULL default 0"); |
| 81 | 91 | if(!(in_array("insertionLocationType", $tblcolums))) |
| 82 | 92 | $wpdb->query("ALTER TABLE ".$wpdb->prefix."xyz_ihs_short_code ADD insertionLocationType int NOT NULL default 0"); |
| 93 | + if(!(in_array("description", $tblcolums))) | |
| 94 | + $wpdb->query("ALTER TABLE ".$wpdb->prefix."xyz_ihs_short_code ADD description TEXT NULL "); | |
| 95 | + $table_name = $wpdb->prefix . 'xyz_ihs_usage'; | |
| 96 | + $charset_collate = $wpdb->get_charset_collate(); | |
| 97 | + $sql = "CREATE TABLE {$table_name} ( | |
| 98 | + post_id BIGINT(20) UNSIGNED NOT NULL, | |
| 99 | + snippet_id BIGINT(20) UNSIGNED NOT NULL, | |
| 100 | + post_type VARCHAR(20) NOT NULL, | |
| 101 | + PRIMARY KEY (post_id, snippet_id), | |
| 102 | + KEY post_id (post_id), | |
| 103 | + KEY snippet_id (snippet_id) | |
| 104 | + ) {$charset_collate};"; | |
| 105 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 106 | + dbDelta($sql); | |
| 107 | + // Set sync flag only if not already set | |
| 108 | + if (get_option('xyz_ihs_sync_needed') === false) { | |
| 109 | + add_option('xyz_ihs_sync_needed', 1); | |
| 110 | + } | |
| 111 | + //Show Snippet Usage Details | |
| 112 | + add_option('xyz_ihs_show_snippet_usage',1);//default enable | |
| 83 | 113 | } |
| 84 | 114 | |
| 85 | 115 | register_activation_hook( XYZ_INSERT_HTML_PLUGIN_FILE ,'xyz_ihs_network_install'); |