wp/wp-includes/class-wp-block-styles-registry.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    34 	 *
    34 	 *
    35 	 * @since 5.3.0
    35 	 * @since 5.3.0
    36 	 *
    36 	 *
    37 	 * @param string $block_name       Block type name including namespace.
    37 	 * @param string $block_name       Block type name including namespace.
    38 	 * @param array  $style_properties Array containing the properties of the style name, label,
    38 	 * @param array  $style_properties Array containing the properties of the style name, label,
    39 	 *                                 style (name of the stylesheet to be enqueued),
    39 	 *                                 is_default, style_handle (name of the stylesheet to be enqueued),
    40 	 *                                 inline_style (string containing the CSS to be added).
    40 	 *                                 inline_style (string containing the CSS to be added).
    41 	 * @return boolean True if the block style was registered with success and false otherwise.
    41 	 * @return bool True if the block style was registered with success and false otherwise.
    42 	 */
    42 	 */
    43 	public function register( $block_name, $style_properties ) {
    43 	public function register( $block_name, $style_properties ) {
    44 
    44 
    45 		if ( ! isset( $block_name ) || ! is_string( $block_name ) ) {
    45 		if ( ! isset( $block_name ) || ! is_string( $block_name ) ) {
    46 			$message = __( 'Block name must be a string.' );
    46 			_doing_it_wrong(
    47 			_doing_it_wrong( __METHOD__, $message, '5.3.0' );
    47 				__METHOD__,
       
    48 				__( 'Block name must be a string.' ),
       
    49 				'5.3.0'
       
    50 			);
    48 			return false;
    51 			return false;
    49 		}
    52 		}
    50 
    53 
    51 		if ( ! isset( $style_properties['name'] ) || ! is_string( $style_properties['name'] ) ) {
    54 		if ( ! isset( $style_properties['name'] ) || ! is_string( $style_properties['name'] ) ) {
    52 			$message = __( 'Block style name must be a string.' );
    55 			_doing_it_wrong(
    53 			_doing_it_wrong( __METHOD__, $message, '5.3.0' );
    56 				__METHOD__,
       
    57 				__( 'Block style name must be a string.' ),
       
    58 				'5.3.0'
       
    59 			);
    54 			return false;
    60 			return false;
    55 		}
    61 		}
    56 
    62 
    57 		$block_style_name = $style_properties['name'];
    63 		$block_style_name = $style_properties['name'];
    58 
    64 
    67 	/**
    73 	/**
    68 	 * Unregisters a block style.
    74 	 * Unregisters a block style.
    69 	 *
    75 	 *
    70 	 * @param string $block_name       Block type name including namespace.
    76 	 * @param string $block_name       Block type name including namespace.
    71 	 * @param string $block_style_name Block style name.
    77 	 * @param string $block_style_name Block style name.
    72 	 * @return boolean True if the block style was unregistered with success and false otherwise.
    78 	 * @return bool True if the block style was unregistered with success and false otherwise.
    73 	 */
    79 	 */
    74 	public function unregister( $block_name, $block_style_name ) {
    80 	public function unregister( $block_name, $block_style_name ) {
    75 		if ( ! $this->is_registered( $block_name, $block_style_name ) ) {
    81 		if ( ! $this->is_registered( $block_name, $block_style_name ) ) {
    76 			/* translators: 1: Block name, 2: Block style name. */
    82 			_doing_it_wrong(
    77 			$message = sprintf( __( 'Block "%1$s" does not contain a style named "%2$s".' ), $block_name, $block_style_name );
    83 				__METHOD__,
    78 			_doing_it_wrong( __METHOD__, $message, '5.3.0' );
    84 				/* translators: 1: Block name, 2: Block style name. */
       
    85 				sprintf( __( 'Block "%1$s" does not contain a style named "%2$s".' ), $block_name, $block_style_name ),
       
    86 				'5.3.0'
       
    87 			);
    79 			return false;
    88 			return false;
    80 		}
    89 		}
    81 
    90 
    82 		unset( $this->registered_block_styles[ $block_name ][ $block_style_name ] );
    91 		unset( $this->registered_block_styles[ $block_name ][ $block_style_name ] );
    83 
    92