'collapsibles', 'title' => esc_html__( 'Collapsibles', 'powerkit' ), 'priority' => 50, 'base' => 'powerkit_collapsibles', 'autoregister' => true, 'fields' => array( array( 'type' => 'section', 'label' => esc_html__( 'Content', 'powerkit' ), ), array( 'type' => 'repeater', 'base' => 'powerkit_collapsible', 'autoregister' => true, 'label' => esc_html__( 'Collapsibles', 'powerkit' ), 'fields' => array( array( 'type' => 'input', 'name' => 'title', 'label' => esc_html__( 'Title', 'powerkit' ), 'default' => '', 'attrs' => array( 'class' => 'widefat', ), ), array( 'type' => 'content', 'name' => 'content', 'label' => esc_html__( 'Content', 'powerkit' ), 'default' => '', 'attrs' => array( 'class' => 'widefat', 'rows' => 6, ), ), array( 'type' => 'checkbox', 'name' => 'opened', 'label' => esc_html__( 'Opened', 'powerkit' ), 'default' => false, ), ), ), ), ) ); /** * Collapsibles Shortcode * * @param array $output Shortcode HTML. * @param array $atts User defined attributes in shortcode tag. * @param string $content Shorcode tag content. * @return string Shortcode result HTML. */ function powerkit_basic_shortcodes_collapsibles( $output, $atts, $content ) { $collapse_id = uniqid(); $output = sprintf( '
%2$s
', $collapse_id, str_replace( 'data-parent="#"', 'data-parent="#pk-collapsibles-' . $collapse_id . '"', $content ) ); return $output; } add_filter( 'powerkit_collapsibles_shortcode', 'powerkit_basic_shortcodes_collapsibles', 10, 3 ); /** * Collapsible Shortcode * * @param array $output Shortcode HTML. * @param array $atts User defined attributes in shortcode tag. * @param string $content Shorcode tag content. * @return string Shortcode result HTML. */ function powerkit_basic_shortcodes_collapsible( $output, $atts, $content ) { $item_id = uniqid(); $output = sprintf( '
%5$s
', $item_id, $atts['title'], ( 'true' === $atts['opened'] ) ? 'display:block;' : 'display:none;', ( 'true' === $atts['opened'] ) ? 'expanded' : '', do_shortcode( $content ) ); return $output; } add_filter( 'powerkit_collapsible_shortcode', 'powerkit_basic_shortcodes_collapsible', 10, 3 );