*/ const OPTIONS = array( 'side' => array( 'left', 'right' ), 'shape' => array( 'rounded', 'square' ), 'fan' => array( 'fanned', 'flat' ), ); /** * The block's folder name. * * @return string */ public function slug() { return 'story-deck'; } /** * The option classes, with the default for anything missing or unknown. * * @param array $attributes Block attributes. * @return string[] Class names. */ public static function classes( $attributes ) { $classes = array(); foreach ( self::OPTIONS as $option => $values ) { $value = isset( $attributes[ $option ] ) ? $attributes[ $option ] : ''; $classes[] = 'purplish-deck-' . $option . '-' . ( in_array( $value, $values, true ) ? $value : $values[0] ); } return $classes; } /** * The wrapper, the stories, the buttons and the status line. * * @param array $attributes Block attributes. * @param string $content Rendered inner blocks. * @param \WP_Block $block Block instance. * @return string */ public function render( $attributes, $content, $block ) { $wrapper = get_block_wrapper_attributes( array( 'class' => implode( ' ', self::classes( $attributes ) ), 'role' => 'region', 'aria-label' => __( 'Customer stories', 'purplish' ), /* translators: 1: story number, 2: number of stories. */ 'data-story-label' => __( 'Story %1$s of %2$s', 'purplish' ), 'data-roledescription' => __( 'carousel', 'purplish' ), ) ); $arrow = ''; return sprintf( '
%2$s

', $wrapper, $content, esc_attr__( 'Previous story', 'purplish' ), is_rtl() ? sprintf( $arrow, 'M9 5l7 7-7 7' ) : sprintf( $arrow, 'M15 5l-7 7 7 7' ), esc_attr__( 'Next story', 'purplish' ), is_rtl() ? sprintf( $arrow, 'M15 5l-7 7 7 7' ) : sprintf( $arrow, 'M9 5l7 7-7 7' ) ); } }