Theme Functions run a function upon activation or preview

Question

My theme currently has the following line in the function.php file:
if ( $_GET['activated'] == 'true' || $_GET['preview'] == 1 ) If this statement is true the code runs a function.

I am getting a php error that says Notice: Undefined index: activated in and Notice: Undefined index: preview in.

I am sure in wordrpess there is another way to do this “if statement” to prevent the Undefined index: error I am getting.

Any suggestions?

Thank you!

Here is the full code:

//ADD OPTION PAGE
add_action('admin_menu', 'ddthemes_admin');

//UPON ACTIVATION OR PREVIEWED
if ( $_GET['activated'] == 'true'  || $_GET['preview'] == 1 ) {
    ddthemes_setup();
}

function ddthemes_admin() {
    /* PROCESS OPTION SAVING HERE */
    if ( 'save' == $_REQUEST['action'] ) {
        if ( $_REQUEST['savetype'] == 'header' ) {
            update_option( 'ddthemes_header', $_REQUEST['ddthemes_header']);
        }
    }
    
    /* SHOW THEME CUSTOMIZE PAGE HERE */
    add_theme_page(__('Logo Options'), __('Logo Options'), 'edit_themes', basename(__FILE__), 'ddthemes_headeropt_page');
}
0
, , user1609391 3 months 0 Answers 48 views 0

Leave an answer