<?php
/**
* @package googlemapsForWP
*/
/*
Plugin Name: googlemapsForWP
Plugin URI: http://www.rachel-webcat.com/
Description: Simple plugin that allows wordpress administrators to store parameters for multiple googlemaps on their wordpress blog
* and easily use those maps in posts/allow users to use the stored maps
Author: webcat
Version: 5.1
Author URI: http://www.rachel-webcat.com/
*/
//#################################################################
// Stop direct call
if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
die('You are not allowed to call this page directly.');
}
//#################################################################
if (!class_exists('googlemapsForWP')) {
/**
* Main class for the plugin
*
* sets up all the links into wordpress and provides access to the output functions
*/
class googlemapsForWP {
/**
* @static string used to check the version of wuwur being used
* @todo function to update plugin
*/
public static $googlemapsForWPVersion = 5.1;
/**
*
* @var string
*/
public static $googlemapsForWPCredits = "googlemapsForWP";
/**
*
* @var string
*/
public static $googlemapsForWPAuthor = "webcat";
/**
*
* @var string
*/
public static $googlemapsForWPURL = "http://www.rachel-webcat.com/googlemapsForWP";
/**
*
* @return string value of this plugins directory
*/
public static function filePath() {
$url = get_settings('siteurl') . '/wp-admin/admin-ajax.php?action=fail&reason=';
return $url;
}
/**
*
* @return string value of this plugins directory
*/
public static function pluginDir() {
return str_replace("googlemapsForWP.php", "", __FILE__);
}
/**
*
* @return string value of this plugins url
*/
public static function pluginURL() {
$url = get_settings('siteurl') . '/wp-content/plugins/googlemapsforp/';
return $url;
}
/**
* @static method to get url for ajax calls
*/
public static function ajaxURL() {
$temp = get_settings('siteurl') . "/wp-admin/admin-ajax.php";
return $temp;
}
/**
* @static method to activate plugin
* @uses googlemapsForWPDBSetup install
*/
public static function register() {
add_option("googlemapsForWPversion", googlemapsForWP::$googlemapsForWPVersion);
}
/**
* @static method to deactivate plugin
* @uses googlemapsForWPDBSetup uninstall()
*/
public static function unregister() {
delete_option("googlemapsForWPversion", googlemapsForWP::$googlemapsForWPVersion);
}
/*
* Admin page
*/
protected $googlemapsForWPadminpage;
protected $googlemapsForWPvisitor;
function __construct() {
try {
if (is_admin ()) {
if (!file_exists(googlemapsForWP::pluginDir() . DIRECTORY_SEPARATOR . 'ui' . DIRECTORY_SEPARATOR . 'googlemapsForWPAdmin.php')) {
throw new Exception('Cannot find the required files');
} else {
require_once(googlemapsForWP::pluginDir() . DIRECTORY_SEPARATOR . 'ui' . DIRECTORY_SEPARATOR . 'googlemapsForWPAdmin.php');
}
register_activation_hook(__FILE__, 'googlemapsForWP::register');
register_deactivation_hook(__FILE__, 'googlemapsForWP::unregister');
if (googlemapsForWP::$googlemapsForWPVersion > get_option("googlemapsForWPversion")) {
$this->update();
}
add_action('admin_print_scripts', array($this, 'scripts'));
$this->googlemapsForWPadminpage = new googlemapsForWPAdminPage;
add_action('admin_menu', array($this, 'googlemapsForWPAdmin'));
}
add_shortcode('getmap', array($this, 'getmap_func'));
} catch (Exception $e) {
die($e->getMessage());
}
}
/**
*
*/
private function update() {
}
/**
*
*/
function getmap_func($args) {
try {
if (!file_exists(googlemapsForWP::pluginDir() . DIRECTORY_SEPARATOR . 'ui' . DIRECTORY_SEPARATOR . 'googlemapsForWPVisitor.php')) {
throw new Exception('Map not available');
} else {
require_once(googlemapsForWP::pluginDir() . DIRECTORY_SEPARATOR . 'ui' . DIRECTORY_SEPARATOR . 'googlemapsForWPVisitor.php');
}
$visitor = new googlemapsForWPVisitor($args);
return $visitor->getShortcode($args);
} catch (Exception $e) {
return $e->getMessage();
}
}
/**
* Used by constructor to create the wordpress menu items for settings and events
* @usedby googlemapsForWP
*/
function googlemapsForWPAdmin() {
if (function_exists('add_options_page')) {
$this->googlemapsForWPadminpage->add_menu();
}
}
/*
* Calls the wordpress script loader to make sure it's available when the scripts run
*/
function scripts() {
wp_print_scripts(array('sack'));
}
}
$googlemapsForWP = new googlemapsForWP;
}
?>