/** * * @return type */ protected function getCurrentSubject() { $userId = AAM_Core_Request::get('user'); if ($userId) { $u = get_user_by('id', $userId); $subject = array('type' => 'user', 'id' => $userId, 'name' => $u->display_name ? $u->display_name : $u->user_nicename); } else { $roles = array_keys(get_editable_roles()); $role = array_shift($roles); $subject = array('type' => 'role', 'id' => $role, 'name' => AAM_Core_API::getRoles()->get_role($role)->name); } return (object) $subject; }
/** * Make sure that AAM UI Page is used * * @return boolean * * @access public */ public static function isAAM() { $page = AAM_Core_Request::get('page'); $action = AAM_Core_Request::post('action'); $intersect = array_intersect(array('aam', 'aamc'), array($page, $action)); return is_admin() && count($intersect); }
/** * Make sure that AAM UI Page is used * * @return boolean * * @access public */ public static function isAAM() { $page = AAM_Core_Request::get('page'); $action = AAM_Core_Request::post('action'); return is_admin() && in_array('aam', array($page, $action)); }
/** * Make sure that AAM UI Page is used * * @return boolean * * @access public */ public static function isAAM() { return AAM_Core_Request::get('page') == 'aam'; }
/** * Get Post ID * * Replication of the same mechanism that is in wp-admin/post.php * * @return WP_Post|null * * @access public */ public function getPost() { if (get_post()) { $post = get_post(); } elseif ($post_id = AAM_Core_Request::get('post')) { $post = get_post($post_id); } elseif ($post_id = AAM_Core_Request::get('post_ID')) { $post = get_post($post_id); } else { $post = null; } return $post; }
/** * Print plugin localization * * @param string $localKey * * @return void * * @access protected */ protected function printLocalization($localKey) { $user = AAM_Core_Request::get('user'); $roles = array_keys(get_editable_roles()); $role = array_shift($roles); wp_localize_script($localKey, 'aamLocal', array('nonce' => wp_create_nonce('aam_ajax'), 'ajaxurl' => admin_url('admin-ajax.php'), 'url' => array('site' => admin_url('index.php'), 'jsbase' => AAM_MEDIA . '/js/aam', 'editUser' => admin_url('user-edit.php'), 'addUser' => admin_url('user-new.php')), 'subject' => array('type' => $user ? 'user' : 'role', 'id' => $user ? $user : $role, 'blog' => get_current_blog_id()), 'welcome' => AAM_Core_API::getOption('aam-welcome', 1))); }