Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix template_url shortcode return code error #10

Closed
ghost opened this issue Jun 8, 2014 · 0 comments
Closed

fix template_url shortcode return code error #10

ghost opened this issue Jun 8, 2014 · 0 comments

Comments

@ghost
Copy link

ghost commented Jun 8, 2014

The template_url shortcode does not check the possibility of strpos() returning false and produces a php error in the next line. The following patch fixes the problem.

--- html.php.orig   2014-06-08 13:30:14.000000000 +0300
+++ html.php    2014-06-08 13:31:42.469818131 +0300
@@ -466,8 +466,10 @@
        $content_str  = 'wp-content';

        $pos          = strpos($content_url, $content_str);
-       $template_url = substr($content_url, 0, $pos-1);
-       return $template_url;
+       if($pos!==false)
+           return substr($content_url, 0, $pos-1);
+       else
+           return $content_url;
    }
    add_shortcode('template_url', 'template_url_shortcode');
 }
cheh added a commit to CherryFramework/cherry-plugin that referenced this issue Jun 11, 2014
@cheh cheh closed this as completed Jun 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant