Making WordPress.org

Changeset 10118


Ignore:
Timestamp:
08/05/2020 03:37:07 AM (6 years ago)
Author:
tellyworth
Message:

Plugin directory: check block plugins for multiple namespaces.

See #5303.

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/cli/class-block-plugin-checker.php

    r10111 r10118  
    578578                                }
    579579                        }
     580                }
     581        }
     582
     583        /**
     584         * Blocks with different namespaces points to a problem, most likely a suite of blocks.
     585         */
     586        function check_for_multiple_namespaces() {
     587                $namespaces = array();
     588                foreach ( $this->blocks as $block ) {
     589                        if ( $parts = explode( '/', $block->name ) ) {
     590                                $namespaces[] = $parts[0];
     591                        }
     592                }
     593
     594                $namespaces = array_unique( $namespaces );
     595
     596                if ( count( $namespaces ) > 1 ) {
     597                        $this->record_result(
     598                                __FUNCTION__,
     599                                'error',
     600                                // translators: %s is the block name.
     601                                sprintf( __( 'Found blocks with %d different namespaces: %s.', 'wporg-plugins' ), count( $namespaces ), '<code>' . implode( ', ', $namespaces ) . '</code>' ),
     602                                $namespaces
     603                        );
    580604                }
    581605        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-block-validator.php

    r10111 r10118  
    326326                        case 'check_total_size':
    327327                                return __( 'Larger plugins will take longer to install. This is more noticeable in the Block Directory, where the user expects blocks to be added immediately. Try reducing your file size by optimizing images & SVGs, only including the assets you need (images, fonts, etc), and using core-provided JavaScript libraries.', 'wporg-plugins' );
     328                        case 'check_for_multiple_namespaces':
     329                                return __( 'Block plugins should contain a single main block. Please ensure there are no extraneous blocks included by mistake.' );
    328330                        // This is a special case, since multiple values may be collapsed.
    329331                        case 'check_block_json_is_valid':
Note: See TracChangeset for help on using the changeset viewer.