SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry wordpress generating backslashes when apostrophe is used

    Hey peeps.
    Ive done some searching on this and everything i found applied to versions prior to 3.0.
    i tried their advice anyway and couldnt get it to work.

    anyone know why its doing this? i am using this theme on several other sites and not experiencing this problem.

    the site is homeimprovementsporthuron.com/wp

    the theme is elitepro theme by inkthemes (its a paid theme)

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Are all these sites hosted on the same server?

    It sounds like a "magic quotes" problem.

  3. #3
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, all the domains on on the same server.

  4. #4
    SitePoint Wizard
    Join Date
    Oct 2005
    Posts
    1,857
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)
    I don't think it's a magic quotes issue. Wordpress handles situations where magic_quotes_gpc is on or off. In fact, Wordpress strips any slashes that magic_quotes_gpc puts on $_POST or $_GET data and then re-adds slashes itself. Wordpress expects data to be escaped.

    You could test to see if magic_quotes_gpc is on by placing this in your footer.php file just ahead of the closing </body> tag:

    PHP Code:
    <?php
    if (get_magic_quotes_gpc())
    {
       echo 
    '<p>Magic Quotes is on.</p>';
    }
    else
    {
       echo 
    '<p>Magic Quotes is off.</p>';
    }
    ?>
    Can you take a look at the post text in the database using phpMyAdmin or something? If you see slashes when viewing the post content, that is an indication that something is being double escaped somewhere. Are you using any plugins or applying any filters to content before it is being place into the database or being displayed, or are you manually escaping anything?

  5. #5
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tried the php code. slashes still there, so im guessing its not magic_quotes.

    heres what im finding: in the page text, the word you'll is displaying as you\'l in the SQL it is you\\''ll

    so,

    input from the admin side: you'll

    on page: you\'ll

    in sql: you\\''l

    context (as dsiplayed on page): You have our promise that you\'ll get a job you absolutely love, 100% guaranteed!

  6. #6
    SitePoint Wizard
    Join Date
    Oct 2005
    Posts
    1,857
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)
    If you made sure magic_quotes_gpc is set to off (I turned it on and tested it and it had no impact on my setup), then did you try reverting to the default theme and disabling all plugins? If you can, revert to the default theme, turn off all your plugins, try making a test post with plenty of apostrophes, and then see if the slashes are there on output. A search reveals you are not the only one who has had this problem with Wordpress, and it is difficult to find a cause. So, if it isn't the theme you are using causing this then we can narrow it down to your server's configuration. Just give it a try and report back.

  7. #7
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok i reverted to the default (2011) theme. no slashes.

    also tried 2010 and Bizway (another one from inkThemes) and no slashes. so it seems like it would be a theme issue.

    im extremely confused because as i said previously the other sites i have been using the elitepro theme on have not had this problem.

  8. #8
    SitePoint Wizard
    Join Date
    Oct 2005
    Posts
    1,857
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by tim@getdim View Post
    Ok i reverted to the default (2011) theme. no slashes.

    also tried 2010 and Bizway (another one from inkThemes) and no slashes. so it seems like it would be a theme issue.

    im extremely confused because as i said previously the other sites i have been using the elitepro theme on have not had this problem.
    OK, now that we narrowed it down...

    You may be using the same theme as on other sites, but is everything exactly the same? Are you using plugins? In the theme you are having trouble with, is there any code in the functions.php file that adds or strips slashes?

  9. #9
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Note: I discovered this problem on one other site using the same theme, but still others are not affected.

    In functions.php there is nothing striping slashes, however in elite-funtions.php i found this:

    Code:
    /* Show analytics code in footer */
    /* ---------------------------------------------------------------------------------- */
    function elite_childtheme_analytics() {
        $output = elite_get_option('elite_analytics');
        if ($output <> "")
            echo stripslashes($output);
    }
    add_action('wp_head', 'elite_childtheme_analytics');

  10. #10
    SitePoint Wizard
    Join Date
    Oct 2005
    Posts
    1,857
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)
    Now that you know your theme is tinkering with slashes, you are going to have to hunt around and try to find the source. Since this is a premium theme, your best bet is to ask the company that created it.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •