示例#1
0
			<?php 
    _e('Logging In...', 'social');
    ?>
		</div>
		<?php 
    if (comments_open()) {
        if (get_option('comment_registration') and !is_user_logged_in()) {
            ?>
		<p class="must-log-in"><?php 
            printf(__('You must be <a href="%s">logged in</a> to post a comment.', 'social'), wp_login_url(apply_filters('the_permalink', get_permalink(get_the_ID()))));
            ?>
</p>
		<?php 
            do_action('comment_form_must_log_in_after');
        }
        echo Social_Comment_Form::instance(get_the_ID());
    } else {
        do_action('comment_form_comments_closed');
        ?>
		<p class="nocomments"><?php 
        _e('Comments are closed.', 'social');
        ?>
</p>
		<?php 
    }
    ?>
	</div>
<?php 
    $form = ob_get_clean();
    ob_start();
    ?>
示例#2
0
 /**
  * Renders the new comment form.
  *
  * @return void
  */
 public function action_reload_form()
 {
     if (!$this->request->is_ajax()) {
         exit;
     }
     if (isset($_COOKIE['social_auth_nonce'])) {
         $cookie_nonce = stripslashes($_COOKIE['social_auth_nonce']);
         // Find the user by NONCE.
         global $wpdb;
         $user_id = $wpdb->get_var($wpdb->prepare("\n\t\t\t\tSELECT user_id\n\t\t\t\t  FROM {$wpdb->usermeta}\n\t\t\t\t WHERE meta_key = %s\n\t\t\t", 'social_auth_nonce_' . $cookie_nonce));
         if ($user_id !== null) {
             Social::log('Found user #:id using nonce :nonce.', array('id' => $user_id, 'nonce' => $cookie_nonce));
             // Log the user in
             wp_set_current_user($user_id);
             add_filter('auth_cookie_expiration', array($this->social, 'auth_cookie_expiration'));
             wp_set_auth_cookie($user_id, true);
             remove_filter('auth_cookie_expiration', array($this->social, 'auth_cookie_expiration'));
             delete_user_meta($user_id, 'social_auth_nonce_' . $cookie_nonce);
             setcookie('social_auth_nonce', '', -3600, '/');
             $post_id = $this->request->query('post_id');
             $form = trim(Social_Comment_Form::instance($post_id)->render());
             echo json_encode(array('result' => 'success', 'html' => $form, 'disconnect_url' => wp_loginout('', false)));
         } else {
             Social::log('Failed to find the user using nonce :nonce.', array('nonce' => $_COOKIE['social_auth_nonce']));
             echo json_encode(array('result' => 'error', 'html' => 'not logged in'));
         }
     } else {
         echo json_encode(array('result' => 'error', 'html' => 'not logged in'));
     }
     exit;
 }