WordPress.org

Ready to get started?Download WordPress

Forums

Keep header on theme change (1 post)

  1. tonny@debug.dk
    Member
    Posted 2 years ago #

    Im trying to make a plugin that will keep my header on theme change. So far i cam up with this. Allthoug this also breaks the posibility to actually change the header, the headers is not kept when changing theme. Any suggestions ?

    <?php 
    
    add_action('pre_update_option_theme_mods_' . get_option( 'stylesheet' ), save_header_image_as_option);
    add_action('switch_theme', 'keep_header'); 
    
    error_log("stylesheet " . get_option( 'stylesheet' ),0);
    error_log("prevous header " . get_option( 'previous_header_image_saved' ),0);
    
    function save_header_image_as_option()
    {
    	$details_before = get_theme_mods($blog_id);
    	update_option("previous_header_image_saved", get_theme_mod('header_image'));
    	error_log("before theme change" . json_encode($details_before), 0);
    	return $details_before;
    }
    
    function keep_header()
    {
    	$details_after = get_theme_mods($blog_id);
    	set_theme_mod('header_image', get_option("previous_header_image_saved"));
    	error_log("after theme change" . json_encode($details_after), 0);
    	return $details_after;
    }
    
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by tonny@debug.dk
  • This topic is not resolved
  • WordPress version: 3.4.1

Tags

No tags yet.