当前位置: 首页>>代码示例>>PHP>>正文


PHP NewsletterModule::upgrade方法代码示例

本文整理汇总了PHP中NewsletterModule::upgrade方法的典型用法代码示例。如果您正苦于以下问题:PHP NewsletterModule::upgrade方法的具体用法?PHP NewsletterModule::upgrade怎么用?PHP NewsletterModule::upgrade使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NewsletterModule的用法示例。


在下文中一共展示了NewsletterModule::upgrade方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upgrade

 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);
     }
 }
开发者ID:radikalportal,项目名称:radikalportal,代码行数:30,代码来源:wp.php

示例2: upgrade

 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");
 }
开发者ID:kfwebdev,项目名称:wp-atd,代码行数:30,代码来源:statistics.php

示例3: upgrade

 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');
         }
     }
 }
开发者ID:radikalportal,项目名称:radikalportal,代码行数:28,代码来源:lock.php

示例4: upgrade

 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");
 }
开发者ID:radikalportal,项目名称:radikalportal,代码行数:31,代码来源:statistics.php

示例5: tinyint

 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;
 }
开发者ID:jrialland,项目名称:site-plr,代码行数:14,代码来源:emails.php

示例6: upgrade

 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;
 }
开发者ID:hbenbrahim,项目名称:wp-capdema,代码行数:42,代码来源:subscription.php

示例7: upgrade

 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");
     }
 }
开发者ID:radikalportal,项目名称:radikalportal,代码行数:41,代码来源:users.php

示例8: upgrade

 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;
 }
开发者ID:blocher,项目名称:oneholyname,代码行数:72,代码来源:plugin.php

示例9: upgrade

 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;
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:59,代码来源:subscription.php

示例10: upgrade

 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;
 }
开发者ID:radikalportal,项目名称:radikalportal,代码行数:84,代码来源:subscription.php

示例11: upgrade

 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;
 }
开发者ID:radikalportal,项目名称:radikalportal,代码行数:97,代码来源:plugin.php


注:本文中的NewsletterModule::upgrade方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。