public static function getAdminPage($custom_data = array()) { global $pagenow, $post, $post_type; $pageData = (object) array('post_type' => $custom_data['post_type'], 'isAdmin' => false, 'isAdminAjax' => false, 'isPostEdit' => false, 'isPostNew' => false, 'isCustomPostEdit' => false, 'isCustomPostNew' => false, 'isCustomAdminPage' => false); if (!is_admin()) { if ($custom_data['post_type'] == CRED_FORMS_CUSTOM_POST_NAME) { self::$currentPage = $pageData; } if ($custom_data['post_type'] == CRED_USER_FORMS_CUSTOM_POST_NAME) { self::$currentUPage = $pageData; } return $pageData; } $pageData->isAdmin = true; $pageData->isPostEdit = (bool) ('post.php' === $pagenow); $pageData->isPostNew = (bool) ('post-new.php' === $pagenow); if (!empty($custom_data)) { $custom_post_type = isset($custom_data['post_type']) ? $custom_data['post_type'] : false; $pageData->isCustomPostEdit = (bool) ($pageData->isPostEdit && $custom_post_type === $post_type); $pageData->isCustomPostNew = (bool) ($pageData->isPostNew && isset($_GET['post_type']) && $custom_post_type === $_GET['post_type']); } if (!empty($custom_data)) { $custom_admin_base = isset($custom_data['base']) ? $custom_data['base'] : false; $custom_admin_pages = isset($custom_data['pages']) ? (array) $custom_data['pages'] : array(); $pageData->isCustomAdminPage = (bool) ($custom_admin_base === $pagenow && isset($_GET['page']) && in_array($_GET['page'], $custom_admin_pages)); } if ($custom_data['post_type'] == CRED_FORMS_CUSTOM_POST_NAME) { self::$currentPage = $pageData; } if ($custom_data['post_type'] == CRED_USER_FORMS_CUSTOM_POST_NAME) { self::$currentUPage = $pageData; } return $pageData; }