Error in custom functions File

Discussion in 'PHP' started by theblurr5495, May 22, 2010.

  1. #1
    When I access my custom functions file, this error comes up:

    Fatal error: Call to undefined function add_action() in /home3/thecomq3/public_html/wp-content/themes/thesis_17/custom/custom_functions.php on line 27

    I really have no idea how to fix it, so anyone how can give me guidance, is a lifesaver. Here's the PHP:

    <?php
    // Using hooks is absolutely the smartest, most bulletproof way to implement things like plugins,
    // custom design elements, and ads. You can add your hook calls below, and they should take the
    // following form:
    // add_action('thesis_hook_name', 'function_name');
    // The function you name above will run at the location of the specified hook. The example
    // hook below demonstrates how you can insert Thesis' default recent posts widget above
    // the content in Sidebar 1:
    // add_action('thesis_hook_before_sidebar_1', 'thesis_widget_recent_posts');

    // Delete this line, including the dashes to the left, and add your hooks in its place.

    /**
    * function custom_bookmark_links() - outputs an HTML list of bookmarking links
    * NOTE: This only works when called from inside the WordPress loop!
    * SECOND NOTE: This is really just a sample function to show you how to use custom functions!
    *
    * @since 1.0
    * @global object $post
    */



    /*---------- ADD TO ABOVE ----------*/
    /*----- Seriously, I wouldn't touch anything past this point if I were you -----*/
    // Admin
    add_action('wp_head', 'extra_css'); // Adds different color option
    remove_action('thesis_hook_footer', 'thesis_attribution'); // Remove Thesis Attribution

    // Header
    add_action('wp_head', 'header_image_replace'); // Add's the search bar in Navigation section
    add_action('thesis_hook_before_header', 'nav_search'); // Add's the search bar in Navigation section
    remove_action('thesis_hook_header', 'thesis_default_header'); // Put Default Header after Second Nav (IE Issues)
    add_action('thesis_hook_header', 'second_nav'); // Add's Our Secondary nav section
    add_action('thesis_hook_header', 'thesis_default_header'); // Put Default Header after Second Nav (IE Issues)
    add_action('thesis_hook_after_header', 'bonus_header'); // Add's the secondary header area (ads, widget)

    // Theme Functions

    function extra_css() {
    global $options; foreach ($options as $value) { if (get_option( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_option( $value['id'] ); } }

    switch ($bu_appearance_theme) {
    case "Blue (Default)": ?>
    <link media="screen, projection" type="text/css" href="<?php bloginfo('template_url'); ?>/custom/css/blue.css" rel="stylesheet" />
    <?php break;
    case "Green": ?>
    <link media="screen, projection" type="text/css" href="<?php bloginfo('template_url'); ?>/custom/css/green.css" rel="stylesheet" />
    <?php break;

    case "Orange": ?>
    <link media="screen, projection" type="text/css" href="<?php bloginfo('template_url'); ?>/custom/css/orange.css" rel="stylesheet" />
    <?php break;

    case "Gray": ?>
    <link media="screen, projection" type="text/css" href="<?php bloginfo('template_url'); ?>/custom/css/gray.css" rel="stylesheet" />
    <?php break;

    }
    }

    function header_image_replace() {
    ?> <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_bloginfo(template_directory);?>/custom/custom_header.css" /> <?php
    }

    function nav_search() { ?>
    <div id="search_bar">
    <form method="get" class="search_form" action="<?php echo bloginfo('url'); ?>">
    <p>
    <input class="text_input" type="text" value="Search this website..." id="stop" name="s" onfocus="if (this.value == 'Search this website') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search this website';}" />
    <input type="submit" id="topsubmit" value="GO" />
    </p>
    </form>
    </div>

    <?php }
    function second_nav() {
    global $options; foreach ($options as $value) { if (get_option( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_option( $value['id'] ); } } ?>
    <div id="second_nav">
    <ul id="second_nav_menu">

    <?php if ($bu_second_nav_one_toggle != "true") { ?><li class="second_nav_one"><a href="<?php echo $bu_second_nav_one_link; ?>"><?php echo $bu_second_nav_one_title; ?> <span class="desc"><?php echo $bu_second_nav_one_description; ?></span></a>

    <?php if ($bu_one_child_one_title != "" or $bu_one_child_two_title != "" or $bu_one_child_three_title != "" or $bu_one_child_four_title != "" or $bu_one_child_five_title != "") { ?>
    <ul class="second_nav_one_sub">
    <?php if ($bu_one_child_one_title != "") { ?><li><a href="<?php echo $bu_one_child_one_link; ?>"><?php echo $bu_one_child_one_title; ?></a></li><?php } ?>
    <?php if ($bu_one_child_two_title != "") { ?><li><a href="<?php echo $bu_one_child_two_link; ?>"><?php echo $bu_one_child_two_title; ?></a></li><?php } ?>
    <?php if ($bu_one_child_three_title != "") { ?><li><a href="<?php echo $bu_one_child_three_link; ?>"><?php echo $bu_one_child_three_title; ?></a></li><?php } ?>
    <?php if ($bu_one_child_four_title != "") { ?><li><a href="<?php echo $bu_one_child_four_link; ?>"><?php echo $bu_one_child_four_title; ?></a></li><?php } ?>
    <?php if ($bu_one_child_five_title != "") { ?><li><a href="<?php echo $bu_one_child_five_link; ?>"><?php echo $bu_one_child_five_title; ?></a></li><?php } ?>
    </ul>
    <?php } ?>
    </li>
    <?php } ?>


    <?php if ($bu_second_nav_two_toggle != "true") { ?><li class="second_nav_two"><a href="<?php echo $bu_second_nav_two_link; ?>"><?php echo $bu_second_nav_two_title; ?> <span class="desc"><?php echo $bu_second_nav_two_description; ?></span></a>

    <?php if ($bu_two_child_one_title != "" or $bu_two_child_two_title != "" or $bu_two_child_three_title != "" or $bu_two_child_four_title != "" or $bu_two_child_five_title != "") { ?>
    <ul class="second_nav_one_sub">
    <?php if ($bu_two_child_one_title != "") { ?><li><a href="<?php echo $bu_two_child_one_link; ?>"><?php echo $bu_two_child_one_title; ?></a></li><?php } ?>
    <?php if ($bu_two_child_two_title != "") { ?><li><a href="<?php echo $bu_two_child_two_link; ?>"><?php echo $bu_two_child_two_title; ?></a></li><?php } ?>
    <?php if ($bu_two_child_three_title != "") { ?><li><a href="<?php echo $bu_two_child_three_link; ?>"><?php echo $bu_two_child_three_title; ?></a></li><?php } ?>
    <?php if ($bu_two_child_four_title != "") { ?><li><a href="<?php echo $bu_two_child_four_link; ?>"><?php echo $bu_two_child_four_title; ?></a></li><?php } ?>
    <?php if ($bu_two_child_five_title != "") { ?><li><a href="<?php echo $bu_two_child_five_link; ?>"><?php echo $bu_two_child_five_title; ?></a></li><?php } ?>
    </ul>
    <?php } ?>
    </li>
    <?php } ?>

    <?php if ($bu_second_nav_three_toggle != "true") { ?><li class="second_nav_three"><a href="<?php echo $bu_second_nav_three_link; ?>"><?php echo $bu_second_nav_three_title; ?> <span class="desc"><?php echo $bu_second_nav_three_description; ?></span></a>

    <?php if ($bu_three_child_one_title != "" or $bu_three_child_two_title != "" or $bu_three_child_three_title != "" or $bu_three_child_four_title != "" or $bu_three_child_five_title != "") { ?>
    <ul class="second_nav_one_sub">
    <?php if ($bu_three_child_one_title != "") { ?><li><a href="<?php echo $bu_three_child_one_link; ?>"><?php echo $bu_three_child_one_title; ?></a></li><?php } ?>
    <?php if ($bu_three_child_two_title != "") { ?><li><a href="<?php echo $bu_three_child_two_link; ?>"><?php echo $bu_three_child_two_title; ?></a></li><?php } ?>
    <?php if ($bu_three_child_three_title != "") { ?><li><a href="<?php echo $bu_three_child_three_link; ?>"><?php echo $bu_three_child_three_title; ?></a></li><?php } ?>
    <?php if ($bu_three_child_four_title != "") { ?><li><a href="<?php echo $bu_three_child_four_link; ?>"><?php echo $bu_three_child_four_title; ?></a></li><?php } ?>
    <?php if ($bu_three_child_five_title != "") { ?><li><a href="<?php echo $bu_three_child_five_link; ?>"><?php echo $bu_three_child_five_title; ?></a></li><?php } ?>
    </ul>
    <?php } ?>
    </li>
    <?php } ?>

    <?php if ($bu_second_nav_four_toggle != "true") { ?><li class="second_nav_four"><a href="<?php echo $bu_second_nav_four_link; ?>"><?php echo $bu_second_nav_four_title; ?> <span class="desc"><?php echo $bu_second_nav_four_description; ?></span></a>

    <?php if ($bu_four_child_one_title != "" or $bu_four_child_two_title != "" or $bu_four_child_three_title != "" or $bu_four_child_four_title != "" or $bu_four_child_five_title != "") { ?>
    <ul class="second_nav_one_sub">
    <?php if ($bu_four_child_one_title != "") { ?><li><a href="<?php echo $bu_four_child_one_link; ?>"><?php echo $bu_four_child_one_title; ?></a></li><?php } ?>
    <?php if ($bu_four_child_two_title != "") { ?><li><a href="<?php echo $bu_four_child_two_link; ?>"><?php echo $bu_four_child_two_title; ?></a></li><?php } ?>
    <?php if ($bu_four_child_three_title != "") { ?><li><a href="<?php echo $bu_four_child_three_link; ?>"><?php echo $bu_four_child_three_title; ?></a></li><?php } ?>
    <?php if ($bu_four_child_four_title != "") { ?><li><a href="<?php echo $bu_four_child_four_link; ?>"><?php echo $bu_four_child_four_title; ?></a></li><?php } ?>
    <?php if ($bu_four_child_five_title != "") { ?><li><a href="<?php echo $bu_four_child_five_link; ?>"><?php echo $bu_four_child_five_title; ?></a></li><?php } ?>
    </ul>
    <?php } ?>
    </li>
    <?php } ?>

    </ul>
    </div>
    <?php }

    function the_breadcrumb() {
    echo '<a href="';
    echo get_option('home');
    echo '">';
    bloginfo('name');
    echo "</a>";
    if (is_category() || is_single()) {
    echo " &nbsp;&#47;&nbsp; ";
    the_category('&nbsp;&#47;&nbsp;');
    if (is_single()) {
    echo " &nbsp;&#47;&nbsp; ";
    the_title();
    }
    } elseif (is_page()) {
    echo " &nbsp;&#47;&nbsp; ";
    echo the_title();
    }
    }
    function add_breadcrumb() { ?>
    <p id="breadcrumb"><?php the_breadcrumb(); ?></p>
    <?php }
    add_action('thesis_hook_after_content_box', 'add_breadcrumb');

    remove_action('thesis_hook_after_post', 'thesis_comments_link');

    // Footer

    function widgetFooter() { ?>
    <div id="foot">
    <div class="full_width">
    <div class="page">
    <div class="col">
    <ul class="sidebar_list">
    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer 1') ){ ?>
    <li class="widget"><h3><?php _e('Footer Widget 1', 'thesis'); ?></h3><p>You can edit the content that appears here by visiting your Widgets panel and modifying the <em>current widgets</em> there.</p></li><?php } ?>
    </ul>
    </div>

    <div class="col">
    <ul class="sidebar_list">
    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer 2') ){ ?>
    <li class="widget"><h3><?php _e('Footer Widget 2', 'thesis'); ?></h3><p>You can edit the content that appears here by visiting your Widgets panel and modifying the <em>current widgets</em> there.</p></li><?php } ?>
    </ul>
    </div>

    <div class="col">
    <ul class="sidebar_list">
    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer 3') ){ ?>
    <li class="widget"><h3><?php _e('Footer Widget 3', 'thesis'); ?></h3><p>You can edit the content that appears here by visiting your Widgets panel and modifying the <em>current widgets</em> there.</p></li><?php } ?>
    </ul>
    </div>
    <div id="copyright">
    <ul class="sidebar_list">
    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Copyright') ){ ?>
    <li class="widget"><p>Drag a <em>text box</em> to the <em>Copyright</em> widget in your Widgets panel to display copyright information here.</p></li><?php } ?>
    </ul>
    </div>
    </div>
    </div>
    </div>
    <?php }
    add_action('thesis_hook_after_html', 'widgetFooter');
    remove_action('thesis_hook_footer', 'thesis_attribution');
    remove_action('thesis_hook_footer', 'thesis_admin_link');

    register_sidebar(array('name'=>'Footer 1', 'before_title'=>'<h3>', 'after_title'=>'</h3>'));
    register_sidebar(array('name'=>'Footer 2', 'before_title'=>'<h3>', 'after_title'=>'</h3>'));
    register_sidebar(array('name'=>'Footer 3', 'before_title'=>'<h3>', 'after_title'=>'</h3>'));
    register_sidebar(array('name'=>'Copyright', 'before_title'=>'<h3>', 'after_title'=>'</h3>'));

    // Widgets

    class bu_featured_widget extends WP_Widget {
    function bu_featured_widget() {
    $widget_ops = array('classname' => 'widget_bu_featured', 'description' => 'Lists the featured article in the header area.' );
    $this->WP_Widget('bu_featured_widget', 'Blogussion - Featured Article', $widget_ops);
    }

    function widget($args, $instance) {
    extract($args, EXTR_SKIP);

    echo $before_widget;
    global $post;

    $the_query = new WP_Query(array('category_name'=>'featured','showposts'=>'1'));
    while ($the_query->have_posts()) : $the_query->the_post(); $do_not_duplicate = $post->ID;
    $image = get_post_meta($post->ID, 'blogussion_featured_image', $single = true);
    $num_comments = get_comments_number();?>
    <div class="featured_articles">
    <a class="image_link" href="<?php echo the_permalink();?>">
    <?php if ($image) { ?><img alt="" src="<?php echo $image;?>"> <?php }
    else { ?><img alt="" src="<?php echo get_bloginfo(template_directory); ?>/custom/images/default/thumb_default.gif" /> <?php } ?></a>
    <h2 class="title_link"><a href="<?php echo the_permalink();?>"><?php echo the_title(); ?></a></h2>
    <p class="by_link">by <?php the_author(); ?> &middot; <a href="<?php echo get_permalink() . '#comments" rel="nofollow"' ?>><?php echo $num_comments; ?> <?php if ($num_comments == 1) { echo 'Comment'; } elseif ($num_comments == 0) { echo 'Comments'; } else { echo 'Comments'; } ?></a></p>
    </div>
    <div class="clearall"></div>
    <?php
    wp_reset_query(); //This fixes the no sidebars issue MAH Mar 2010
    endwhile;
    echo $after_widget;
    }

    function update($new_instance, $old_instance) {
    $instance = $old_instance;
    return $instance;
    }

    function form($instance) { ?>
    <p>To feature a post create a category,name it <strong>Featured</strong> and mark any post with the category.</p>
    <?php }
    }

    register_widget('bu_featured_widget');


    /* HOME PAGE CUSTOM TEMPLATE */

    function home_pagecustom() {
    /* check to see if homepage. has to happen inside the function */
    if (is_page('test-page') || is_page('77')) { ?>
    <div id="content">
    <div class="post_box">
    <div class="headline_area">
    <h2>Your Headline</h2>
    </div>
    ...This is where your content goes...
    </div>
    </div>


    <?php } }

    /* Now we tell Thesis to use the home page custom template */

    remove_action('thesis_hook_custom_template', 'thesis_custom_template_sample');
    add_action('thesis_hook_custom_template', 'home_pagecustom');


    class bu_text_widget extends WP_Widget {
    function bu_text_widget() {
    $widget_ops = array('classname' => 'widget_bu_text', 'description' => 'Input styled text in the header area.' );
    $this->WP_Widget('bu_text_widget', 'Blogussion - Featured Text', $widget_ops);
    }

    function widget($args, $instance) {
    extract($args, EXTR_SKIP);

    echo $before_widget;
    $title = empty($instance['title']) ? '&nbsp;' : apply_filters('widget_title', $instance['title']);
    $entry_content = empty($instance['entry_content']) ? '&nbsp;' : apply_filters('widget_entry_content', $instance['entry_content']);
    echo '<div class="widget_box"><div class="featured_default">';
    if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
    echo '<p>' . $entry_content . '</p></div></div>';
    echo $after_widget;
    }

    function update($new_instance, $old_instance) {
    $instance = $old_instance;
    $instance['title'] = strip_tags($new_instance['title']);
    //$instance['entry_content'] = strip_tags($new_instance['entry_content']);
    $instance['entry_content'] = $new_instance['entry_content']; //Fixed to not strip tags MAH Mar 2010

    return $instance;
    }

    function form($instance) {
    $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'entry_content' => '' ) );
    $title = strip_tags($instance['title']);
    //$entry_content = strip_tags($instance['entry_content']);
    $entry_content = $instance['entry_content']; //Fixed to not strip tags MAH Mar 2010
    ?>
    <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
    <p><label for="<?php echo $this->get_field_id('entry_content'); ?>">Content: <textarea class="widefat" id="<?php echo $this->get_field_id('entry_content'); ?>" name="<?php echo $this->get_field_name('entry_content'); ?>" type="text" cols="20" rows="16"><?php echo attribute_escape($entry_content); ?></textarea></label></p>
    <?php
    }
    }
    register_widget('bu_text_widget');

    class bu_subscribe_widget extends WP_Widget {
    function bu_subscribe_widget() {
    $widget_ops = array('classname' => 'widget_bu_subscribe', 'description' => 'Styled RSS, Email Updates, and Twitter subscribe box in header.' );
    $this->WP_Widget('bu_subscribe_widget', 'Blogussion - Subscribe Box', $widget_ops);
    }

    function widget($args, $instance) {
    extract($args, EXTR_SKIP);

    echo $before_widget;
    $title = empty($instance['title']) ? '&nbsp;' : apply_filters('widget_title', $instance['title']);
    $rss_link = empty($instance['rss_link']) ? '&nbsp;' : apply_filters('widget_rss_link', $instance['rss_link']);
    $email_link = empty($instance['email_link']) ? '&nbsp;' : apply_filters('widget_email_link', $instance['email_link']);
    $twitter_link = empty($instance['twitter_link']) ? '&nbsp;' : apply_filters('widget_twitter_link', $instance['twitter_link']);
    echo '<div class="featured_subscribe">';
    if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }; ?>

    <h4>Stay up to date with our content</h4>
    <ul class="subscribe_icons">
    <li class="rss"><a title="Subscribe to the RSS Feed" href="<?php echo $rss_link; ?>">RSS Feed <span>Easy access</span></a></li>
    <li class="email"><a title="Subscribe to the RSS Feed via Email" href="<?php echo $email_link; ?>">Email Updates <span>Sent to your inbox</span></a></li>
    <li class="twitter"><a title="Follow us on Twitter" href="http://www.twitter.com/<?php echo $twitter_link; ?>">Twitter <span>Follow us</span></a></li>
    </ul>
    <?php
    echo '</div>';
    echo $after_widget;
    }

    function update($new_instance, $old_instance) {
    $instance = $old_instance;
    $instance['title'] = strip_tags($new_instance['title']);
    $instance['rss_link'] = strip_tags($new_instance['rss_link']);
    $instance['email_link'] = strip_tags($new_instance['email_link']);
    $instance['twitter_link'] = strip_tags($new_instance['twitter_link']);


    return $instance;
    }

    function form($instance) {
    $rss_default = get_bloginfo('rss2_url');
    $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'rss_link' => $rss_default, 'email_link' => '', 'twitter_link' => '') );
    $title = strip_tags($instance['title']);
    $rss_link = strip_tags($instance['rss_link']);
    $email_link = strip_tags($instance['email_link']);
    $twitter_link = strip_tags($instance['twitter_link']);
    ?>
    <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
    <p><label for="<?php echo $this->get_field_id('rss_link'); ?>">RSS Feed Link: <input class="widefat" id="<?php echo $this->get_field_id('rss_link'); ?>" name="<?php echo $this->get_field_name('rss_link'); ?>" type="text" value="<?php echo attribute_escape($rss_link); ?>" /></label></p>
    <p><label for="<?php echo $this->get_field_id('email_link'); ?>">Email Updates Link: <input class="widefat" id="<?php echo $this->get_field_id('email_link'); ?>" name="<?php echo $this->get_field_name('email_link'); ?>" type="text" value="<?php echo attribute_escape($email_link); ?>" /></label></p>
    <p><label for="<?php echo $this->get_field_id('twitter_link'); ?>">Twitter Username: <input class="widefat" id="<?php echo $this->get_field_id('twitter_link'); ?>" name="<?php echo $this->get_field_name('twitter_link'); ?>" type="text" value="<?php echo attribute_escape($twitter_link); ?>" /></label></p>

    <?php
    }
    }
    register_widget('bu_subscribe_widget');
    require_once ('admin/skin_options.php'); // Include Our Admin Page ?>

    Thanks in advance!
     
    theblurr5495, May 22, 2010 IP
  2. Trikun3

    Trikun3 Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your custom_functions.php page isn't being loaded with the wp-includes/plugin.php page. If I'm not mistaken, your page should be named functions.php, rather than custom_functions.php. I'm not sure if that's going to fix it, as I haven't done a Wordpress template in a very long time.
     
    Trikun3, May 22, 2010 IP
  3. theblurr5495

    theblurr5495 Active Member

    Messages:
    436
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #3
    No it's supposed to be called custom_functions. Everything was fine till I edited the file.
     
    theblurr5495, May 23, 2010 IP