WordPress.org

Ready to get started?Download WordPress

Forums

Hierarchical Page Template Redirect
Don't send empty strings to load_template()! (1 post)

  1. Rulatir
    Member
    Posted 1 year ago #

    When you check for current page's and ancestors' page template meta, you need to check if you got a nonempty string before passing it to locate_template. Otherwise locate_template with second argument set to true will sometimes (not always - weird!) error out trying to require a nonexistent file. This may be a bug in WordPress 3.4.2, but a quick fix for your plugin is to check if you got nonempty strings. From line 36:

    Fatal error:  require_once(): Failed opening required '/srv/http-vhosts.d/mi/wordpress/wp-content/themes/mocinspiracji//' (include_path='.:/usr/share/pear') in /srv/http-vhosts.d/mi/wordpress/wp-includes/template.php on line 390
    Stack trace:
      1. {main}() /srv/http-vhosts.d/mi/wordpress/index.php:0
      2. require() /srv/http-vhosts.d/mi/wordpress/index.php:17
      3. require_once() /srv/http-vhosts.d/mi/wordpress/wp-blog-header.php:16
      4. do_action() /srv/http-vhosts.d/mi/wordpress/wp-includes/template-loader.php:7
      5. call_user_func_array() /srv/http-vhosts.d/mi/wordpress/wp-includes/plugin.php:403
      6. hierarchical_page_template_redirect() /srv/http-vhosts.d/mi/wordpress/wp-includes/plugin.php:403
      7. locate_template() /srv/http-vhosts.d/mi/wordpress/wp-content/plugins/hierarchical-page-template-redirect-plugin-hptr/wp-hptr.php:37
      8. load_template() /srv/http-vhosts.d/mi/wordpress/wp-includes/template.php:366

    When this happens, the $current_page_template variable contains an empty string. This apparently confuses locate_template(). Please add !=="" checks at line 37 and 42.

    http://wordpress.org/extend/plugins/hierarchical-page-template-redirect-plugin-hptr/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.