WP-ShowHide - Version 1.01

Version Description

N/A

Download this release

Release Info

Developer GamerZ
Plugin Icon WP-ShowHide
Version 1.01
Comparing to
See all releases

Code changes from version 1.00 to 1.01

Files changed (2) hide show
  1. readme.txt +31 -11
  2. wp-showhide.php +28 -11
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === WP-ShowHide ===
2
- Contributors: GamerZ
3
- Donate link: http://lesterchan.net/site/donation/
4
- Tags: show, hide, content, visibility, press release, toggle
5
- Requires at least: 3.0
6
- Tested up to: 3.5.1
7
- Stable tag: trunk
8
 
9
  Allows you to embed content within your blog post via WordPress ShortCode API and toggling the visibility of the cotent via a link.
10
 
@@ -16,14 +16,11 @@ By default the content is hidden and user will have to click on the "Show Conten
16
  * N/A
17
 
18
  = Development =
19
- * [http://dev.wp-plugins.org/browser/wp-showhide/](http://dev.wp-plugins.org/browser/wp-showhide/ "http://dev.wp-plugins.org/browser/wp-showhide/")
20
 
21
  = Translations =
22
  * [http://dev.wp-plugins.org/browser/wp-showhide/i18n/](http://dev.wp-plugins.org/browser/wp-showhide/i18n/ "http://dev.wp-plugins.org/browser/wp-showhide/i18n/")
23
 
24
- = Support Forums =
25
- * [http://forums.lesterchan.net/index.php?board=36.0](http://forums.lesterchan.net/index.php?board=36.0 "http://forums.lesterchan.net/index.php?board=36.0")
26
-
27
  = Credits =
28
  * N/A
29
 
@@ -32,6 +29,9 @@ By default the content is hidden and user will have to click on the "Show Conten
32
 
33
  == Changelog ==
34
 
 
 
 
35
  = Version 1.00 (01-05-2011) =
36
  * FIXED: Initial Release
37
 
@@ -53,6 +53,26 @@ By default the content is hidden and user will have to click on the "Show Conten
53
  1. If you want to set the default visibility to display.
54
  2. Example: `[showhide hidden="no"]Press release content goes in here.[/showhide]`
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  == Upgrading ==
57
 
58
  1. Deactivate `WP-ShowHide` Plugin
@@ -73,4 +93,4 @@ N/A
73
 
74
  == Frequently Asked Questions ==
75
 
76
- N/A
1
  === WP-ShowHide ===
2
+ Contributors: GamerZ
3
+ Donate link: http://lesterchan.net/site/donation/
4
+ Tags: show, hide, content, visibility, press release, toggle
5
+ Requires at least: 3.0
6
+ Tested up to: 3.9
7
+ Stable tag: 1.01
8
 
9
  Allows you to embed content within your blog post via WordPress ShortCode API and toggling the visibility of the cotent via a link.
10
 
16
  * N/A
17
 
18
  = Development =
19
+ * [https://github.com/lesterchan/wp-showhide](https://github.com/lesterchan/wp-showhide "https://github.com/lesterchan/wp-showhide")
20
 
21
  = Translations =
22
  * [http://dev.wp-plugins.org/browser/wp-showhide/i18n/](http://dev.wp-plugins.org/browser/wp-showhide/i18n/ "http://dev.wp-plugins.org/browser/wp-showhide/i18n/")
23
 
 
 
 
24
  = Credits =
25
  * N/A
26
 
29
 
30
  == Changelog ==
31
 
32
+ = Version 1.01 =
33
+ * NEW: Added additional "show" or "hide" class to the link and content depending on the visiblity of the content to allow more precise CSS styling.
34
+
35
  = Version 1.00 (01-05-2011) =
36
  * FIXED: Initial Release
37
 
53
  1. If you want to set the default visibility to display.
54
  2. Example: `[showhide hidden="no"]Press release content goes in here.[/showhide]`
55
 
56
+ 1. You can style the content via CSS that is generated by the plugin. Here is a sample of the generated HTML. Note that pressrelease is the default type.
57
+ <code>
58
+ &lt;div id="pressrelease-link-1" class="pressrelease-link hide"&gt;
59
+ &nbsp;&nbsp;&lt;a href="#"&gt;
60
+ &nbsp;&nbsp;&nbsp;&nbsp;&lt;span id="pressrelease-toggle-1"&gt;Show Press Release (4 More Words)&lt;/span&gt;
61
+ &nbsp;&nbsp;&lt;/a&gt;
62
+ &lt;/div&gt;
63
+ &lt;div id="pressrelease-content-1" class="pressrelease-content hide" style="display: none;"&gt;Content&lt;/div&gt;
64
+ </code>
65
+
66
+ 2. With the example above, here are the following styles you can use in your CSS:
67
+ <code>
68
+ .pressrelease-link { }
69
+ .pressrelease-link.hide A { }
70
+ .pressrelease-link.show A { }
71
+ .pressrelease-content { }
72
+ .pressrelease-content.hide { }
73
+ .pressrelease-content.show { }
74
+ </code>
75
+
76
  == Upgrading ==
77
 
78
  1. Deactivate `WP-ShowHide` Plugin
93
 
94
  == Frequently Asked Questions ==
95
 
96
+ N/A
wp-showhide.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP-ShowHide
4
  Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
  Description: Allows you to embed content within your blog post via WordPress ShortCode API and toggling the visibility of the cotent via a link. By default the content is hidden and user will have to click on the "Show Content" link to toggle it. Similar to what Engadget is doing for their press releases. Example usage: <code>[showhide type="pressrelease"]Press Release goes in here.[/showhide]</code>
6
- Version: 1.00
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-showhide
@@ -11,7 +11,7 @@ Text Domain: wp-showhide
11
 
12
 
13
  /*
14
- Copyright 2013 Lester Chan (email : lesterchan@gmail.com)
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
@@ -56,8 +56,10 @@ function showhide_shortcode($atts, $content = null) {
56
  $less_text = sprintf($less_text, $word_count);
57
 
58
  // Determine Whether To Show Or Hide Press Release
 
59
  $hidden_css = 'display: none;';
60
  if($hidden == 'no') {
 
61
  $hidden_css = 'display: block;';
62
  $tmp_text = $more_text;
63
  $more_text = $less_text;
@@ -65,8 +67,8 @@ function showhide_shortcode($atts, $content = null) {
65
  }
66
 
67
  // Format HTML Output
68
- $output = '<div class="'.$type.'-link"><a href="#" onclick="showhide_toggle(\''.$type.'\', '.$post_id.', \''.esc_js($more_text).'\', \''.esc_js($less_text).'\'); return false;"><span id="'.$type.'-toggle-'.$post_id.'">'.$more_text.'</span></a></div>';
69
- $output .= '<div id="'.$type.'-content-'.$post_id.'" class="'.$type.'-content" style="'.$hidden_css.'">'.$content.'</div>';
70
 
71
  return $output;
72
  }
@@ -75,10 +77,25 @@ function showhide_shortcode($atts, $content = null) {
75
  ### Function: Add JavaScript To Footer
76
  add_action('wp_footer', 'showhide_footer');
77
  function showhide_footer() {
78
- echo '<script type="text/javascript">'."\n";
79
- echo '/* <![CDATA[ */'."\n";
80
- echo 'function showhide_toggle(a,b,c,d){jQuery("#"+a+"-content-"+b).toggle();jQuery("#"+a+"-toggle-"+b).text(jQuery("#"+a+"-toggle-"+b).text()==c?d:c)};'."\n";
81
- echo '/* ]]> */'."\n";
82
- echo '</script>'."\n";
83
- }
84
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Plugin Name: WP-ShowHide
4
  Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
  Description: Allows you to embed content within your blog post via WordPress ShortCode API and toggling the visibility of the cotent via a link. By default the content is hidden and user will have to click on the "Show Content" link to toggle it. Similar to what Engadget is doing for their press releases. Example usage: <code>[showhide type="pressrelease"]Press Release goes in here.[/showhide]</code>
6
+ Version: 1.01
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-showhide
11
 
12
 
13
  /*
14
+ Copyright 2014 Lester Chan (email : lesterchan@gmail.com)
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
56
  $less_text = sprintf($less_text, $word_count);
57
 
58
  // Determine Whether To Show Or Hide Press Release
59
+ $hidden_class = 'hide';
60
  $hidden_css = 'display: none;';
61
  if($hidden == 'no') {
62
+ $hidden_class = 'show';
63
  $hidden_css = 'display: block;';
64
  $tmp_text = $more_text;
65
  $more_text = $less_text;
67
  }
68
 
69
  // Format HTML Output
70
+ $output = '<div id="'.$type.'-link-'.$post_id.'" class="'.$type.'-link '.$hidden_class.'"><a href="#" onclick="showhide_toggle(\''.$type.'\', '.$post_id.', \''.esc_js($more_text).'\', \''.esc_js($less_text).'\'); return false;"><span id="'.$type.'-toggle-'.$post_id.'">'.$more_text.'</span></a></div>';
71
+ $output .= '<div id="'.$type.'-content-'.$post_id.'" class="'.$type.'-content '.$hidden_class.'" style="'.$hidden_css.'">'.$content.'</div>';
72
 
73
  return $output;
74
  }
77
  ### Function: Add JavaScript To Footer
78
  add_action('wp_footer', 'showhide_footer');
79
  function showhide_footer() {
80
+ ?>
81
+ <?php if(WP_DEBUG): ?>
82
+ <script type="text/javascript">
83
+ function showhide_toggle(type, post_id, more_text, less_text) {
84
+ var $link = jQuery("#"+ type + "-link-" + post_id)
85
+ , $content = jQuery("#"+ type + "-content-" + post_id)
86
+ , $toggle = jQuery("#"+ type + "-toggle-" + post_id)
87
+ , show_hide_class = 'show hide';
88
+ $link.toggleClass(show_hide_class);
89
+ $content.toggleClass(show_hide_class).toggle();
90
+ if($toggle.text() === more_text) {
91
+ $toggle.text(less_text);
92
+ } else {
93
+ $toggle.text(more_text);
94
+ }
95
+ }
96
+ </script>
97
+ <?php else : ?>
98
+ <script type="text/javascript">function showhide_toggle(a,b,c,d){var e=jQuery("#"+a+"-link-"+b),f=jQuery("#"+a+"-content-"+b);a=jQuery("#"+a+"-toggle-"+b);e.toggleClass("show hide");f.toggleClass("show hide").toggle();a.text()===c?a.text(d):a.text(c)};</script>
99
+ <?php endif; ?>
100
+ <?php
101
+ }