コード例 #1
0
 public function wp_head_callback()
 {
     //This function is triggered by the wp_head action hook
     //Check if members only commenting is allowed then customize the form accordingly
     SwpmCommentFormRelated::customize_comment_form();
     //Other wp_head related tasks go here.
 }
コード例 #2
0
 public function do_init_tasks()
 {
     //Set up localisation. First loaded ones will override strings present in later loaded file.
     //Allows users to have a customized language in a different folder.
     $locale = apply_filters('plugin_locale', get_locale(), 'swpm');
     load_textdomain('swpm', WP_LANG_DIR . "/swpm-{$locale}.mo");
     load_plugin_textdomain('swpm', false, SIMPLE_WP_MEMBERSHIP_DIRNAME . '/languages/');
     if (!isset($_COOKIE['swpm_session'])) {
         // give a unique ID to current session.
         $uid = md5(microtime());
         $_COOKIE['swpm_session'] = $uid;
         // fake it for current session/
         setcookie('swpm_session', $uid, 0, '/');
     }
     //Crete the custom post types
     $this->create_post_type();
     //Do frontend-only init time tasks
     if (!is_admin()) {
         SwpmAuth::get_instance();
         $this->verify_and_delete_account();
         $swpm_logout = filter_input(INPUT_GET, 'swpm-logout');
         if (!empty($swpm_logout)) {
             SwpmAuth::get_instance()->logout();
             $home_url = home_url();
             wp_redirect(trailingslashit($home_url));
             exit(0);
         }
         $this->process_password_reset();
         $this->register_member();
         $this->edit_profile();
         SwpmCommentFormRelated::check_and_restrict_comment_posting_to_members();
     } else {
         //Do admin side init time tasks
         if (current_user_can(SWPM_MANAGEMENT_PERMISSION)) {
             //Admin dashboard side stuff
             $this->admin_init();
         }
     }
     //IPN listener
     $this->swpm_ipn_listener();
 }