Plugin Directory

Changeset 2273372

Timestamp:
04/01/2020 09:04:40 PM (4 years ago)
Author:
shaampk1
Message:

Bug fixes, and tested with the latest build

Location:
wp-custom-rest-api-generator/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-custom-rest-api-generator/trunk/admin/wpcrag_settings_api_function.php

    r1997824 r2273372  
    1212    $user_info = get_user_meta(get_the_author_meta('ID'));
    1313
    14     $author_meta = (object) ['author_name' => implode($user_info[nickname]),
    15 
    16         'author_description' => implode($user_info[description]),
    17 
    18         'author_user_level' => (int) implode($user_info[wp_user_level]),
     14    $author_meta = (object) ['author_name' => implode($user_info[]),
     15
     16        'author_description' => implode($user_info[]),
     17
     18        'author_user_level' => (int) implode($user_info[]),
    1919
    2020        'author_avatar' => get_avatar_url(get_the_author_meta('ID')),
     
    3030function wpcrag_get_featured_image()
    3131{
     32
    3233
    3334    $featured_image = (object) ['size_thumbnail' => get_the_post_thumbnail_url($post->ID, 'thumbnail'),
     
    4142    ];
    4243
    43     return $featured_image;
     44    return $featured_image;
    4445
    4546}
     
    116117
    117118            $custom_field_keys = get_post_custom_keys($post_id);
    118 
    119             foreach ($custom_field_keys as $key => $field_name) {
    120 
    121                 $valuet = trim($field_name);
    122 
    123                 if ('_' == $valuet{0}) {
    124 
    125                     continue;
     119           
     120            if ($custom_field_keys) {
     121                foreach ($custom_field_keys as $key => $field_name) {
     122
     123                    $valuet = trim($field_name);
     124
     125                    if ('_' == $valuet[0]) {
     126
     127                        continue;
     128
     129                    }
     130
     131                    // matches value in the db, if found then registers to Rest API
     132
     133                    $post_field_key = $post_type . '_' . $field_name;
     134
     135                    if (is_array($options) && array_key_exists($post_field_key, $options)) {
     136
     137                        register_rest_field($post_type,
     138
     139                            $field_name,
     140
     141                            array(
     142
     143                                'get_callback' => 'wpcrag_get_post_meta',
     144
     145                                'update_callback' => null,
     146
     147                                'schema' => null,
     148
     149                            )
     150
     151                        );
     152
     153                    }
    126154
    127155                }
    128 
    129                 // matches value in the db, if found then registers to Rest API
    130 
    131                 $post_field_key = $post_type . '_' . $field_name;
    132 
    133                 if (is_array($options) && array_key_exists($post_field_key, $options)) {
    134 
    135                     register_rest_field($post_type,
    136 
    137                         $field_name,
    138 
    139                         array(
    140 
    141                             'get_callback' => 'wpcrag_get_post_meta',
    142 
    143                             'update_callback' => null,
    144 
    145                             'schema' => null,
    146 
    147                         )
    148 
    149                     );
    150 
    151                 }
    152 
    153156            }
    154157
  • wp-custom-rest-api-generator/trunk/admin/wpcrag_settings_callback.php

    r1997824 r2273372  
    122122                                        $valuet = trim($value);
    123123
    124                                         if ('_' == $valuet{0}) {
     124                                        if ('_' == $valuet) {
    125125
    126126                                            continue;
  • wp-custom-rest-api-generator/trunk/readme.txt

    r2193542 r2273372  
    44Tags: rest api, rest, api, wp api, admin, json, custom fields, taxonomy
    55Requires at least: 5.0
    6 Tested up to: 5.3
    7 Stable tag: 1.0.2
     6Tested up to: 5.
     7Stable tag: 1.0.
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4545== Changelog ==
    4646
     47
     48
     49
    4750= 1.0.2 =
    4851* Tested with the latest build
    4952
    5053= 1.0.1 =
    51 * updated meta information
     54* pdated meta information
    5255
    5356= 1.0.0 =
  • wp-custom-rest-api-generator/trunk/wp_custom_rest_api_generator.php

    r2193542 r2273372  
    99Description:  Admin panel for enabling Author Meta, Featured Image, Custom Fields and Taxonomies for all available Post Types in WordPress Rest API
    1010
    11 Version:      1.0.2
     11Version:      1.0.
    1212
    1313Author:       Centangle Interactive
     
    2525the Free Software Foundation, either version 2 of the License, or
    2626any later version.
    27  
     27
    2828WP Custom REST API Generator is distributed in the hope that it will be useful,
    2929but WITHOUT ANY WARRANTY; without even the implied warranty of
    3030MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    3131GNU General Public License for more details.
    32  
     32
    3333You should have received a copy of the GNU General Public License
    34 along with WP Custom REST API Generator. If not, see License URI: 
     34along with WP Custom REST API Generator. If not, see License URI:
    3535https://www.gnu.org/licenses/gpl-2.0.html
    3636
Note: See TracChangeset for help on using the changeset viewer.