Making WordPress.org


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

Plugin directory: check block plugins for multiple namespaces.

See #5303.

File:
1 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    }
Note: See TracChangeset for help on using the changeset viewer.