| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) |
| 3 |
exit; |
| 4 |
|
| 5 |
|
| 6 |
function xyz_ips_network_install($networkwide) { |
| 7 |
global $wpdb; |
| 8 |
if (function_exists('is_multisite') && is_multisite()) { |
| 9 |
// check if it is a network activation - if so, run the activation function for each blog id |
| 10 |
if ($networkwide) { |
| 11 |
$old_blog = $wpdb->blogid; |
| 12 |
// Get all blog ids |
| 13 |
$blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
| 14 |
foreach ($blogids as $blog_id) { |
| 15 |
switch_to_blog($blog_id); |
| 16 |
xyz_ips_install(); |
| 17 |
} |
| 18 |
switch_to_blog($old_blog); |
| 19 |
return; |
| 20 |
} |
| 21 |
} |
| 22 |
xyz_ips_install(); |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
function xyz_ips_install(){ |
| 27 |
global $wpdb; |
| 28 |
|
| 29 |
$pluginName = 'xyz-wp-insert-code-snippet/xyz-wp-insert-code-snippet.php'; |
| 30 |
if (is_plugin_active($pluginName)) { |
| 31 |
wp_die( "The plugin Insert PHP Code Snippet cannot be activated unless the premium version of this plugin is deactivated. Back to <a href='".admin_url()."plugins.php'>Plugin Installation</a>." ); |
| 32 |
} |
| 33 |
if(get_option('xyz_ips_sort_order')==''){ |
| 34 |
add_option('xyz_ips_sort_order','desc'); |
| 35 |
} |
| 36 |
|
| 37 |
if(get_option('xyz_ips_sort_field_name')==''){ |
| 38 |
add_option('xyz_ips_sort_field_name','id'); |
| 39 |
} |
| 40 |
|
| 41 |
if(get_option('xyz_credit_link') == ""){ |
| 42 |
add_option("xyz_credit_link",0); |
| 43 |
} |
| 44 |
|
| 45 |
if(get_option('xyz_ips_credit_dismiss') == ""){ |
| 46 |
add_option("xyz_ips_credit_dismiss",0); |
| 47 |
} |
| 48 |
|
| 49 |
if(get_option('xyz_ips_premium_version_ads')==""){ |
| 50 |
add_option('xyz_ips_premium_version_ads',1); |
| 51 |
} |
| 52 |
|
| 53 |
if(get_option('xyz_ips_auto_insert')==""){ |
| 54 |
add_option('xyz_ips_auto_insert',1); |
| 55 |
} |
| 56 |
|
| 57 |
$xyz_ips_installed_date = get_option('xyz_ips_installed_date'); |
| 58 |
if ($xyz_ips_installed_date=="") { |
| 59 |
$xyz_ips_installed_date = time(); |
| 60 |
update_option('xyz_ips_installed_date', $xyz_ips_installed_date); |
| 61 |
} |
| 62 |
add_option('xyz_ips_limit',20); |
| 63 |
$queryInsertPhp = "CREATE TABLE IF NOT EXISTS ".$wpdb->prefix."xyz_ips_short_code ( |
| 64 |
`id` int NOT NULL AUTO_INCREMENT, |
| 65 |
`title` varchar(1000) COLLATE utf8_unicode_ci NOT NULL, |
| 66 |
`content` longtext COLLATE utf8_unicode_ci NOT NULL, |
| 67 |
`short_code` varchar(2000) COLLATE utf8_unicode_ci NOT NULL, |
| 68 |
`status` int NOT NULL, |
| 69 |
PRIMARY KEY (`id`) |
| 70 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1"; |
| 71 |
$wpdb->query($queryInsertPhp); |
| 72 |
} |
| 73 |
register_activation_hook( XYZ_INSERT_PHP_PLUGIN_FILE ,'xyz_ips_network_install'); |
| 74 |
?> |
| 75 |
|