PluginProbe
Insert PHP Code Snippet / 1.3.6
Insert PHP Code Snippet v1.3.6
1.4.7 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 All 27 releases
insert-php-code-snippet / admin / install.php

install.php in Insert PHP Code Snippet 1.3.6, at admin/install.php

103 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 if(get_option('xyz_ips_auto_exception')==""){
58 add_option('xyz_ips_auto_exception',1);
59 }
60
61 $xyz_ips_installed_date = get_option('xyz_ips_installed_date');
62 if ($xyz_ips_installed_date=="") {
63 $xyz_ips_installed_date = time();
64 update_option('xyz_ips_installed_date', $xyz_ips_installed_date);
65 }
66 add_option('xyz_ips_limit',20);
67 add_option('xyz_ips_exception_email',"0");
68
69 $charset_collate = $wpdb->get_charset_collate();
70 $queryInsertPhp = "CREATE TABLE IF NOT EXISTS ".$wpdb->prefix."xyz_ips_short_code (
71 `id` int NOT NULL AUTO_INCREMENT,
72 `title` varchar(1000) NOT NULL,
73 `content` longtext NOT NULL,
74 `short_code` varchar(2000) NOT NULL,
75 `status` int NOT NULL,
76 PRIMARY KEY (`id`)
77 ) ENGINE=InnoDB ".$charset_collate." AUTO_INCREMENT=1";
78 $wpdb->query($queryInsertPhp);
79
80
81 //preview page
82 $user_ID = get_current_user_id();
83 $slug = 'xyz-ics-preview-page';
84 $title = 'Snippet Preview';
85 $content = '';
86 // Cheks if doen't exists a post with slug "wordpress-post-created-with-code".
87 if( !xyz_ips_page_exists_by_slug( $slug ) ) {
88 // Set the post ID
89 $post_id = wp_insert_post(
90 array(
91 'post_author' => $user_ID,
92 'post_name' => $slug,
93 'post_title' => $title,
94 'post_content' => $content,
95 'post_status' => 'draft',
96 'post_type' => 'page'
97 )
98 );
99 }
100 }
101 register_activation_hook( XYZ_INSERT_PHP_PLUGIN_FILE ,'xyz_ips_network_install');
102 ?>
103