Update wprest.php
This commit is contained in:
parent
56e7c5c0a3
commit
89d6551485
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
if(!function_exists("get_wp_posts")) {
|
if(!function_exists("get_wp_posts")) {
|
||||||
function get_wp_posts($wp_server_url) {
|
function get_wp_posts($wp_server_url) {
|
||||||
$result = array();
|
$results = array();
|
||||||
|
|
||||||
$posts = parse_wp_posts($wp_server_url);
|
$posts = parse_wp_posts($wp_server_url);
|
||||||
$url_res = parse_url($wp_server_url);
|
$url_res = parse_url($wp_server_url);
|
||||||
|
@ -18,18 +18,19 @@ if(!function_exists("get_wp_posts")) {
|
||||||
$title = $post['title'];
|
$title = $post['title'];
|
||||||
$content = $post['content'];
|
$content = $post['content'];
|
||||||
$link = $post['link'];
|
$link = $post['link'];
|
||||||
|
$object_id = $post['id'];
|
||||||
|
|
||||||
$new_message = get_wp_new_message($title, $content, $link);
|
$new_message = get_wp_new_message($title, $content, $link);
|
||||||
$alt_message = get_wp_new_message($title, $content);
|
$alt_message = get_wp_new_message($title, $content);
|
||||||
|
|
||||||
$result[] = array(
|
$results[] = array(
|
||||||
"origin" => $origin,
|
"origin" => $origin,
|
||||||
"title" => $title,
|
"title" => $title,
|
||||||
"content" => $content,
|
"content" => $content,
|
||||||
"link" => $link,
|
"link" => $link,
|
||||||
"message" => $new_message,
|
"message" => $new_message,
|
||||||
"alt_message" => $alt_message,
|
"alt_message" => $alt_message,
|
||||||
"object_id" => $post->id,
|
"object_id" => $object_id,
|
||||||
"hash_title" => get_hashed_text($title),
|
"hash_title" => get_hashed_text($title),
|
||||||
"hash_content" => get_hashed_text($content),
|
"hash_content" => get_hashed_text($content),
|
||||||
"hash_link" => get_hashed_text($link),
|
"hash_link" => get_hashed_text($link),
|
||||||
|
@ -38,22 +39,23 @@ if(!function_exists("get_wp_posts")) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!function_exists("parse_wp_posts")) {
|
if(!function_exists("parse_wp_posts")) {
|
||||||
function parse_wp_posts($wp_server_url) {
|
function parse_wp_posts($wp_server_url) {
|
||||||
$rest_no_route = false;
|
$rest_no_route = false;
|
||||||
|
|
||||||
$posts = array();
|
$posts = array();
|
||||||
$data = array();
|
$results = array();
|
||||||
|
|
||||||
$response = get_web_json($wp_server_url, "get", array(
|
$response = get_web_json($wp_server_url, "get", array(
|
||||||
"rest_route" => "/wp/v2/posts/"
|
"rest_route" => "/wp/v2/posts/"
|
||||||
));
|
));
|
||||||
|
|
||||||
$code = get_value_in_class("code", $response);
|
$code = get_value_in_object("code", $response);
|
||||||
if($code == "rest_no_route") {
|
if($code === "rest_no_route") {
|
||||||
$rest_no_route = true;
|
$rest_no_route = true;
|
||||||
$response = get_web_xml($wp_server_url, "get", array(
|
$response = get_web_xml($wp_server_url, "get", array(
|
||||||
"feed" => "rss2"
|
"feed" => "rss2"
|
||||||
|
@ -63,24 +65,28 @@ if(!function_exists("parse_wp_posts")) {
|
||||||
if($rest_no_route === false) {
|
if($rest_no_route === false) {
|
||||||
$posts = $response;
|
$posts = $response;
|
||||||
foreach($posts as $post) {
|
foreach($posts as $post) {
|
||||||
$data[] = array(
|
$results[] = array(
|
||||||
"title" => get_clean_xss($post->title->rendered, 1),
|
"title" => get_clean_xss($post->title->rendered, 1),
|
||||||
"content" => get_clean_xss($post->content->rendered, 1),
|
"content" => get_clean_xss($post->content->rendered, 1),
|
||||||
"link" => get_clean_xss($post->guid->rendered, 1),
|
"link" => get_clean_xss($post->guid->rendered, 1),
|
||||||
|
"id" => $post->id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$posts = $response->channel->item;
|
$posts = $response->channel->item;
|
||||||
foreach($posts as $post) {
|
foreach($posts as $post) {
|
||||||
$data[] = array(
|
$post_link = get_clean_xss($post->link);
|
||||||
|
$post_link_paths = explode("/", $post_link);
|
||||||
|
$results[] = array(
|
||||||
"title" => get_clean_xss($post->title),
|
"title" => get_clean_xss($post->title),
|
||||||
"content" => get_clean_xss($post->description),
|
"content" => get_clean_xss($post->description),
|
||||||
"link" => get_clean_xss($post->link),
|
"link" => $post_link,
|
||||||
|
"id" => end($post_link_paths),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user