WordPress.org

Ready to get started?Download WordPress

Forums

Joel's Acronym Replacer Problem (2 posts)

  1. Jaxia
    Member
    Posted 9 years ago #

    I am trying to use the option that makes the replacer case sensitive. When I upload the file, I get an error that tells me I have an unexpected $ on line 187, but line 187 doesn't have a $. Here is the bottom of the file:

    $text = " $text ";
    foreach($acronym_acronym as $acronym => $description) {

    /* For advanced users, there are several possible regular expressions here....
    * The safest, "default" one is at the top ...
    * You (or I) may choose to use one of the others!
    * Pick whichever you want, and make SURE there is only one that isn't preceded by slashes: //
    */
    // NEW DEFAULT
    // ANOTHER ATTEMPT (v2.8)
    /// $text = preg_replace("|(?!<[^<>]*?)(?<![?./&])\b$acronym\b(?!:)(?![^<>]*?>)|imsU","$acronym" , $text);

    // DEFAULT:
    // OLD DEFAULT: CONSERVATIVE ****************************************************************************************
    /// $text = preg_replace("|([\s\>])$acronym([\s\<\.,;:\\/\-])|imsU" , "$1$acronym$2" , $text);

    // NEW DEFAULT: MORE DARING *****************************************************************************************
    /// $text = preg_replace("|([^./?&]\b)$acronym(\b[^:])|imsU" , "$1$acronym$2" , $text);
    //do it twice, in case they used the same acronym in their title and alt tag...
    /// $text = preg_replace("|(<[A-Za-z]+[^>]*)$acronym([^>]*>)|imsU" , "$1$acronym$2" , $text);
    /// $text = preg_replace("|(<[A-Za-z]+[^>]*)$acronym([^>]*>)|imsU" , "$1$acronym$2" , $text);
    /// $text = preg_replace("|(<[A-Za-z]+[^>]*)$acronym([^>]*>)|imsU" , "$1$acronym$2" , $text);

    // SAME AS ABOVE, but CASE SENSITIVE ********************************************************************************
    $text = preg_replace("|([^./]\b)$acronym(\b[^:])|msU" , "$1$acronym$2" , $text);
    $text = preg_replace("|(<[A-Za-z]* [^>]*)$acronym([^<]*>)|msU" , "$1$acronym$2" , $text);

    // BY REQUEST: if you UNCOMMENT the last commented line here: *******************************************************
    // acronyms wrapped in dollar signs will just be unwrapped: *********************************************
    // So: $AOL$ will become AOL, without the AOL *****************
    // $text = preg_replace("|[$]$acronym[$]|imsU" , "$acronym" , $text);
    }
    return trim( $text );
    }

    add_filter('the_content', 'acronyms', 18);
    add_filter('comment_text', 'acronyms', 18);

    ?>

    So, any ideas on how to fix this and have the case sensitive replacer work?

    Thanks!

  2. Jaxia
    Member
    Posted 9 years ago #

    resolved
    please disregard

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.