Changeset 13035
- Timestamp:
- 12/08/2023 05:02:12 AM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r13033 r13035 735 735 return true; 736 736 } 737 738 // Other users can only use the preview button if plugin committers have enabled it. 739 $post = get_post( $post ); 740 if ( get_post_meta( $post->ID, '_public_preview', true ) ) { 741 return true; 742 } 737 743 } 738 744 return false; … … 748 754 $post = get_post( $post ); 749 755 750 $blueprints = get_post_meta( $post->ID, 'assets_blueprints', true);756 $blueprints = self::get_blueprints( $post ); 751 757 // Note: for now, only use a file called `blueprint.json`. 752 758 if ( !isset( $blueprints['blueprint.json'] ) ) { … … 754 760 } 755 761 $blueprint = $blueprints['blueprint.json']; 756 if ( !$blueprint || !isset( $blueprint['contents'] ) || !is_string( $blueprint['contents'] ) ) { 757 return false; 758 } 759 760 $blueprint_url = sprintf( 'https://wordpress.org/plugins/wp-json/plugins/v1/plugin/%s/blueprint.json?rev=%d', $post->post_name, $blueprint['revision'] ); 761 762 return sprintf( 'https://playground.wordpress.net/?plugin=%s&blueprint-url=%s', esc_attr($post->post_name), esc_attr($blueprint_url ) ); 762 763 return sprintf( 'https://playground.wordpress.net/?plugin=%s&blueprint-url=%s', esc_attr($post->post_name), esc_attr($blueprint['url'] ) ); 764 } 765 766 /** 767 * Return a list of blueprints for the given plugin. 768 * 769 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 770 * @return array An array of blueprints. 771 */ 772 public static function get_blueprints( $post = null ) { 773 $post = get_post( $post ); 774 775 $out = array(); 776 777 $blueprints = get_post_meta( $post->ID, 'assets_blueprints', true ); 778 if ( $blueprints ) { 779 foreach ( $blueprints as $filename => $item ) { 780 if ( isset( $item['contents'] ) ) { 781 $out[ $filename ] = array( 782 'filename' => $filename, 783 'url' => sprintf( 'https://wordpress.org/plugins/wp-json/plugins/v1/plugin/%s/blueprint.json?rev=%d', $post->post_name, $item['revision'] ) 784 ); 785 } 786 } 787 } 788 789 return $out; 763 790 } 764 791
Note: See TracChangeset
for help on using the changeset viewer.