WordPress.org

Ready to get started?Download WordPress

Forums

Expander
[resolved] Change text on Open? (23 posts)

  1. Frank Gomez
    Member
    Posted 1 year ago #

    Is there any way to change the word "More" to "less" when the text is expanded? Or to change the styling via css when clicked open vs. clicked shut?

    http://wordpress.org/extend/plugins/expander/

  2. iamnotadoll
    Member
    Posted 1 year ago #

    Try replacing the following function with this.
    I also changed the shortcodes.

    function wpex_process($content) {
    	$offset = 0;
    	$stag = '[more ';
    	$etag = '[/more]';
    	while(stripos($content, $stag, $offset)) {
    		// string to replace
    		$s = stripos($content, $stag, $offset);
    		$e = stripos($content, $etag, $s) + strlen($etag); 
    
    		// inside data
    		$ds = stripos($content, ']', $s) + 1;
    		$de = $e - strlen($etag);
    
    		// style tag
    		$ss = $s + strlen($stag);
    		$se = $ds - 1;
    
    		$sstring = substr($content, $s, $e - $s);
    		$sdesc = substr($content, $ss, $se - $ss);
    		$sdata = substr($content, $ds, $de - $ds);
    
    		mt_srand((double)microtime() * 1000000);
    		$rnum = mt_rand();
    
    		$new_string .= '<a class="plsreadmore" id="showmore' . $rnum . '" onclick="this.className=\'hide\'" href="javascript:expand(document.getElementById(\'wpex' . $rnum . '\'))"> ... ' . $sdesc . ' </a>';
    		$new_string .= '<span class="wpex_div" id="wpex' . $rnum . '">';
    		$new_string .= '<script>expand(document.getElementById(\'wpex' . $rnum . '\')); expand(document.getElementById(\'wpexlink' . $rnum . '\'))</script>';
    
    		$sdata = preg_replace('^</br>sim', '', $sdata);
    
    		$content = wpex_str_replace_once($sstring, $new_string . $sdata . '<a class="plsreadmore" onclick="document.getElementById(\'showmore' . $rnum . '\').className=\'plsreadmore\'" href="javascript:expand(document.getElementById(\'wpex' . $rnum . '\'))"> ... close </a></span>', $content);
    
    		$offset = $s + 1;
    	}
    
    	return $content;
    }
  3. ampatel
    Member
    Posted 11 months ago #

    I was also looking for a solution to the read more, read less (once opened) - is there a way to do this?

  4. Frank Gomez
    Member
    Posted 11 months ago #

    What following function? Where? in custom functions or Plugin functions?
    AND why would I do that? Shouldn't the plugin be updated to include this in the first place?

  5. Ciprian
    Member
    Plugin Author

    Posted 9 months ago #

    @Frank Gomez, give me an example of CSS styling so I know how to implement it.

    I will also update the plugin to add a customizable "Less" parameter.

    @iamnotadoll, thank you for your function.

  6. Frank Gomez
    Member
    Posted 9 months ago #

    I think I was thinking that the part expanded would have a different look or something...
    div.wpex_div{
    background:rgba(255, 255, 255, 0.2)
    }
    Of course I realize that this probably won't work on every site because site might have a different color background and so maybe you should leave it alone, I can do this with custom css anyway.

    BUT YES, I would love adding the "Less" parameter.

  7. Ciprian
    Member
    Plugin Author

    Posted 9 months ago #

    You got it, I'll add it tomorrow.

    I understand what you say regarding the CSS div change, and I could implement a custom CSS area.

    If you're proficient with CSS, you can add it directly to your style.css file, as it's not a general rule, as you said.

  8. Ciprian
    Member
    Plugin Author

    Posted 9 months ago #

    Plugin has been updated and a "Less" option has been added to the shortcode. Plugin is smaller now and has better performance.

    Don't forget to rate it!
    Cheers!

  9. Frank Gomez
    Member
    Posted 9 months ago #

    Can you double check this it isn't working on this site: http://gentlestorm.com/other-media-related-services/

    I'll leave it "broken" for a short time in case it helps you.

    If I click on More... it just switches to ...Less (what I wanted it to say but the hidden part isn't hidden.

  10. Frank Gomez
    Member
    Posted 9 months ago #

    I removed the short code, looking forward to your reply.

  11. mtyaron
    Member
    Posted 9 months ago #

    Not working on my site either.

  12. Ciprian
    Member
    Plugin Author

    Posted 9 months ago #

    @Frank, Hi, could you re-add it as I'll be online all day and I need to check it on your site.

    It works on my dev test, so it must be some JS bit that does this and it's easily fixable, but I cannot reproduce it.

    @mtyaron, do you have a live site?

  13. mtyaron
    Member
    Posted 9 months ago #

    yes i have (ism.technion.ac.il) but i reinstalled an older version of the plugin till it will be fixed.
    If you want i can put the new version again.

  14. Ciprian
    Member
    Plugin Author

    Posted 9 months ago #

    @mtyaron, I'd like you to put up the new version.

    I'm here.

  15. mtyaron
    Member
    Posted 9 months ago #

    updated

  16. Ciprian
    Member
    Plugin Author

    Posted 9 months ago #

    OK, I think I know what the problem is. I should change a [paragraph] tag into a [div] tag.

  17. pcaines
    Member
    Posted 9 months ago #

    Hi is there anywhere where i can download the previous version from as the changes have made things go a bit funny.

    i have changed the more="" and less="" tags, but if i include any new lines within the hidden text it does not hide anything after the new line.

    Many thanks

  18. Ciprian
    Member
    Plugin Author

    Posted 9 months ago #

    @pcaines, I know, I'll update the plugin in an hour.

  19. pcaines
    Member
    Posted 9 months ago #

    Wow, super fast response, great support :)

  20. mtyaron
    Member
    Posted 9 months ago #

    Thanks a lot for the fast response - it works great !!!

  21. Ciprian
    Member
    Plugin Author

    Posted 9 months ago #

    Thank you guys, don't forget to rate it!

  22. Frank Gomez
    Member
    Posted 9 months ago #

    Thank you, Your plugin is now officially "AWESOME!"

  23. Ciprian
    Member
    Plugin Author

    Posted 9 months ago #

    Cheers!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags