コード例 #1
0
 /**
  * Activates the module
  *
  * Callback for "tml_activate_themed-profiles/themed-profiles.php" hook in method Theme_My_Login_Modules_Admin::activate_module()
  *
  * @see Theme_My_Login_Modules_Admin::activate_module()
  * @since 6.0
  * @access public
  */
 public function activate()
 {
     if (!($page_id = Theme_My_Login::get_page_id('profile'))) {
         $page_id = wp_insert_post(array('post_title' => __('Your Profile'), 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => '[theme-my-login]', 'comment_status' => 'closed', 'ping_status' => 'closed'));
         update_post_meta($page_id, '_tml_action', 'profile');
     }
 }
コード例 #2
0
 /**
  * Returns action title
  *
  * @since 6.0
  * @access public
  *
  * @param string $action The action to retrieve. Defaults to current action.
  * @return string Title of $action
  */
 public function get_title($action = '')
 {
     if (empty($action)) {
         $action = $this->get_option('default_action');
     }
     if (is_admin()) {
         return;
     }
     if (is_user_logged_in() && 'login' == $action && $action == $this->get_option('default_action')) {
         $title = sprintf(__('Welcome, %s', 'theme-my-login'), wp_get_current_user()->display_name);
     } else {
         if ($page_id = Theme_My_Login::get_page_id($action)) {
             $title = get_post_field('post_title', $page_id);
         } else {
             switch ($action) {
                 case 'register':
                     $title = __('Register', 'theme-my-login');
                     break;
                 case 'lostpassword':
                 case 'retrievepassword':
                 case 'resetpass':
                 case 'rp':
                     $title = __('Lost Password', 'theme-my-login');
                     break;
                 case 'login':
                 default:
                     $title = __('Log In', 'theme-my-login');
             }
         }
     }
     return apply_filters('tml_title', $title, $action);
 }
コード例 #3
0
 /**
  * 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();
 }