Title: Hide patch
Last modified: August 21, 2016

---

# Hide patch

 *  [Gael Abadin](https://wordpress.org/support/users/gaelikun/)
 * (@gaelikun)
 * [13 years ago](https://wordpress.org/support/topic/hide-patch/)
 * Since your plugin is the best I found for the purpose but has no ‘hide again’
   function, I took the liberty of implementing a hide function. (Apply with: `patch-
   p0 lwp-showmore.php < patch.txt`)
 * patch.txt:
 *     ```
       --- lwp-showmore_old.php	2011-06-06 12:07:10.000000000 +0200
       +++ lwp-showmore.php	2013-05-11 15:24:19.980000674 +0200
       @@ -1,69 +1,85 @@
       -<?php
       -/*
       -Plugin Name: LWP Show More
       -Plugin URI: http://loadedpress.com
       -Description: Convert [showmore], [more] shortcodes into an easy to use hidden / expanding content area. Useful for hiding images, long quotes, etc. Also part of the Loaded WordPress system, <a href="http://loadedpress.com">Click here to take a tour</a>.
       -Version: 0.2
       -Author: LoadedPress
       -Author URI: http://loadedpress.com/
       -*/
       -
       -function lwp_showmore( $atts, $content = null ) {
       -   extract( shortcode_atts( array(
       -
       -      ), $atts ) );
       -	STATIC $i = 0;
       -	STATIC $j = 0;
       -	$i++;
       -
       -	if ($j == 0){
       -		$j++;
       -	}else if ($j == 1){
       -		$j=0;
       -	}
       -
       -	$content = str_replace('[more]', '<div class="lwpshowmore" id="showmore_-'.$i.'">', $content);
       -	$content = str_replace('[/more]', '</div>', $content);
       -
       -	return '<div class="showmore showmore-'.$j.'" id="showmore_ID-'.$i.'" name="showmore_ID-'.$i.'">' . $content . '</div>';
       -
       -}
       -
       -add_shortcode('showmore', 'lwp_showmore');
       -
       -
       -function lwp_showmore_scripts(){
       -		wp_enqueue_script('jquery');
       -?>
       -<script type="text/javascript">
       -jQuery(document).ready(function($) {
       -	$('.showmore').each(function(){
       -		var showmoreid = ($(this).attr('id')).replace('showmore_ID-', '');
       -			$(this).find('a').each(function(){
       -					$(this).attr('href', '#showmore_-'+showmoreid);
       -				$(this).click(function(e){
       -					e.preventDefault();
       -
       -					$(this).fadeOut('fast',function(){
       -						$('#showmore_-'+showmoreid).fadeIn();
       -					});
       -				});
       -			});
       -	});
       -});
       -</script>
       -
       -<style type="text/css">
       -.lwpshowmore{display:none;}
       -</style>
       -
       -<?php
       -
       -}
       -
       -
       -
       -
       -add_action('wp_head', 'lwp_showmore_scripts');
       -
       -?>
       +<?php
       +/*
       +Plugin Name: LWP Show More
       +Plugin URI: http://loadedpress.com
       +Description: Convert [showmore], [more] shortcodes into an easy to use hidden / expanding content area. Useful for hiding images, long quotes, etc. Also part of the Loaded WordPress system, <a href="http://loadedpress.com">Click here to take a tour</a>.
       +Version: 0.2
       +Author: LoadedPress
       +Author URI: http://loadedpress.com/
       +*/
       +
       +function lwp_showmore( $atts, $content = null ) {
       +   extract( shortcode_atts( array(
       +
       +      ), $atts ) );
       +	STATIC $i = 0;
       +	STATIC $j = 0;
       +	$i++;
       +
       +	if ($j == 0){
       +		$j++;
       +	}else if ($j == 1){
       +		$j=0;
       +	}
       +
       +	$content = str_replace('[more]', '<div class="lwpshowmore" id="showmore_-'.$i.'">', $content);
       +	$content = str_replace('[/more]', '</div>', $content);
       +
       +	return '<div class="showmore showmore-'.$j.'" id="showmore_ID-'.$i.'" name="showmore_ID-'.$i.'">' . $content . '</div>';
       +
       +}
       +
       +add_shortcode('showmore', 'lwp_showmore');
       +
       +
       +function lwp_showmore_scripts(){
       +		wp_enqueue_script('jquery');
       +?>
       +<script type="text/javascript">
       +jQuery(document).ready(function($) {
       +	$('.showmore').each(function(){
       +		var showmoreid = ($(this).attr('id')).replace('showmore_ID-', '');
       +			$(this).find('a').each(function(){
       +					$(this).attr('href', '#showmore_-'+showmoreid);
       +					$(this).attr('id','showmorelink_ID-'+showmoreid);
       +				$(this).click(function(e){
       +					e.preventDefault();
       +
       +					$(this).fadeOut('fast',function(){
       +						$('#showmore_-'+showmoreid).fadeIn();
       +					});
       +				});
       +			});
       +	});
       +	$('.lwpshowmore').each(function(){
       +		var showmoreid = ($(this).attr('id')).replace('showmore_-', '');
       +			$(this).find('a').each(function(){
       +					$(this).attr('href', '#showmore_ID-'+showmoreid);
       +					$(this).attr('id','showmorelink_-'+showmoreid);
       +					$(this).off('click');
       +				$(this).on('click.hide',function(e){
       +					e.preventDefault();
       +
       +					$('#showmore_-'+showmoreid).fadeOut('fast',function(){
       +						$('#showmorelink_ID-'+showmoreid).fadeIn();
       +					});
       +				});
       +			});
       +	});
       +});
       +</script>
       +
       +<style type="text/css">
       +.lwpshowmore{display:none;}
       +</style>
       +
       +<?php
       +
       +}
       +
       +
       +
       +
       +add_action('wp_head', 'lwp_showmore_scripts');
       +
       +?>
       \ No newline at end of file
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [Gael Abadin](https://wordpress.org/support/users/gaelikun/)
 * (@gaelikun)
 * [13 years ago](https://wordpress.org/support/topic/hide-patch/#post-3741962)
 * Also, I noticed your code changes any link’s href attribute inside the tag, turning
   the link into a “show content” link. How about modifying it only on the links
   with href=’#show’ or href=’#hide’?
 * You can see the result here (click on ‘Mostrar Track List’ link at the bottom):
   [http://www.relaxacion.com/best-of-chillout-100-chill-out-hits/](http://www.relaxacion.com/best-of-chillout-100-chill-out-hits/)
 * The patch changing this too would be:
 *     ```
       --- lwp-showmore_old.php	2011-06-06 12:07:10.000000000 +0200
       +++ lwp-showmore.php	2013-05-11 15:53:22.843000674 +0200
       @@ -1,69 +1,89 @@
       -<?php
       -/*
       -Plugin Name: LWP Show More
       -Plugin URI: http://loadedpress.com
       -Description: Convert [showmore], [more] shortcodes into an easy to use hidden / expanding content area. Useful for hiding images, long quotes, etc. Also part of the Loaded WordPress system, <a href="http://loadedpress.com">Click here to take a tour</a>.
       -Version: 0.2
       -Author: LoadedPress
       -Author URI: http://loadedpress.com/
       -*/
       -
       -function lwp_showmore( $atts, $content = null ) {
       -   extract( shortcode_atts( array(
       -
       -      ), $atts ) );
       -	STATIC $i = 0;
       -	STATIC $j = 0;
       -	$i++;
       -
       -	if ($j == 0){
       -		$j++;
       -	}else if ($j == 1){
       -		$j=0;
       -	}
       -
       -	$content = str_replace('[more]', '<div class="lwpshowmore" id="showmore_-'.$i.'">', $content);
       -	$content = str_replace('[/more]', '</div>', $content);
       -
       -	return '<div class="showmore showmore-'.$j.'" id="showmore_ID-'.$i.'" name="showmore_ID-'.$i.'">' . $content . '</div>';
       -
       -}
       -
       -add_shortcode('showmore', 'lwp_showmore');
       -
       -
       -function lwp_showmore_scripts(){
       -		wp_enqueue_script('jquery');
       -?>
       -<script type="text/javascript">
       -jQuery(document).ready(function($) {
       -	$('.showmore').each(function(){
       -		var showmoreid = ($(this).attr('id')).replace('showmore_ID-', '');
       -			$(this).find('a').each(function(){
       -					$(this).attr('href', '#showmore_-'+showmoreid);
       -				$(this).click(function(e){
       -					e.preventDefault();
       -
       -					$(this).fadeOut('fast',function(){
       -						$('#showmore_-'+showmoreid).fadeIn();
       -					});
       -				});
       -			});
       -	});
       -});
       -</script>
       -
       -<style type="text/css">
       -.lwpshowmore{display:none;}
       -</style>
       -
       -<?php
       -
       -}
       -
       -
       -
       -
       -add_action('wp_head', 'lwp_showmore_scripts');
       -
       -?>
       +<?php
       +/*
       +Plugin Name: LWP Show More
       +Plugin URI: http://loadedpress.com
       +Description: Convert [showmore], [more] shortcodes into an easy to use hidden / expanding content area. Useful for hiding images, long quotes, etc. Also part of the Loaded WordPress system, <a href="http://loadedpress.com">Click here to take a tour</a>.
       +Version: 0.2
       +Author: LoadedPress
       +Author URI: http://loadedpress.com/
       +*/
       +
       +function lwp_showmore( $atts, $content = null ) {
       +   extract( shortcode_atts( array(
       +
       +      ), $atts ) );
       +	STATIC $i = 0;
       +	STATIC $j = 0;
       +	$i++;
       +
       +	if ($j == 0){
       +		$j++;
       +	}else if ($j == 1){
       +		$j=0;
       +	}
       +
       +	$content = str_replace('[more]', '<div class="lwpshowmore" id="showmore_-'.$i.'">', $content);
       +	$content = str_replace('[/more]', '</div>', $content);
       +
       +	return '<div class="showmore showmore-'.$j.'" id="showmore_ID-'.$i.'" name="showmore_ID-'.$i.'">' . $content . '</div>';
       +
       +}
       +
       +add_shortcode('showmore', 'lwp_showmore');
       +
       +
       +function lwp_showmore_scripts(){
       +		wp_enqueue_script('jquery');
       +?>
       +<script type="text/javascript">
       +jQuery(document).ready(function($) {
       +	$('.showmore').each(function(){
       +		var showmoreid = ($(this).attr('id')).replace('showmore_ID-', '');
       +			$(this).find('a').each(function(){
       +				if ($(this).attr('href')==='#show'){
       +					$(this).attr('href', '#showmore_-'+showmoreid);
       +					$(this).attr('id','showmorelink_ID-'+showmoreid);
       +					$(this).click(function(e){
       +						e.preventDefault();
       +
       +						$(this).fadeOut('fast',function(){
       +							$('#showmore_-'+showmoreid).fadeIn();
       +						});
       +					});
       +				}
       +			});
       +	});
       +	$('.lwpshowmore').each(function(){
       +		var showmoreid = ($(this).attr('id')).replace('showmore_-', '');
       +			$(this).find('a').each(function(){
       +				if ($(this).attr('href')==='#hide'){
       +					$(this).attr('href', '#showmore_ID-'+showmoreid);
       +					$(this).attr('id','showmorelink_-'+showmoreid);
       +					$(this).off('click');
       +					$(this).on('click.hide',function(e){
       +						e.preventDefault();
       +
       +						$('#showmore_-'+showmoreid).fadeOut('fast',function(){
       +							$('#showmorelink_ID-'+showmoreid).fadeIn();
       +						});
       +					});
       +				}
       +			});
       +	});
       +});
       +</script>
       +
       +<style type="text/css">
       +.lwpshowmore{display:none;}
       +</style>
       +
       +<?php
       +
       +}
       +
       +
       +
       +
       +add_action('wp_head', 'lwp_showmore_scripts');
       +
       +?>
       \ No newline at end of file
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Hide patch’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/loadedpress-showmore.svg)
 * [LoadedPress Show More](https://wordpress.org/plugins/loadedpress-showmore/)
 * [Support Threads](https://wordpress.org/support/plugin/loadedpress-showmore/)
 * [Active Topics](https://wordpress.org/support/plugin/loadedpress-showmore/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/loadedpress-showmore/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/loadedpress-showmore/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Gael Abadin](https://wordpress.org/support/users/gaelikun/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/hide-patch/#post-3741962)
 * Status: not resolved