Making WordPress.org

Changeset 9055


Ignore:
Timestamp:
07/18/2019 08:28:52 AM (6 years ago)
Author:
tellyworth
Message:

Plugin dir: include block metadata in results.

This returns blocks and block_assets fields in search results for block queries.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php

    r8729 r9055  
    217217            }
    218218        }
     219
     220        // Block metadata, if available
     221        $result['blocks'] = get_post_meta( $post_id, 'all_blocks', true ) ?: [];
     222        $result['block_assets'] = get_post_meta( $post_id, 'block_files', true ) ?: [];
    219223
    220224        // That's all folks!
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api-request.php

    r9051 r9055  
    3333        'tested'            => false,
    3434        'stable_tag'        => false,
     35        'blocks'            => false,
     36        'block_assets'      => false,
    3537    );
    3638
     
    5254        'tags'              => true,
    5355        'tested'            => true,
     56        'blocks'            => false,
     57        'block_assets'      => false,
    5458    );
    5559
     
    8387        'tags'              => true,
    8488        'tested'            => true,
     89        'blocks'            => false,
     90        'block_assets'      => false,
    8591    );
    8692
     
    152158        }
    153159
     160        // If it's a block search, include blocks in the response by default
     161        if ( ! empty( $this->args->block ) ) {
     162            $fields['blocks']       = true;
     163            $fields['block_assets'] = true;
     164        }
     165
    154166        $fields = array_merge( $fields, $this->requested_fields );
    155167
Note: See TracChangeset for help on using the changeset viewer.