Refactor
This commit is contained in:
parent
10a60f7c5d
commit
dffd5d45f4
3 changed files with 26 additions and 7 deletions
24
src/classes/blog.php
Normal file
24
src/classes/blog.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The wishthis blog.
|
||||
*/
|
||||
|
||||
namespace wishthis;
|
||||
|
||||
class Blog
|
||||
{
|
||||
private const URL = 'https://wishthis.online/src/blog';
|
||||
private const ENDPOINT_POSTS = self::URL . '/wp-json/wp/v2/posts';
|
||||
|
||||
public static function getPosts(): array {
|
||||
$posts_remote = file_get_contents(self::ENDPOINT_POSTS);
|
||||
$posts = array();
|
||||
|
||||
if (false !== $posts_remote) {
|
||||
$posts = json_decode($posts_remote);
|
||||
}
|
||||
|
||||
return $posts;
|
||||
}
|
||||
}
|
|
@ -456,7 +456,7 @@ class Page
|
|||
array(
|
||||
'text' => __('Blog'),
|
||||
'url' => '/?page=blog',
|
||||
'icon' => 'blog',
|
||||
'icon' => 'rss',
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -13,12 +13,7 @@ $page->header();
|
|||
$page->bodyStart();
|
||||
$page->navigation();
|
||||
|
||||
$posts_remote = file_get_contents('https://wishthis.online/src/blog/wp-json/wp/v2/posts');
|
||||
$posts = array();
|
||||
|
||||
if (false !== $posts_remote) {
|
||||
$posts = json_decode($posts_remote);
|
||||
}
|
||||
$posts = Blog::getPosts();
|
||||
?>
|
||||
|
||||
<main>
|
||||
|
|
Loading…
Reference in a new issue