function colabsthemes_metabox_handle() { $post_id = ''; global $globals, $post; $colabs_metaboxes = get_option('colabs_custom_template'); $seo_metaboxes = get_option('colabs_custom_seo_template'); if (!empty($seo_metaboxes) and get_option('seo_colabs_hide_fields') != 'true') { $colabs_metaboxes = array_merge($colabs_metaboxes, $seo_metaboxes); } // Sanitize post ID. if (isset($_POST['post_ID'])) { $post_id = intval($_POST['post_ID']); } // End IF Statement // Don't continue if we don't have a valid post ID. if ($post_id == 0) { return; } // End IF Statement if (isset($_POST['action']) && 'editpost' == $_POST['action']) { colabs_custom_meta_save_handler($post_id, $colabs_metaboxes); } // End IF Statement }
function colabs_save_meta_box($post_id) { global $post, $property_details, $key; if (!isset($_POST[$key . '_wpnonce'])) { return $post_id; } if (!wp_verify_nonce($_POST[$key . '_wpnonce'], 'colabs_property_details_nounce')) { return $post_id; } if (!current_user_can('edit_post', $post_id)) { return $post_id; } if (isset($_POST['action']) && 'editpost' == $_POST['action'] && COLABS_POST_TYPE == $post->post_type) { colabs_custom_meta_save_handler($post_id, $property_details); $attachment_ids = array_filter(explode(',', sanitize_text_field($_POST['property_image_gallery']))); update_post_meta($post_id, '_property_image_gallery', implode(',', $attachment_ids)); $property_status = empty($_POST['property-status']) ? 'sale' : sanitize_title(stripslashes($_POST['property-status'])); wp_set_object_terms($post_id, $property_status, COLABS_TAX_STATUS); if ('rent' == $property_status) { update_post_meta($post_id, 'property_price_periode', $_POST['property_price_periode']); } } // Update location if (!empty($_POST['colabs_address'])) { $latitude = colabs_clean_coordinate($_POST['colabs_geo_latitude']); $longitude = colabs_clean_coordinate($_POST['colabs_geo_longitude']); update_post_meta($post_id, '_colabs_geo_latitude', $latitude); update_post_meta($post_id, '_colabs_geo_longitude', $longitude); if ($latitude && $longitude) { $address = colabs_reverse_geocode($latitude, $longitude); update_post_meta($post_id, 'geo_address', $address['address']); update_post_meta($post_id, 'geo_country', $address['country']); update_post_meta($post_id, 'geo_short_address', $address['short_address']); update_post_meta($post_id, 'geo_short_address_country', $address['short_address_country']); update_post_meta($post_id, 'geo_long_address', $address['long_address']); } } else { // They left the field blank so we assume the property is for 'anywhere' delete_post_meta($post_id, '_colabs_geo_latitude'); delete_post_meta($post_id, '_colabs_geo_longitude'); delete_post_meta($post_id, 'geo_address'); delete_post_meta($post_id, 'geo_country'); delete_post_meta($post_id, 'geo_short_address'); delete_post_meta($post_id, 'geo_short_address_country'); delete_post_meta($post_id, 'geo_long_address'); } }