Plugin Directory

Changeset 3075060


Ignore:
Timestamp:
04/22/2024 01:48:52 PM (11 months ago)
Author:
zapier
Message:

Add endpoint to retrieve support fields for custom-type posts

Location:
zapier
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • zapier/tags/1.1.0/readme.txt

    r3069174 r3075060  
    55Tested up to: 6.4
    66Requires PHP: 7.0
    7 Stable tag: 1.0.7
     7Stable tag: 1.1.0
    88License: Expat (MIT License)
    99License URI: https://spdx.org/licenses/MIT.html
     
    102102* Updated description.
    103103* Hotfix: Fix User-Agent header validation.
     104
     105= 1.1.0 =
     106
     107* Add endpoint to retrieve support fields for custom-type posts.
  • zapier/tags/1.1.0/zapier.php

    r3069174 r3075060  
    44 * Plugin Name:       Zapier for WordPress
    55 * Description:       Zapier enables you to automatically share your posts to social media, create WordPress posts from Mailchimp newsletters, and much more. Visit https://zapier.com/apps/wordpress/integrations for more details.
    6  * Version:           1.0.7
     6 * Version:           1.1.0
    77 * Author:            Zapier
    88 * Author URI:        https://zapier.com
     
    9494            'permission_callback' => '__return_true'
    9595        ));
     96
     97        register_rest_route($this->namespace, '/(?P<type>[a-zA-Z0-9_-]+)/supports', array(
     98            'methods' => "GET",
     99            'callback' => array($this, 'get_custom_type_supports'),
     100            'permission_callback' => '__return_true'
     101        ));
     102    }
     103
     104    public function get_custom_type_supports($request)
     105    {
     106        $type = $request['type'];
     107        $types = get_post_types(array());
     108
     109        if(!in_array($type, $types)) {
     110            return new WP_Error(
     111                'invalid_post_type',
     112                'Invalid post type',
     113                array(
     114                    'status' => 404,
     115                )
     116            );
     117        }
     118       
     119        return array('supports' => get_all_post_type_supports($type));
    96120    }
    97121
  • zapier/trunk/readme.txt

    r3069174 r3075060  
    55Tested up to: 6.4
    66Requires PHP: 7.0
    7 Stable tag: 1.0.7
     7Stable tag: 1.1.0
    88License: Expat (MIT License)
    99License URI: https://spdx.org/licenses/MIT.html
     
    102102* Updated description.
    103103* Hotfix: Fix User-Agent header validation.
     104
     105= 1.1.0 =
     106
     107* Add endpoint to retrieve support fields for custom-type posts.
  • zapier/trunk/zapier.php

    r3069174 r3075060  
    44 * Plugin Name:       Zapier for WordPress
    55 * Description:       Zapier enables you to automatically share your posts to social media, create WordPress posts from Mailchimp newsletters, and much more. Visit https://zapier.com/apps/wordpress/integrations for more details.
    6  * Version:           1.0.7
     6 * Version:           1.1.0
    77 * Author:            Zapier
    88 * Author URI:        https://zapier.com
     
    9494            'permission_callback' => '__return_true'
    9595        ));
     96
     97        register_rest_route($this->namespace, '/(?P<type>[a-zA-Z0-9_-]+)/supports', array(
     98            'methods' => "GET",
     99            'callback' => array($this, 'get_custom_type_supports'),
     100            'permission_callback' => '__return_true'
     101        ));
     102    }
     103
     104    public function get_custom_type_supports($request)
     105    {
     106        $type = $request['type'];
     107        $types = get_post_types(array());
     108
     109        if(!in_array($type, $types)) {
     110            return new WP_Error(
     111                'invalid_post_type',
     112                'Invalid post type',
     113                array(
     114                    'status' => 404,
     115                )
     116            );
     117        }
     118       
     119        return array('supports' => get_all_post_type_supports($type));
    96120    }
    97121
Note: See TracChangeset for help on using the changeset viewer.