示例#1
0
 function evo_save_taxonomy_custom_meta($term_id)
 {
     if (isset($_POST['term_meta'])) {
         $t_id = $term_id;
         $taxonomy = $_REQUEST['taxonomy'];
         //$term_meta = get_option( "taxonomy_$t_id" );
         $term_meta = array();
         $cat_keys = array_keys($_POST['term_meta']);
         foreach ($cat_keys as $key) {
             if (in_array($key, array('location_lon', 'location_lat'))) {
                 continue;
             }
             if ($key == 'location_address') {
                 // location lat long override
                 if ($key == 'location_address') {
                     $latlon = eventon_get_latlon_from_address($_POST['term_meta']['location_address']);
                 }
                 // longitude
                 $term_meta['location_lon'] = !empty($_POST['term_meta']['location_lon']) ? $_POST['term_meta']['location_lon'] : (!empty($latlon['lng']) ? floatval($latlon['lng']) : null);
                 // latitude
                 $term_meta['location_lat'] = !empty($_POST['term_meta']['location_lat']) ? $_POST['term_meta']['location_lat'] : (!empty($latlon['lat']) ? floatval($latlon['lat']) : null);
             }
             $term_meta[$key] = isset($_POST['term_meta'][$key]) ? $_POST['term_meta'][$key] : null;
         }
         // Save the option array.
         // /update_option( "taxonomy_$t_id", $term_meta );
         evo_save_term_metas($taxonomy, $t_id, $term_meta);
     }
 }
示例#2
0
 * Update EVO to 2.3.22
 *
 * @author 		AJDE
 * @category 	Admin
 * @package 	eventon/Admin/Updates
 * @version     2.3.22
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
global $eventon;
// All locations auto generate lat long and save them for faster google map drawing
$locations = get_terms('event_location', array('hide_empty' => false));
if (count($locations) > 0) {
    foreach ($locations as $term) {
        $t_id = $term->term_id;
        $term_meta = get_option("taxonomy_{$t_id}");
        if (empty($term_meta['location_address'])) {
            continue;
        }
        $address = stripslashes(str_replace('"', "'", esc_attr($term_meta['location_address'])));
        $latlon = eventon_get_latlon_from_address($address);
        // if lat lon generated save those values
        $term_meta['location_lon'] = !empty($term_meta['location_lon']) ? $term_meta['location_lon'] : (!empty($latlon['lng']) ? floatval($latlon['lng']) : null);
        // longitude
        $term_meta['location_lat'] = !empty($term_meta['location_lat']) ? $term_meta['location_lat'] : (!empty($latlon['lat']) ? floatval($latlon['lat']) : null);
        // update the new values to location taxonomy
        update_option("taxonomy_" . $t_id, $term_meta);
    }
}
示例#3
0
function evoadmin_save_event_tax_termmeta($post_id)
{
    $taxs = apply_filters('evo_event_tax_save_values', array('event_location' => array('select' => 'evcal_location_name_select', 'name' => 'evcal_location_name', 'id' => 'evo_location_tax_id', 'fields' => array('evcal_location_link', 'location_address', 'evo_loc_img')), 'event_organizer' => array('select' => 'evcal_organizer_name_select', 'name' => 'evcal_organizer', 'id' => 'evo_organizer_tax_id', 'fields' => array('evcal_org_contact', 'evcal_org_address', 'evo_org_img', 'evcal_org_exlink', '_evocal_org_exlink_target'))));
    // each taxonomy
    foreach ($taxs as $tax => $data) {
        $taxtermID = false;
        // tax name chosen from the list
        if (isset($_POST[$data['select']]) && isset($_POST[$data['name']]) && $_POST[$data['select']] == $_POST[$data['name']]) {
            if (!empty($_POST[$data['id']])) {
                $taxtermID = (int) $_POST[$data['id']];
            }
        } elseif (isset($_POST[$data['name']])) {
            // create new term
            $term_name = esc_attr(stripslashes($_POST[$data['name']]));
            $term = term_exists($term_name, $tax);
            if ($term !== 0 && $term !== null) {
                $taxtermID = (int) $term['term_id'];
                wp_set_object_terms($post_id, $taxtermID, $tax);
            } else {
                // create slug from location name
                $trans = array(" " => '-', "," => '');
                $term_slug = strtr($term_name, $trans);
                // create wp term
                $new_term_ = wp_insert_term($term_name, $tax, array('slug' => $term_slug));
                if (!is_wp_error($new_term_)) {
                    $taxtermID = (int) $new_term_['term_id'];
                }
            }
        }
        // update term meta and assign term to event
        if ($taxtermID) {
            $term_meta = array();
            foreach ($data['fields'] as $field) {
                do_action('evo_tax_save_each_field', $field);
                if ($field == 'location_address') {
                    if (isset($_POST['evcal_location'])) {
                        $latlon = eventon_get_latlon_from_address($_POST['evcal_location']);
                    }
                    // longitude
                    $term_meta['location_lon'] = !empty($_POST['evcal_lon']) ? $_POST['evcal_lon'] : (!empty($latlon['lng']) ? floatval($latlon['lng']) : null);
                    // latitude
                    $term_meta['location_lat'] = !empty($_POST['evcal_lat']) ? $_POST['evcal_lat'] : (!empty($latlon['lat']) ? floatval($latlon['lat']) : null);
                    $term_meta['location_address'] = isset($_POST['evcal_location']) ? $_POST['evcal_location'] : null;
                    continue;
                }
                $term_meta[$field] = isset($_POST[$field]) ? str_replace('"', "'", $_POST[$field]) : null;
            }
            // save meta values
            evo_save_term_metas($tax, $taxtermID, $term_meta);
            // assign term to event & replace
            wp_set_object_terms($post_id, $taxtermID, $tax, false);
        }
    }
    // endforeach
}