Make WordPress Core

Changeset 43680


Ignore:
Timestamp:
10/08/2018 01:49:51 PM (6 years ago)
Author:
danielbachhuber
Message:

REST API: Define taxonomy visibility settings in schema

For Gutenberg and other admin-type interfaces, it's
useful to be able to see the visibility settings for
taxonomies.

The original changeset was partially included in [43445].

Merges [42729], [42730], [42973] to the 5.0 branch.
Props joehoyle, TimothyBlynJacobs, pento.
Fixes #42707

Location:
branches/5.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php

    r43445 r43680  
    323323                    'readonly'     => true,
    324324                ),
     325                'visibility'       => array(
     326                    'description'  => __( 'The visibility settings for the taxonomy.' ),
     327                    'type'         => 'object',
     328                    'context'      => array( 'edit' ),
     329                    'readonly'     => true,
     330                ),
    325331                'rest_base'            => array(
    326332                    'description'  => __( 'REST base route for the taxonomy.' ),
  • branches/5.0/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php

    r43445 r43680  
    198198        $data = $response->get_data();
    199199        $properties = $data['schema']['properties'];
    200         $this->assertEquals( 9, count( $properties ) );
     200        $this->assertEquals( 10, count( $properties ) );
    201201        $this->assertArrayHasKey( 'capabilities', $properties );
    202202        $this->assertArrayHasKey( 'description', $properties );
     
    207207        $this->assertArrayHasKey( 'show_cloud', $properties );
    208208        $this->assertArrayHasKey( 'types', $properties );
     209        $this->assertArrayHasKey( 'visibility', $properties );
    209210        $this->assertArrayHasKey( 'rest_base', $properties );
    210211    }
     
    240241            $this->assertEquals( $tax_obj->labels, $data['labels'] );
    241242            $this->assertEquals( $tax_obj->show_tagcloud, $data['show_cloud'] );
     243
     244            $this->assertEquals( $tax_obj->public, $data['visibility']['public'] );
     245            $this->assertEquals( $tax_obj->publicly_queryable, $data['visibility']['publicly_queryable'] );
     246            $this->assertEquals( $tax_obj->show_admin_column, $data['visibility']['show_admin_column'] );
     247            $this->assertEquals( $tax_obj->show_in_nav_menus, $data['visibility']['show_in_nav_menus'] );
     248            $this->assertEquals( $tax_obj->show_in_quick_edit, $data['visibility']['show_in_quick_edit'] );
     249            $this->assertEquals( $tax_obj->show_ui, $data['visibility']['show_ui'] );
    242250        } else {
    243251            $this->assertFalse( isset( $data['capabilities'] ) );
    244252            $this->assertFalse( isset( $data['labels'] ) );
    245253            $this->assertFalse( isset( $data['show_cloud'] ) );
     254            $this->assertFalse( isset( $data['visibility'] ) );
    246255        }
    247256    }
Note: See TracChangeset for help on using the changeset viewer.