'blog-post', 'title' => null, 'content' => null, 'require' => true ); return self::$currentPage; } if (get_queried_object_id() != 0) { $pageId = get_queried_object_id(); } if (!$pageId) { $menuID = self::getMenuID(); $items = wp_get_nav_menu_items($menuID); $items = self::toArray($items); if (empty($items)) { return false; } // $items = reset($items); $pageId = $items['object_id']; } if (!$pageId) { return false; } // $pages = get_pages(array( 'post_type' => 'page', 'post_status' => 'publish', 'include' => array($pageId) )); if (empty($pages)) { return false; } $pages = self::toArray($pages); // $pages = reset($pages); self::$currentPage = array( 'id' => null, 'title' => $pages['post_title'], 'content' => $pages['post_content'] ); return self::$currentPage; } public static function getPostData($postId = null) { $postId = get_the_ID(); if (!$postId) { return false; } $postData = get_post($postId); if (!$postData) { return false; } $postData = json_decode(json_encode($postData), true); $postData['post_time'] = strtotime($postData['post_date']); return $postData; } public static function getMenuID() { $menuList = wp_get_nav_menus(); $menuList = self::toArray($menuList); foreach ($menuList as $e) { if ($e['taxonomy'] == 'nav_menu') return $e['term_id']; } return false; } public static function toArray($object) { return json_decode(json_encode($object), true); } public static function thisIsHomePage() { if (is_front_page() && empty($_GET['page_id'])) { return true; } else { return false; } } }