-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwp-address-schema.php
117 lines (99 loc) · 3.17 KB
/
wp-address-schema.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* @package WP-Address-Schema
*/
/*
Plugin Name: WP Address Schema
Text Domain: wp-address-schema
Plugin URI: http://www.creare.co.uk
Description: A simple plugin for displaying correctly formatted address information, as per the standards set out by http://schema.org/LocalBusiness.
Version: 0.1.0
Author: Creare
Author URI: http://www.creare.co.uk
License: GPLv2 or later
*/
/*
Copyright 2014 Creare (email : tom.f@creare.co.uk)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
if(!class_exists('WP_Adress_Schema')) {
class WP_Address_Schema
{
/**
* Define Constants
*/
protected $inc_dir;
protected $plugin_url;
/**
* Construct the plugin object
*/
public function __construct()
{
// Set constants
$this->inc_dir = 'inc/';
$this->plugin_url = plugins_url().'/wp-address-schema/';
// Config post type
require_once $this->inc_dir."wp-address-schema-posttype.php";
$wp_address_schema_posttype = new WP_Address_Schema_Posttype();
add_action('init', array(&$this, 'initShortcodes'));
// PHP 5.2<= function
add_action('widgets_init',
create_function('', 'return register_widget("Wp_Address_Schema_Widget");')
);
// PHP 5.3>= function
//add_action('widgets_init', function(){
//register_widget( 'Creare_Wp_Address_Schema_Widget' );
//});
}
// PHP 4 Support
public function WP_Address_Schema() {
$this->__construct();
}
public function initShortcodes() {
add_shortcode('address_schema', array(&$this, 'addressShortcode'));
}
public function addressShortcode($args) {
extract(shortcode_atts(array('address'=>''), $args, 'address_schema'));
$code = $address;
$code_a = explode('_', $code);
$code_a = array_reverse($code_a);
$id = $code_a[0];
require_once $this->inc_dir.'wp-address-schema-display.php';
$display = new Wp_Address_Schema_Display();
return $display->parseAddress($id);
}
/**
* Activate the plugin
*/
public static function activate()
{
// Do nothing
}
/**
* Deactivate the plugin
*/
public static function deactivate()
{
// Do nothing
}
}
}
if(class_exists('WP_Address_Schema'))
{
// Installation and uninstallation hooks
register_activation_hook(__FILE__, array('WP_Address_Schema', 'activate'));
register_deactivation_hook(__FILE__, array('WP_Address_Schema', 'deactivate'));
require_once 'inc/wp-address-schema-widget.php';
// instantiate the plugin class
$wp_address_schema = new WP_Address_Schema();
}
?>