Advanced Theme Switcher functions errors

After removing plugin, Advanced Theme Switcher via the plugin panel, I now get this error message when creating a new site as a new guest.

Warning: fopen(/home/wbtmr/public_html/wp-content/plugins/advanced-theme-switcher/advanced-theme-switcher.php) [function.fopen]: failed to open stream: No such file or directory in /home/webtamer/public_html/wp-includes/functions.php on line 3493

Warning: fread(): supplied argument is not a valid stream resource in /home/wbtmr/public_html/wp-includes/functions.php on line 3496

Warning: fclose(): supplied argument is not a valid stream resource in /home/wbtmr/public_html/wp-includes/functions.php on line 3499

And when creating a new site from the Network Admin panel, it has a fourth line as such....

Warning: Cannot modify header information - headers already sent by (output started at /home/wbtmr/public_html/wp-includes/functions.php:3493) in /home/webtamer/public_html/wp-includes/pluggable.php on line 876

Note: I tried to create this question in Plugins category but I have removed the plugin so can't select a plugin from the dropdown so moved this to the General category.

Thanks for your help.

  • Jan

    Thanks @Paul

    The quick reply is greatly appreciated. Here are lines 3480-3510 from the functions.php file.

     * If the file data is not within that first 8kiB, then the author should correct
     * their plugin file and move the data headers to the top.
     * @see
     * @since 2.9.0
     * @param string $file Path to the file
     * @param array $default_headers List of headers, in the format array('HeaderKey' => 'Header Name')
     * @param string $context If specified adds filter hook "extra_{$context}_headers"
    function get_file_data( $file, $default_headers, $context = '' ) {
    	// We don't need to write to the file, so just open for reading.
    	$fp = fopen( $file, 'r' );
    	// Pull only the first 8kiB of the file in.
    	$file_data = fread( $fp, 8192 );
    	// PHP will close file handle, but we are good citizens.
    	fclose( $fp );
    	// Make sure we catch CR-only line endings.
    	$file_data = str_replace( "\r", "\n", $file_data );
    	if ( $context && $extra_headers = apply_filters( "extra_{$context}_headers", array() ) ) {
    		$extra_headers = array_combine( $extra_headers, $extra_headers ); // keys equal values
    		$all_headers = array_merge( $extra_headers, (array) $default_headers );
    	} else {
    		$all_headers = $default_headers;

    And lines 850-879 from the pluggables.php file that was referenced in the fourth error message when creating a site from the Network Admin panel which may not matter with the other issues fixed but wanted to include it so you would have all referenced errors.

    if ( !function_exists('wp_redirect') ) :
     * Redirects to another page.
     * @since 1.5.1
     * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
     * @param string $location The path to redirect to
     * @param int $status Status code to use
     * @return bool False if $location is not set
    function wp_redirect($location, $status = 302) {
    	global $is_IIS;
    	$location = apply_filters('wp_redirect', $location, $status);
    	$status = apply_filters('wp_redirect_status', $status, $location);
    	if ( !$location ) // allows the wp_redirect filter to cancel a redirect
    		return false;
    	$location = wp_sanitize_redirect($location);
    	if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
    		status_header($status); // This causes problems on IIS and some FastCGI setups
    	header("Location: $location", true, $status);

    Thanks again for your help.

  • Paul


    Wanted to jump in here and respond.

    Warning: fopen(/home/wbtmr/public_html/wp-content/plugins/advanced-theme-switcher/advanced-theme-switcher.php) [function.fopen]: failed to open stream: No such file or directory in /home/webtamer/public_html/wp-includes/functions.php on line 3493

    From your previous statement you have removed the Advanced Theme Switcher plugin. So I'm trying to figure out why your theme is loading it directly. This is NOT how the plugin is intended to be used. The Advanced Theme Switcher plugin works like many other plugins in that there are no needed edits to WordPress core files or your theme. The rest of the errors you are seeing are a result of this warning.

    You best option is to figure out what the theme was attempting to do with the loading the plugin file directly.

  • Paul

    would you recommend commenting out the lines that she pasted from her functions.php or would that just cause another error?

    Since these line are in the functions.php which is part of the theme I'm hesitant to recommend commenting out the lines without knowing what the theme author was trying to do. Meaning if they are in there then my assumption is the theme author somehow build the theme dependent on the Advanced Theme Switcher being available.

    So I guess the question for @janlfox is what theme is the sit running? Maybe we can download it and take a look at the complete theme.

  • Jan

    Hi Paul and Paul,

    The main site theme is an Elegant Themes theme, MyCuisine. I meant to test the Advanced Theme Switcher on one of the test sub-domains but inadvertently did it on the main site. It completely messed the site up. I had to delete the plugin via the Plugins panel and reactivate the child theme that I was viewing and then reactivate the theme used for the main site. Of course, I had to restore widget areas, etc.

    You are more than welcome to view the site back end or download to view, whichever works to get it fixed.

    How do I send you sign on credentials?

    Thanks so much for your help.

  • Paul


    Login info received. First an apology. When I was reading this thread this morning I took one of the message the wrong way. The first error (below) I took to be your theme's functions.php. My apologies this is NOT your theme but one of the WP core file. It was before I have all my coffee.

    Warning: fopen(/home/wbtmr/public_html/wp-content/plugins/advanced-theme-switcher/advanced-theme-switcher.php) [function.fopen]: failed to open stream: No such file or directory in /home/webtamer/public_html/wp-includes/functions.php on line 3493

    So I'm logged into the site. Where would I see the errors you have reported??

  • Paul


    Ok. I've had my play creating some sites my myself and my friends. :slight_smile:

    Seriously, I see the issue. And after reading the functions.php section I see what is happening. Internally, WordPress keeps a list of plugins on your site. This list is both activated and deactivated plugins. Somehow WP thinks the Advanced Theme Switcher plugin is still on the site. So it calls the function within functions.php to load the plugin file header. This is where the information about the plugin, author, version, etc. is pulled from. Problem is is the plugin does not exist you see that error.

    To test this I re-installed the plugin but didn't activate it. Created another new site. This time no error was seen. So now deleted the plugin again. Tried creating a new site and received same error. I'm wondering for example if you delete some other plugins that you are not using will you see the similar error.

    Also a note about Snapshot and BackupBuddy. I see you are running both on your server and that is fine. The issue is this. Both plugins create files on your system. So for example Snapshot creates .zip files under /wp-content/snapshots/ Then when BavkupBuddy runs it will include these are part of the backup. So you are in effect backing up a backup file. That is IF you are doing file backups via BackupBuddy.

  • Jan

    I'm still testing and removing plugins and themes. I was thinking that maybe the theme that malfunctioned at the same time that I used Advanced Theme Switcher was the culprit but I can't remember which theme I used. I removed all of the Builder themes because that's the series that break when using as a blog template. I know it has to do with Pro Sites because when I disable it, everything works as should--no errors. Still trying different scenarios and still removing plugins but guess I need to go ahead and delete Pro Sites and re-install. Was trying to avoid that....but here goes, hope it works out when I re-install.

  • Paul

    @janlfox, So this morning logged back into your site. Checked the plugins I see only the WPMU DEV Dashboard active. So then created a new site (paul5). Went off without an issue. Next, activated the Pro Sites plugin. Went to add another new site (paul6) received the original error.

    Very strange indeed. I'm at a loss. It is almost as if somehow the plugins listing is getting cached and effecting things. I can't think how or why ProSites would be doing this. I've tested locally on my own Multisite system and don't see these errors.

    So I see WP 3.5.1 is released. Any chance you can upgrade. See if this might have an effect. Purely reaching for anything at this point.

  • Jan


    You bet, I have no problem with you downloading a backup to see if you can figure it out. I have already deleted the backups but you can run another one if you like or I can send one before I removed all of the themes and plugins. I won't have time to work on this until Sunday or Monday so will not do a backup to an older install until then. I may move this whole project to another domain altogether since this is my main site. - Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.