Suggested improvement: new tag of class
-
Many thanks for this useful plugin. I use it for several sites and it works great. I made a small change to your php code that let’s me include a new shortcode attribute of class=”myclass”.
The usage notes would change to:
* Usage: [wpex class="wpex-link" more="Read more" less="Read less"]hidden text[/wpex]
Here is the new code for the function called “wpex-main”:
function wpex_main($atts, $content = null) { extract(shortcode_atts(array( 'more' => 'Read more', 'less' => 'Read less', 'class' => 'wpex-link' ), $atts)); mt_srand((double)microtime() * 1000000); $rnum = mt_rand(); $new_string = '<a onclick="wpex_toggle(' . $rnum . ', \'' . addslashes($more) . '\', \'' . addslashes($less) . '\'); return false;" class="' . addslashes($class) . '" id="wpexlink' . $rnum . '" href="#">' . addslashes($more) . '</a>' . "\n"; $new_string .= '<div class="wpex_div" id="wpex' . $rnum . '" style="display: none;">' . do_shortcode($content) . '</div>'; return $new_string; }
In fact there are only two small changes to your code: 1- Added the line to extract “class” attribute with a default to “wpex-link” and 2- Change the portion of the building of “new_string” that relates to class=”wpex-link” to use the new extracted tag.
I hope you find this a useful improvement for the next version.
- The topic ‘Suggested improvement: new tag of class’ is closed to new replies.