ThemeShaper Forums » Thematic

[closed]

Get a blank page upon updating posts or pages

(4 posts)
  • Started 8 years ago by duckdog
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. Hi,

    I'm using a child theme of Thematic and wonder if the changes I've made to the functions.php file have caused this problem: If I click the "update" button after changing or creating a page or a post I get a blank page in return. The update occurs, which is good, but this is making everything much harder, and I'm always wondering if the problem will get worse. I suspect my functions file anyway because I've had a hard time logging into the admin for this site each morning. But if I delete the functions file on the server, then login, then re-upload the functions file, I'm able to log in.

    My site is here: http://savepointreyeswilderness.org/

    Since I suspect the functions file, I'll add the code I've got there below. I'm a newbie and have cobbled together everything you see here:

    <?php
    // ---------- "Child Theme Options" menu STARTS HERE
    
    add_action('admin_menu' , 'childtheme_add_admin');
    
    function childtheme_add_admin() {
    	add_submenu_page('themes.php', 'Child Theme Options', 'Child Theme Options', 'edit_themes', basename(__FILE__), 'childtheme_admin');
    }
    
    function childtheme_admin() {
    
    	$child_theme_image = get_option('child_theme_image');
    	$enabled = get_option('child_theme_logo_enabled');
    
    	if ($_POST['options-submit']){
    		$enabled = htmlspecialchars($_POST['enabled']);
    		update_option('child_theme_logo_enabled', $enabled);
    
    		$file_name = $_FILES['logo_image']['name'];
    		$temp_file = $_FILES['logo_image']['tmp_name'];
    		$file_type = $_FILES['logo_image']['type'];
    
    		if($file_type=="image/gif" || $file_type=="image/jpeg" || $file_type=="image/pjpeg" || $file_type=="image/png"){
    			$fd = fopen($temp_file,’rb’);
    			$file_content=file_get_contents($temp_file);
    			fclose($fd);
    
    			$wud = wp_upload_dir();
    
    			if (file_exists($wud[path].'/'.strtolower($file_name))){
    				unlink ($wud[path].'/'.strtolower($file_name));
    			}
    
    			$upload = wp_upload_bits( $file_name, '', $file_content);
    		//	echo $upload['error'];
    
    			$child_theme_image = $wud[url].'/'.strtolower($file_name);
    			update_option('child_theme_image', $child_theme_image);
    		}
    
    		?>
    			<div class="updated"><p>Your new options have been successfully saved.</p></div>
    		<?php
    
    	}
    
    	if($enabled) $checked='checked="checked"';
    
    	?>
    		<div class="wrap">
    			<div id="icon-themes" class="icon32"></div>
    			<h2>Child Theme Options</h2>
    			<form name="theform" method="post" enctype="multipart/form-data" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']);?>">
    				<table class="form-table">
    					<tr>
    						<td width="200">Use logo image instead of blog title and description:</td>
    						<td><input type="checkbox" name="enabled" value="1" <?php echo $checked; ?>/></td>
    					</tr>
    					<tr>
    						<td>Current image:</td>
    						<td><img src="<?php echo $child_theme_image; ?>" /></td>
    					</tr>
    					<tr>
    						<td>Logo image to use (gif/jpeg/png):</td>
    						<td><input type="file" name="logo_image"><br />(you must have writing permissions for your uploads directory)</td>
    					</tr>
    				</table>
    				<input type="hidden" name="options-submit" value="1" />
    				<p class="submit"><input type="submit" name="submit" value="Save Options" /></p>
    			</form>
    		</div>
    	<?php
    }
    
    // ---------- "Child Theme Options" menu ENDS HERE
    
    // ---------- Adding the logo image to the header STARTS HERE
    
    if(get_option('child_theme_logo_enabled')){
    	function remove_thematic_blogtitle() {
    	 remove_action('thematic_header','thematic_blogtitle',3);
    	}
    	add_action('init','remove_thematic_blogtitle');
    
    	function remove_thematic_blogdescription() {
    	 remove_action('thematic_header','thematic_blogdescription',5);
    	}
    	add_action('init','remove_thematic_blogdescription');
    
    	function thematic_logo_image() {
    		echo '<div id="logo-image"><a href="'.get_option('home').'"><img src="'.get_option('child_theme_image').'" /></a></div>';
    	}
    	add_action('thematic_header','thematic_logo_image',4);
    }
    // ---------- Adding the logo image to the header ENDS HERE
    
    // ---------- Adding a container for the facebook link STARTS HERE
    
    function childtheme_header_conatainer() {
    	?>
    	<span class="fb-link"><a href="http://www.facebook.com/savepointreyeswilderness"></a></span>
    	<?php
    }
    add_action('thematic_header', 'childtheme_header_conatainer', 6);
    
    ?>
    
    <?php
    
    function remove_comments(){
    	if(is_page()){
    	remove_action('thematic_comments_template','thematic_include_comments',5);
    	}
    	remove_post_type_support( 'page', 'comments' ); //totally disable comments in backend
    }
    add_action('init','remove_comments');
    ?>
    
    <?php
    function my_footer($thm_footertext) {
    	$thm_footertext = 'Copyright &copy; 2011 SavePointReyesWilderness.org<br /> <a href="http://www.duckdogdesign.com" target="_blank">DuckDog Design</a><br />
    	<a href="http://savepointreyeswilderness.org/">Home</a> | <a href="http://savepointreyeswilderness.org/take-action/">Take Action</a> | <a href="http://savepointreyeswilderness.org/newsroom/">Newsroom</a> | <a href="http://savepointreyeswilderness.org/read-more/">Learn More</a> | <a href="http://savepointreyeswilderness.org/coalition-members/">Coalition</a> | <a href="http://savepointreyeswilderness.org/donate/">Donate</a>';
    	return $thm_footertext;
    }
    add_filter('thematic_footertext', 'my_footer');
    ?>

    thanks,
    Lisa

    Posted 8 years ago #
  2. From a non-programmer I'm guessing its related to messing with the admin menu.

    Posted 8 years ago #
  3. I'm still struggling with this problem.
    If the error is occurring because I've messed with the admin, then can anybody assist me with a way to use an image in place of the blog title and logo which doesn't utilize the admin area? There's really no need to do so—it's simply the solution I found that allowed me to customize that area. (The header image doesn't need to be changed once in place.)

    Otherwise, if you're familiar with php, is there something out of place that could be causing 1) blank page upon "updating", "publishing", or changing things in the admin, and 2) having to delete the functions.php file in order to log into the admin area?

    Really appreciate the help! Currently, I'm having to leave a tab open 24/7 logged into the admin so that I don't have to delete the functions file.

    *******

    <?php
    // ---------- "Child Theme Options" menu STARTS HERE
    
    add_action('admin_menu' , 'childtheme_add_admin');
    
    function childtheme_add_admin() {
    	add_submenu_page('themes.php', 'Child Theme Options', 'Child Theme Options', 'edit_themes', basename(__FILE__), 'childtheme_admin');
    }
    
    function childtheme_admin() {
    
    	$child_theme_image = get_option('child_theme_image');
    	$enabled = get_option('child_theme_logo_enabled');
    
    	if ($_POST['options-submit']){
    		$enabled = htmlspecialchars($_POST['enabled']);
    		update_option('child_theme_logo_enabled', $enabled);
    
    		$file_name = $_FILES['logo_image']['name'];
    		$temp_file = $_FILES['logo_image']['tmp_name'];
    		$file_type = $_FILES['logo_image']['type'];
    
    		if($file_type=="image/gif" || $file_type=="image/jpeg" || $file_type=="image/pjpeg" || $file_type=="image/png"){
    			$fd = fopen($temp_file,’rb’);
    			$file_content=file_get_contents($temp_file);
    			fclose($fd);
    
    			$wud = wp_upload_dir();
    
    			if (file_exists($wud[path].'/'.strtolower($file_name))){
    				unlink ($wud[path].'/'.strtolower($file_name));
    			}
    
    			$upload = wp_upload_bits( $file_name, '', $file_content);
    		//	echo $upload['error'];
    
    			$child_theme_image = $wud[url].'/'.strtolower($file_name);
    			update_option('child_theme_image', $child_theme_image);
    		}
    
    		?>
    			<div class="updated"><p>Your new options have been successfully saved.</p></div>
    		<?php
    
    	}
    
    	if($enabled) $checked='checked="checked"';
    
    	?>
    		<div class="wrap">
    			<div id="icon-themes" class="icon32"></div>
    			<h2>Child Theme Options</h2>
    			<form name="theform" method="post" enctype="multipart/form-data" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']);?>">
    				<table class="form-table">
    					<tr>
    						<td width="200">Use logo image instead of blog title and description:</td>
    						<td><input type="checkbox" name="enabled" value="1" <?php echo $checked; ?>/></td>
    					</tr>
    					<tr>
    						<td>Current image:</td>
    						<td><img src="<?php echo $child_theme_image; ?>" /></td>
    					</tr>
    					<tr>
    						<td>Logo image to use (gif/jpeg/png):</td>
    						<td><input type="file" name="logo_image"><br />(you must have writing permissions for your uploads directory)</td>
    					</tr>
    				</table>
    				<input type="hidden" name="options-submit" value="1" />
    				<p class="submit"><input type="submit" name="submit" value="Save Options" /></p>
    			</form>
    		</div>
    	<?php
    }
    
    // ---------- "Child Theme Options" menu ENDS HERE
    
    // ---------- Adding the logo image to the header STARTS HERE
    
    if(get_option('child_theme_logo_enabled')){
    	function remove_thematic_blogtitle() {
    	 remove_action('thematic_header','thematic_blogtitle',3);
    	}
    	add_action('init','remove_thematic_blogtitle');
    
    	function remove_thematic_blogdescription() {
    	 remove_action('thematic_header','thematic_blogdescription',5);
    	}
    	add_action('init','remove_thematic_blogdescription');
    
    	function thematic_logo_image() {
    		echo '<div id="logo-image"><a href="'.get_option('home').'"><img src="'.get_option('child_theme_image').'" /></a></div>';
    	}
    	add_action('thematic_header','thematic_logo_image',4);
    }
    ?>
    
    <?php
    
    function remove_comments(){
    	if(is_page()){
    	remove_action('thematic_comments_template','thematic_include_comments',5);
    	}
    	remove_post_type_support( 'page', 'comments' ); //totally disable comments in backend
    }
    add_action('init','remove_comments');
    ?>
    
    <?php
    function my_footer($thm_footertext) {
    	$thm_footertext = 'Copyright &copy; 2011 SavePointReyesWilderness.org<br /> <a href="http://www.duckdogdesign.com" target="_blank">DuckDog Design</a><br />
    	<a href="http://savepointreyeswilderness.org/">Home</a> | <a href="http://savepointreyeswilderness.org/take-action/">Take Action</a> | <a href="http://savepointreyeswilderness.org/newsroom/">Newsroom</a> | <a href="http://savepointreyeswilderness.org/read-more/">Learn More</a> | <a href="http://savepointreyeswilderness.org/coalition-members/">Coalition</a> | <a href="http://savepointreyeswilderness.org/donate/">Donate</a><br />
    	Harbor Seal image from <a href="http://www.alaskawhalefoundation.org">Alaska Whale Foundation</a>, Image under NMFS Permit No. 716-1456.';
    	return $thm_footertext;
    }
    add_filter('thematic_footertext', 'my_footer');
    ?>

    *****

    Thanks!

    Posted 8 years ago #
  4. my suggestion is to empty out your functions.php and then add things back to it 1 function at a time until you find the one that is causing the problem. first step in debugging is to isolate the problem.

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.