ThemeShaper Forums » Thematic

Blank site and wp-admin caused by unknown functions.php problem

(8 posts)
  • Started 5 years ago by mrsteveman1
  • Latest reply from mrsteveman1
  • This topic is resolved
  1. mrsteveman1
    Member

    Can only replicate this one once or twice a day, fixing it only requires moving functions.php to a new name and back again in the shell (functions.php>func>functions.php). After that, site works fine for a few more hours till i come back and find http 500 error codes in the access log.

    The site is not production so breaks are not a problem but i'd like to fix them of course. PHP error logging is turned on but nothing of any help is turning up in the logfile i have set.

    I have tried to replicate the bug by pulling specific hooks but it does not seem to make a bit of difference.

    Here is functions.php since it clearly seems to be the problem, we may be hooking some of these things incorrectly:

    <?php

    function childtheme_favicon() { ?>
    <link rel="shortcut icon" href="<?php echo bloginfo('stylesheet_directory') ?>/images/favicon.ico">
    <?php }
    add_action('wp_head', 'childtheme_favicon');

    function remove_blogtitle() {
    remove_action('thematic_header','thematic_blogtitle',3);
    }
    add_action('init', 'remove_blogtitle');

    function macosrumors_blogtitle() { ?>
    <div id="blog-title">
    /" title="<?php bloginfo('name') ?>" rel="home"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/mosrnew.png">
    <h1 class="blogtitle">Mac OS Rumors</h1>
    </div>
    <?php }
    add_action('thematic_header','macosrumors_blogtitle',3);

    function remove_brandingclose() {
    remove_action('thematic_header','thematic_brandingclose',7);
    }
    add_action('init', 'remove_brandingclose');

    function macosrumors_brandingclose() { ?>
    <div id="Tips">Submit Tips:</div>
    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/gmail-32.png" alt="Submit by email">
    <div id="FollowUs">Follow Mac OS Rumors:</div>
    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/twitter-80x80.png" alt="Follow us">
    /feed"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/feed-icon-50x50.png" alt="Subscribe">
    </div><!-- #branding -->
    <?php }
    add_action('thematic_header','macosrumors_brandingclose',7);

    function remove_access() {
    remove_action('thematic_header','thematic_access',9);
    }
    add_action('init', 'remove_access');

    function macosrumors_nav_menu() { ?>
    <div id="access">
    <ul class="sf-menu sf-js-enabled">

  2. /" title="<?php bloginfo('name') ?>" rel="home">Home
  3. <?php
    $articles = get_cat_id('articles');
    wp_list_categories('title_li=&include=' . $articles);
    ?>

    <?php
    $aboutpage = get_page_by_title('About');
    $aboutpageid = $aboutpage->ID;

    $contactpage = get_page_by_title('Contact');
    $contactpageid = $contactpage->ID;

    $privacypage = get_page_by_title('Privacy');
    $privacypageid = $privacypage->ID;

    wp_page_menu('menu_class=menu&echo=true&include=' . $aboutpageid . "," . $contactpageid . "," . $privacypageid);
    ?>

    <ul class="sf-menu sf-js-enabled"><li id="search-box">
    <form action="http://www.google.com/cse" id="cse-search-box" target="_blank">
    <div>
    <input type="hidden" name="cx" value="partner-pub-8554564026690663:kjchh3-n0ft" />
    <input type="hidden" name="ie" value="ISO-8859-1" />
    <input type="text" name="q" size="31" />

    </div>
    </form>
    <script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script>

    </div><!-- #access -->
    <?php }
    add_action('thematic_header','macosrumors_nav_menu');

    function thematic_postheader() {
    global $id, $post, $authordata;

    if (is_single() || is_page()) {
    $posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
    } elseif (is_404()) {
    $posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
    } else {
    $posttitle = '<h2 class="entry-title"><a href="';
    $posttitle .= get_permalink();
    $posttitle .= '" title="';
    $posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
    $posttitle .= '" rel="bookmark">';
    $posttitle .= get_the_title();
    $posttitle .= "</h2>\n";
    }
    $posttitle = apply_filters('thematic_postheader_posttitle',$posttitle);

    $postmeta = '<div class="entry-meta">';
    $postmeta .= '<span class="meta-prep meta-prep-author">' . __('By ', 'thematic') . '</span>';
    $postmeta .= '<span class="author vcard">'. '<a class="url fn n" href="';
    $postmeta .= get_author_link(false, $authordata->ID, $authordata->user_nicename);
    $postmeta .= '" title="' . __('View all posts by ', 'thematic') . get_the_author() . '">';
    $postmeta .= get_the_author();
    $postmeta .= '</span><span class="meta-sep meta-sep-entry-date"> | </span>';
    $postmeta .= '<span class="meta-prep meta-prep-entry-date">' . __('Published: ', 'thematic') . '</span>';
    $postmeta .= '<span class="entry-date"><abbr class="published" title="';
    $postmeta .= get_the_time(thematic_time_title()) . '">';
    $postmeta .= get_the_time(thematic_time_display());
    $postmeta .= '</abbr></span>';
    $postmeta .= "</div><!-- .entry-meta -->\n";
    $postmeta = apply_filters('thematic_postheader_postmeta',$postmeta);

    if ($post->post_type == 'page' || is_404()) {
    $postheader = $postmeta . $posttitle;
    } else {
    $postheader = $postmeta . $posttitle;
    }
    echo apply_filters( 'thematic_postheader', $postheader ); // Filter to override default post header
    } // end thematic_postheader

    //creates the content
    function thematic_content() {

    if (is_home() || is_front_page()) {
    $content = 'full';
    } elseif (is_single()) {
    $content = 'full';
    } elseif (is_tag()) {
    $content = 'full';
    } elseif (is_search()) {
    $content = 'full';
    } elseif (is_category()) {
    $content = 'full';
    } elseif (is_author()) {
    $content = 'full';
    } elseif (is_archive()) {
    $content = 'full';
    }
    $content = apply_filters('thematic_content', $content);
    if ( strtolower($content) == 'full' ) {
    $post = get_the_content(more_text());
    $post = apply_filters('the_content', $post);
    $post = str_replace(']]>', ']]>', $post);
    } elseif ( strtolower($content) == 'excerpt') {
    $post = get_the_excerpt();
    } elseif ( strtolower($content) == 'none') {
    } else {
    $post = get_the_content(more_text());
    $post = apply_filters('the_content', $post);
    $post = str_replace(']]>', ']]>', $post);
    }
    echo apply_filters('thematic_post', $post);
    } // end thematic_content
    ?>

Posted 5 years ago #
  • Chris
    Moderator

    Hi,

    this is weird .. this functions.php shouldn't work at all!

    Remove the functions thematic_postheader() and thematic_content() .. and it should run stable

    Normally the page should be blank all the time 'cause you can't have two functions with the same name.

    Chris

    Posted 5 years ago #
  • mrsteveman1
    Member

    So i hooked or filtered those areas incorrectly then right?

    I figured i couldn't just shove the same function in there but it worked for some reason.....

    Posted 5 years ago #
  • Chris
    Moderator

    .. yes ..

    Filtering thematic_content() would be something like this (.. think you want to display the full content everywhere):

    function full_content() {
        return 'full';
    }
    add_filter('thematic_content', 'full_content');

    Chris

    Posted 5 years ago #
  • mrsteveman1
    Member

    Sweet! One down one to go :)

    The reason i replaced postheader was to put the post metadata on top of the post title (normally the other way around) so i put "$postmeta . $posttitle" in there.

    Is that similarly easy to do?

    Posted 5 years ago #
  • mrsteveman1
    Member

    I can see that i could include all the contents of my thematic_postheader function into a newly named function, return $postheader at the end and filter thematic_postheader with it, is there an easier way?

    Posted 5 years ago #
  • Chris
    Moderator

    Almost :)

    function my_postheader() {
        global $id, $post, $authordata;
    
        // Create $posteditlink
        $posteditlink .= '<a href="' . thm_bloginfo('wpurl', FALSE) . '/wp-admin/post.php?action=edit&amp;post=' . $id;
        $posteditlink .= '" title="' . __('Edit post', 'thematic') .'">';
        $posteditlink .= __('Edit', 'thematic') . '</a>';
        $posteditlink = apply_filters('thematic_postheader_posteditlink',$posteditlink); 
    
        if (is_single() || is_page()) {
            $posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
        } elseif (is_404()) {
            $posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
        } else {
            $posttitle = '<h2 class="entry-title"><a href="';
            $posttitle .= get_permalink();
            $posttitle .= '" title="';
            $posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
            $posttitle .= '" rel="bookmark">';
            $posttitle .= get_the_title();
            $posttitle .= "</a></h2>\n";
        }
        $posttitle = apply_filters('thematic_postheader_posttitle',$posttitle); 
    
        $postmeta = '<div class="entry-meta">';
        $postmeta .= '<span class="meta-prep meta-prep-author">' . __('By ', 'thematic') . '</span>';
        $postmeta .= '<span class="author vcard">'. '<a class="url fn n" href="';
        $postmeta .= get_author_link(false, $authordata->ID, $authordata->user_nicename);
        $postmeta .= '" title="' . __('View all posts by ', 'thematic') . get_the_author() . '">';
        $postmeta .= get_the_author();
        $postmeta .= '</a></span><span class="meta-sep meta-sep-entry-date"> | </span>';
        $postmeta .= '<span class="meta-prep meta-prep-entry-date">' . __('Published: ', 'thematic') . '</span>';
        $postmeta .= '<span class="entry-date"><abbr class="published" title="';
        $postmeta .= get_the_time(thematic_time_title()) . '">';
        $postmeta .= get_the_time(thematic_time_display());
        $postmeta .= '</abbr></span>';
        // Display edit link
        if (current_user_can('edit_posts')) {
            $postmeta .= ' <span class="meta-sep meta-sep-edit">|</span> ' . '<span class="edit">' . $posteditlink . '</span>';
        }
        $postmeta .= "</div><!-- .entry-meta -->\n";
        $postmeta = apply_filters('thematic_postheader_postmeta',$postmeta); 
    
        $postheader = $posttitle . $postmeta;
    
    }
    add_filter('thematic_postheader', 'my_postheader');

    Should be it. Haven't checked, if you only changed the $posttitle.$postmeta thing.

    Anyway .. I'm not very happy with this. I'll put this on my To-Do list for one of the next releases. Something that makes it easier to change thematic_postheader().

    Chris

    Posted 5 years ago #
  • mrsteveman1
    Member

    I think you got just about the same thing i did. I pulled the edit link since we don't use it though.

    I'm new to php but i'm "pretty good" in objective-c and c, so thanks for all the help :)

    function reverse_header() {
    global $id, $post, $authordata;
    
    if (is_single() || is_page()) {
    $posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
    } elseif (is_404()) {
    $posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
    } else {
    $posttitle = '<h2 class="entry-title"><a href="';
    $posttitle .= get_permalink();
    $posttitle .= '" title="';
    $posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
    $posttitle .= '" rel="bookmark">';
    $posttitle .= get_the_title();
    $posttitle .= "</a></h2>\n";
    }
    $posttitle = apply_filters('thematic_postheader_posttitle',$posttitle);
    
    $postmeta = '<div class="entry-meta">';
    $postmeta .= '<span class="meta-prep meta-prep-author">' . __('By ', 'thematic') . '</span>';
    $postmeta .= '<span class="author vcard">'. '<a class="url fn n" href="';
    $postmeta .= get_author_link(false, $authordata->ID, $authordata->user_nicename);
    $postmeta .= '" title="' . __('View all posts by ', 'thematic') . get_the_author() . '">';
    $postmeta .= get_the_author();
    $postmeta .= '</a></span><span class="meta-sep meta-sep-entry-date"> | </span>';
    $postmeta .= '<span class="meta-prep meta-prep-entry-date">' . __('Published: ', 'thematic') . '</span>';
    $postmeta .= '<span class="entry-date"><abbr class="published" title="';
    $postmeta .= get_the_time(thematic_time_title()) . '">';
    $postmeta .= get_the_time(thematic_time_display());
    $postmeta .= '</abbr></span>';
    $postmeta .= "</div><!-- .entry-meta -->\n";
    $postmeta = apply_filters('thematic_postheader_postmeta',$postmeta);
    
           $postheader = $postmeta . $posttitle;
           return $postheader;
    }
    add_filter('thematic_postheader', 'reverse_header');
    Posted 5 years ago #

  • RSS feed for this topic

    Reply

    You must log in to post.