コード例 #1
0
ファイル: wp.php プロジェクト: radikalportal/radikalportal
 function upgrade()
 {
     parent::upgrade();
     if ($this->old_version < '1.0.0') {
         // Locked content configuration migration
         $old_options = $old_options = NewsletterSubscription::instance()->get_options();
         if (isset($old_options['wp_welcome'])) {
             $this->options['welcome'] = $old_options['wp_welcome'];
         }
         if (isset($old_options['wp_delete'])) {
             $this->options['delete'] = $old_options['wp_delete'];
         }
         if (isset($old_options['subscribe_wp_users_label'])) {
             $this->options['subscribe_label'] = $old_options['subscribe_wp_users_label'];
         }
         if (isset($old_options['subscribe_wp_users'])) {
             $this->options['subscribe'] = $old_options['subscribe_wp_users'];
         }
         if (isset($old_options['wp_send_confirmation'])) {
             $this->options['confirmation'] = $old_options['wp_send_confirmation'];
         }
         $this->save_options($this->options);
         unset($old_options['wp_welcome']);
         unset($old_options['wp_delete']);
         unset($old_options['subscribe_wp_users_label']);
         unset($old_options['subscribe_wp_users']);
         unset($old_options['wp_send_confirmation']);
         NewsletterSubscription::instance()->save_options($old_options);
     }
 }
コード例 #2
0
ファイル: statistics.php プロジェクト: kfwebdev/wp-atd
 function upgrade()
 {
     global $wpdb, $charset_collate;
     parent::upgrade();
     // This before table creation or update for compatibility
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats change column newsletter_id user_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats change column newsletter_id user_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats change column date created timestamp not null default current_timestamp");
     // Just for test since it will be part of statistics module
     // This table stores clicks and email opens. An open is registered with a empty url.
     $this->upgrade_query("create table if not exists {$wpdb->prefix}newsletter_stats (id int auto_increment, primary key (id)) {$charset_collate}");
     // References
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column user_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column email_id int not null default 0");
     // Future... see the links table
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column link_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column created timestamp not null default current_timestamp");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column url varchar(255) not null default ''");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column anchor varchar(200) not null default ''");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column ip varchar(20) not null default ''");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column country varchar(4) not null default ''");
     $this->upgrade_query("ALTER TABLE `{$wpdb->prefix}newsletter_stats` ADD INDEX `email_id` (`email_id`)");
     $this->upgrade_query("ALTER TABLE `{$wpdb->prefix}newsletter_stats` ADD INDEX `user_id` (`user_id`)");
     // Stores the link of every email to create short links
     //        $this->upgrade_query("create table if not exists {$wpdb->prefix}newsletter_links (id int auto_increment, primary key (id)) $charset_collate");
     //        $this->upgrade_query("alter table {$wpdb->prefix}newsletter_links add column email_id int not null default 0");
     //        $this->upgrade_query("alter table {$wpdb->prefix}newsletter_links add column token varchar(10) not null default ''");
     //        $this->upgrade_query("alter table {$wpdb->prefix}newsletter_links add column text varchar(255) not null default ''");
     //$this->upgrade_query("create table if not exists {$wpdb->prefix}newsletter_stats (id int auto_increment, primary key (id)) $charset_collate");
 }
コード例 #3
0
ファイル: lock.php プロジェクト: radikalportal/radikalportal
 function upgrade()
 {
     parent::upgrade();
     if ($this->old_version < '1.0.2') {
         // Locked content configuration migration
         $old_options = Newsletter::instance()->get_options();
         if (isset($old_options['lock_message']) || isset($old_options['lock_ids']) || isset($old_options['lock_url'])) {
             $this->options['ids'] = $old_options['lock_ids'];
             $this->options['url'] = $old_options['lock_url'];
             $this->options['message'] = $old_options['lock_message'];
             $this->options['enabled'] = 1;
             $this->save_options($this->options);
             unset($old_options['lock_ids']);
             unset($old_options['lock_url']);
             unset($old_options['lock_message']);
             Newsletter::instance()->save_options($old_options);
         }
         $old_options = NewsletterSubscription::instance()->get_options('lock');
         if (!empty($old_options)) {
             $this->options['ids'] = $old_options['ids'];
             $this->options['url'] = $old_options['url'];
             $this->options['message'] = $old_options['message'];
             $this->options['enabled'] = 1;
             $this->save_options($this->options);
             NewsletterSubscription::instance()->delete_options('lock');
         }
     }
 }
コード例 #4
0
 function upgrade()
 {
     global $wpdb, $charset_collate;
     parent::upgrade();
     // This before table creation or update for compatibility
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats change column newsletter_id user_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats change column newsletter_id user_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats change column date created timestamp not null default current_timestamp");
     // Just for test since it will be part of statistics module
     // This table stores clicks and email opens. An open is registered with a empty url.
     $this->upgrade_query("create table if not exists {$wpdb->prefix}newsletter_stats (id int auto_increment, primary key (id)) {$charset_collate}");
     // References
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column user_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column email_id int not null default 0");
     // Future... see the links table
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column link_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column created timestamp not null default current_timestamp");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column url varchar(255) not null default ''");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column anchor varchar(200) not null default ''");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column ip varchar(20) not null default ''");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column country varchar(4) not null default ''");
     $this->upgrade_query("ALTER TABLE `{$wpdb->prefix}newsletter_stats` ADD INDEX `email_id` (`email_id`)");
     $this->upgrade_query("ALTER TABLE `{$wpdb->prefix}newsletter_stats` ADD INDEX `user_id` (`user_id`)");
     if (empty($this->options['key'])) {
         $this->options['key'] = md5($_SERVER['REMOTE_ADDR'] . rand(100000, 999999) . time());
         $this->save_options($this->options);
     }
     $this->upgrade_query("ALTER TABLE `{$wpdb->prefix}newsletter_emails` ADD COLUMN `open_count` int UNSIGNED NOT NULL DEFAULT 0");
     $this->upgrade_query("ALTER TABLE `{$wpdb->prefix}newsletter_emails` ADD COLUMN `click_count`  int UNSIGNED NOT NULL DEFAULT 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_emails change column read_count open_count int not null default 0");
 }
コード例 #5
0
ファイル: emails.php プロジェクト: jrialland/site-plr
 function upgrade()
 {
     global $wpdb, $charset_collate;
     parent::upgrade();
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " change column `type` `type` varchar(50) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column token varchar(10) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " drop column visibility");
     $this->upgrade_query("update " . NEWSLETTER_EMAILS_TABLE . " set type='message' where type=''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column private tinyint(1) not null default 0");
     // Force a token to email without one already set.
     $token = self::get_token();
     $wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set token='" . $token . "' where token=''");
     return true;
 }
コード例 #6
0
 function upgrade()
 {
     global $wpdb, $charset_collate, $newsletter;
     parent::upgrade();
     // Migrate the profile_text from profile to subscription options
     $options_profile = $this->get_options('profile');
     $default_options_profile = $this->get_default_options('profile');
     if (empty($options_profile)) {
         update_option('newsletter_profile', $this->get_default_options('profile'));
     } else {
         update_option('newsletter_profile', array_merge($default_options_profile, $options_profile));
     }
     $default_options = $this->get_default_options();
     if (empty($this->options['error_text'])) {
         $this->options['error_text'] = $default_options['error_text'];
         $this->save_options($this->options);
     }
     // Old migration code
     if (isset($options_profile['profile_text'])) {
         $this->options['profile_text'] = $options_profile['profile_text'];
         if (empty($this->options['profile_text'])) {
             $this->options['profile_text'] = '{profile_form}<p><a href="{unsubscription_url}">I want to unsubscribe.</a>';
         }
         $this->save_options($this->options);
         unset($options_profile['profile_text']);
         update_option('newsletter_profile', $options_profile);
     }
     if (isset($options_profile['profile_saved'])) {
         $this->options['profile_saved'] = $options_profile['profile_saved'];
         $this->save_options($this->options);
         unset($options_profile['profile_saved']);
         update_option('newsletter_profile', $options_profile);
     }
     // Very old...
     if (!isset($this->options['url']) && !empty($newsletter->options['url'])) {
         $this->options['url'] = $newsletter->options['url'];
         $this->save_options($this->options);
     }
     // Because users do not understand how to create an "extensions" folder...
     @wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter/subscription');
     return true;
 }
コード例 #7
0
ファイル: users.php プロジェクト: radikalportal/radikalportal
 function upgrade()
 {
     global $wpdb, $charset_collate;
     parent::upgrade();
     $this->upgrade_query("create table if not exists " . NEWSLETTER_USERS_TABLE . " (id int auto_increment, `email` varchar(100) not null default '', primary key (id), unique key email (email)) {$charset_collate}");
     // User personal data
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column name varchar(100) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column surname varchar(100) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column sex char(1) not null default 'n'");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " change column sex sex char(1) not null default 'n'");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column status char(1) not null default 'S'");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column created timestamp not null default current_timestamp");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column token varchar(50) not null default ''");
     // Feed by mail
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column feed tinyint(4) not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column feed_time bigint(20) not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column country varchar(4) not null default ''");
     // List/Preferences
     for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
         $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column list_{$i} tinyint(4) not null default 0");
     }
     // Profiles
     for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
         $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column profile_{$i} varchar(255) not null default ''");
     }
     // TODO: Still makes sense the referrer?
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column referrer varchar(50) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column http_referer varchar(255) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column wp_user_id int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column ip varchar(50) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column test tinyint(4) not null default 0");
     // TODO: Flow module should add that it self (?)
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column flow tinyint(4) not null default 0");
     // Old problems...
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " convert to character set utf8");
     $this->upgrade_query("update " . NEWSLETTER_USERS_TABLE . " set sex='n' where sex='' or sex=' '");
     if ($this->old_version < '1.0.5') {
         $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column unsub_email_id int not null default 0");
         $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column unsub_time int not null default 0");
     }
 }
コード例 #8
0
ファイル: plugin.php プロジェクト: blocher/oneholyname
 function upgrade()
 {
     global $wpdb, $charset_collate;
     parent::upgrade();
     $this->upgrade_query("create table if not exists " . NEWSLETTER_EMAILS_TABLE . " (id int auto_increment, primary key (id)) {$charset_collate}");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column message longtext");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column message_text longtext");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column subject varchar(255) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column type varchar(50) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column created timestamp not null default current_timestamp");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column status enum('new','sending','sent','paused') not null default 'new'");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column total int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column last_id int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column sent int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column send_on int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column track tinyint not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column editor tinyint not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column sex char(1) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " change column sex sex char(1) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column query text");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column preferences text");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column options longtext");
     // Cleans up old installations
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " drop column name");
     $this->upgrade_query("drop table if exists " . $wpdb->prefix . "newsletter_work");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " convert to character set utf8");
     if ($charset_collate != 'utf8mb4') {
         require_once ABSPATH . 'wp-admin/includes/upgrade.php';
         if (function_exists('maybe_convert_table_to_utf8mb4')) {
             maybe_convert_table_to_utf8mb4(NEWSLETTER_EMAILS_TABLE);
         }
     }
     // Some setting check to avoid the common support request for mis-configurations
     $options = $this->get_options();
     if (empty($options['sender_email'])) {
         // That code was taken from WordPress
         $sitename = strtolower($_SERVER['SERVER_NAME']);
         if (substr($sitename, 0, 4) == 'www.') {
             $sitename = substr($sitename, 4);
         }
         // WordPress build an address in the same way using wordpress@...
         $options['sender_email'] = 'newsletter@' . $sitename;
         $this->save_options($options);
     }
     if (empty($options['scheduler_max']) || !is_numeric($options['scheduler_max'])) {
         $options['scheduler_max'] = 100;
         $this->save_options($options);
     }
     if (empty($options['api_key'])) {
         $options['api_key'] = self::get_token();
         $this->save_options($options);
     }
     if (empty($options['scheduler_max'])) {
         $options['scheduler_max'] = 100;
         $this->save_options($options);
     }
     wp_clear_scheduled_hook('newsletter');
     wp_schedule_event(time() + 30, 'newsletter', 'newsletter');
     wp_clear_scheduled_hook('newsletter_extension_versions');
     wp_schedule_event(time() + 30, 'newsletter_extension_versions', 'newsletter_weekly');
     add_option('newsletter_extension_versions', array(), null, 'no');
     wp_clear_scheduled_hook('newsletter_update');
     wp_clear_scheduled_hook('newsletter_check_versions');
     wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter');
     wp_mkdir_p(WP_CONTENT_DIR . '/cache/newsletter');
     //wp_clear_scheduled_hook('newsletter_updates_run');
     wp_clear_scheduled_hook('newsletter_statistics_version_check');
     wp_clear_scheduled_hook('newsletter_reports_version_check');
     wp_clear_scheduled_hook('newsletter_feed_version_check');
     wp_clear_scheduled_hook('newsletter_popup_version_check');
     return true;
 }
コード例 #9
0
 function upgrade()
 {
     global $wpdb, $charset_collate, $newsletter;
     parent::upgrade();
     // Migrate the profile_text from profile to subscription options
     $options_profile = $this->get_options('profile');
     $default_options_profile = $this->get_default_options('profile');
     if (empty($options_profile)) {
         update_option('newsletter_profile', $this->get_default_options('profile'));
     } else {
         update_option('newsletter_profile', array_merge($default_options_profile, $options_profile));
     }
     $default_options = $this->get_default_options();
     if (empty($this->options['error_text'])) {
         $this->options['error_text'] = $default_options['error_text'];
         $this->save_options($this->options);
     }
     // Old migration code
     if (isset($options_profile['profile_text'])) {
         $this->options['profile_text'] = $options_profile['profile_text'];
         if (empty($this->options['profile_text'])) {
             $this->options['profile_text'] = '{profile_form}<p><a href="{unsubscription_url}">I want to unsubscribe.</a>';
         }
         $this->save_options($this->options);
         unset($options_profile['profile_text']);
         update_option('newsletter_profile', $options_profile);
     }
     if (isset($options_profile['profile_saved'])) {
         $this->options['profile_saved'] = $options_profile['profile_saved'];
         $this->save_options($this->options);
         unset($options_profile['profile_saved']);
         update_option('newsletter_profile', $options_profile);
     }
     // Very old...
     if (!isset($this->options['url']) && !empty($newsletter->options['url'])) {
         $this->options['url'] = $newsletter->options['url'];
         $this->save_options($this->options);
     }
     // Locked content configuration migration
     $options_lock = $this->get_options('lock');
     if (empty($options_lock)) {
         $options_main = Newsletter::instance()->get_options();
         if (isset($options_main['message'])) {
             $options_lock['ids'] = $options_main['lock_ids'];
             $options_lock['url'] = $options_main['lock_url'];
             $options_lock['message'] = $options_main['lock_message'];
             update_option('newsletter_subscription_lock', $options_lock);
         }
     }
     $options_template = $this->get_options('template');
     if (empty($options_template)) {
         $options_template['enabled'] = isset($this->options['template_enabled']) ? 1 : 0;
         $options_template['template'] = isset($this->options['template']) ? $this->options['template'] : '';
         add_option('newsletter_subscription_template', $options_template, null, 'no');
     }
     // Because users do not understand how to create an "extensions" folder...
     @wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter/subscription');
     return true;
 }
コード例 #10
0
 function upgrade()
 {
     global $wpdb, $charset_collate, $newsletter;
     parent::upgrade();
     $this->init_options('profile');
     $this->init_options('lists');
     $default_options = $this->get_default_options();
     if (empty($this->options['error_text'])) {
         $this->options['error_text'] = $default_options['error_text'];
         $this->save_options($this->options);
     }
     // Old migration code
     if (isset($options_profile['profile_text'])) {
         $this->options['profile_text'] = $options_profile['profile_text'];
         if (empty($this->options['profile_text'])) {
             $this->options['profile_text'] = '{profile_form}<p><a href="{unsubscription_url}">I want to unsubscribe.</a>';
         }
         $this->save_options($this->options);
         unset($options_profile['profile_text']);
         update_option('newsletter_profile', $options_profile);
     }
     if (isset($options_profile['profile_saved'])) {
         $this->options['profile_saved'] = $options_profile['profile_saved'];
         $this->save_options($this->options);
         unset($options_profile['profile_saved']);
         update_option('newsletter_profile', $options_profile);
     }
     // Very old...
     if (!isset($this->options['url']) && !empty($newsletter->options['url'])) {
         $this->options['url'] = $newsletter->options['url'];
         $this->save_options($this->options);
     }
     // Locked content configuration migration
     //        $options_lock = $this->get_options('lock');
     //        if (empty($options_lock)) {
     //            $options_main = Newsletter::instance()->get_options();
     //            if (isset($options_main['lock_message'])) {
     //                $options_lock['ids'] = $options_main['lock_ids'];
     //                $options_lock['url'] = $options_main['lock_url'];
     //                $options_lock['message'] = $options_main['lock_message'];
     //                update_option('newsletter_subscription_lock', $options_lock);
     //            }
     //        }
     //
     //        $this->init_options('lock');
     $options_template = $this->get_options('template');
     if (empty($options_template)) {
         $options_template['enabled'] = isset($this->options['template_enabled']) ? 1 : 0;
         $options_template['template'] = isset($this->options['template']) ? $this->options['template'] : '';
         add_option('newsletter_subscription_template', $options_template, null, 'no');
     }
     $this->init_options('template', false);
     //        $options_wp = $this->get_options('wp');
     //        if (empty($options_wp)) {
     //            if (isset($this->options['wp_welcome'])) {
     //                $options_wp['welcome'] = $this->options['wp_welcome'];
     //            }
     //            if (isset($this->options['wp_delete'])) {
     //                $options_wp['delete'] = $this->options['wp_delete'];
     //            }
     //            if (isset($this->options['subscribe_wp_users_label'])) {
     //                $options_wp['subscribe_label'] = $this->options['subscribe_wp_users_label'];
     //            }
     //            if (isset($this->options['subscribe_wp_users'])) {
     //                $options_wp['subscribe'] = $this->options['subscribe_wp_users'];
     //            }
     //            if (isset($this->options['send_confirmation'])) {
     //                $options_wp['confirmation'] = $this->options['send_confirmation'];
     //            }
     //            $this->save_options($options_wp, 'wp');
     //
     //            unset($this->options['wp_welcome']);
     //            unset($this->options['wp_delete']);
     //            unset($this->options['subscribe_wp_users_label']);
     //            unset($this->options['subscribe_wp_users']);
     //            unset($this->options['send_confirmation']);
     //            $this->save_options($this->options);
     //        }
     //
     //        $this->init_options('wp', false);
     // Because users do not understand how to create an "extensions" folder...
     //@wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter/subscription');
     return true;
 }
コード例 #11
0
 function upgrade()
 {
     global $wpdb, $charset_collate;
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     parent::upgrade();
     $this->upgrade_query("create table if not exists " . NEWSLETTER_EMAILS_TABLE . " (id int auto_increment, primary key (id)) {$charset_collate}");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column message longtext");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column message_text longtext");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column subject varchar(255) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column type varchar(50) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column created timestamp not null default current_timestamp");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column status enum('new','sending','sent','paused') not null default 'new'");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column total int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column last_id int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column sent int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column send_on int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column track tinyint not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column editor tinyint not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column sex char(1) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " change column sex sex char(1) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column query text");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column preferences text");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column options longtext");
     // Cleans up old installations
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " drop column name");
     $this->upgrade_query("drop table if exists " . $wpdb->prefix . "newsletter_work");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " convert to character set utf8");
     // WP does not manage composite primary key when it tries to upgrade a table...
     $suppress_errors = $wpdb->suppress_errors(true);
     dbDelta("CREATE TABLE " . $wpdb->prefix . "newsletter_sent (\n            email_id int(10) unsigned NOT NULL DEFAULT '0',\n            user_id int(10) unsigned NOT NULL DEFAULT '0',\n            status tinyint(1) unsigned NOT NULL DEFAULT '0',\n            open tinyint(1) unsigned NOT NULL DEFAULT '0',\n            time int(10) unsigned NOT NULL DEFAULT '0',\n            error varchar(100) NOT NULL DEFAULT '',\n\t    ip varchar(100) NOT NULL DEFAULT '',\n            PRIMARY KEY (email_id,user_id),\n            KEY user_id (user_id),\n            KEY email_id (email_id)\n          ) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
     $wpdb->suppress_errors($suppress_errors);
     if ('utf8mb4' === $wpdb->charset) {
         require_once ABSPATH . 'wp-admin/includes/upgrade.php';
         if (function_exists('maybe_convert_table_to_utf8mb4')) {
             maybe_convert_table_to_utf8mb4(NEWSLETTER_EMAILS_TABLE);
         }
     }
     // Some setting check to avoid the common support request for mis-configurations
     $options = $this->get_options();
     if (empty($options['sender_email'])) {
         // That code was taken from WordPress
         $sitename = strtolower($_SERVER['SERVER_NAME']);
         if (substr($sitename, 0, 4) == 'www.') {
             $sitename = substr($sitename, 4);
         }
         // WordPress build an address in the same way using wordpress@...
         $options['sender_email'] = 'newsletter@' . $sitename;
         $this->save_options($options);
     }
     if (empty($options['scheduler_max']) || !is_numeric($options['scheduler_max'])) {
         $options['scheduler_max'] = 100;
         $this->save_options($options);
     }
     if (empty($options['api_key'])) {
         $options['api_key'] = self::get_token();
         $this->save_options($options);
     }
     if (empty($options['scheduler_max'])) {
         $options['scheduler_max'] = 100;
         $this->save_options($options);
     }
     wp_clear_scheduled_hook('newsletter');
     wp_schedule_event(time() + 30, 'newsletter', 'newsletter');
     wp_clear_scheduled_hook('newsletter_extension_versions');
     wp_schedule_event(time() + 30, 'newsletter_extension_versions', 'newsletter_weekly');
     add_option('newsletter_extension_versions', array(), null, 'no');
     wp_clear_scheduled_hook('newsletter_update');
     wp_clear_scheduled_hook('newsletter_check_versions');
     //wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter');
     //wp_mkdir_p(WP_CONTENT_DIR . '/cache/newsletter');
     //wp_clear_scheduled_hook('newsletter_updates_run');
     wp_clear_scheduled_hook('newsletter_statistics_version_check');
     wp_clear_scheduled_hook('newsletter_reports_version_check');
     wp_clear_scheduled_hook('newsletter_feed_version_check');
     wp_clear_scheduled_hook('newsletter_popup_version_check');
     // If the original options has already saved once
     if (isset($options['smtp_host'])) {
         $smtp_options['enabled'] = $options['smtp_enabled'];
         $smtp_options['test_email'] = $options['smtp_test_email'];
         $smtp_options['host'] = $options['smtp_host'];
         $smtp_options['pass'] = $options['smtp_pass'];
         $smtp_options['port'] = $options['smtp_port'];
         $smtp_options['user'] = $options['smtp_user'];
         $smtp_options['secure'] = $options['smtp_secure'];
         $this->save_options($smtp_options, 'smtp');
         unset($options['smtp_enabled']);
         unset($options['smtp_test_email']);
         unset($options['smtp_pass']);
         unset($options['smtp_port']);
         unset($options['smtp_user']);
         unset($options['smtp_secure']);
         unset($options['smtp_host']);
         $this->save_options($options);
     }
     $this->init_options('smtp');
     return true;
 }