/** * Installs TML * * @since 6.0 * @access public */ public function install() { global $wpdb; // Current version $version = $this->get_option('version', Theme_My_Login::version); // Check if legacy page exists if ($page_id = $this->get_option('page_id')) { $page = get_post($page_id); } else { $page = get_page_by_title('Login'); } // 4.4 upgrade if (version_compare($version, '4.4', '<')) { remove_role('denied'); } // 6.0 upgrade if (version_compare($version, '6.0', '<')) { // Replace shortcode if ($page) { $page->post_content = str_replace('[theme-my-login-page]', '[theme-my-login]', $page->post_content); wp_update_post($page); } } // 6.3 upgrade if (version_compare($version, '6.3.3', '<')) { // Delete obsolete options $this->delete_option('page_id'); $this->delete_option('show_page'); $this->delete_option('initial_nag'); $this->delete_option('permalinks'); $this->delete_option('flush_rules'); // Move options to their own rows foreach ($this->get_options() as $key => $value) { if (in_array($key, array('active_modules'))) { continue; } if (!is_array($value)) { continue; } update_option("theme_my_login_{$key}", $value); $this->delete_option($key); } // Maybe create login page? if ($page) { // Make sure the page is not in the trash if ('trash' == $page->post_status) { wp_untrash_post($page->ID); } update_post_meta($page->ID, '_tml_action', 'login'); } } // 6.3.7 upgrade if (version_compare($version, '6.3.7', '<')) { // Convert TML pages to regular pages $wpdb->update($wpdb->posts, array('post_type' => 'page'), array('post_type' => 'tml_page')); // Get rid of stale rewrite rules flush_rewrite_rules(false); } // 6.4 upgrade if (version_compare($version, '6.4', '<')) { // Convert e-mail login option if ($this->get_option('email_login')) { $this->set_option('login_type', 'both'); } $this->delete_option('email_login'); } // Setup default pages foreach (Theme_My_Login::default_pages() as $action => $title) { if (!($page_id = Theme_My_Login::get_page_id($action))) { $page_id = wp_insert_post(array('post_title' => $title, 'post_name' => $action, 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => '[theme-my-login]', 'comment_status' => 'closed', 'ping_status' => 'closed')); update_post_meta($page_id, '_tml_action', $action); } } // Activate modules foreach ($this->get_option('active_modules', array()) as $module) { if (file_exists(WP_PLUGIN_DIR . '/theme-my-login/modules/' . $module)) { include_once WP_PLUGIN_DIR . '/theme-my-login/modules/' . $module; } do_action('tml_activate_' . $module); } $this->set_option('version', Theme_My_Login::version); $this->save_options(); }