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: https://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="https://loadedpress.com">Click here to take a tour</a>. -Version: 0.2 -Author: LoadedPress -Author URI: https://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: https://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="https://loadedpress.com">Click here to take a tour</a>. +Version: 0.2 +Author: LoadedPress +Author URI: https://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)
Viewing 1 replies (of 1 total)
- The topic ‘Hide patch’ is closed to new replies.