Changeset 2895651
- Timestamp:
- 04/07/2023 02:57:59 PM (3 years ago)
- Location:
- headless-cms/trunk
- Files:
-
- 2 added
- 5 edited
-
headless-cms.php (modified) (1 diff)
-
inc/classes/api/class-get-post.php (modified) (5 diffs)
-
inc/classes/api/class-get-posts.php (modified) (2 diffs)
-
inc/classes/api/class-wc-countries.php (added)
-
inc/classes/api/class-wc-states.php (added)
-
inc/classes/class-plugin.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
headless-cms/trunk/headless-cms.php
r2761306 r2895651 8 8 * License: GPL2 9 9 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 * Version: 2.0. 110 * Version: 2.0.3 11 11 * Text Domain: headless-cms 12 12 * -
headless-cms/trunk/inc/classes/api/class-get-post.php
r2445779 r2895651 12 12 use WP_REST_Request; 13 13 use WP_REST_Response; 14 use WP_ Query;14 use WP_Post; 15 15 16 16 /** … … 50 50 * Handle Posts Request: GET Request 51 51 * 52 * This endpoint takes 'p age_no' in query params of the request.52 * This endpoint takes 'post_id' or 'post_slug' in query params of the request. 53 53 * Returns the posts data object on success 54 54 * Also handles error by returning the relevant error. 55 55 * 56 56 * 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 57 58 */ 58 59 register_rest_route( … … 80 81 $parameters = $request->get_params(); 81 82 $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'] ) : ''; 82 84 83 85 // Error Handling. 84 86 $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 } 85 93 86 94 $post_data = $this->get_required_post_data( $post_id ); … … 128 136 $post_data['excerpt'] = get_the_excerpt( $post_ID ); 129 137 $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 ); 130 141 $post_data['attachment_image'] = [ 131 142 'img_sizes' => wp_get_attachment_image_sizes( $attachment_id ), … … 137 148 'author_id' => $author_id, 138 149 'author_name' => get_the_author_meta( 'display_name', $author_id ), 150 'author_url' => get_author_posts_url( $author_id ), 139 151 ]; 140 152 -
headless-cms/trunk/inc/classes/api/class-get-posts.php
r2445779 r2895651 181 181 $post_data['excerpt'] = get_the_excerpt( $post_ID ); 182 182 $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; 183 186 $post_data['attachment_image'] = [ 184 187 'img_sizes' => wp_get_attachment_image_sizes( $attachment_id ), … … 190 193 'author_id' => $author_id, 191 194 'author_name' => get_the_author_meta( 'display_name', $author_id ), 195 'author_url' => get_author_posts_url( $author_id ), 192 196 ]; 193 197 -
headless-cms/trunk/inc/classes/class-plugin.php
r2761306 r2895651 15 15 use Headless_CMS\Features\Inc\Api\Wc_Cart; 16 16 use Headless_CMS\Features\Inc\Api\Post_By_Tax; 17 use Headless_CMS\Features\Inc\Api\Wc_Countries; 18 use Headless_CMS\Features\Inc\Api\Wc_States; 17 19 use Headless_CMS\Features\Inc\Mutations\Add_Wishlist; 18 20 use Headless_CMS\Features\Inc\Mutations\Delete_Wishlist; … … 54 56 Post_By_Tax::get_instance(); 55 57 Wc_Cart::get_instance(); 58 Wc_Countries::get_instance(); 59 Wc_States::get_instance(); 56 60 57 61 // Queries. -
headless-cms/trunk/readme.txt
r2761308 r2895651 3 3 Tags: headless-cms, decoupled, graphql 4 4 Requires at least: 4.6 5 Tested up to: 6.0.15 Tested up to: 5.4.2 6 6 Stable tag: 4.9.2 7 7 Requires PHP: 5.2.4 … … 23 23 4. Custom header and footer menus. 24 24 5. Custom Widgets. 25 6. Custom Header , Footer, SchemaGraphQL fields when using [wp-graphql](https://github.com/wp-graphql/wp-graphql) plugin25 6. Custom Header and Footer GraphQL fields when using [wp-graphql](https://github.com/wp-graphql/wp-graphql) plugin 26 26 27 27 == Feature Details == … … 74 74 Please check the demo of an example React front-end application, where this plugin can be used. 75 75 76 [2020-07-02] Demo 1.76 [2020-07-02] Demo. 77 77 78 78 [youtube https://youtu.be/nYXL1KKjKrc] 79 80 [2020-09-29] Demo 2.81 82 [youtube https://youtu.be/ygaE8ZdPEX8]83 79 84 80 = Its not working.
Note: See TracChangeset
for help on using the changeset viewer.