Make WordPress Core

Ticket #42707: 42707.2.diff

File 42707.2.diff, 5.0 KB (added by joehoyle, 8 years ago)
  • src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
    index 1438481..8b245dd 100644
    a b class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    191191                        'show_cloud'   => $taxonomy->show_tagcloud,
    192192                        'hierarchical' => $taxonomy->hierarchical,
    193193                        'rest_base'    => $base,
     194                        'visibility'   => array(
     195                                'public'             => (bool) $taxonomy->public,
     196                                'publicly_queryable' => (bool) $taxonomy->publicly_queryable,
     197                                'show_admin_column'  => (bool) $taxonomy->show_admin_column,
     198                                'show_in_nav_menus'  => (bool) $taxonomy->show_in_nav_menus,
     199                                'show_in_quick_edit' => (bool) $taxonomy->show_in_quick_edit,
     200                                'show_ui'            => (bool) $taxonomy->show_ui,
     201                        ),
    194202                );
    195203
    196204                $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
     205
    197206                $data    = $this->add_additional_fields_to_object( $data, $request );
    198207                $data    = $this->filter_response_by_context( $data, $context );
    199208
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    295304                                        'context'     => array( 'view', 'edit', 'embed' ),
    296305                                        'readonly'    => true,
    297306                                ),
     307                                'visibility'       => array(
     308                                        'description'  => __( 'The visibility settings for the taxomonmy.' ),
     309                                        'type'         => 'object',
     310                                        'context'      => array( 'edit' ),
     311                                        'readonly'     => true,
     312                                        'properties'   => array(
     313                                                'public' => array(
     314                                                        'descriptoin' => 'Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users.',
     315                                                        'type'        => 'boolean',
     316                                                ),
     317                                                'publicly_queryable' => array(
     318                                                        'descriptoin' => 'Whether the taxonomy is publicly queryable.',
     319                                                        'type'        => 'boolean',
     320                                                ),
     321                                                'show_ui' => array(
     322                                                        'descriptoin' => 'Whether to generate a default UI for managing this taxonomy.',
     323                                                        'type'        => 'boolean',
     324                                                ),
     325                                                'show_admin_column' => array(
     326                                                        'descriptoin' => 'Whether to allow automatic creation of taxonomy columns on associated post-types table.',
     327                                                        'type'        => 'boolean',
     328                                                ),
     329                                                'show_in_nav_menus' => array(
     330                                                        'descriptoin' => 'Whetgher to make the taxonomy available for selection in navigation menus.',
     331                                                        'type'        => 'boolean',
     332                                                ),
     333                                                'show_in_quick_edit' => array(
     334                                                        'descriptoin' => 'Whether to show the taxonomy in the quick/bulk edit panel.',
     335                                                        'type'        => 'boolean',
     336                                                ),
     337
     338                                        ),
     339                                ),
    298340                        ),
    299341                );
    300342                return $this->add_additional_fields_schema( $schema );
  • tests/phpunit/tests/rest-api/rest-taxonomies-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php b/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php
    index 205a041..b86acf3 100644
    a b class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas 
    144144                $response   = $this->server->dispatch( $request );
    145145                $data       = $response->get_data();
    146146                $properties = $data['schema']['properties'];
    147                 $this->assertEquals( 9, count( $properties ) );
     147                $this->assertEquals( 10, count( $properties ) );
    148148                $this->assertArrayHasKey( 'capabilities', $properties );
    149149                $this->assertArrayHasKey( 'description', $properties );
    150150                $this->assertArrayHasKey( 'hierarchical', $properties );
    class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas 
    153153                $this->assertArrayHasKey( 'slug', $properties );
    154154                $this->assertArrayHasKey( 'show_cloud', $properties );
    155155                $this->assertArrayHasKey( 'types', $properties );
     156                $this->assertArrayHasKey( 'visibility', $properties );
    156157                $this->assertArrayHasKey( 'rest_base', $properties );
    157158        }
    158159
    class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas 
    186187                        $this->assertEquals( $tax_obj->cap, $data['capabilities'] );
    187188                        $this->assertEquals( $tax_obj->labels, $data['labels'] );
    188189                        $this->assertEquals( $tax_obj->show_tagcloud, $data['show_cloud'] );
     190
     191                        $this->assertEquals( $tax_obj->public, $data['visibility']['public'] );
     192                        $this->assertEquals( $tax_obj->publicly_queryable, $data['visibility']['publicly_queryable'] );
     193                        $this->assertEquals( $tax_obj->show_admin_column, $data['visibility']['show_admin_column'] );
     194                        $this->assertEquals( $tax_obj->show_in_nav_menus, $data['visibility']['show_in_nav_menus'] );
     195                        $this->assertEquals( $tax_obj->show_in_quick_edit, $data['visibility']['show_in_quick_edit'] );
     196                        $this->assertEquals( $tax_obj->show_ui, $data['visibility']['show_ui'] );
    189197                } else {
    190198                        $this->assertFalse( isset( $data['capabilities'] ) );
    191199                        $this->assertFalse( isset( $data['labels'] ) );
    192200                        $this->assertFalse( isset( $data['show_cloud'] ) );
     201                        $this->assertFalse( isset( $data['visibility'] ) );
    193202                }
    194203        }
    195204