@@ -86,6 +86,7 @@ abstract class Ajaxer {
8686 public function __construct () {
8787 if ( false !== $ this ->is_single ) {
8888 \add_action ( 'wp_ajax_ ' . $ this ->action , array ( &$ this , 'ajax_request_single ' ) );
89+ \add_action ( 'wp_ajax_nopriv_ ' . $ this ->action , array ( &$ this , 'ajax_request_single ' ) );
8990 } else {
9091 foreach ( $ this ->actions as $ action => $ nopriv ) {
9192 \add_action ( 'wp_ajax_ ' . $ this ->ajax_slug ( $ action ), array ( &$ this , 'ajax_request ' ) );
@@ -132,9 +133,9 @@ final public function ajax_request_single() {
132133 $ _action = $ this ->extract_action_slug ( $ action );
133134
134135 if ( false !== $ action && isset ( $ this ->actions [ $ _action ] ) ) {
135- if ( false === \is_user_logged_in () && true === $ this ->actions [ $ _action ] ) {
136+ if ( false === $ this -> is_logged_in () && true === $ this ->actions [ $ _action ] ) {
136137 $ this ->trigger_ajax_callback ( $ action );
137- } elseif ( \is_user_logged_in () === true ) {
138+ } elseif ( $ this -> is_logged_in () === true ) {
138139 $ this ->trigger_ajax_callback ( $ action );
139140 }
140141 }
@@ -456,5 +457,14 @@ public function validate_get( $key, $error_title = false, $error_message = false
456457 public function validate_request ( $ key , $ error_title = false , $ error_message = false ) {
457458 return $ this ->validate ( $ key , $ error_title , $ error_message , 'REQUEST ' );
458459 }
460+
461+ /**
462+ * Checks if user is logged in.
463+ *
464+ * @return bool
465+ */
466+ public function is_logged_in () {
467+ return ( function_exists ( 'is_user_logged_in ' ) && is_user_logged_in () ) ? true : false ;
468+ }
459469 }
460470}
0 commit comments