WordPress.org

Ready to get started?Download WordPress

Forums

Shortcodes Ultimate
Modification (2 posts)

  1. InsightDezign
    Member
    Posted 5 months ago #

    Just thought I'd share in case you wanted to incorporate this in a future release. I wanted to be able to define an excerpt of the content to show when a spoiler was closed but not have the excerpt displayed when the spoiler is opened. I modified the two files accordingly and added custom styling to my theme.

    assets/js/other-shortcodes.js
    added after line 9:

    // show/hide excerpt
    		$('.su-spoiler-excerpt', this).toggle();

    inc/core/shortcodes.php
    changed spoiler function to:

    public static function spoiler( $atts = null, $content = null ) {
    		$atts = shortcode_atts( array(
    				'title'  => __( 'Spoiler title', 'su' ),
    				'open'   => 'no',
    				'style'  => 'default',
    				'icon'   => 'plus',
    				'anchor' => '',
    				'class'  => '',
    				'excerpt' => ''
    			), $atts, 'spoiler' );
    		$atts['excerpt'] = ( $atts['excerpt'] ) ? '<div class="su-spoiler-excerpt">' . $atts['excerpt'] . '<div>' : '';
    		$atts['style'] = str_replace( array( '1', '2' ), array( 'default', 'fancy' ), $atts['style'] );
    		$atts['anchor'] = ( $atts['anchor'] ) ? ' data-anchor="' . str_replace( ' ', '', trim( sanitize_text_field( $atts['anchor'] ) ) ) . '"' : '';
    		if ( $atts['open'] !== 'yes' ) $atts['class'] .= ' su-spoiler-closed';
    		su_query_asset( 'css', 'font-awesome' );
    		su_query_asset( 'css', 'su-box-shortcodes' );
    		su_query_asset( 'js', 'jquery' );
    		su_query_asset( 'js', 'su-other-shortcodes' );
    		do_action( 'su/shortcode/spoiler', $atts );
    		return '<div class="su-spoiler su-spoiler-style-' . $atts['style'] . ' su-spoiler-icon-' . $atts['icon'] . su_ecssc( $atts ) . '"' . $atts['anchor'] . '><div class="su-spoiler-title"><span class="su-spoiler-icon"></span>' . su_scattr( $atts['title'] ) . '' . $atts['excerpt'] . '</div><div class="su-spoiler-content">' . su_do_shortcode( $content, 's' ) . '</div></div>';
    	}

    http://wordpress.org/plugins/shortcodes-ultimate/

  2. InsightDezign
    Member
    Posted 5 months ago #

    Sorry forgot the closing / on <div> in:
    $atts['excerpt'] = ( $atts['excerpt'] ) ? '<div class="su-spoiler-excerpt">' . $atts['excerpt'] . '<div>' : '';

Reply

You must log in to post.

About this Plugin

About this Topic