Title: Modification
Last modified: August 21, 2016

---

# Modification

 *  [Insight Dezign](https://wordpress.org/support/users/insightdezign/)
 * (@insightdezign)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/modification-1/)
 * 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/](http://wordpress.org/plugins/shortcodes-ultimate/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Insight Dezign](https://wordpress.org/support/users/insightdezign/)
 * (@insightdezign)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/modification-1/#post-4553937)
 * Sorry forgot the closing / on <div> in:
    `$atts['excerpt'] = ( $atts['excerpt'])?'
   <div class="su-spoiler-excerpt">' . $atts['excerpt'] . '<div>' : '';`

Viewing 1 replies (of 1 total)

The topic ‘Modification’ is closed to new replies.

 * ![](https://ps.w.org/shortcodes-ultimate/assets/icon-256x256.gif?rev=2547563)
 * [WP Shortcodes Plugin — Shortcodes Ultimate](https://wordpress.org/plugins/shortcodes-ultimate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcodes-ultimate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcodes-ultimate/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcodes-ultimate/reviews/)

## Tags

 * [excerpt](https://wordpress.org/support/topic-tag/excerpt/)
 * [modification](https://wordpress.org/support/topic-tag/modification/)
 * [toggle](https://wordpress.org/support/topic-tag/toggle/)

 * 1 reply
 * 1 participant
 * Last reply from: [Insight Dezign](https://wordpress.org/support/users/insightdezign/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/modification-1/#post-4553937)
 * Status: not resolved