renderer = $renderer; } /** * Registers the hooks. */ public function register_hooks() { add_action( 'init', array( $this, 'register' ) ); } /** * Registers the shortcode. */ public function register() { add_shortcode( self::TAG, array( $this, 'render' ) ); } /** * Renders the shortcode. * * @param array|string $atts Shortcode attributes. * @return string */ public function render( $atts ) { $atts = shortcode_atts( array( 'form' => 0, 'heading' => 3, 'anchor' => '', 'width' => 'reading', 'columns' => '1', ), $atts, self::TAG ); $html = $this->renderer->render( absint( $atts['form'] ), absint( $atts['heading'] ) ); if ( '' === $html ) { return ''; } $anchor = sanitize_html_class( $atts['anchor'] ); $style = 'full' === $atts['width'] ? '--primiko-width:none;' : ''; $columns = '2' === (string) $atts['columns']; if ( '' === $anchor && '' === $style && ! $columns ) { return $html; } return '