WordPress.org

Forums

[resolved] [closed] WP 3.9: Warning: strpos() expects parameter 1 to be string (27 posts)

  1. Andrew.Bloom
    Member
    Posted 1 year ago #

    Updated to WP 3.9 and am getting this error:

    Warning: strpos() expects parameter 1 to be string, array given in /public_html/wp-includes/shortcodes.php on line 193

    I researched a bit, and it seems to be a functions.php issue with blank space. But I do not have any blank space there.

    Is anyone else experiencing this issue?

    Thanks

  2. Drew Jaynes
    4.2 Release Lead
    Posted 1 year ago #

    Hi Andrew,

    Have you first tried disabling all of your plugins?

  3. Andrew.Bloom
    Member
    Posted 1 year ago #

    I did, but it looks like the theme is the culprit.

    Is there any easy way to revert to 3.8.3?

  4. eugenealegiojo
    Member
    Posted 1 year ago #

    Have you tried to switched to another theme just to conclude that it's really a theme issue?

  5. Andrew.Bloom
    Member
    Posted 1 year ago #

    Yes, it was the theme.

    I have successfully reverted to 3.8.3 until the theme author fixes this issue.

  6. brandonlucius
    Member
    Posted 1 year ago #

    This is the same issue that I'mchaving, I guess I need to contact the theme author as well.

  7. Webstract Marketing
    Member
    Posted 1 year ago #

    I found a quick fix...

    On in /wp-includes/shortcodes.php on line 193

    Change:
    if ( false === strpos( $content, '[' ) ) {

    To:
    if ( false === strpos( (string) $content, '[' ) ) {

    Basically just cast the $content variable as a string

  8. brandonlucius
    Member
    Posted 1 year ago #

    Is this additional code that's added in WordPress 3.9? I want to test this code out, but I'm not seeing if ( false === strpos( $content, '[' ) ) { in in my shortcodes.php file.

  9. Webstract Marketing
    Member
    Posted 1 year ago #

  10. brandonlucius
    Member
    Posted 1 year ago #

    I went back to 3.8.3 when the issue occurred, so I see it will be there in 3.9 so that I can go ahead and make the changes.

  11. webbrewers
    Member
    Posted 1 year ago #

    Webstract Marketing - thanks, this fixed it. These auto updates are a pain in the ..... Can't really blame the theme makers - how are they supposed to keep up?

  12. danieldude
    Member
    Posted 1 year ago #

    im having the same issue it shows only in my contact us page where i added the buildin wordpress contact form maybe it has somthing to do with that?

  13. danieldude
    Member
    Posted 1 year ago #

    Change:
    if ( false === strpos( $content, '[' ) ) {

    To:
    if ( false === strpos( (string) $content, '[' ) ) {

    Basically just cast the $content variable as a string

    this didn't fix my issue for some reason

  14. danieldude
    Member
    Posted 1 year ago #

    ops.... never mind it worked! thanks!

  15. Flexer
    Member
    Posted 1 year ago #

    Thanks for the fix @Webstract Marketing. If you google the error you get tons of sites, must be a 3.9 bug.

    Wouldn't this fix be erased whenever we update wordpress? I was using TwentyTwelve and got this issue. Alterantively perhaps it will be fixed in the next update to 3.9.

  16. What theme?

    Also, what is the context here? What is the content of the post where this shows up at?

  17. Flexer
    Member
    Posted 1 year ago #

    The theme was twentytwelve child
    It was while embedding the Jetpack form. If you Google the error it looks like it is other Jetpack forms.

    Flexer

  18. clixbits
    Member
    Posted 1 year ago #

    Add my name to the list having the same issue with 3.9

  19. David Chandra Purnama
    Member
    Posted 1 year ago #

    After debugging for several minutes, I think i found the problem.

    In grunion-contact-form.php line 601.

    parse_content( $content )

    is used in: (line 508)
    __construct( $attributes, $content = null )

    where:

    $this->parse_content( $content );

    and the $content there is not passing the sanitation to make it a string.

    to solve this:
    simply change (line 593)

    $this->parse_content( $content );

    to

    $this->parse_content( $this->content );

    probably just small typo?

  20. Flexer
    Member
    Posted 1 year ago #

    Cool that worked.

    I previously opened a support ticket with JetPack and I'll update them with your solution turtlepod. It should go into future code so your solution does not get erased when JP gets an update.

    Thanks
    Daveed

  21. vaibhavathare
    Member
    Posted 1 year ago #

    Thanks Webstart Marketing

    I was able to edit the file using notepad++

    However i am not able to replace it in the wp-includes folder
    I am also no able the edit the file inside the folder itself.

    Can anyone please assist me as to how i can edit the shortcodes file

  22. Evan Herman
    Member
    Posted 1 year ago #

    Why are you nto able to edit the file? Are you getting an eror?

    My guess- read write permissions are incorrect

  23. vaibhavathare
    Member
    Posted 1 year ago #

    Interestingly it does not give any error message when i edit file in the wp-includes folder.

    While copying an edited file in the location it states "Cant copy this file in this location".

    I even changed the permission for the wp-includes folder to User - Read Write and Execute.

  24. WPfreak
    Member
    Posted 1 year ago #

    In the text editor after "add this form to my post", I simply deleted the text in this particular warning. The rest of the fields came out fine. You would only have trouble if you're creating dozens of contact forms (would be tedious)

    My form starts here:

    Give us some feedback. We do appreciate!
    Warning: strpos() expects parameter 1 to be string, array given in /home/..../wp-includes/shortcodes.php on line 193
    [contact-form][contact-field label... etc etc

  25. sem101
    Member
    Posted 1 year ago #

    I'm getting this warning in 3.9.1. I have disabled all warnings for now. But what is the fix for shortcodes? The warning shows up on ANY page I have a shortcode on.

    PHP is 5.4 cannnot be changed.

    Do not not edit core php files.

  26. Ledez
    Member
    Posted 11 months ago #

    if ( false === strpos( (string) $content, '[' ) ) {

    Can someone help? warning gone, but now layer slider is gone.

  27. Tonibcreative
    Member
    Posted 11 months ago #

    Webstract Marketing YOU ARE A FRICKEN GODSEND THANK YOU

Topic Closed

This topic has been closed to new replies.

About this Topic