', $cols ); } public static function close_grid(): string { return ''; } /** * One of the plugin's blocks rendered outside post content, for a page the * plugin builds when it is shown (a review's, a team member's). * * @param array $attrs */ public static function block( string $name, array $attrs ): string { return render_block( [ 'blockName' => $name, 'attrs' => $attrs, 'innerBlocks' => [], 'innerHTML' => '', 'innerContent' => [], ] ); } /** * A coupon's discount as the customer reads it: "10% off", "$25 off", or * '' for no amount. */ public static function discount( float $amount, string $type ): string { if ( $amount <= 0 ) { return ''; } // number_format() always emits the decimal point, so trimming trailing // zeros here cannot eat the last digit of a whole number (10 stays 10%). $value = 'percent' === $type ? rtrim( rtrim( number_format( $amount, 2, '.', '' ), '0' ), '.' ) . '%' : '$' . number_format_i18n( $amount ); /* translators: %s: the discount, for example "10%" or "$25". */ return sprintf( __( '%s off', 'flexa-local-services' ), $value ); } /** * Whether a post's content carries any of the plugin's blocks: the owner * has the page's blocks, and arranged them as they want, so nothing is * added around them. */ public static function has_plugin_blocks( \WP_Post $post ): bool { return str_contains( $post->post_content, '