/** * Get a list of maps attached to the post * * @param int $postid Post for which to get the list * @return an array of all maps for the post or FALSE if no maps */ static function get_post_map_list($postid) { global $wpdb; $posts_table = $wpdb->prefix . 'mappress_posts'; $results = $wpdb->get_results($wpdb->prepare("SELECT postid, mapid FROM {$posts_table} WHERE postid = %d", $postid)); if ($results === false) { return false; } // Get all of the maps $maps = array(); foreach ($results as $key => $result) { $map = Mappress_Map::get($result->mapid); if ($map) { $maps[] = $map; } } return $maps; }
/** * There are several WP bugs that prevent correct activation in multisitie: * http://core.trac.wordpress.org/ticket/14170 * http://core.trac.wordpress.org/ticket/14718) * These bugs have been open for months. A workaround is to just 'activate' the plugin whenever it runs * (the tables are only created if they don't exist already) * */ function init() { // Load text domain load_plugin_textdomain('mappress', false, dirname(self::$basename) . '/languages'); // Register hooks and create database tables Mappress_Map::register(); // Register static classes if (class_exists('Mappress_Pro')) { Mappress_Icons::register(); Mappress_Query::register(); } // Check if upgrade is needed $current_version = get_option('mappress_version'); if ($current_version < '2.38.2') { self::$options->metaKeys = array(self::$options->metaKey); self::$options->save(); } update_option('mappress_version', self::VERSION); }
function metabox_demo($object, $metabox) { $poi = new Mappress_Poi(array("title" => sprintf("<a href='http://www.wphostreviews.com/mappress'>%s</a>", __("MapPress", 'mappress')), "body" => __("Easy Google Maps", 'mappress'), "point" => array('lat' => 37.370157, 'lng' => -119.333496))); $pois = array($poi); $map = new Mappress_Map(array("width" => "100%", "height" => 300, "pois" => $pois, "poiList" => false, "zoom" => 4)); // Display the map // Note that the alignment options "left", "center", etc. cause the map to not display properly in the metabox, so force it off echo $map->display(array("alignment" => "default")); }
?> </div> <hr/> <div id='mapp_m_list_panel' style='display:none'> <b><?php _e('Maps for This Post', 'mappress'); ?> </b> <input class='button' type='button' id='mapp_m_add_map' value='<?php esc_attr_e('New Map', 'mappress'); ?> ' /> <div id='mapp_m_maplist'> <?php echo Mappress_Map::get_map_list(); ?> </div> </div> <div id='mapp_m_edit_panel' style='display:none'> <div class='mapp-panel'> <table> <tr> <td><?php _e('Map ID', 'mappress'); ?> :</td> <td><span id='mapp_m_mapid'></span></td> </tr>
function _load($options) { global $mappress; static $loaded; if ($loaded) { return; } else { $loaded = true; } $url = isset($_GET['mp_remote']) ? "http://localhost/wordpress/wp-content/plugins/mappress-google-maps-for-wordpress" : plugins_url('', __FILE__); $min = $mappress->debug ? "" : ".min"; echo "<script type='text/javascript' src='http://www.google.com/jsapi'></script>"; echo "<script type='text/javascript' src='{$url}/mappress_lib.min.js?version={$mappress->version}'></script>"; echo "<script type='text/javascript' src='{$url}/mappress{$min}.js?version={$mappress->version}'></script>"; if (class_exists('Mappress_Pro')) { Mappress_Pro::_load_icons(plugins_url('', __FILE__), $options); } $script = "var mappl10n = " . json_encode(Mappress_Map::_localize()) . ";" . "var s = document.createElement('LINK'); s.rel = 'stylesheet'; s.type = 'text/css';" . "s.href = '{$url}/css/mappress.css?version={$mappress->version}'; document.getElementsByTagName('head').item(0).appendChild(s);"; // Add custom CSS if ($options->customCSS && !empty($options->customCSS)) { // Older versions may just have "true" in the customCSS setting - if so ignore it if ($options->customCSS !== true) { $script .= "var s = document.createElement('LINK'); s.rel = 'stylesheet'; s.type = 'text/css';" . "s.href = '{$options->customCSS}?version={$mappress->version}'; document.getElementsByTagName('head').item(0).appendChild(s);"; } } echo "<script type='text/javascript'>/* <![CDATA[ */ {$script} /* ]]> */</script>"; }
function set_options($input) { // If reset defaults was clicked if (isset($_POST['reset_defaults'])) { $options = new Mappress_Options(); return get_object_vars($this); } // If resize was clicked then resize ALL maps if (isset($_POST['force_resize']) && $_POST['resize_from']['width'] && $_POST['resize_from']['height'] && $_POST['resize_to']['width'] && $_POST['resize_to']['height']) { $maps = Mappress_Map::get_list(); foreach ($maps as $map) { if ($map->width == $_POST['resize_from']['width'] && $map->height == $_POST['resize_from']['height']) { $map->width = $_POST['resize_to']['width']; $map->height = $_POST['resize_to']['height']; $map->save($postid); } } } // Force checkboxes to boolean $input['mapTypeControl'] = isset($input['mapTypeControl']) ? true : false; $input['overviewMapControl'] = isset($input['overviewMapControl']) ? true : false; $input['overviewMapControlOptions']['opened'] = isset($input['overviewMapControlOptions']['opened']) ? true : false; $input['streetViewControl'] = isset($input['streetViewControl']) ? true : false; $input['scrollwheel'] = isset($input['scrollwheel']) ? true : false; $input['keyboardShortcuts'] = isset($input['keyboardShortcuts']) ? true : false; $input['initialOpenInfo'] = isset($input['initialOpenInfo']) ? true : false; $input['traffic'] = isset($input['traffic']) ? true : false; $input['tooltips'] = isset($input['tooltips']) ? true : false; if (class_exists('Mappress_Pro')) { $input = $this->set_options_pro($input); } else { $input['control'] = true; unset($input['metaKey'], $input['metaSyncSave'], $input['metaSyncUpdate']); } return $input; }