function shortcode_wpgeo_longitude($atts, $content = null) { global $post; return get_wpgeo_longitude($post->ID); }
/** * Get WP Geo Post Coord * Gets the post coordinates. * * @param int $post_id (optional) Post ID. * @return object WPGeo_Coord. */ function get_wpgeo_post_coord($post_id = 0) { return new WPGeo_Coord(get_wpgeo_latitude($post_id), get_wpgeo_longitude($post_id)); }
function networkpub_post($post_id) { $options = get_option(NETWORKPUB_WIDGET_NAME_INTERNAL); if (!is_array($options)) { return; } if (array_key_exists('networkpub_enable', $options)) { $networkpub_enable_value = $options['networkpub_enable']; } else { $networkpub_enable_value = 1; } if (!$networkpub_enable_value) { return; } if (!$options['networkpub_post_types']) { return; } $post_types_enabled = explode(',', $options['networkpub_post_types']); $post_type = get_post_type($post_id); if (!in_array($post_type, $post_types_enabled)) { return; } //Network keys if (empty($options['api_key']) or empty($options['id_2'])) { return; } $id = $options['id_2']; $api_key = $options['api_key']; //Post data $post_data = get_post($post_id, ARRAY_A); //Post Published? if (!in_array($post_data['post_status'], array('future', 'publish'))) { return; } //post too old? $post_date = strtotime($post_data['post_date_gmt']); $current_date = time(); $diff = $current_date - $post_date; $days = floor($diff / (60 * 60 * 24)); if ($days > 3) { return; } $post_message = get_post_meta($post_id, 'networkpub_postmessage', true); $post_summary = get_post_meta($post_id, 'networkpub_postsummary', true); $post_twitterhandle = get_post_meta($post_id, 'networkpub_twitterhandle', true); $post_twitterhash = get_post_meta($post_id, 'networkpub_twitterhash', true); $post_ogtypefacebook = get_post_meta($post_id, 'networkpub_ogtype_facebook', true); $post_meta_publish = get_post_meta($post_id, 'networkpub_meta_publish', true); $post_image_video = get_post_meta($post_id, 'networkpub_post_image_video', true); if (!$post_meta_publish) { return; } if ($post_meta_publish == "selected") { $api_key = get_post_meta($post_id, 'networkpub_api_keys_selected', true); if (!$api_key) { return; } } $networkpub_meta_published = get_post_meta($post_id, '_networkpub_meta_published', true); if ($networkpub_meta_published == 'done') { return; } //Post meta - networkpub_meta_content $networkpub_meta_content = get_post_meta($post_id, '_networkpub_meta_content', true); //Post data: id, content and title $post_title = $post_data['post_title']; if ($networkpub_meta_content) { $post_content = $post_data['post_excerpt']; } else { $post_content = $post_data['post_content']; } //Post data: Permalink $post_link = get_permalink($post_id); //Post data: Categories $post_categories_array = array(); $post_categories_data = get_the_category($post_id); foreach ($post_categories_data as $category) { $post_categories_array[] = $category->cat_name; } $post_categories = implode(",", $post_categories_array); $post_tags_array = array(); $post_tags_data = wp_get_post_tags($post_id); foreach ($post_tags_data as $tag) { $post_tags_array[] = $tag->name; } $post_tags = implode(",", $post_tags_array); if (function_exists('get_wpgeo_latitude')) { if (get_wpgeo_latitude($post_id) and get_wpgeo_longitude($post_id)) { $post_geotag = get_wpgeo_latitude($post_id) . ' ' . get_wpgeo_longitude($post_id); } } if (!isset($post_geotag)) { $post_geotag = ''; } #Prepare HTTP data $link = NETWORKPUB_API_URL . 'networkpubpost'; $params = array('id' => $id, 'api_key' => $api_key, 'post_id' => $post_id, 'post_link' => $post_link, 'post_title' => $post_title, 'post_content' => $post_content, 'post_author' => get_the_author_meta('user_login', $post_data['post_author']), 'plugin' => NETWORKPUB_WIDGET_NAME_INTERNAL_NW, 'plugin_version' => networkpub_version(), 'post_categories' => $post_categories, 'post_tags' => $post_tags, 'post_geotag' => $post_geotag, 'twitterhandle' => $post_twitterhandle, 'hashtag' => $post_twitterhash, 'content_message' => $post_message, 'content_summary' => $post_summary, 'post_image_video' => $post_image_video); #Image $post_image = networkpub_thumbnail_link($post_id, $post_data['post_content']); if ($post_image) { $params['post_image'] = $post_image; } #Make HTTP call $response_full = networkpub_http_post($link, $params); $response_code = $response_full[0]; if ($response_code == 200) { update_post_meta($post_id, '_networkpub_meta_published', 'done'); } else { update_post_meta($post_id, '_networkpub_meta_published', 'failed'); } networkpub_video($post_id, $post_content); return; }
/** * @method WP Geo Map Link * @description Gets a link to an external map. * @param $args = Array of arguments (optional) * @return (string) Map URL */ function wpgeo_map_link($args = null) { global $post; $defaults = array('post_id' => $post->ID, 'latitude' => null, 'longitude' => null, 'zoom' => 5, 'echo' => 1); // Validate Args $r = wp_parse_args($args, $defaults); $r['post_id'] = absint($r['post_id']); $r['latitude'] = (double) $r['latitude']; $r['longitude'] = (double) $r['longitude']; $r['zoom'] = absint($r['zoom']); $r['echo'] = absint($r['echo']); // If a post is specified override lat/lng... if (!$r['latitude'] && !$r['longitude']) { $r['latitude'] = get_wpgeo_latitude($r['post_id']); $r['longitude'] = get_wpgeo_longitude($r['post_id']); } // If lat/lng... $url = ''; if ($r['latitude'] && $r['longitude']) { $q = 'q=' . $r['latitude'] . ',' . $r['longitude']; $z = $r['zoom'] ? '&z=' . $r['zoom'] : ''; $url = 'http://maps.google.co.uk/maps?' . $q . $z; $url = apply_filters('wpgeo_map_link', $url, $r); } // Output if ($r['echo'] == 0) { return $url; } else { echo $url; } }