SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: My site crashed when I added a code from sitepoint to my theme's functions.php file.

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Aug 2012
    Location
    I live in Singapore.
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy My site crashed when I added a code from sitepoint to my theme's functions.php file.

    Hi,

    I'm an avid fan of sitepoint eBooks. I recently purchased "The
    Wordpress Anthology" and was very keen to go through with this ebook.

    Ok. So far so good. Everything was ok until I hit chapter 4 about Post Types.

    I followed the instructions carefully as I was trying out the php
    codes on my live site which I'm using to go through with this book.

    According to the book's instructions, I needed to paste the following
    codes into my theme's functions.php file. And I did that rightly. I
    went to my theme editor and opened up the functions.php via my
    wordpress panel. And pasted this code which was provided by sitepoint.

    ----------------------------------------------------------------------------

    function check_current_screen() {
    if( !is_admin() ) return;
    global $current_screen;
    print_r( $current_screen );
    }
    //add_action( 'admin_notices', 'check_current_screen' );


    function conference_contextual_help() {

    $editspeaker = "From this screen, you can view and update all
    your conference's
    speakers...";
    $addspeaker = "Enter the details of a new speaker...";

    $editsession = "View and edit your conference's sessions...";
    $addsession = "Add a new session ...";

    $editsessiontopics = "Add and edit topics...";

    add_contextual_help('edit-conference_speaker', $editspeaker);
    add_contextual_help('conference_speaker', $addspeaker);

    add_contextual_help('edit-conference_session', $editsession);
    add_contextual_help('conference_session', $addsession);

    add_contextual_help('edit-conference_topics', $editsessiontopics);

    }

    add_action('admin_init', 'conference_contextual_help');

    --------------------------------------------------------------------------

    After updating this file, my site kind of crashed giving this error message:

    Fatal error: Cannot redeclare check_current_screen() (previously declared in
    /home/uawrsp/public_html/wp-content/plugins/sitepoint-custom-types.php:198) in
    /home/uawrsp/public_html/wp-content/themes/Chameleon/functions.php on line 317


    I'm not sure what went wrong and I even deleted this whole code and
    saved the file again, but to no avail. In the end I've got to email my
    host and told them to rectify my problem which they did.

    But I was disappointed in the end that this happened. Right now I'm
    too nervous to touch any php files within my wordpress system

    Can someone tell me what actually went wrong?

    You need to have a live environment to try out the instructions on this ebook. How else can I try out without the need to worry about messing up any of the php files?

    Thank You.

    Regards,
    Sunil

  2. #2
    Community Advisor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,130
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    @VSunil

    Welcome to the forum.

    Robin my C++ lecturer always used to say "read the error messages".

    According to your error message your script already has a function called check_current_screen() and only one is allowed.

    Try renaming one of the functions tp XXX_check_current_screen() and see if that cures your current problem.


    Fatal error: Cannot redeclare check_current_screen() (previously declared in
    /home/uawrsp/public_html/wp-content/plugins/sitepoint-custom-types.php:198) in
    /home/uawrsp/public_html/wp-content/themes/Chameleon/functions.php on line 317
    Last edited by John_Betong; Aug 16, 2012 at 21:08. Reason: spelling: not my fortay

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •