Plugin Directory

Changeset 2521956


Ignore:
Timestamp:
04/27/2021 09:14:38 AM (5 years ago)
Author:
pressmate
Message:

2.3.1 - Fixed

Location:
makestories-helper/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • makestories-helper/trunk/api/publish.php

    r2521947 r2521956  
    306306            "updatedAt" => strtotime($post->post_modified) * 1000,
    307307            "post_id" => $post->ID,
     308            "category" => $category,
     309        ];
     310    }
     311    die(json_encode($toSend));
     312}
     313
     314
     315add_action("wp_ajax_ms_get_published_posts_all", "ms_get_published_posts_all");
     316
     317
     318function ms_get_published_posts_all(){
     319    ms_protect_ajax_route();
     320    header("Content-Type: application/json");
     321    $args = [
     322        "post_type" => MS_POST_TYPE,
     323        "numberposts" => -1,
     324    ];
     325    $posts = get_posts($args);
     326    $toSend = [
     327        "posts" => [],
     328    ];
     329    foreach ($posts as $post){
     330        $storyId = get_post_meta($post->ID, "story_id", true);
     331        $category = [];
     332        $terms = wp_get_post_terms($post->ID, MS_TAXONOMY);
     333        foreach ($terms as $term){
     334            $category[] = $term->name;
     335        }
     336        $title = $post->post_name;
     337        $meta = get_post_meta($post->ID, "publisher_details", true);
     338        $poster = "";
     339        if($meta && is_string($meta) && strlen($meta)){
     340            try{
     341                $parsed = json_decode($meta, true);
     342                if($parsed && is_array($parsed)){
     343                    if(isset($parsed['title'])){
     344                        $title = $parsed['title'];
     345                    }
     346                    if(isset($parsed['poster-portrait-src'])){
     347                        $poster = $parsed['poster-portrait-src'];
     348                    }
     349                }
     350            }catch (Exception $e){
     351                //Do nothing - Just for safety
     352            }
     353        }
     354        $toSend['posts'][$post->ID] = [
     355            "link" => get_post_permalink($post->ID),
     356            "title" => $title,
     357            "poster" => $poster,
     358            "updatedAt" => strtotime($post->post_modified) * 1000,
     359            "post_id" => $post->ID,
     360            "story_id" => $storyId,
    308361            "category" => $category,
    309362        ];
  • makestories-helper/trunk/pages/category-structure.php

    r2521947 r2521956  
    140140                    data: {
    141141                        _wpnonce: nonce,
    142                         action: "ms_get_published_posts",
     142                        action: "ms_get_published_posts_all",
    143143                    },
    144144                    success: function(data){
Note: See TracChangeset for help on using the changeset viewer.