Plugin Directory

Changeset 2895651


Ignore:
Timestamp:
04/07/2023 02:57:59 PM (3 years ago)
Author:
gsayed786
Message:

Add new file

Location:
headless-cms/trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • headless-cms/trunk/headless-cms.php

    r2761306 r2895651  
    88 * License:     GPL2
    99 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
    10  * Version:     2.0.1
     10 * Version:     2.0.3
    1111 * Text Domain: headless-cms
    1212 *
  • headless-cms/trunk/inc/classes/api/class-get-post.php

    r2445779 r2895651  
    1212use WP_REST_Request;
    1313use WP_REST_Response;
    14 use WP_Query;
     14use WP_Post;
    1515
    1616/**
     
    5050         * Handle Posts Request: GET Request
    5151         *
    52          * This endpoint takes 'page_no' in query params of the request.
     52         * This endpoint takes 'post_id' or 'post_slug' in query params of the request.
    5353         * Returns the posts data object on success
    5454         * Also handles error by returning the relevant error.
    5555         *
    5656         * Example: http://example.com/wp-json/rae/v1/post?post_id=1
     57         * http://example.com/wp-json/rae/v1/post?post_slug=hello-world
    5758         */
    5859        register_rest_route(
     
    8081        $parameters = $request->get_params();
    8182        $post_id    = ! empty( $parameters['post_id'] ) ? intval( sanitize_text_field( $parameters['post_id'] ) ) : '';
     83        $post_slug  = ! empty( $parameters['post_slug'] ) ? sanitize_text_field( $parameters['post_slug'] ) : '';
    8284
    8385        // Error Handling.
    8486        $error = new WP_Error();
     87
     88        // Get id from slug
     89        if ( ! empty( $post_slug ) ) {
     90            $the_post = get_page_by_path( $post_slug, OBJECT, 'post' );
     91            $post_id = $the_post instanceof WP_Post ? $the_post->ID : $post_id;
     92        }
    8593
    8694        $post_data = $this->get_required_post_data( $post_id );
     
    128136        $post_data['excerpt']          = get_the_excerpt( $post_ID );
    129137        $post_data['date']             = get_the_date( '', $post_ID );
     138        $post_data['slug']             = get_post_field( 'post_name', $post_ID );
     139        $post_data['permalink']        = get_the_permalink( $post_ID );
     140        $post_data['content']          = get_post_field( 'post_content', $post_ID );
    130141        $post_data['attachment_image'] = [
    131142            'img_sizes'  => wp_get_attachment_image_sizes( $attachment_id ),
     
    137148            'author_id'   => $author_id,
    138149            'author_name' => get_the_author_meta( 'display_name', $author_id ),
     150            'author_url'  => get_author_posts_url( $author_id ),
    139151        ];
    140152
  • headless-cms/trunk/inc/classes/api/class-get-posts.php

    r2445779 r2895651  
    181181            $post_data['excerpt']          = get_the_excerpt( $post_ID );
    182182            $post_data['date']             = get_the_date( '', $post_ID );
     183            $post_data['slug']             = get_post_field( 'post_name', $post_ID );
     184            $post_data['permalink']        = get_the_permalink($post_ID);
     185            $post_data['attach_id']        = $attachment_id;
    183186            $post_data['attachment_image'] = [
    184187                'img_sizes'  => wp_get_attachment_image_sizes( $attachment_id ),
     
    190193                'author_id'   => $author_id,
    191194                'author_name' => get_the_author_meta( 'display_name', $author_id ),
     195                'author_url'  => get_author_posts_url( $author_id ),
    192196            ];
    193197
  • headless-cms/trunk/inc/classes/class-plugin.php

    r2761306 r2895651  
    1515use Headless_CMS\Features\Inc\Api\Wc_Cart;
    1616use Headless_CMS\Features\Inc\Api\Post_By_Tax;
     17use Headless_CMS\Features\Inc\Api\Wc_Countries;
     18use Headless_CMS\Features\Inc\Api\Wc_States;
    1719use Headless_CMS\Features\Inc\Mutations\Add_Wishlist;
    1820use Headless_CMS\Features\Inc\Mutations\Delete_Wishlist;
     
    5456        Post_By_Tax::get_instance();
    5557        Wc_Cart::get_instance();
     58        Wc_Countries::get_instance();
     59        Wc_States::get_instance();
    5660
    5761        // Queries.
  • headless-cms/trunk/readme.txt

    r2761308 r2895651  
    33Tags: headless-cms, decoupled, graphql
    44Requires at least: 4.6
    5 Tested up to: 6.0.1
     5Tested up to: 5.4.2
    66Stable tag: 4.9.2
    77Requires PHP: 5.2.4
     
    23234. Custom header and footer menus.
    24245. Custom Widgets.
    25 6. Custom Header, Footer, Schema GraphQL fields when using [wp-graphql](https://github.com/wp-graphql/wp-graphql) plugin
     256. Custom Header and Footer GraphQL fields when using [wp-graphql](https://github.com/wp-graphql/wp-graphql) plugin
    2626
    2727== Feature Details ==
     
    7474Please check the demo of an example React front-end application, where this plugin can be used.
    7575
    76 [2020-07-02] Demo 1.
     76[2020-07-02] Demo.
    7777
    7878[youtube https://youtu.be/nYXL1KKjKrc]
    79 
    80 [2020-09-29] Demo 2.
    81 
    82 [youtube https://youtu.be/ygaE8ZdPEX8]
    8379
    8480= Its not working.
Note: See TracChangeset for help on using the changeset viewer.