mantismamita
4/20/2015 - 8:44 AM

lines 672-673 and 854-862

lines 672-673 and 854-862

// for 672-673 this might work better:

add_action('save_post','wpc_save_metabox');

function wpc_save_metabox($post_id){

	if ( 'wpc-weather' === $get_post_type($post_id)) {
		//do stuff...
	}

// for lines 854 - 862:

add_action('save_post','wpc_clear_cache_current');

function wpc_clear_cache_current() {
// no access to $post until the post is created 
	global $post;
	if ( 'wpc-weather' === $post->post_type) { 
        global $wpdb;
		$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_myweather%' ");
		$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout_myweather%' ");
    }
}

// I would suggest :
add_action('save_post','wpc_clear_cache_current');
function wpc_clear_cache_current() {

	if ( 'wpc-weather' === $get_post_type()) {
        global $wpdb;
		$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_myweather%' ");
		$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout_myweather%' ");
    }
}