Footer Putter - Version 1.11

Version Description

Add option to set Copyright Text

Download this release

Release Info

Developer powerblogservice
Plugin Icon 128x128 Footer Putter
Version 1.11
Comparing to
See all releases

Code changes from version 1.10 to 1.11

classes/class-admin.php CHANGED
@@ -1,109 +1,275 @@
1
<?php
2
- class Footer_Putter_Admin {
3
- const CODE = 'footer-putter';
4
-
5
- private static $screen_id;
6
-
7
- private static function get_screen_id(){
8
- return self::$screen_id;
9
}
10
11
- static function init() {
12
- add_action('admin_menu',array(__CLASS__, 'admin_menu'));
13
- add_action('admin_print_styles',array(__CLASS__, 'style_icon'));
14
}
15
16
- static function style_icon() {
17
- print <<< STYLES
18
- <style type="text/css">
19
- #adminmenu .menu-icon-generic.toplevel_page_footer-putter div.wp-menu-image:before { content: '\\f346'; }
20
- </style>
21
- STYLES;
22
}
23
24
- static function admin_menu() {
25
- $intro = sprintf('Intro (v%1$s)', Footer_Credits_Plugin::get_version());
26
- self::$screen_id = add_menu_page(FOOTER_PUTTER_FRIENDLY_NAME, FOOTER_PUTTER_FRIENDLY_NAME, 'manage_options',
27
- Footer_Credits_Plugin::get_slug(), array(__CLASS__,'settings_panel') );
28
- add_submenu_page(Footer_Credits_Plugin::get_slug(), FOOTER_PUTTER_FRIENDLY_NAME, $intro, 'manage_options', Footer_Credits_Plugin::get_slug(), array(__CLASS__,'settings_panel') );
29
}
30
31
- static function settings_panel() {
32
- $home_url = FOOTER_PUTTER_HOME_URL;
33
- $plugin = FOOTER_PUTTER_FRIENDLY_NAME;
34
- $version = FOOTER_PUTTER_VERSION;
35
- $widgets_url = admin_url('widgets.php');
36
- $credits_url = Footer_Credits_Admin::get_url();
37
- $trademarks_url = Footer_Trademarks_Admin::get_url();
38
- $screenshot = plugins_url('screenshot-1.jpg',dirname(__FILE__));
39
- $logo = plugins_url('images/logo.png', dirname(__FILE__));
40
- print <<< ADMIN_PANEL
41
<div class="wrap">
42
- <h2>{$plugin} {$version} Overview</h2>
43
- <img class="alignright" src="{$logo}" alt="Footer Putter Plugin" />
44
-
45
- <p>{$plugin} allows you to put a footer to your site that adds credibility to your site, with BOTH visitors and search engines.</p>
46
- <p>Google is looking for some indicators that the site is about a real business.</p>
47
- <ol>
48
- <li>The name of the business or site owner</li>
49
- <li>A copyright notice that is up to date</li>
50
- <li>A telephone number</li>
51
- <li>A postal address</li>
52
- <li>Links to Privacy Policy and Terms of Use pages</p>
53
- </ol>
54
-
55
- <p>Human visitors may pay some credence to this information but will likely be more motivated by trade marks, trust marks and service marks.</p>
56
-
57
- <h2>{$plugin} Widgets</h2>
58
-
59
- The plugins define two widgets:
60
- <ol>
61
- <li>a <b>Footer Copyright Widget</b> that places a line at the foot of your site containing as many of the items listed above that you want to disclose.</li>
62
- <li>a <b>Trademarks Widget</b> that displays a line of trademarks that you have previously set up as "Links".
63
- </ol>
64
- <p>Typically you will drag both widgets into the Custom Footer Widget Area.</p>
65
-
66
- <h2>Instructions For Building A Footer</h2>
67
- <h3>Create Standard Pages And Footer Menu</h3>
68
- <ol>
69
- <li>Create a <i>Privacy Policy</i> page with the slug/permalink <em>privacy</em>, choose a page template with no sidebar.</li>
70
- <li>Create a <i>Terms of Use</i> page with the slug/permalink <em>terms</em>, choose a page template with no sidebar.</li>
71
- <li>Create a <i>Contact</i> page with a contact form.</li>
72
- <li>Create an <i>About</i> page, with information either about the site or about its owner.</li>
73
- <li>If the site is selling an information product you may want to create a <i>Disclaimer</i> page, regarding any claims about the product performance.</li>
74
- <li>Create a WordPress menu called <i>Footer Menu</i> with the above pages.</li>
75
- </ol>
76
- <h3>Update Business Information</h3>
77
- <ol>
78
- <li>Go to <a href="{$credits_url}">Footer Credits</a> and update the Site Owner details, contact and legal information.</li>
79
- <li>Optionally include contact details such as telephone and email. You may also want to add Geographical co-ordinates for your office location for the purposes of local search.</li>
80
- </ol>
81
- <h3>Create Trademark Links</h3>
82
- <ol>
83
- <li>Go to <a href="{$trademarks_url}"><i>Footer Trademarks</i></a> and follow the instructions:</li>
84
- <li>Create a link category with a name such as <i>Trademarks</i></li>
85
- <li>Add a link for each of your trademarks and put each in the <i>Trademarks</i> link category</li>
86
- <li>For each link specify the link URL and the image URL</li>
87
- </ol>
88
- <h3>Set Up Footer Widgets</h3>
89
- <ol>
90
- <li>Go to <a href="{$widgets_url}"><i>Appearance > Widgets</i></a></li>
91
- <li>Drag a <i>Footer Copyright Widget</i> and a <i>Footer Trademarks widget</i> into a suitable footer Widget Area</li>
92
- <li>For the <i>Footer Trademarks</i> widget and choose your link category, e.g. <i>Trademarks</i>, and select a sort order</li>
93
- <li>For the <i>Footer Copyright</i> widget, select the <i>Footer Menu</i> and choose what copyright and contact information you want to you display</li>
94
- <li>Review the footer of the site. You can use the widget to change font sizes and colors using pre-defined classes such as <i>tiny</i>, <i>small</i>, <i>dark</i>, <i>light</i> or <i>white</i> or add your own custom classes</li>
95
- <li>You can also choose to suppress the widgets on special pages such as landing pages.</li>
96
- <li>If the footer is not in the right location you can use the <i>Footer Hook</i> feature described below to add a new widget area called <i>Credibility Footer</i> where you can locate the footer widgets.</li>
97
- </ol>
98
-
99
- <h3>Footer Hook</h3>
100
- <p>The footer hook is only required if your theme does not already have a footer widget area into which you can drag the two widgets.</p>
101
- <p>For some themes, the footer hook is left blank, for others use a WordPress hook such as <i>get_footer</i> or <i>wp_footer</i>,
102
- or use a theme-specific hook such as <i>twentyten_credits</i>, <i>twentyeleven_credits</i>, <i>twentytwelve_credits</i>,
103
- <i>twentythirteen_credits</i>, <i>genesis_footer</i>, <i>pagelines_leaf</i>, etc.</p>
104
-
105
- <h3>Getting Help</h3>
106
- <p>Check out the <a href="{$home_url}">Footer Putter Plugin page</a> for more information about the plugin.</p>
107
- ADMIN_PANEL;
108
}
109
}
1
<?php
2
+ abstract class Footer_Putter_Admin {
3
+ protected $version;
4
+ protected $path;
5
+ protected $parent_slug;
6
+ protected $slug;
7
+ protected $screen_id;
8
+ private $tooltips;
9
+ private $tips = array();
10
+
11
+ function __construct($version, $path, $parent_slug, $slug = '') {
12
+ $this->version = $version;
13
+ $this->path = $path;
14
+ $this->parent_slug = $parent_slug;
15
+ if (empty($slug))
16
+ $this->slug = $this->parent_slug;
17
+ else
18
+ $this->slug = $this->parent_slug.'-'.$slug;
19
+ $this->tooltips = new Footer_Putter_Tooltip($this->tips);
20
+ $this->init();
21
+ }
22
+
23
+ function get_screen_id(){
24
+ return $this->screen_id;
25
+ }
26
+
27
+ function get_version() {
28
+ return $this->version;
29
+ }
30
+
31
+ function get_path() {
32
+ return $this->path;
33
+ }
34
+
35
+ function get_parent_slug() {
36
+ return $this->parent_slug;
37
+ }
38
+
39
+ function get_slug() {
40
+ return $this->slug;
41
+ }
42
+
43
+ function get_url() {
44
+ return admin_url('admin.php?page='.$this->get_slug());
45
+ }
46
+
47
+ function get_code($code='') {
48
+ $format = empty($code) ? '%1$s' : '%1$s-%2$s';
49
+ return sprintf($format, $this->get_parent_slug(), $code);
50
+ }
51
+
52
+ function get_keys() {
53
+ return array_keys($this->tips);
54
+ }
55
+
56
+ function get_tip($label) {
57
+ return $this->tooltips->tip($label);
58
+ }
59
+
60
+ function plugin_action_links ( $links, $file ) {
61
+ if ( is_array($links) && ($this->get_path() == $file )) {
62
+ $settings_link = '<a href="' .$this->get_url() . '">Settings</a>';
63
+ array_unshift( $links, $settings_link );
64
+ }
65
+ return $links;
66
+ }
67
+
68
+ function set_tooltips($tips) {
69
+ $this->tips = $tips;
70
+ $this->tooltips = new Footer_Putter_Tooltip($this->tips);
71
+ $this->add_tooltip_support();
72
+ }
73
+
74
+ function add_tooltip_support() {
75
+ add_action('admin_enqueue_scripts', array( $this, 'enqueue_tooltip_styles'));
76
+ add_action('admin_enqueue_scripts', array( $this, 'enqueue_color_picker_styles'));
77
+ add_action('admin_enqueue_scripts', array( $this, 'enqueue_color_picker_scripts'));
78
+ }
79
+
80
+ function register_tooltip_styles() {
81
+ wp_register_style('diy-tooltip', plugins_url('styles/tooltip.css',dirname(__FILE__)), array(), $this->get_version());
82
+ }
83
+
84
+ function register_admin_styles() {
85
+ wp_register_style($this->get_code('admin'), plugins_url('styles/admin.css',dirname(__FILE__)), array(),$this->get_version());
86
}
87
88
+ function enqueue_admin_styles() {
89
+ wp_enqueue_style($this->get_code('admin'));
90
+ }
91
+
92
+ function enqueue_tooltip_styles() {
93
+ wp_enqueue_style('diy-tooltip');
94
+ wp_enqueue_style('dashicons');
95
+ }
96
+
97
+ function enqueue_color_picker_styles() {
98
+ wp_enqueue_style('wp-color-picker');
99
+ }
100
+
101
+ function enqueue_color_picker_scripts() {
102
+ wp_enqueue_script('wp-color-picker');
103
+ add_action('admin_print_footer_scripts', array($this, 'enable_color_picker'));
104
+ }
105
+
106
+ function enable_color_picker() {
107
+ print <<< SCRIPT
108
+ <script type="text/javascript">
109
+ //<![CDATA[
110
+ jQuery(document).ready( function($) {
111
+ $('.color-picker').wpColorPicker();
112
+ });
113
+ //]]>
114
+ </script>
115
+ SCRIPT;
116
+ }
117
+
118
+ function enqueue_postbox_scripts() {
119
+ wp_enqueue_script('common');
120
+ wp_enqueue_script('wp-lists');
121
+ wp_enqueue_script('postbox');
122
+ add_action('admin_footer-'.$this->get_screen_id(), array($this, 'toggle_postboxes'));
123
+ }
124
+
125
+ function toggle_postboxes() {
126
+ $hook = $this->get_screen_id();
127
+ print <<< SCRIPT
128
+ <script type="text/javascript">
129
+ //<![CDATA[
130
+ jQuery(document).ready( function($) {
131
+ $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
132
+ postboxes.add_postbox_toggles('{$hook}');
133
+ });
134
+ //]]>
135
+ </script>
136
+ SCRIPT;
137
+ }
138
+
139
+ function add_meta_box($code, $title, $callback_func, $callback_params = null, $context = 'normal', $priority = 'core', $post_type = false ) {
140
+ if (empty($post_type)) $post_type = $this->get_screen_id();
141
+ add_meta_box($this->get_code($code), __($title), array($this, $callback_func), $post_type, $context, $priority, $callback_params);
142
}
143
144
+ function form_field($id, $name, $label, $value, $type, $options = array(), $args = array(), $wrap = false) {
145
+ if (!$label) $label = $id;
146
+ $label_args = (is_array($args) && array_key_exists('label_args', $args)) ? $args['label_args'] : false;
147
+ return Footer_Putter_Utils::form_field($id, $name, $this->tooltips->tip($label, $label_args), $value, $type, $options, $args, $wrap);
148
+ }
149
+
150
+ function print_form_field($fld, $value, $type, $options = array(), $args = array(), $wrap = false) {
151
+ print $this->form_field($fld, $fld, false, $value, $type, $options, $args, $wrap);
152
+ }
153
+
154
+ function print_text_field($fld, $value, $args = array()) {
155
+ $this->print_form_field($fld, $value, 'text', array(), $args);
156
+ }
157
+
158
+ function admin_heading($title = '', $icon_class = '') {
159
+ if (empty($title)) $title = sprintf('%1$s %2$s', ucwords(str_replace('-',' ',$this->slug)), $this->get_version());
160
+ $icon = empty($icon_class) ? '' : sprintf('<i class="%1$s"></i>',
161
+ 'dashicons-'==substr($icon_class,0,10) ? ('dashicons '.$icon_class) : $icon_class) ;
162
+ return sprintf('<h2 class="title">%2$s%1$s</h2>', $title, $icon);
163
}
164
165
+ function print_admin_form_with_sidebar_start($title) {
166
+ print <<< ADMIN_START
167
+ <div class="wrap">
168
+ {$title}
169
+ <div id="poststuff" class="metabox-holder has-right-sidebar">
170
+ <div id="side-info-column" class="inner-sidebar">
171
+ ADMIN_START;
172
+ }
173
+
174
+ function print_admin_form_with_sidebar_middle() {
175
+ $this_url = $_SERVER['REQUEST_URI'];
176
+ print <<< ADMIN_MIDDLE
177
+ </div>
178
+ <div id="post-body" class="has-sidebar"><div id="post-body-content" class="has-sidebar-content diy-wrap">
179
+ <form id="diy_options" method="post" action="{$this_url}">
180
+ ADMIN_MIDDLE;
181
}
182
183
+ function print_admin_form_start($title, $enctype = false) {
184
+ $this_url = $_SERVER['REQUEST_URI'];
185
+ $enctype = $enctype ? 'enctype="multipart/form-data" ' : '';
186
+ print <<< ADMIN_START
187
<div class="wrap">
188
+ {$title}
189
+ <div id="poststuff" {$enctype}class="metabox-holder"><div id="post-body"><div id="post-body-content">
190
+ <form id="diy_options" method="post" {$enctype}action="{$this_url}">
191
+ ADMIN_START;
192
+ }
193
+
194
+ function print_admin_form_end($referer = false, $keys = false, $button_text = 'Save Changes') {
195
+ $nonces = $referer ? $this->get_nonces($referer) : '';
196
+ $page_options = $button = '';
197
+ if ($keys) {
198
+ $keys = is_array($keys) ? implode(',', $keys) : $keys;
199
+ $page_options = sprintf('<input type="hidden" name="page_options" value="%1$s" />', $keys);
200
+ $button = $this->submit_button($button_text);
201
+ }
202
+ print <<< ADMIN_END
203
+ <p class="submit">{$button}{$page_options}{$nonces}</p>
204
+ </form></div></div><br class="clear"/></div></div>
205
+ ADMIN_END;
206
}
207
+
208
+ function get_nonces($referer) {
209
+ return wp_nonce_field($referer, '_wpnonce', true, false).
210
+ wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false, false ).
211
+ wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false, false);
212
+ }
213
+
214
+ function submit_button($button_text='Save Changes') {
215
+ return sprintf('<input type="submit" name="options_update" value="%1$s" class="button-primary" />', $button_text);
216
+ }
217
+
218
+ function save_options($options_class, $settings_name, $trim_option_prefix = false) {
219
+
220
+ $page_options = explode(",", stripslashes($_POST['page_options']));
221
+
222
+ if (is_array($page_options)) {
223
+ $options = call_user_func( array($options_class, 'get_options'));
224
+ $updates = false;
225
+ foreach ($page_options as $option) {
226
+ $option = trim($option);
227
+ $val = array_key_exists($option, $_POST) ? trim(stripslashes($_POST[$option])) : '';
228
+ if ($trim_option_prefix) $option = substr($option,$trim_option_prefix); //remove prefix
229
+ $options[$option] = $val;
230
+ } //end for
231
+ $saved = call_user_func( array($options_class, 'save_options'), $options) ;
232
+ if ($saved) {
233
+ $class='updated fade';
234
+ $message = 'settings saved successfully.';
235
+ } else {
236
+ $class='error fade';
237
+ $message = 'settings have not been changed.';
238
+ }
239
+ } else {
240
+ $class='error';
241
+ $message= 'settings not found!';
242
+ }
243
+ return sprintf('<div id="message" class="%1$s"><p>%2$s %3$s</p></div>',
244
+ $class, __($settings_name), __($message));
245
+ }
246
+
247
+ function fetch_message() {
248
+ $message = '' ;
249
+ if (isset($_REQUEST['message']) && ! empty($_REQUEST['message'])) {
250
+ $message = urldecode($_REQUEST['message']);
251
+ $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
252
+ $style = strpos($message,'success') !== FALSE ? ' success' : (strpos($message,'fail') !== FALSE ? ' error' : '');
253
+ $message = sprintf('<div class="updated %2$">%1$s</div>',$message,$style);
254
+ }
255
+ return $message;
256
+ }
257
+
258
+ function screen_layout_columns($columns, $screen) {
259
+ if (!defined( 'WP_NETWORK_ADMIN' ) && !defined( 'WP_USER_ADMIN' )) {
260
+ if ($screen == $this->get_screen_id()) {
261
+ $columns[$this->get_screen_id()] = 2;
262
+ }
263
+ }
264
+ return $columns;
265
+ }
266
+
267
+ abstract function init() ;
268
+
269
+ abstract function admin_menu() ;
270
+
271
+ abstract function page_content();
272
+
273
+ abstract function load_page();
274
+
275
}
classes/class-credits-admin.php CHANGED
@@ -1,14 +1,7 @@
1
<?php
2
3
- if (!class_exists('Footer_Credits_Admin')) {
4
- class Footer_Credits_Admin {
5
- const CODE = 'footer-credits'; //prefix ID of CSS elements
6
- const FOOTER = 'Footer_Credits'; //class that builds footer
7
- const SLUG = 'credits';
8
- private static $slug;
9
- private static $screen_id;
10
- private static $keys;
11
- private static $tips = array(
12
'owner' => array('heading' => 'Owner or Business Name', 'tip' => 'Enter the name of the legal entity that owns and operates the site.'),
13
'microdata' => array('heading' => 'Use Microdata', 'tip' => 'Markup the organization details with HTML5 microdata.'),
14
'address' => array('heading' => 'Full Address', 'tip' => 'Enter the full address that you want to appear in the footer and the privacy and terms pages.'),
@@ -24,6 +17,7 @@ class Footer_Credits_Admin {
24
'email' => array('heading' => 'Email Address', 'tip' => 'Enter the email address here if you want it to appear in the footer and in the privacy statement.'),
25
'courts' => array('heading' => 'Legal Jurisdiction' , 'tip' => 'The Courts that have jurisdiction over any legal disputes regarding this site. For example: <i>the state and federal courts in Santa Clara County, California</i>, or <i>the Law Courts of England and Wales</i>'),
26
'updated' => array('heading' => 'Last Updated' , 'tip' => 'This will be defaulted as today. For example, Oct 23rd, 2012'),
27
'copyright_start_year' => array('heading' => 'Copyright Start' , 'tip' => 'The start year of the business appears in the copyright statement in the footer and an on the Terms and Conditions page.'),
28
'return_text' => array('heading' => 'Link Text' , 'tip' => 'The text of the Return To Top link. For example, <i>Return To Top</i> or <i>Back To Top</i>.'),
29
'return_class' => array('heading' => 'Return To Top Class' , 'tip' => 'Add any custom class you want to apply to the Return To Top link.'),
@@ -34,119 +28,46 @@ class Footer_Credits_Admin {
34
'privacy_contact' => array('heading' => 'Add Privacy Contact?', 'tip' => 'Add a section to the end of the Privacy page with contact information'),
35
'terms_contact' => array('heading' => 'Add Terms Contact?', 'tip' => 'Add a section to the end of the Terms page with contact and legal information'),
36
);
37
- private static $tooltips;
38
-
39
- public static function init() {
40
- self::$slug = Footer_Credits_Plugin::get_slug() . '-' . self::SLUG;
41
- add_action('admin_menu',array(__CLASS__, 'admin_menu'));
42
- }
43
-
44
- public static function get_slug(){
45
- return self::$slug;
46
- }
47
48
- private static function get_screen_id(){
49
- return self::$screen_id;
50
}
51
52
- private static function get_keys(){
53
- return self::$keys;
54
- }
55
-
56
- public static function get_url() {
57
- return admin_url('admin.php?page='.self::get_slug());
58
- }
59
-
60
- public static function enable_screen($show_screen,$screen) {
61
- if ($screen->id == self::get_screen_id())
62
- return true;
63
- else
64
- return $show_screen;
65
- }
66
-
67
- public static function admin_menu() {
68
- self::$screen_id = add_submenu_page(Footer_Credits_Plugin::get_slug(), __('Footer Credits'), __('Footer Credits'), 'manage_options',
69
- self::get_slug(), array(__CLASS__,'settings_panel'));
70
- add_action('load-'.self::get_screen_id(), array(__CLASS__, 'load_page'));
71
}
72
73
74
- public static function load_page() {
75
- $message = isset($_POST['options_update']) ? self::save() : '';
76
- $options = Footer_Credits::get_options();
77
$callback_params = array ('options' => $options, 'message' => $message);
78
- add_meta_box(self::CODE.'-intro', __('Introduction'), array(__CLASS__, 'intro_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
79
- add_meta_box(self::CODE.'-owner', __('Site Owner Details'), array(__CLASS__, 'owner_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
80
- add_meta_box(self::CODE.'-contact', __('Contact Details'), array(__CLASS__, 'contact_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
81
- add_meta_box(self::CODE.'-legal', __('Legal Details'), array(__CLASS__, 'legal_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
82
- add_meta_box(self::CODE.'-return', __('Return To Top'), array(__CLASS__, 'return_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
83
- add_meta_box(self::CODE.'-example', __('Preview Footer Content'), array(__CLASS__, 'preview_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
84
- add_meta_box(self::CODE.'-advanced', __('Advanced'), array(__CLASS__, 'advanced_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
85
- add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_styles'));
86
- add_action('admin_enqueue_scripts',array(__CLASS__, 'enqueue_scripts'));
87
- self::$keys = array_keys(self::$tips);
88
- self::$tooltips = new DIY_Tooltip(self::$tips);
89
- }
90
-
91
- public static function enqueue_styles() {
92
- wp_enqueue_style(self::CODE, plugins_url('styles/footer-credits.css', dirname(__FILE__)), array(),Footer_Credits_Plugin::get_version());
93
- wp_enqueue_style(self::CODE.'-admin', plugins_url('styles/admin.css',dirname(__FILE__)), array(),Footer_Credits_Plugin::get_version());
94
- wp_enqueue_style(self::CODE.'-tooltip', plugins_url('styles/tooltip.css',dirname(__FILE__)), array(),Footer_Credits_Plugin::get_version());
95
- }
96
-
97
- public static function enqueue_scripts() {
98
- wp_enqueue_script('common');
99
- wp_enqueue_script('wp-lists');
100
- wp_enqueue_script('postbox');
101
- add_action('admin_footer-'.self::get_screen_id(), array(__CLASS__, 'toggle_postboxes'));
102
- }
103
-
104
- public static function save() {
105
- check_admin_referer(__CLASS__);
106
- $page_options = explode(',', stripslashes($_POST['page_options']));
107
- if ($page_options) {
108
- $options = Footer_Credits::get_options();
109
- foreach ($page_options as $option) {
110
- $val = array_key_exists($option, $_POST) ? trim(stripslashes($_POST[$option])) : '';
111
- if (Footer_Credits::is_terms_key($option))
112
- $options['terms'][$option] = $val;
113
- else switch($option) {
114
- case 'footer_remove' : $options[$option] = !empty($val); break;
115
- case 'footer_hook':
116
- case 'footer_filter_hook': $options[$option] = preg_replace('/\W/','',$val); break;
117
- default: $options[$option] = trim($val);
118
- }
119
- } //end for
120
- $class='updated fade';
121
- $saved = Footer_Credits::save($options) ;
122
- if ($saved) {
123
- $message = 'Footer Settings saved.';
124
- } else
125
- $message = 'Footer Settings have not been changed.';
126
- } else {
127
- $class='error';
128
- $message= 'Footer Settings not found!';
129
- }
130
- return sprintf('<div id="message" class="%1$s "><p>%2$s</p></div>',$class, __($message));
131
- }
132
-
133
- public static function toggle_postboxes() {
134
- $hook = self::get_screen_id();
135
- print <<< SCRIPT
136
- <script type="text/javascript">
137
- //<![CDATA[
138
- jQuery(document).ready( function($) {
139
- // close postboxes that should be closed
140
- $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
141
- // postboxes setup
142
- postboxes.add_postbox_toggles('{$hook}');
143
- });
144
- //]]>
145
- </script>
146
- SCRIPT;
147
- }
148
-
149
- public static function intro_panel($post,$metabox){
150
$message = $metabox['args']['message'];
151
print <<< INTRO_PANEL
152
<p>The following information is used in the Footer Copyright Widget and optionally at the end of the Privacy Statement and Terms and Conditions pages.</p>
@@ -154,127 +75,98 @@ SCRIPT;
154
INTRO_PANEL;
155
}
156
157
- public static function owner_panel($post,$metabox){
158
$terms = $metabox['args']['options']['terms'];
159
- $tip1 = self::$tooltips->tip('owner');
160
- $tip2 = self::$tooltips->tip('country');
161
- $tip3 = self::$tooltips->tip('address');
162
- $tip4 = self::$tooltips->tip('street_address');
163
- $tip5 = self::$tooltips->tip('locality');
164
- $tip6 = self::$tooltips->tip('region');
165
- $tip7 = self::$tooltips->tip('postal_code');
166
- $tip8 = self::$tooltips->tip('latitude');
167
- $tip9 = self::$tooltips->tip('longitude');
168
- $tip10 = self::$tooltips->tip('map');
169
- print <<< OWNER_PANEL
170
- <label>{$tip1}</label><input type="text" name="owner" size="30" value="{$terms['owner']}" /><br/>
171
- <label>{$tip2}</label><input type="text" name="country" size="30" value="{$terms['country']}" /><br/>
172
- <label>{$tip3}</label><input type="text" name="address" size="80" value="{$terms['address']}" /><br/>
173
- OWNER_PANEL;
174
- if (Footer_Credits::is_html5()) print <<< ADDRESS_DATA
175
- <p>Leave the above address field blank and fill in the various parts of the organization address below if you want to be able to use HTML5 microdata.</p>
176
- <h4>Organization Address</h4>
177
- <label>{$tip4}</label><input type="text" name="street_address" size="30" value="{$terms['street_address']}" /><br/>
178
- <label>{$tip5}</label><input type="text" name="locality" size="30" value="{$terms['locality']}" /><br/>
179
- <label>{$tip6}</label><input type="text" name="region" size="30" value="{$terms['region']}" /><br/>
180
- <label>{$tip7}</label><input type="text" name="postal_code" size="12" value="{$terms['postal_code']}" /><br/>
181
- <h4>Geographical Co-ordinates</h4>
182
- <p>The geographical co-ordinates are optional and are visible only to the search engines.</p>
183
- <label>{$tip8}</label><input type="text" name="latitude" size="12" value="{$terms['latitude']}" /><br/>
184
- <label>{$tip9}</label><input type="text" name="longitude" size="12" value="{$terms['longitude']}" /><br/>
185
- <label>{$tip10}</label><input type="text" name="map" size="30" value="{$terms['map']}" /><br/>
186
- ADDRESS_DATA;
187
- }
188
-
189
- public static function contact_panel($post,$metabox){
190
$terms = $metabox['args']['options']['terms'];
191
- $tip1 = self::$tooltips->tip('email');
192
- $tip2 = self::$tooltips->tip('telephone');
193
- $tip3 = self::$tooltips->tip('privacy_contact');
194
- $tip4 = self::$tooltips->tip('terms_contact');
195
- $privacy_contact = $terms['privacy_contact'] ? 'checked="checked"' : '';
196
- $terms_contact = $terms['terms_contact'] ? 'checked="checked"' : '';
197
- print <<< CONTACT_PANEL
198
- <label>{$tip1}</label><input type="text" name="email" size="30" value="{$terms['email']}" /><br/>
199
- <label>{$tip2}</label><input type="text" name="telephone" size="30" value="{$terms['telephone']}" /><br/>
200
- <label>{$tip3}</label><input type="checkbox" name="privacy_contact" {$privacy_contact} value="1" /><br/>
201
- <label>{$tip4}</label><input type="checkbox" name="terms_contact" {$terms_contact} value="1" /><br/>
202
- CONTACT_PANEL;
203
}
204
205
- public static function legal_panel($post,$metabox){
206
$terms = $metabox['args']['options']['terms'];
207
- $tip1 = self::$tooltips->tip('courts');
208
- $tip2 = self::$tooltips->tip('updated');
209
- $tip3 = self::$tooltips->tip('copyright_start_year');
210
- print <<< LEGAL_PANEL
211
- <label>{$tip1}</label><input type="text" name="courts" size="80" value="{$terms['courts']}" /><br/>
212
- <label>{$tip2}</label><input type="text" name="updated" size="30" value="{$terms['updated']}" /><br/>
213
- <label>{$tip3}</label><input type="text" name="copyright_start_year" size="5" value="{$terms['copyright_start_year']}" /><br/>
214
- LEGAL_PANEL;
215
}
216
217
- public static function return_panel($post,$metabox){
218
$options = $metabox['args']['options'];
219
- $tip1 = self::$tooltips->tip('return_text');
220
- print <<< RETURN_PANEL
221
- <label>{$tip1}</label><input type="text" name="return_text" size="20" value="{$options['return_text']}" /><br/>
222
- RETURN_PANEL;
223
}
224
225
- public static function preview_panel($post,$metabox){
226
$options = $metabox['args']['options'];
227
echo Footer_Credits::footer(array('nav_menu' => 'Footer Menu'));
228
}
229
230
- public static function advanced_panel($post,$metabox){
231
$options = $metabox['args']['options'];
232
- $tip1 = self::$tooltips->tip('footer_hook');
233
- $tip2 = self::$tooltips->tip('footer_remove');
234
- $tip3 = self::$tooltips->tip('footer_filter_hook');
235
$url = 'http://www.diywebmastery.com/footer-credits-compatible-themes-and-hooks';
236
- $footer_remove = $options['footer_remove'] ? 'checked="checked" ' : '';
237
print <<< ADVANCED_PANEL
238
<p>You can place the Copyright and Trademark widgets in any existing widget area. However, if your theme does not have a suitably located widget area in the footer then you can create one by specifying the hook
239
where the Widget Area will be located.</p>
240
<p>You may use a standard WordPress hook like <i>get_footer</i> or <i>wp_footer</i> or choose a hook that is theme-specific such as <i>twentyten_credits</i>,
241
<i>twentyeleven_credits</i>, <i>twentytwelve_credits</i>,<i>twentythirteen_credits</i> or <i>twentyfourteen_credits</i>. If you using a Genesis child theme and the theme does not have a suitable widget area then use
242
the hook <i>genesis_footer</i> or maybe <i>genesis_after</i>. See what looks best. Click for <a href="{$url}">suggestions of which hook to use for common WordPress themes</a>.</p>
243
- <label>{$tip1}</label><input type="text" name="footer_hook" size="30" value="{$options['footer_hook']}" /><br/>
244
- <label>{$tip2}</label><input type="checkbox" name="footer_remove" {$footer_remove}value="1" /><br/>
245
<p>If your WordPress theme supplies a filter hook rather than an action hook where it generates the footer, and you want to suppress the theme footer,
246
then specify the hook below. For example, entering <i>genesis_footer_output</i> will suppress the standard Genesis child theme footer.</p>
247
- <label>{$tip3}</label><input type="text" name="footer_filter_hook" size="30" value="{$options['footer_filter_hook']}" /><br/>
248
- ADVANCED_PANEL;
249
}
250
251
- public static function settings_panel() {
252
- $this_url = $_SERVER['REQUEST_URI'];
253
- $keys = implode(',',self::get_keys());
254
- $title = sprintf('<h2 class="title">%1$s</h2>', __('Footer Credits Settings'));
255
-
256
- ?>
257
- <div class="wrap">
258
- <?php echo $title; ?>
259
- <div id="poststuff" class="metabox-holder">
260
- <div id="post-body" class="with-tooltips">
261
- <div id="post-body-content">
262
- <form id="footer_options" method="post" action="<?php echo $this_url; ?>">
263
- <?php do_meta_boxes(self::get_screen_id(), 'normal', null); ?>
264
- <p class="submit">
265
- <input type="submit" class="button-primary" name="options_update" value="Save Changes" />
266
- <input type="hidden" name="page_options" value="<?php echo $keys; ?>" />
267
- <?php wp_nonce_field(__CLASS__); ?>
268
- <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
269
- <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
270
- </p>
271
- </form>
272
- </div>
273
- </div>
274
- <br class="clear"/>
275
- </div>
276
- </div>
277
- <?php
278
- }
279
- }
280
}
1
<?php
2
+ class Footer_Credits_Admin extends Footer_Putter_Admin{
3
4
+ private $tips = array(
5
'owner' => array('heading' => 'Owner or Business Name', 'tip' => 'Enter the name of the legal entity that owns and operates the site.'),
6
'microdata' => array('heading' => 'Use Microdata', 'tip' => 'Markup the organization details with HTML5 microdata.'),
7
'address' => array('heading' => 'Full Address', 'tip' => 'Enter the full address that you want to appear in the footer and the privacy and terms pages.'),
17
'email' => array('heading' => 'Email Address', 'tip' => 'Enter the email address here if you want it to appear in the footer and in the privacy statement.'),
18
'courts' => array('heading' => 'Legal Jurisdiction' , 'tip' => 'The Courts that have jurisdiction over any legal disputes regarding this site. For example: <i>the state and federal courts in Santa Clara County, California</i>, or <i>the Law Courts of England and Wales</i>'),
19
'updated' => array('heading' => 'Last Updated' , 'tip' => 'This will be defaulted as today. For example, Oct 23rd, 2012'),
20
+ 'copyright_preamble' => array('heading' => 'Copyright Text' , 'tip' => 'Something like:<br/> Copyright &copy; All Rights Reserved.'),
21
'copyright_start_year' => array('heading' => 'Copyright Start' , 'tip' => 'The start year of the business appears in the copyright statement in the footer and an on the Terms and Conditions page.'),
22
'return_text' => array('heading' => 'Link Text' , 'tip' => 'The text of the Return To Top link. For example, <i>Return To Top</i> or <i>Back To Top</i>.'),
23
'return_class' => array('heading' => 'Return To Top Class' , 'tip' => 'Add any custom class you want to apply to the Return To Top link.'),
28
'privacy_contact' => array('heading' => 'Add Privacy Contact?', 'tip' => 'Add a section to the end of the Privacy page with contact information'),
29
'terms_contact' => array('heading' => 'Add Terms Contact?', 'tip' => 'Add a section to the end of the Terms page with contact and legal information'),
30
);
31
32
+ function init() {
33
+ add_action('admin_menu',array($this, 'admin_menu'));
34
}
35
36
+ function admin_menu() {
37
+ $this->screen_id = add_submenu_page($this->get_parent_slug(), __('Footer Credits'), __('Footer Credits'), 'manage_options',
38
+ $this->get_slug(), array($this,'page_content'));
39
+ add_action('load-'.$this->get_screen_id(), array($this, 'load_page'));
40
}
41
42
+ function page_content() {
43
+ $title = $this->admin_heading('Footer Credits',FOOTER_PUTTER_ICON);
44
+ $this->print_admin_form_start($title);
45
+ do_meta_boxes($this->get_screen_id(), 'normal', null);
46
+ $this->print_admin_form_end(__CLASS__, $this->get_keys());
47
+ }
48
49
+ function load_page() {
50
+ $message = isset($_POST['options_update']) ? $this->save_credits() : '';
51
+ $options = Footer_Credits_Options::get_options();
52
$callback_params = array ('options' => $options, 'message' => $message);
53
+ $this->add_meta_box('introduction', 'Introduction' , 'intro_panel', $callback_params);
54
+ $this->add_meta_box('owner', 'Site Owner Details' , 'owner_panel', $callback_params);
55
+ $this->add_meta_box('contact', 'Contact Details' , 'contact_panel', $callback_params);
56
+ $this->add_meta_box('legal', 'Legal Details' , 'legal_panel', $callback_params);
57
+ $this->add_meta_box('return', 'Return To Top' , 'return_panel', $callback_params);
58
+ $this->add_meta_box('example', 'Preview Footer Content' , 'preview_panel', $callback_params);
59
+ $this->add_meta_box('advanced', 'Advanced' , 'advanced_panel', $callback_params);
60
+ $this->set_tooltips($this->tips);
61
+ add_action('admin_enqueue_scripts', array($this, 'enqueue_credits_styles'));
62
+ add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
63
+ add_action('admin_enqueue_scripts',array($this, 'enqueue_postbox_scripts'));
64
+ }
65
+
66
+ function enqueue_credits_styles() {
67
+ wp_enqueue_style($this->get_code(), plugins_url('styles/footer-credits.css', dirname(__FILE__)), array(),$this->get_version());
68
+ }
69
+
70
+ function intro_panel($post,$metabox) {
71
$message = $metabox['args']['message'];
72
print <<< INTRO_PANEL
73
<p>The following information is used in the Footer Copyright Widget and optionally at the end of the Privacy Statement and Terms and Conditions pages.</p>
75
INTRO_PANEL;
76
}
77
78
+ function owner_panel($post,$metabox) {
79
$terms = $metabox['args']['options']['terms'];
80
+ $this->print_text_field('owner', $terms['owner'], array('size' =>30));
81
+ $this->print_text_field('country', $terms['country'], array('size' => 30));
82
+ $this->print_text_field('address', $terms['address'], array('size' => 80));
83
+ if (Footer_Credits::is_html5()) {
84
+ print('<p>Leave the above address field blank and fill in the various parts of the organization address below if you want to be able to use HTML5 microdata.</p>');
85
+ print('<h4>Organization Address</h4>');
86
+ $this->print_text_field('street_address', $terms['street_address'], array('size' => 30));
87
+ $this->print_text_field('locality', $terms['locality'], array('size' => 30));
88
+ $this->print_text_field('region', $terms['region'], array('size' => 30));
89
+ $this->print_text_field('postal_code', $terms['postal_code'], array('size' => 12));
90
+ print('<h4>Geographical Co-ordinates</h4>');
91
+ print('<p>The geographical co-ordinates are optional and are visible only to the search engines.</p>');
92
+ $this->print_text_field('latitude', $terms['latitude'], array('size' => 12));
93
+ $this->print_text_field('longitude', $terms['longitude'], array('size' => 12));
94
+ $this->print_text_field('map', $terms['map'], array('size' =>30));
95
+ }
96
+ }
97
+
98
+ function contact_panel($post,$metabox) {
99
$terms = $metabox['args']['options']['terms'];
100
+ $this->print_text_field('email', $terms['email'], array('size' => 30));
101
+ $this->print_text_field('telephone', $terms['telephone'], array('size' => 30));
102
+ $this->print_form_field('privacy_contact', $terms['privacy_contact'], 'checkbox');
103
+ $this->print_form_field('terms_contact', $terms['terms_contact'], 'checkbox');
104
}
105
106
+ function legal_panel($post,$metabox) {
107
$terms = $metabox['args']['options']['terms'];
108
+ $this->print_text_field('courts', $terms['courts'], array('size' => 80));
109
+ $this->print_text_field('updated', $terms['updated'], array('size' => 30));
110
+ $this->print_text_field('copyright_preamble', $terms['copyright_preamble'], array('size' => 30));
111
+ $this->print_text_field('copyright_start_year', $terms['copyright_start_year'], array('size' => 5));
112
}
113
114
+ function return_panel($post,$metabox) {
115
$options = $metabox['args']['options'];
116
+ $this->print_text_field('return_text', $options['return_text'], array('size' => 20));
117
}
118
119
+ function preview_panel($post,$metabox) {
120
$options = $metabox['args']['options'];
121
echo Footer_Credits::footer(array('nav_menu' => 'Footer Menu'));
122
}
123
124
+ function advanced_panel($post,$metabox) {
125
$options = $metabox['args']['options'];
126
$url = 'http://www.diywebmastery.com/footer-credits-compatible-themes-and-hooks';
127
print <<< ADVANCED_PANEL
128
<p>You can place the Copyright and Trademark widgets in any existing widget area. However, if your theme does not have a suitably located widget area in the footer then you can create one by specifying the hook
129
where the Widget Area will be located.</p>
130
<p>You may use a standard WordPress hook like <i>get_footer</i> or <i>wp_footer</i> or choose a hook that is theme-specific such as <i>twentyten_credits</i>,
131
<i>twentyeleven_credits</i>, <i>twentytwelve_credits</i>,<i>twentythirteen_credits</i> or <i>twentyfourteen_credits</i>. If you using a Genesis child theme and the theme does not have a suitable widget area then use
132
the hook <i>genesis_footer</i> or maybe <i>genesis_after</i>. See what looks best. Click for <a href="{$url}">suggestions of which hook to use for common WordPress themes</a>.</p>
133
+ ADVANCED_PANEL;
134
+ $this->print_text_field('footer_hook', $options['footer_hook'], array('size' => 30));
135
+ $this->print_form_field('footer_remove', $options['footer_remove'], 'checkbox');
136
+ print <<< REMOVE_PANEL
137
<p>If your WordPress theme supplies a filter hook rather than an action hook where it generates the footer, and you want to suppress the theme footer,
138
then specify the hook below. For example, entering <i>genesis_footer_output</i> will suppress the standard Genesis child theme footer.</p>
139
+ REMOVE_PANEL;
140
+ $this->print_text_field('footer_filter_hook', $options['footer_filter_hook'], array('size' => 30));
141
+ }
142
+
143
+ function save_credits() {
144
+ check_admin_referer(__CLASS__);
145
+ $page_options = explode(',', stripslashes($_POST['page_options']));
146
+ if ($page_options) {
147
+ $options = Footer_Credits_Options::get_options();
148
+ foreach ($page_options as $option) {
149
+ $val = array_key_exists($option, $_POST) ? trim(stripslashes($_POST[$option])) : '';
150
+ if (Footer_Credits_Options::is_terms_key($option))
151
+ $options['terms'][$option] = $val;
152
+ else switch($option) {
153
+ case 'footer_remove' : $options[$option] = !empty($val); break;
154
+ case 'footer_hook':
155
+ case 'footer_filter_hook': $options[$option] = preg_replace('/\W/','',$val); break;
156
+ default: $options[$option] = trim($val);
157
+ }
158
+ } //end for
159
+ $class='updated fade';
160
+ $saved = Footer_Credits_Options::save_options($options) ;
161
+ if ($saved) {
162
+ $message = 'Footer Settings saved.';
163
+ } else
164
+ $message = 'Footer Settings have not been changed.';
165
+ } else {
166
+ $class='error';
167
+ $message= 'Footer Settings not found!';
168
+ }
169
+ return sprintf('<div id="message" class="%1$s "><p>%2$s</p></div>',$class, __($message));
170
}
171
172
}
classes/class-dashboard.php ADDED
@@ -0,0 +1,118 @@
1
+ <?php
2
+ class Footer_Putter_Dashboard extends Footer_Putter_Admin {
3
+
4
+ function init() {
5
+ add_action('admin_menu', array($this, 'admin_menu'));
6
+ add_action('load-widgets.php', array($this, 'add_tooltip_support'));
7
+ add_action('admin_enqueue_scripts', array($this ,'register_tooltip_styles'));
8
+ add_action('admin_enqueue_scripts', array($this ,'register_admin_styles'));
9
+ add_filter('plugin_action_links',array($this, 'plugin_action_links'), 10, 2 );
10
+ }
11
+
12
+ function admin_menu() {
13
+ $intro = sprintf('Intro (v%1$s)', $this->get_version());
14
+ $this->screen_id = add_menu_page(FOOTER_PUTTER_FRIENDLY_NAME, FOOTER_PUTTER_FRIENDLY_NAME, 'manage_options',
15
+ $this->get_slug(), array($this,'page_content'), FOOTER_PUTTER_ICON );
16
+ add_submenu_page($this->get_slug(), FOOTER_PUTTER_FRIENDLY_NAME, $intro, 'manage_options', $this->get_slug(), array($this,'page_content') );
17
+ add_action('load-'.$this->get_screen_id(), array($this, 'load_page'));
18
+ }
19
+
20
+ function page_content() {
21
+ $title = $this->admin_heading('Footer Putter', FOOTER_PUTTER_ICON);
22
+ $this->print_admin_form_start($title);
23
+ do_meta_boxes($this->get_screen_id(), 'normal', null);
24
+ $this->print_admin_form_end(__CLASS__);
25
+ }
26
+
27
+ function load_page() {
28
+ $this->add_tooltip_support();
29
+ add_action('admin_enqueue_scripts', array($this, 'register_admin_styles'));
30
+ add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
31
+ add_action('admin_enqueue_scripts', array($this, 'enqueue_postbox_scripts'));
32
+ $this->add_meta_box('intro', 'Introduction', 'intro_panel');
33
+ $this->add_meta_box('widgets','Widgets', 'widgets_panel');
34
+ $this->add_meta_box('instructions', 'Instructions', 'instructions_panel');
35
+ $this->add_meta_box('hooks', 'Footer Hook', 'hooks_panel');
36
+ }
37
+
38
+ function intro_panel() {
39
+ $plugin = FOOTER_PUTTER_FRIENDLY_NAME;
40
+ print <<< INTRO_PANEL
41
+ <p>{$plugin} allows you to put a footer to your site that adds credibility to your site, with BOTH visitors and search engines.</p>
42
+ <p>Google is looking for some indicators that the site is about a real business.</p>
43
+ <ol>
44
+ <li>The name of the business or site owner</li>
45
+ <li>A copyright notice that is up to date</li>
46
+ <li>A telephone number</li>
47
+ <li>A postal address</li>
48
+ <li>Links to Privacy Policy and Terms of Use pages</p>
49
+ </ol>
50
+
51
+ <p>Human visitors may pay some credence to this information but will likely be more motivated by trade marks, trust marks and service marks.</p>
52
+ INTRO_PANEL;
53
+ }
54
+
55
+ function widgets_panel() {
56
+ print <<< WIDGETS_PANEL
57
+ <p>The plugins define two widgets:
58
+ <ol>
59
+ <li>a <b>Footer Copyright Widget</b> that places a line at the foot of your site containing as many of the items listed above that you want to disclose.</li>
60
+ <li>a <b>Trademarks Widget</b> that displays a line of trademarks that you have previously set up as "Links".
61
+ </ol></p>
62
+ <p>Typically you will drag both widgets into the Custom Footer Widget Area.</p>
63
+ WIDGETS_PANEL;
64
+ }
65
+
66
+ function instructions_panel() {
67
+ $plugin = FOOTER_PUTTER_FRIENDLY_NAME;
68
+ $widgets_url = admin_url('widgets.php');
69
+ $credits_url = Footer_Putter_Plugin::get_link_url('credits');
70
+ $trademarks_url = Footer_Putter_Plugin::get_link_url('trademarks');
71
+ print <<< INSTRUCTIONS_PANEL
72
+ <h4>Create Standard Pages And Footer Menu</h4>
73
+ <ol>
74
+ <li>Create a <i>Privacy Policy</i> page with the slug/permalink <em>privacy</em>, choose a page template with no sidebar.</li>
75
+ <li>Create a <i>Terms of Use</i> page with the slug/permalink <em>terms</em>, choose a page template with no sidebar.</li>
76
+ <li>Create a <i>Contact</i> page with a contact form.</li>
77
+ <li>Create an <i>About</i> page, with information either about the site or about its owner.</li>
78
+ <li>If the site is selling an information product you may want to create a <i>Disclaimer</i> page, regarding any claims about the product performance.</li>
79
+ <li>Create a WordPress menu called <i>Footer Menu</i> with the above pages.</li>
80
+ </ol>
81
+ <h4>Update Business Information</h4>
82
+ <ol>
83
+ <li>Go to <a href="{$credits_url}">Footer Credits</a> and update the Site Owner details, contact and legal information.</li>
84
+ <li>Optionally include contact details such as telephone and email. You may also want to add Geographical co-ordinates for your office location for the purposes of local search.</li>
85
+ </ol>
86
+ <h4>Create Trademark Links</h4>
87
+ <ol>
88
+ <li>Go to <a href="{$trademarks_url}"><i>Footer Trademarks</i></a> and follow the instructions:</li>
89
+ <li>Create a link category with a name such as <i>Trademarks</i></li>
90
+ <li>Add a link for each of your trademarks and put each in the <i>Trademarks</i> link category</li>
91
+ <li>For each link specify the link URL and the image URL</li>
92
+ </ol>
93
+ <h4>Set Up Footer Widgets</h4>
94
+ <ol>
95
+ <li>Go to <a href="{$widgets_url}"><i>Appearance > Widgets</i></a></li>
96
+ <li>Drag a <i>Footer Copyright Widget</i> and a <i>Footer Trademarks widget</i> into a suitable footer Widget Area</li>
97
+ <li>For the <i>Footer Trademarks</i> widget and choose your link category, e.g. <i>Trademarks</i>, and select a sort order</li>
98
+ <li>For the <i>Footer Copyright</i> widget, select the <i>Footer Menu</i> and choose what copyright and contact information you want to you display</li>
99
+ <li>Review the footer of the site. You can use the widget to change font sizes and colors using pre-defined classes such as <i>tiny</i>, <i>small</i>, <i>dark</i>, <i>light</i> or <i>white</i> or add your own custom classes</li>
100
+ <li>You can also choose to suppress the widgets on special pages such as landing pages.</li>
101
+ <li>If the footer is not in the right location you can use the <i>Footer Hook</i> feature described below to add a new widget area called <i>Credibility Footer</i> where you can locate the footer widgets.</li>
102
+ </ol>
103
+ INSTRUCTIONS_PANEL;
104
+ }
105
+
106
+ function hooks_panel() {
107
+ $home_url = FOOTER_PUTTER_HOME_URL;
108
+ $plugin = FOOTER_PUTTER_FRIENDLY_NAME;
109
+ print <<< HOOKS_PANEL
110
+
111
+ <p>The footer hook is only required if your theme does not already have a footer widget area into which you can drag the two widgets.</p>
112
+ <p>For some themes, the footer hook is left blank, for others use a WordPress hook such as <i>get_footer</i> or <i>wp_footer</i>,
113
+ or use a theme-specific hook such as <i>twentyten_credits</i>, <i>twentyeleven_credits</i>, <i>twentytwelve_credits</i>,
114
+ <i>twentythirteen_credits</i>, <i>twentyfourteen_credits</i>, <i>genesis_footer</i>, <i>pagelines_leaf</i>, etc.</p>
115
+ <p>Check out the <a href="{$home_url}">{$plugin} page</a> for more information about the plugin.</p>
116
+ HOOKS_PANEL;
117
+ }
118
+ }
classes/class-diy-options.php ADDED
@@ -0,0 +1,87 @@
1
+ <?php
2
+ class Footer_Putter_DIY_Options {
3
+
4
+ protected $option_name;
5
+ protected $options = array();
6
+ protected $defaults = array();
7
+ protected $encoded = false;
8
+
9
+ function __construct($option_name, $defaults = array(), $encoded = false) {
10
+ $this->option_name = $option_name;
11
+ $this->defaults = $defaults;
12
+ $this->encoded = $encoded;
13
+ }
14
+
15
+ function add_defaults($more = array()) {
16
+ $this->defaults = array_merge($this->defaults, (array)$more);
17
+ $this->options = array(); //clear cache
18
+ }
19
+
20
+ function get_defaults() {
21
+ return $this->defaults;
22
+ }
23
+
24
+ function get_default($option_name) {
25
+ if ($option_name && array_key_exists($option_name, $this->defaults))
26
+ return $this->defaults[$option_name];
27
+ else
28
+ return false;
29
+ }
30
+
31
+ function get_option_name() {
32
+ return $this->option_name;
33
+ }
34
+
35
+ function get_options($cache = true) {
36
+ if ($cache && (count($this->options) > 0)) return $this->options;
37
+ $the_options = get_option($this->get_option_name());
38
+ if (! empty($the_options) && ! is_array($the_options) && $this->encoded)
39
+ $the_options = unserialize(strrev(base64_decode($the_options)));
40
+ $this->options = empty($the_options) ? $this->get_defaults() : shortcode_atts( $this->get_defaults(), $the_options);
41
+ return $this->options;
42
+ }
43
+
44
+ function get_option($option_name, $cache = true) {
45
+ $options = $this->get_options($cache);
46
+ if ($option_name && $options && array_key_exists($option_name,$options))
47
+ return $options[$option_name];
48
+ else
49
+ return false;
50
+ }
51
+
52
+ function save_options($new_options) {
53
+ $options = $this->get_options(false);
54
+ $new_options = shortcode_atts( $this->get_defaults(), array_merge($options, $new_options));
55
+ if ($this->encoded) $new_options = base64_encode(strrev(serialize($new_options)));
56
+ $updated = update_option($this->get_option_name(),$new_options);
57
+ if ($updated) $this->get_options(false);
58
+ return $updated;
59
+ }
60
+
61
+ function validate_options($defaults, $options ) {
62
+ if (is_array($options) && is_array($defaults) )
63
+ return shortcode_atts($defaults, $options);
64
+ else
65
+ return false;
66
+ }
67
+
68
+ function upgrade_options() {
69
+ $new_options = array();
70
+ $defaults = $this->get_defaults();
71
+ $options = get_option($this->get_option_name());
72
+
73
+ if (is_array($options)) {
74
+ /* Remove old options and set defaults for new options */
75
+ foreach ($defaults as $key => $subdefaults)
76
+ if (array_key_exists($key, $options))
77
+ if (is_array($options[$key]) && is_array($subdefaults))
78
+ $new_options[$key] = shortcode_atts($subdefaults, $options[$key]);
79
+ else
80
+ $new_options[$key] = $options[$key];
81
+ } else {
82
+ $new_options = $defaults;
83
+ }
84
+ $this->save_options($new_options);
85
+ }
86
+
87
+ }
classes/class-footer-widgets.php CHANGED
@@ -1,15 +1,36 @@
1
<?php
2
3
- if (!class_exists('Footer_Credits_Copyright_Widget')) {
4
- class Footer_Credits_Copyright_Widget extends WP_Widget {
5
-
6
- const DOMAIN = 'Footer_Credits';
7
-
8
private $defaults = array(
9
'nav_menu' => 0, 'center' => true, 'two_lines' => true,
10
'show_copyright' => true, 'show_address' => true, 'show_telephone' => true, 'show_email' => false,
11
'show_return' => true, 'return_class' => '', 'footer_class' => '', 'visibility' => '');
12
13
function __construct() {
14
$widget_ops = array( 'description' => __( "A widget displaying menu links, copyright and company details" ) );
15
parent::__construct('footer_copyright', __('Footer Copyright Widget'), $widget_ops);
@@ -17,14 +38,15 @@ if (!class_exists('Footer_Credits_Copyright_Widget')) {
17
18
function widget( $args, $instance ) {
19
extract( $args );
20
- if (Footer_Credits::hide_widget($instance)) return; //check visibility requirements
21
22
if ($footer = Footer_Credits::footer($instance))
23
printf ('%1$s%2$s%3$s', $before_widget, $footer, $after_widget);
24
}
25
26
function update( $new_instance, $old_instance ) {
27
- $instance = $old_instance;
28
$instance['nav_menu'] = !empty($new_instance['nav_menu']) ? $new_instance['nav_menu'] : 0;
29
$instance['show_copyright'] = !empty($new_instance['show_copyright']) ? 1 : 0;
30
$instance['show_telephone'] = !empty($new_instance['show_telephone']) ? 1 : 0;
@@ -43,23 +65,25 @@ if (!class_exists('Footer_Credits_Copyright_Widget')) {
43
function form( $instance ) {
44
$menu_terms = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
45
if ( !$menu_terms ) {
46
- echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.', FOOTER_PUTTER_DOMAIN ), admin_url('nav-menus.php') ) .'</p>';
47
return;
48
}
49
$menus = array();
50
- $menus[0] = 'Do not show a menu';
51
foreach ( $menu_terms as $term ) $menus[ $term->term_id ] = $term->name;
52
53
- $instance = wp_parse_args( (array) $instance, $this->defaults);
54
- $this->print_form_field($instance, 'nav_menu', 'Select Footer Menu', 'select', $menus);
55
- $this->print_form_field($instance, 'center', 'Center Menu', 'checkbox');
56
- $this->print_form_field($instance, 'two_lines', 'Spread Over Two Lines', 'checkbox');
57
- $this->print_form_field($instance, 'show_copyright', 'Show Copyright', 'checkbox');
58
- $this->print_form_field($instance, 'show_address', 'Show Address', 'checkbox');
59
- $this->print_form_field($instance, 'show_telephone', 'Show Telephone number', 'checkbox');
60
- $this->print_form_field($instance, 'show_email', 'Show Email Address', 'checkbox');
61
- $this->print_form_field($instance, 'show_return', 'Show Return To Top Links', 'checkbox');
62
- if (Footer_Credits::is_html5()) $this->print_form_field($instance, 'use_microdata', 'Use HTML5 Microdata', 'checkbox');
63
64
print <<< CUSTOM_CLASSES
65
<h4>Custom Classes (Optional)</h4>
@@ -68,32 +92,49 @@ if (!class_exists('Footer_Credits_Copyright_Widget')) {
68
<i>small</i> and <i>tiny</i>. Feel free to use these alongside your own custom CSS classes.</p>
69
CUSTOM_CLASSES;
70
71
- $this->print_form_field($instance, 'return_class', 'Return To Top', 'text', array(), array('size' => 10));
72
- $this->print_form_field($instance, 'footer_class', 'Footer Credits', 'text', array(), array('size' => 10));
73
- $this->print_form_field($instance, 'visibility', '<h4>Widget Visibility</h4>', 'radio',
74
- Footer_Credits::get_visibility_options(), array('separator' => '<br/>'));
75
}
76
77
- function print_form_field($instance, $fld, $label, $type, $options = array(), $args = array()) {
78
- $value = array_key_exists($fld,$instance) ? $instance[$fld] : false;
79
- print Footer_Credits::form_field(
80
- $this->get_field_id($fld), $this->get_field_name($fld), $label, $value, $type, $options, $args);
81
}
82
- }
83
}
84
85
- if (!class_exists('Footer_Credits_Trademark_Widget')) {
86
- class Footer_Credits_Trademark_Widget extends WP_Widget {
87
88
private $defaults = array( 'title' => '',
89
- 'category' => false, 'orderby' => 'name', 'limit' => '', 'visibility' => '', 'nofollow' => false);
90
91
function __construct() {
92
- $widget_ops = array('description' => __( 'Trademarks, Service Marks and Kitemarks', FOOTER_PUTTER_DOMAIN) );
93
- parent::__construct('footer_trademarks', __('Footer Trademarks Widget', FOOTER_PUTTER_DOMAIN), $widget_ops);
94
}
95
96
-
97
function nofollow_links( $content) {
98
return preg_replace_callback( '/<a([^>]*)>(.*?)<\/a[^>]*>/is', array( &$this, 'nofollow_link' ), $content ) ;
99
}
@@ -116,7 +157,9 @@ if (!class_exists('Footer_Credits_Trademark_Widget')) {
116
117
function widget( $args, $instance ) {
118
extract($args, EXTR_SKIP);
119
- if (Footer_Credits::hide_widget($instance)) return; //check visibility requirements
120
$title = apply_filters('widget_title', $instance['title'] );
121
$category = isset($instance['category']) ? $instance['category'] : false;
122
$orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';
@@ -147,6 +190,7 @@ if (!class_exists('Footer_Credits_Trademark_Widget')) {
147
148
function update( $new_instance, $old_instance ) {
149
$new_instance = (array) $new_instance;
150
$instance['title'] = strip_tags( $new_instance['title'] );
151
$instance['orderby'] = 'name';
152
if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) )
@@ -159,31 +203,32 @@ if (!class_exists('Footer_Credits_Trademark_Widget')) {
159
}
160
161
function form( $instance ) {
162
- $instance = wp_parse_args( (array) $instance, $this->defaults );
163
$links = array();
164
$link_cats = get_terms( 'link_category' );
165
foreach ( $link_cats as $link_cat ) {
166
$id = intval($link_cat->term_id);
167
$links[$id] = $link_cat->name;
168
}
169
- $this->print_form_field($instance, 'title', 'Title: ', 'text');
170
- $this->print_form_field($instance, 'category', 'Select Link Category for Your Trademarks', 'select', $links);
171
- $this->print_form_field($instance, 'orderby', 'Sort by', 'select', array(
172
'name' => __( 'Link title'),
173
'rating' => __( 'Link rating'),
174
'id' => __( 'Link ID'),
175
'rand' => __( 'Random')
176
));
177
- $this->print_form_field($instance, 'limit', 'Number of links to show', 'text', array(), array('size' => 3 ,'maxlength' => 3));
178
- $this->print_form_field($instance, 'nofollow', ' NoFollow links', 'checkbox');
179
- $this->print_form_field($instance, 'visibility', '<h4>Widget Visibility</h4>', 'radio',
180
- Footer_Credits::get_visibility_options(), array('separator' => '<br/>'));
181
}
182
183
- function print_form_field($instance, $fld, $label, $type, $options = array(), $args = array()) {
184
- $value = array_key_exists($fld,$instance) ? $instance[$fld] : false;
185
- print Footer_Credits::form_field(
186
- $this->get_field_id($fld), $this->get_field_name($fld), $label, $value, $type, $options, $args);
187
}
188
- }
189
- }
1
<?php
2
+ class Footer_Putter_Copyright_Widget extends WP_Widget {
3
4
+ private $instance;
5
+ private $tooltips;
6
private $defaults = array(
7
'nav_menu' => 0, 'center' => true, 'two_lines' => true,
8
'show_copyright' => true, 'show_address' => true, 'show_telephone' => true, 'show_email' => false,
9
'show_return' => true, 'return_class' => '', 'footer_class' => '', 'visibility' => '');
10
11
+ private $tips = array(
12
+ 'nav_menu' => array('heading' => 'Footer Menu', 'tip' => 'Choose the menu to display in the footer'),
13
+ 'center' => array('heading' => 'Center Menu', 'tip' => 'Center the footer horizontally'),
14
+ 'two_lines' => array('heading' => 'Spread Over Two Lines', 'tip' => 'Place the menu and copyright on one line and the contact details on the other'),
15
+ 'show_copyright' => array('heading' => 'Show Copyright', 'tip' => 'Show copyright holder an year range'),
16
+ 'show_address' => array('heading' => 'Show Address', 'tip' => 'Show contact address'),
17
+ 'show_telephone' => array('heading' => 'Show Telephone Number', 'tip' => 'Show telephone number(s)'),
18
+ 'show_email' => array('heading' => 'Show Email Address', 'tip' => 'Show email'),
19
+ 'use_microdata' => array('heading' => 'Use HTML5 Microdata', 'tip' => 'Express organization, contact and any geo-coordinates using HTML5 microdata'),
20
+ 'show_return' => array('heading' => 'Show Return To Top Links', 'tip' => 'Show link to return to the top of the page'),
21
+ 'return_class' => array('heading' => 'Return To Top', 'tip' => 'Add custom classes to apply to the return to top links'),
22
+ 'footer_class' => array('heading' => 'Footer Credits', 'tip' => 'Add custom classes to apply to the footer menu, copyright and contact information'),
23
+ 'visibility' => array('heading' => 'Widget Visibility', 'tip' => 'Determine on which pages the footer widget is displayed'),
24
+ );
25
+
26
+ function get_tips() {
27
+ return $this->tips;
28
+ }
29
+
30
+ function get_defaults() {
31
+ return $this->defaults;
32
+ }
33
+
34
function __construct() {
35
$widget_ops = array( 'description' => __( "A widget displaying menu links, copyright and company details" ) );
36
parent::__construct('footer_copyright', __('Footer Copyright Widget'), $widget_ops);
38
39
function widget( $args, $instance ) {
40
extract( $args );
41
+ $instance = wp_parse_args( (array) $instance, $this->defaults );
42
+ if (Footer_Putter_Utils::hide_widget($instance['visibility'])) return; //check visibility requirements
43
44
if ($footer = Footer_Credits::footer($instance))
45
printf ('%1$s%2$s%3$s', $before_widget, $footer, $after_widget);
46
}
47
48
function update( $new_instance, $old_instance ) {
49
+ $instance = wp_parse_args( (array) $old_instance, $this->defaults );
50
$instance['nav_menu'] = !empty($new_instance['nav_menu']) ? $new_instance['nav_menu'] : 0;
51
$instance['show_copyright'] = !empty($new_instance['show_copyright']) ? 1 : 0;
52
$instance['show_telephone'] = !empty($new_instance['show_telephone']) ? 1 : 0;
65
function form( $instance ) {
66
$menu_terms = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
67
if ( !$menu_terms ) {
68
+ echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.' ), admin_url('nav-menus.php') ) .'</p>';
69
return;
70
}
71
$menus = array();
72
+ $menus[0] = 'No menu';
73
foreach ( $menu_terms as $term ) $menus[ $term->term_id ] = $term->name;
74
75
+ $this->instance = wp_parse_args( (array) $instance, $this->get_defaults() );
76
+ $this->tooltips = new Footer_Putter_Tooltip($this->get_tips());
77
+
78
+ $this->print_form_field('nav_menu', 'select', $menus);
79
+ $this->print_form_field('center', 'checkbox');
80
+ $this->print_form_field('two_lines', 'checkbox');
81
+ $this->print_form_field('show_copyright', 'checkbox');
82
+ $this->print_form_field('show_address', 'checkbox');
83
+ $this->print_form_field('show_telephone', 'checkbox');
84
+ $this->print_form_field('show_email', 'checkbox');
85
+ $this->print_form_field('show_return', 'checkbox');
86
+ if (Footer_Putter_Utils::is_html5()) $this->print_form_field('use_microdata', 'checkbox');
87
88
print <<< CUSTOM_CLASSES
89
<h4>Custom Classes (Optional)</h4>
92
<i>small</i> and <i>tiny</i>. Feel free to use these alongside your own custom CSS classes.</p>
93
CUSTOM_CLASSES;
94
95
+ $this->print_form_field('return_class', 'text', array(), array('size' => 10));
96
+ $this->print_form_field('footer_class', 'text', array(), array('size' => 10));
97
+ $this->print_form_field('visibility', 'radio', Footer_Putter_Utils::get_visibility_options(), array('separator' => '<br />'));
98
}
99
100
+ function print_form_field($fld, $type, $options = array(), $args = array()) {
101
+ $value = array_key_exists($fld,$this->instance) ? $this->instance[$fld] : false;
102
+ print Footer_Putter_Utils::form_field(
103
+ $this->get_field_id($fld), $this->get_field_name($fld), $this->tooltips->tip($fld), $value, $type, $options, $args, 'br');
104
}
105
}
106
107
+ class Footer_Putter_Trademark_Widget extends WP_Widget {
108
+
109
+ private $instance;
110
+ private $tooltips;
111
+
112
+ private $tips = array(
113
+ 'title' => array('heading' => 'Title', 'tip' => 'Widget Title'),
114
+ 'category' => array('heading' => 'Category', 'tip' => 'Select Link Category for Your Trademarks'),
115
+ 'limit' => array('heading' => 'Number of links', 'tip' => 'Number of trademarks to show'),
116
+ 'orderby' => array('heading' => 'Order By', 'tip' => 'Sort by name, rating, ID or random'),
117
+ 'nofollow' => array('heading' => 'Make Links Nofollow', 'tip' => 'Mark the links with rel=nofollow'),
118
+ 'visibility' => array('heading' => 'Widget Visibility', 'tip' => 'Determine on which pages the footer widget is displayed'),
119
+ );
120
121
private $defaults = array( 'title' => '',
122
+ 'category' => false, 'limit' => '', 'orderby' => 'name', 'nofollow' => false, 'visibility' => '');
123
+
124
+ function get_tips() {
125
+ return $this->tips;
126
+ }
127
+
128
+ function get_defaults() {
129
+ return $this->defaults;
130
+ }
131
132
function __construct() {
133
+ add_filter('pre_option_link_manager_enabled', '__return_true' );
134
+ $widget_ops = array('description' => __( 'Trademarks, Service Marks and Kitemarks') );
135
+ parent::__construct('footer_trademarks', __('Trademarks Widget'), $widget_ops);
136
}
137
138
function nofollow_links( $content) {
139
return preg_replace_callback( '/<a([^>]*)>(.*?)<\/a[^>]*>/is', array( &$this, 'nofollow_link' ), $content ) ;
140
}
157
158
function widget( $args, $instance ) {
159
extract($args, EXTR_SKIP);
160
+ $instance = wp_parse_args( (array) $instance, $this->defaults );
161
+ if (Footer_Putter_Utils::hide_widget($instance['visibility'])) return; //check visibility requirements
162
+
163
$title = apply_filters('widget_title', $instance['title'] );
164
$category = isset($instance['category']) ? $instance['category'] : false;
165
$orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';
190
191
function update( $new_instance, $old_instance ) {
192
$new_instance = (array) $new_instance;
193
+ $instance = wp_parse_args( (array) $old_instance, $this->defaults );
194
$instance['title'] = strip_tags( $new_instance['title'] );
195
$instance['orderby'] = 'name';
196
if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) )
203
}
204
205
function form( $instance ) {
206
+ $this->instance = wp_parse_args( (array) $instance, $this->get_defaults() );
207
+ $this->tooltips = new Footer_Putter_Tooltip($this->get_tips());
208
+
209
$links = array();
210
$link_cats = get_terms( 'link_category' );
211
foreach ( $link_cats as $link_cat ) {
212
$id = intval($link_cat->term_id);
213
$links[$id] = $link_cat->name;
214
}
215
+ $this->print_form_field('title', 'text', array(), array('size' => 10));
216
+ $this->print_form_field('category', 'select', $links);
217
+ $this->print_form_field('orderby', 'select', array(
218
'name' => __( 'Link title'),
219
'rating' => __( 'Link rating'),
220
'id' => __( 'Link ID'),
221
'rand' => __( 'Random')
222
));
223
+ $this->print_form_field('limit', 'text', array(), array('size' => 3 ,'maxlength' => 3));
224
+ $this->print_form_field('nofollow', 'checkbox');
225
+ $this->print_form_field('visibility', 'radio',
226
+ Footer_Putter_Utils::get_visibility_options(), array('separator' => '<br />'));
227
}
228
229
+ function print_form_field ($fld, $type, $options = array(), $args = array()) {
230
+ $value = array_key_exists($fld,$this->instance) ? $this->instance[$fld] : false;
231
+ print Footer_Putter_Utils::form_field(
232
+ $this->get_field_id($fld), $this->get_field_name($fld), $this->tooltips->tip($fld), $value, $type, $options, $args,'br');
233
}
234
+ }
classes/class-footer.php CHANGED
@@ -1,62 +1,11 @@
1
<?php
2
- if (!class_exists('Footer_Credits')) {
3
- class Footer_Credits {
4
const CODE = 'footer-credits'; //element prefix
5
- const OPTIONS_NAME = 'footer_credits_options';
6
const SIDEBAR_ID = 'last-footer';
7
-
8
- protected static $is_html5 = false;
9
- protected static $is_landing = false;
10
- protected static $landing_page_templates = array('page_landing.php');
11
-
12
- protected static $options = array();
13
- protected static $defaults = array(
14
- 'terms' => array(
15
- 'site' => '',
16
- 'owner' => '',
17
- 'address' => '',
18
- 'street_address' => '',
19
- 'locality' => '',
20
- 'region' => '',
21
- 'postal_code' => '',
22
- 'country' => '',
23
- 'latitude' => '',
24
- 'longitude' => '',
25
- 'map' => '',
26
- 'email' => '',
27
- 'telephone' => '',
28
- 'copyright' => '',
29
- 'copyright_start_year' => '',
30
- 'courts' => '',
31
- 'updated' => '',
32
- 'privacy_contact' => '',
33
- 'terms_contact' => ''),
34
- 'nav_menu' => 0,
35
- 'separator' => '&nbsp;&middot;&nbsp;',
36
- 'center' => true,
37
- 'two_lines' => true,
38
- 'show_copyright' => true,
39
- 'show_telephone' => true,
40
- 'show_email' => false,
41
- 'show_address' => true,
42
- 'show_return' => true,
43
- 'return_text' => 'Return To Top',
44
- 'return_class' => '',
45
- 'footer_class' => '',
46
- 'footer_hook' => '',
47
- 'footer_remove' => true,
48
- 'footer_filter_hook' => '',
49
- 'visibility' => '' ,
50
- 'use_microdata' => false
51
- );
52
-
53
- public static function is_html5(){
54
- return self::$is_html5;
55
- }
56
57
public static function init() {
58
- self::$is_html5 = function_exists('current_theme_supports') && current_theme_supports('html5');
59
- self::theme_specific_defaults();
60
add_action('widgets_init',array(__CLASS__,'register'),20);
61
add_filter( 'wp_nav_menu_items', array(__CLASS__, 'fix_home_link'), 10, 2 );
62
if (!is_admin()) add_action('wp',array(__CLASS__,'prepare'));
@@ -68,7 +17,7 @@ if (!class_exists('Footer_Credits')) {
68
}
69
70
private static function register_sidebars() {
71
- if (self::get_option('footer_hook')) {
72
$tag = self::is_html5() ? 'section' : 'div';
73
register_sidebar( array(
74
'id' => self::SIDEBAR_ID,
@@ -81,173 +30,73 @@ if (!class_exists('Footer_Credits')) {
81
}
82
83
private static function register_widgets() {
84
- register_widget( 'Footer_Credits_Copyright_Widget' );
85
- register_widget( 'Footer_Credits_Trademark_Widget' );
86
}
87
88
public static function prepare() {
89
- add_shortcode(self::CODE.'-copyright', array(__CLASS__, 'copyright_owner' ) );
90
- add_shortcode(self::CODE.'-menu', array(__CLASS__, 'footer_menu' ) );
91
add_shortcode(self::CODE, array(__CLASS__, 'footer' ) );
92
add_filter('widget_text', 'do_shortcode', 11);
93
add_action('wp_enqueue_scripts',array(__CLASS__, 'enqueue_styles' ));
94
95
- self::$is_landing = self::is_landing_page(); //is this a landing page
96
-
97
//insert custom footer at specified hook
98
- if ($footer_hook = self::get_option('footer_hook')) {
99
- if (self::get_option('footer_remove')) remove_all_actions( $footer_hook);
100
add_action( $footer_hook, array(__CLASS__, 'custom_footer'));
101
}
102
103
//suppress footer output
104
- if ($ffs = self::get_option('footer_filter_hook'))
105
add_filter($ffs, array(__CLASS__, 'no_footer'),100);
106
107
- if (is_page('privacy') && self::get_term('privacy_contact'))
108
add_filter('the_content', array(__CLASS__, 'add_privacy_footer'),9 );
109
110
- if (is_page('terms') && self::get_term('terms_contact'))
111
add_filter('the_content', array(__CLASS__, 'add_terms_footer'),9 );
112
113
if (is_page('terms') || is_page('privacy') || is_page('affiliates') || is_page('disclaimer'))
114
add_filter('the_content', array(__CLASS__, 'terms_filter') );
115
116
}
117
-
118
public static function enqueue_styles() {
119
- wp_enqueue_style(__CLASS__, plugins_url('styles/footer-credits.css',dirname(__FILE__)), array(), Footer_Credits_Plugin::get_version());
120
}
121
122
- public static function fix_home_link( $content, $args) {
123
- $class = is_front_page()? ' class="current_page_item"' : '';
124
- $home_linktexts = array('Home','<span>Home</span>');
125
- foreach ($home_linktexts as $home_linktext) {
126
- $home_link = sprintf('<a>%1$s</a>',$home_linktext);
127
- if (strpos($content, $home_link) !== FALSE)
128
- $content = str_replace ($home_link,sprintf('<a href="%1$s"%2$s>%3$s</a>',home_url(),$class,$home_linktext),$content);
129
- }
130
- return $content;
131
- }
132
-
133
- private static function sanitize_terms($new_terms) {
134
- $new_terms = wp_parse_args($new_terms, self::$defaults['terms']); //ensure terms are complete
135
- $new_terms['site'] = self::get_default_site();
136
- $new_terms['copyright'] = self::get_copyright($new_terms['copyright_start_year']); //generate copyright
137
- return $new_terms;
138
}
139
140
- public static function save($new_options) {
141
- $options = self::get_options(false);
142
- $new_options = wp_parse_args( $new_options, $options);
143
- $new_options['terms'] = self::sanitize_terms($new_options['terms']);
144
- $updated = update_option(self::OPTIONS_NAME,$new_options);
145
- if ($updated) self::get_options(false);
146
- return $updated;
147
- }
148
-
149
- public static function get_options ($cache = true) {
150
- if ($cache && (count(self::$options) > 0)) return self::$options;
151
-
152
- $the_options = array();
153
- $the_options = get_option(self::OPTIONS_NAME);
154
- if (empty($the_options)) {
155
- self::$options = self::$defaults;
156
- } else {
157
- self::$options = shortcode_atts( self::$defaults, $the_options);
158
- }
159
- return self::$options;
160
- }
161
-
162
- public static function get_option($option_name) {
163
- $options = self::get_options();
164
- if ($option_name && $options && array_key_exists($option_name,$options))
165
- return $options[$option_name];
166
- else
167
- return false;
168
- }
169
-
170
- private static function get_terms() {
171
- return self::get_option('terms');
172
- }
173
-
174
- private static function get_term($term_name) {
175
- $options = self::get_options();
176
- $terms = is_array($options) && array_key_exists('terms',$options) ? $options['terms'] : false;
177
- if ($term_name && $terms && array_key_exists($term_name,$terms) && $terms[$term_name])
178
- return $terms[$term_name];
179
- else
180
- return self::get_default_term($term_name);
181
- }
182
-
183
- private static function get_default_term($key) {
184
- $default='';
185
- switch ($key) {
186
- case 'owner' : $default = self::get_term('site'); break;
187
- case 'copyright' : $default = self::get_copyright(self::get_term('copyright_start_year')); break;
188
- case 'copyright_start_year': $default = date('Y'); break;
189
- case 'country' : $default = 'The United States'; break;
190
- case 'courts' : $default = ucwords(sprintf('the courts of %1$s',self::get_term('country'))); break;
191
- case 'email' : $default = 'privacy@'.strtolower(self::get_term('site')); break;
192
- case 'site' : $default = self::get_default_site(); break;
193
- case 'updated' : $default = date('d M Y'); break;
194
- default: $default=''; //default is blank for others
195
- }
196
- return $default;
197
- }
198
-
199
- private static function get_default_site() {
200
- $domain = strtolower(parse_url(site_url(),PHP_URL_HOST));
201
- $p = strpos($domain,'www.') ;
202
- if (($p !== FALSE) && ($p == 0)) $domain = substr($domain,4);
203
- return $domain;
204
- }
205
-
206
- public static function get_copyright($startyear){
207
- $thisyear = date("Y");
208
- if(empty( $startyear)) $startyear = $thisyear;
209
- return sprintf('Copyright &copy; %1$s%2$s', $startyear, $thisyear == $startyear ? '' : ("-".$thisyear));
210
- }
211
212
- public static function copyright_owner($attr){
213
- $defaults['owner'] = self::get_term('owner');
214
- $defaults['copyright_start_year'] = self::get_term('copyright_start_year');
215
- $params = shortcode_atts( $defaults, $attr ); //apply plugin defaults
216
- return sprintf('<span class="copyright">%1$s %2$s</span>',
217
- self::get_copyright($params['copyright_start_year']), $params['owner']);
218
- }
219
-
220
- private static function format_address ($address, $separator) {
221
- $s='';
222
- $addlines = explode(',', trim($address));
223
- foreach ($addlines as $a) {
224
- $a = trim($a);
225
- if (!empty($a)) $s .= $a . $separator;
226
- }
227
- return $s;
228
- }
229
230
- public static function footer_menu($menu) {
231
- return wp_nav_menu(array('menu' => $menu, 'echo' => false, 'container' => false));
232
- }
233
-
234
public static function return_to_top( $text, $class) {
235
return sprintf( '<div id="footer-return" class="%1$s"><a rel="nofollow" href="#" onclick="window.scrollTo(0,0); return false;" >%2$s</a></div>', trim($class), $text);
236
}
237
238
- private static function contact_info($params, $item_separator, $section_separator) {
239
$org ='';
240
- if ($address = self::contact_address($params['show_address'], $params['use_microdata'], $params['separator'], $section_separator)) $org .= $address;
241
- if ($telephone = self::contact_telephone($params['show_telephone'], $params['use_microdata'], $item_separator)) $org .= $telephone;
242
- if ($email = self::contact_email($params['show_email'], $params['use_microdata'], $item_separator)) $org .= $email;
243
- if ($org && $params['use_microdata'])
244
- return sprintf('<span itemscope="itemscope" itemtype="http://schema.org/Organization">%1$s</span>', $org);
245
- else
246
- return $org;
247
}
248
249
private static function contact_telephone($show_telephone, $microdata, $prefix) {
250
- if ($show_telephone && ($telephone = self::get_term('telephone')))
251
if ($microdata)
252
return sprintf('%1$s<span itemprop="telephone" class="telephone">%2$s</span>', $prefix, $telephone) ;
253
else
@@ -257,7 +106,7 @@ if (!class_exists('Footer_Credits')) {
257
}
258
259
private static function contact_email($show_email, $microdata, $prefix) {
260
- if ($show_email && ($email = self::get_term('email')))
261
return sprintf('%1$s<a href="mailto:%2$s" class="email"%3$s>%2$s</a>', $prefix, $email, $microdata ? ' itemprop="email"' : '') ;
262
else
263
return '';
@@ -267,11 +116,21 @@ if (!class_exists('Footer_Credits')) {
267
if ($show_address)
268
if ($microdata) {
269
return self::org_location($separator, $prefix);
270
- } elseif ($address = self::get_term('address'))
271
- return sprintf('%1$s<span class="address">%2$s%3$s</span>', $prefix, self::format_address($address, $separator), self::get_term('country'));
272
return '';
273
}
274
275
private static function org_location($separator, $prefix) {
276
$location = '';
277
if ($loc_address = self::location_address( $separator)) $location .= $loc_address;
@@ -285,15 +144,15 @@ if (!class_exists('Footer_Credits')) {
285
286
private static function location_address($separator) {
287
$address = '';
288
- if ( $street_address = self::get_term('street_address'))
289
$address .= sprintf('<span itemprop="streetAddress">%1$s</span>', self::format_address($street_address, $separator)) ;
290
- if ( $locality = self::get_term('locality'))
291
$address .= sprintf('<span itemprop="addressLocality">%1$s</span>', self::format_address($locality, $separator)) ;
292
- if ( $region = self::get_term('region'))
293
$address .= sprintf('<span itemprop="addressRegion">%1$s</span>', self::format_address($region, $separator)) ;
294
- if ( $postal_code = self::get_term('postal_code'))
295
$address .= sprintf('<span itemprop="postalCode">%1$s</span>', self::format_address($postal_code, $separator)) ;
296
- if ( $country = self::get_term('country'))
297
$address .= sprintf('<span itemprop="addressCountry">%1$s</span>', $country) ;
298
299
if ($address)
@@ -304,48 +163,82 @@ if (!class_exists('Footer_Credits')) {
304
305
private static function location_geo() {
306
$geo = '';
307
- if ( $latitude = self::get_term('latitude')) $geo .= sprintf('<meta itemprop="latitude" content="%1$s" />', $latitude) ;
308
- if ( $longitude = self::get_term('longitude')) $geo .= sprintf('<meta itemprop="longitude" content="%1$s" />', $longitude) ;
309
return $geo ? sprintf('<span itemprop="geo" itemscope="itemscope" itemtype="http://schema.org/GeoCoordinates">%1$s</span>', $geo) : '';
310
}
311
312
private static function location_map() {
313
- if ( $map = self::get_term('map'))
314
return sprintf('<a rel="nofollow external" target="_blank" class="map" itemprop="map" href="%1$s">%2$s</a>', $map, __('Map')) ;
315
else
316
return '';
317
}
318
319
public static function footer($atts = array()) {
320
- $params = shortcode_atts( self::get_options(), $atts ); //apply plugin defaults
321
322
if ($params['center']) {
323
- $item_separator = '&nbsp;';
324
- $section_separator = $params['two_lines'] ? '<br/>' : $params['separator'];
325
$params['return_class'] .= ' return-center';
326
$params['footer_class'] .= ' footer-center';
327
$clear = '';
328
} else {
329
- $item_separator = $params['two_lines'] ? $params['separator'] : '<br/>' ;
330
- $section_separator = '<br/>';
331
$params['return_class'] .= ' return-left';
332
$params['footer_class'] .= ' footer-right';
333
$clear = '<div class="clear"></div>';
334
}
335
return (empty($params['show_return']) ? '' :
336
self::return_to_top($params['return_text'], $params['return_class'])) .
337
- sprintf('<div id="%1$s" class="%2$s">%3$s%4$s%5$s</div>%6$s<!-- end #%1$s -->',
338
self::CODE,
339
$params['footer_class'],
340
- (empty($params['nav_menu']) ? '' : self::footer_menu($params['nav_menu'])),
341
- (empty($params['show_copyright']) ? '' : sprintf('%1$s%2$s', $item_separator, self::copyright_owner(self::get_terms()))),
342
- self::contact_info($params, $item_separator, $section_separator),
343
$clear
344
);
345
}
346
347
public static function terms_filter($content) {
348
- if ($terms = self::get_terms()) {
349
$from = array();
350
$to = array();
351
foreach ($terms as $term => $value) {
@@ -373,156 +266,46 @@ if (!class_exists('Footer_Credits')) {
373
374
public static function no_footer($content) { return ''; }
375
376
- public static function is_terms_key($key) {
377
- return array_key_exists($key, self::$defaults['terms']);
378
- }
379
-
380
- private static function theme_specific_defaults() {
381
- switch (basename( TEMPLATEPATH ) ) {
382
- case 'twentyten':
383
- self::$defaults['footer_hook'] = 'twentyten_credits'; break;
384
- case 'twentyeleven':
385
- self::$defaults['footer_hook'] = 'twentyeleven_credits'; break;
386
- case 'twentytwelve':
387
- self::$defaults['footer_hook'] = 'twentytwelve_credits'; break;
388
- case 'twentythirteen':
389
- self::$defaults['footer_hook'] = 'twentythirteen_credits'; break;
390
- case 'twentyfourteen':
391
- self::$defaults['footer_hook'] = 'twentyfourteen_credits'; break;
392
- case 'delicate':
393
- self::$defaults['footer_hook'] = 'get_footer'; break;
394
- case 'genesis':
395
- self::$defaults['footer_hook'] = 'genesis_footer';
396
- self::$defaults['footer_filter_hook'] = 'genesis_footer_output';
397
- break;
398
- case 'graphene':
399
- self::$defaults['footer_hook'] = 'graphene_footer'; break;
400
- case 'pagelines':
401
- self::$defaults['footer_hook'] = 'pagelines_leaf'; break;
402
- default:
403
- self::$defaults['footer_hook'] = 'wp_footer';
404
- self::$defaults['footer_remove'] = false;
405
- break;
406
- }
407
- }
408
-
409
public static function add_privacy_footer($content) {
410
- $email = self::get_term('email');
411
- $address = self::get_term('address');
412
- $country = self::get_term('country');
413
- $owner = self::get_term('owner');
414
$contact = <<< PRIVACY
415
<h2>How to Contact Us</h2>
416
- <p>Questions about this statement or about our handling of your information may be sent by email to <a href="mailto:{$email}">{$email}</a>, or by post to {$owner} Privacy Office, {$address} {$country}. </p>
417
PRIVACY;
418
return (strpos($content,'%%') == FALSE) ? ($content . $contact) : $content;
419
}
420
421
public static function add_terms_footer($content) {
422
- $email = self::get_term('email');
423
- $address = self::get_term('address');
424
- $country = self::get_term('country');
425
- $courts = self::get_term('courts');
426
- $owner = self::get_term('owner');
427
- $copyright = self::get_term('copyright');
428
- $updated = self::get_term('updated');
429
- $terms_contact = self::get_term('terms_contact');
430
$disputes = <<< DISPUTES
431
<h2>Dispute Resolution</h2>
432
- <p>These terms, and any dispute arising from the use of this site, will be governed by {$courts} without regard to its conflicts of laws provisions.</p>
433
DISPUTES;
434
$terms = <<< TERMS
435
<h2>Feedback And Information</h2>
436
- <p>Any feedback you provide at this site shall be deemed to be non-confidential. {$owner} shall be free to use such information on an unrestricted basis.</p>
437
<p>The terms and conditions for this web site are subject to change without notice.<p>
438
- <p>{$copyright} {$owner} All rights reserved.<br/> {$owner}, {$address} {$country}</p>
439
- <p>Updated by The {$owner} Legal Team on {$updated}</p>
440
TERMS;
441
if (strpos($content,'%%') == FALSE) {
442
- $content .= $courts ? $disputes : '';
443
- $content .= $address ? $terms : '';
444
}
445
return $content ;
446
}
447
448
- public static function hide_widget($instance) {
449
- $hide = false;
450
- if (array_key_exists('visibility',$instance))
451
- switch ($instance['visibility']) {
452
- case 'hide_landing' : $hide = self::$is_landing; break; //hide only on landing pages
453
- case 'show_landing' : $hide = ! self::$is_landing; break; //hide except on landing pages
454
- }
455
- return $hide;
456
- }
457
-
458
- public static function get_visibility_options(){
459
- return array(
460
- '' => 'Show on all pages',
461
- 'hide_landing' => 'Hide on landing pages',
462
- 'show_landing' => 'Show only on landing pages');
463
- }
464
-
465
- public static function form_field($fld_id, $fld_name, $label, $value, $type, $options = array(), $args = array()) {
466
- if ($args) extract($args);
467
- $input = '';
468
- $label = sprintf('<label for="%1$s">%2$s</label>', $fld_id, __($label));
469
- switch ($type) {
470
- case 'text':
471
- $input .= sprintf('<input type="text" id="%1$s" name="%2$s" value="%3$s" %4$s %5$s %6$s/> %7$s',
472
- $fld_id, $fld_name, $value,
473
- isset($size) ? ('size="'.$size.'"') : '', isset($maxlength) ? ('maxlength="'.$maxlength.'"') : '',
474
- isset($class) ? ('class="'.$class.'"') : '', isset($suffix) ? $suffix : '');
475
- return sprintf('<p>%1$s: %2$s</p>', $label, $input);
476
- break;
477
- case 'textarea':
478
- $input .= sprintf('<textarea id="%1$s" name="%2$s"%3$s%4$s%5$s>%6$s</textarea>',
479
- $fld_id, $fld_name,
480
- isset($rows) ? (' rows="'.$rows.'"') : '', isset($cols) ? (' cols="'.$cols.'"') : '',
481
- isset($class) ? (' class="'.$class.'"') : '', $value);
482
- return sprintf('<p>%1$s: %2$s</p>', $label, $input);
483
- break;
484
- case 'checkbox':
485
- $input .= sprintf('<input type="checkbox" class="checkbox" id="%1$s" name="%2$s" %3$svalue="1"/>',
486
- $fld_id, $fld_name, checked($value, '1', false));
487
- return sprintf('%1$s%2$s<br/>', $input, $label);
488
- break;
489
- case 'radio':
490
- $sep = (is_array($args) && array_key_exists('separator', $args)) ? $args['separator'] : '&nbsp;&nbsp;';
491
- if (is_array($options))
492
- foreach ($options as $optkey => $optlabel)
493
- $input .= sprintf('<input type="radio" id="%1$s" name="%2$s" %3$s value="%4$s" />&nbsp;%5$s%6$s',
494
- $fld_id, $fld_name, checked($optkey, $value, false), $optkey, $optlabel, $sep);
495
- return sprintf('<p>%1$s%2$s</p>', $label, $input);
496
- break;
497
- case 'select':
498
- if (is_array($options))
499
- foreach ($options as $optkey => $optlabel)
500
- $input .= sprintf('<option%1$s value="%2$s">%3$s</option>',
501
- selected($optkey, $value, false), $optkey, $optlabel);
502
- return sprintf('<p>%1$s: %2$s</p>', $label, self::selector($fld_id, $fld_name, $value, $options));
503
- break;
504
- }
505
}
506
507
- private static function selector($fld_id, $fld_name, $value, $options) {
508
- $input = '';
509
- if (is_array($options))
510
- foreach ($options as $optkey => $optlabel)
511
- $input .= sprintf('<option%1$s value="%2$s">%3$s</option>',
512
- selected($optkey, $value, false), $optkey, $optlabel);
513
- return sprintf('<select id="%1$s" name="%2$s">%3$s</select>', $fld_id, $fld_name, $input);
514
- }
515
-
516
- public static function is_landing_page() {
517
- if (is_page()) {
518
- global $post;
519
- $page_template_file = get_post_meta($post->ID,'_wp_page_template',true);
520
- // you can add your own landing page templates to the array using the filter
521
- $landing_page_templates = (array) apply_filters('footer_putter_landing_page_templates', self::$landing_page_templates);
522
- return in_array($page_template_file, $landing_page_templates );
523
- } else {
524
- return false;
525
- }
526
- }
527
- }
528
}
1
<?php
2
+
3
+ class Footer_Credits {
4
+
5
const CODE = 'footer-credits'; //element prefix
6
const SIDEBAR_ID = 'last-footer';
7
8
public static function init() {
9
add_action('widgets_init',array(__CLASS__,'register'),20);
10
add_filter( 'wp_nav_menu_items', array(__CLASS__, 'fix_home_link'), 10, 2 );
11
if (!is_admin()) add_action('wp',array(__CLASS__,'prepare'));
17
}
18
19
private static function register_sidebars() {
20
+ if (Footer_Credits_Options::get_option('footer_hook')) {
21
$tag = self::is_html5() ? 'section' : 'div';
22
register_sidebar( array(
23
'id' => self::SIDEBAR_ID,
30
}
31
32
private static function register_widgets() {
33
+ if (class_exists('Footer_Putter_Copyright_Widget')) register_widget('Footer_Putter_Copyright_Widget');
34
+ if (class_exists('Footer_Putter_Trademark_Widget')) register_widget('Footer_Putter_Trademark_Widget');
35
}
36
+
37
+ public static function is_html5() {
38
+ return Footer_Putter_Utils::is_html5();
39
+ }
40
41
public static function prepare() {
42
add_shortcode(self::CODE, array(__CLASS__, 'footer' ) );
43
+ add_shortcode(self::CODE.'-contact', array(__CLASS__, 'contact' ) );
44
+ add_shortcode(self::CODE.'-copyright', array(__CLASS__, 'copyright' ) );
45
+ add_shortcode(self::CODE.'-menu', array(__CLASS__, 'footer_menu' ) );
46
add_filter('widget_text', 'do_shortcode', 11);
47
add_action('wp_enqueue_scripts',array(__CLASS__, 'enqueue_styles' ));
48
49
+ $options = Footer_Credits_Options::get_options();
50
+
51
//insert custom footer at specified hook
52
+ if ($footer_hook = $options['footer_hook']) {
53
+ if ($options['footer_remove']) remove_all_actions( $footer_hook);
54
add_action( $footer_hook, array(__CLASS__, 'custom_footer'));
55
}
56
57
//suppress footer output
58
+ if ($ffs = $options['footer_filter_hook'])
59
add_filter($ffs, array(__CLASS__, 'no_footer'),100);
60
61
+ if (is_page('privacy') && Footer_Credits_Options::get_term('privacy_contact'))
62
add_filter('the_content', array(__CLASS__, 'add_privacy_footer'),9 );
63
64
+ if (is_page('terms') && Footer_Credits_Options::get_term('terms_contact'))
65
add_filter('the_content', array(__CLASS__, 'add_terms_footer'),9 );
66
67
if (is_page('terms') || is_page('privacy') || is_page('affiliates') || is_page('disclaimer'))
68
add_filter('the_content', array(__CLASS__, 'terms_filter') );
69
70
}
71
+
72
public static function enqueue_styles() {
73
+ wp_enqueue_style('footer-credits', plugins_url('styles/footer-credits.css',dirname(__FILE__)), array(), FOOTER_PUTTER_VERSION);
74
}
75
76
+ public static function register_admin_styles() {
77
+ wp_register_style('footer-credits-admin', plugins_url('styles/admin.css',dirname(__FILE__)), array(), FOOTER_PUTTER_VERSION);
78
}
79
80
+ public static function enqueue_admin_styles() {
81
+ wp_enqueue_style('footer-credits-admin');
82
+ }
83
84
85
public static function return_to_top( $text, $class) {
86
return sprintf( '<div id="footer-return" class="%1$s"><a rel="nofollow" href="#" onclick="window.scrollTo(0,0); return false;" >%2$s</a></div>', trim($class), $text);
87
}
88
89
+ private static function contact_info($params) {
90
$org ='';
91
+ if ($address = self::contact_address($params['show_address'], $params['use_microdata'], $params['separator'], $params['section_separator'])) $org .= $address;
92
+ if ($telephone = self::contact_telephone($params['show_telephone'], $params['use_microdata'], $params['item_separator'])) $org .= $telephone;
93
+ if ($email = self::contact_email($params['show_email'], $params['use_microdata'], $params['item_separator'])) $org .= $email;
94
+ $format = '<span' . ($params['use_microdata'] ? ' itemscope="itemscope" itemtype="http://schema.org/Organization"' : '') . '>%1$s</span>';
95
+ return sprintf($format, $org);
96
}
97
98
private static function contact_telephone($show_telephone, $microdata, $prefix) {
99
+ if ($show_telephone && ($telephone = Footer_Credits_Options::get_term('telephone')))
100
if ($microdata)
101
return sprintf('%1$s<span itemprop="telephone" class="telephone">%2$s</span>', $prefix, $telephone) ;
102
else
106
}
107
108
private static function contact_email($show_email, $microdata, $prefix) {
109
+ if ($show_email && ($email = Footer_Credits_Options::get_term('email')))
110
return sprintf('%1$s<a href="mailto:%2$s" class="email"%3$s>%2$s</a>', $prefix, $email, $microdata ? ' itemprop="email"' : '') ;
111
else
112
return '';
116
if ($show_address)
117
if ($microdata) {
118
return self::org_location($separator, $prefix);
119
+ } elseif ($address = Footer_Credits_Options::get_term('address'))
120
+ return sprintf('%1$s<span class="address">%2$s%3$s</span>', $prefix, self::format_address($address, $separator), Footer_Credits_Options::get_term('country'));
121
return '';
122
}
123
124
+ private static function format_address ($address, $separator) {
125
+ $s='';
126
+ $addlines = explode(',', trim($address));
127
+ foreach ($addlines as $a) {
128
+ $a = trim($a);
129
+ if (!empty($a)) $s .= $a . $separator;
130
+ }
131
+ return $s;
132
+ }
133
+
134
private static function org_location($separator, $prefix) {
135
$location = '';
136
if ($loc_address = self::location_address( $separator)) $location .= $loc_address;
144
145
private static function location_address($separator) {
146
$address = '';
147
+ if ( $street_address = Footer_Credits_Options::get_term('street_address'))
148
$address .= sprintf('<span itemprop="streetAddress">%1$s</span>', self::format_address($street_address, $separator)) ;
149
+ if ( $locality = Footer_Credits_Options::get_term('locality'))
150
$address .= sprintf('<span itemprop="addressLocality">%1$s</span>', self::format_address($locality, $separator)) ;
151
+ if ( $region = Footer_Credits_Options::get_term('region'))
152
$address .= sprintf('<span itemprop="addressRegion">%1$s</span>', self::format_address($region, $separator)) ;
153
+ if ( $postal_code = Footer_Credits_Options::get_term('postal_code'))
154
$address .= sprintf('<span itemprop="postalCode">%1$s</span>', self::format_address($postal_code, $separator)) ;
155
+ if ( $country = Footer_Credits_Options::get_term('country'))
156
$address .= sprintf('<span itemprop="addressCountry">%1$s</span>', $country) ;
157
158
if ($address)
163
164
private static function location_geo() {
165
$geo = '';
166
+ if ( $latitude = Footer_Credits_Options::get_term('latitude')) $geo .= sprintf('<meta itemprop="latitude" content="%1$s" />', $latitude) ;
167
+ if ( $longitude = Footer_Credits_Options::get_term('longitude')) $geo .= sprintf('<meta itemprop="longitude" content="%1$s" />', $longitude) ;
168
return $geo ? sprintf('<span itemprop="geo" itemscope="itemscope" itemtype="http://schema.org/GeoCoordinates">%1$s</span>', $geo) : '';
169
}
170
171
private static function location_map() {
172
+ if ( $map = Footer_Credits_Options::get_term('map'))
173
return sprintf('<a rel="nofollow external" target="_blank" class="map" itemprop="map" href="%1$s">%2$s</a>', $map, __('Map')) ;
174
else
175
return '';
176
}
177
178
+ public static function copyright_owner($params){
179
+ return sprintf('<span class="copyright">%1$s %2$s</span>',
180
+ Footer_Credits_Options::get_copyright($params['copyright_start_year']), $params['owner']);
181
+ }
182
+
183
+ public static function contact($atts = array()) {
184
+ $all_defaults = Footer_Credits_Options::get_defaults();
185
+ $defaults = array();
186
+ $defaults['show_telephone'] = $all_defaults['show_telephone'];
187
+ $defaults['show_email'] = $all_defaults['show_email'];
188
+ $defaults['show_address'] = $all_defaults['show_address'];
189
+ $defaults['use_microdata'] = $all_defaults['use_microdata'];
190
+ $defaults['separator'] = $all_defaults['separator'];
191
+ $defaults['item_separator'] = $all_defaults['item_separator'];
192
+ $defaults['section_separator'] = $all_defaults['section_separator'];
193
+ $defaults['footer_class'] = self::CODE;
194
+ $params = shortcode_atts( $defaults, $atts ); //apply plugin defaults
195
+ return sprintf ('<span class="%1$s">%2$s</span>', $params['footer_class'], self::contact_info($params));
196
+ }
197
+
198
+ public static function copyright($atts = array()){
199
+ $defaults = array();
200
+ $defaults['owner'] = Footer_Credits_Options::get_term('owner');
201
+ $defaults['copyright_start_year'] = Footer_Credits_Options::get_term('copyright_start_year');
202
+ $defaults['footer_class'] = self::CODE;
203
+ $params = shortcode_atts( $defaults, $atts ); //apply plugin defaults
204
+ return sprintf ('<span class="%1$s">%2$s</span>', $params['footer_class'], self::copyright_owner($params));
205
+ }
206
+
207
+ public static function footer_menu($atts = array()) {
208
+ $defaults = array('menu' => 'Footer Menu', 'echo' => false, 'container' => false, 'footer_class' => self::CODE);
209
+ $params = shortcode_atts( $defaults, $atts ); //apply plugin defaults
210
+ return sprintf ('<span class="%1$s">%2$s</span>', $params['footer_class'], wp_nav_menu($params));
211
+ }
212
+
213
public static function footer($atts = array()) {
214
+ $params = shortcode_atts( Footer_Credits_Options::get_options(), $atts ); //apply plugin defaults
215
216
if ($params['center']) {
217
+ if (! $params['two_lines']) $params['section_separator'] = $params['item_separator'];
218
$params['return_class'] .= ' return-center';
219
$params['footer_class'] .= ' footer-center';
220
$clear = '';
221
} else {
222
+ if (! $params['two_lines']) $params['item_separator'] = $params['section_separator'] ;
223
$params['return_class'] .= ' return-left';
224
$params['footer_class'] .= ' footer-right';
225
$clear = '<div class="clear"></div>';
226
}
227
+ $format = '<div id="%1$s" class="%2$s">%3$s%4$s%5$s</div>%6$s';
228
return (empty($params['show_return']) ? '' :
229
self::return_to_top($params['return_text'], $params['return_class'])) .
230
+ sprintf($format,
231
self::CODE,
232
$params['footer_class'],
233
+ (empty($params['nav_menu']) ? '' : self::footer_menu(array('menu' => $params['nav_menu']))),
234
+ (empty($params['show_copyright']) ? '' : sprintf('%1$s%2$s', $params['item_separator'], self::copyright_owner(Footer_Credits_Options::get_terms()))),
235
+ self::contact_info($params),
236
$clear
237
);
238
}
239
240
public static function terms_filter($content) {
241
+ if ($terms = Footer_Credits_Options::get_terms()) {
242
$from = array();
243
$to = array();
244
foreach ($terms as $term => $value) {
266
267
public static function no_footer($content) { return ''; }
268
269
public static function add_privacy_footer($content) {
270
+ $terms = Footer_Credits_Options::get_terms();
271
+ $email = $terms['email'];
272
$contact = <<< PRIVACY
273
<h2>How to Contact Us</h2>
274
+ <p>Questions about this statement or about our handling of your information may be sent by email to <a href="mailto:{$email}">{$email}</a>, or by post to {$terms['owner']} Privacy Office, {$terms['address']} {$terms['country']}. </p>
275
PRIVACY;
276
return (strpos($content,'%%') == FALSE) ? ($content . $contact) : $content;
277
}
278
279
public static function add_terms_footer($content) {
280
+ $terms = Footer_Credits_Options::get_terms();
281
$disputes = <<< DISPUTES
282
<h2>Dispute Resolution</h2>
283
+ <p>These terms, and any dispute arising from the use of this site, will be governed by {$terms['courts']} without regard to its conflicts of laws provisions.</p>
284
DISPUTES;
285
$terms = <<< TERMS
286
<h2>Feedback And Information</h2>
287
+ <p>Any feedback you provide at this site shall be deemed to be non-confidential. {$terms['owner']} shall be free to use such information on an unrestricted basis.</p>
288
<p>The terms and conditions for this web site are subject to change without notice.<p>
289
+ <p>{$terms['copyright']} {$terms['owner']} All rights reserved.<br/> {$terms['owner']}, {$terms['address']} {$terms['country']}</p>
290
+ <p>Updated by The {$terms['owner']} Legal Team on {$terms['updated']}</p>
291
TERMS;
292
if (strpos($content,'%%') == FALSE) {
293
+ $content .= $terms['courts'] ? $disputes : '';
294
+ $content .= $terms['address'] ? $terms : '';
295
}
296
return $content ;
297
}
298
299
+ public static function fix_home_link( $content, $args) {
300
+ $class = is_front_page()? ' class="current_page_item"' : '';
301
+ $home_linktexts = array('Home','<span>Home</span>');
302
+ foreach ($home_linktexts as $home_linktext) {
303
+ $home_link = sprintf('<a>%1$s</a>',$home_linktext);
304
+ if (strpos($content, $home_link) !== FALSE)
305
+ $content = str_replace ($home_link,sprintf('<a href="%1$s"%2$s>%3$s</a>',home_url(),$class,$home_linktext),$content);
306
+ }
307
+ return $content;
308
}
309
310
}
311
+
classes/class-options.php ADDED
@@ -0,0 +1,160 @@
1
+ <?php
2
+ class Footer_Credits_Options {
3
+
4
+ const OPTIONS_NAME = 'footer_credits_options';
5
+
6
+ protected static $options = null;
7
+
8
+ protected static $defaults = array(
9
+ 'terms' => array(
10
+ 'site' => '',
11
+ 'owner' => '',
12
+ 'address' => '',
13
+ 'street_address' => '',
14
+ 'locality' => '',
15
+ 'region' => '',
16
+ 'postal_code' => '',
17
+ 'country' => '',
18
+ 'latitude' => '',
19
+ 'longitude' => '',
20
+ 'map' => '',
21
+ 'email' => '',
22
+ 'telephone' => '',
23
+ 'copyright' => '',
24
+ 'copyright_start_year' => '',
25
+ 'copyright_preamble' => '',
26
+ 'courts' => '',
27
+ 'updated' => '',
28
+ 'privacy_contact' => '',
29
+ 'terms_contact' => ''),
30
+ 'nav_menu' => 0,
31
+ 'center' => true,
32
+ 'two_lines' => true,
33
+ 'separator' => '&nbsp;&middot;&nbsp;',
34
+ 'item_separator' => '&nbsp;',
35
+ 'section_separator' => '<br/>',
36
+ 'show_copyright' => true,
37
+ 'show_telephone' => true,
38
+ 'show_email' => false,
39
+ 'show_address' => true,
40
+ 'show_return' => true,
41
+ 'return_text' => 'Return To Top',
42
+ 'return_class' => '',
43
+ 'footer_class' => '',
44
+ 'footer_hook' => '',
45
+ 'footer_remove' => true,
46
+ 'footer_filter_hook' => '',
47
+ 'visibility' => '' ,
48
+ 'use_microdata' => false
49
+ );
50
+
51
+ public static function init() {
52
+ self::theme_specific_defaults();
53
+ self::$options = new Footer_Putter_DIY_Options(self::OPTIONS_NAME, self::$defaults);
54
+ }
55
+
56
+ public static function get_defaults() {
57
+ return self::$defaults;
58
+ }
59
+
60
+ public static function is_terms_key($key) {
61
+ return array_key_exists($key, self::$defaults['terms']);
62
+ }
63
+
64
+ public static function get_option($option_name) {
65
+ $options = self::get_options();
66
+ if ($option_name && $options && array_key_exists($option_name,$options))
67
+ return $options[$option_name];
68
+ else
69
+ return false;
70
+ }
71
+
72
+ public static function get_options() {
73
+ return self::$options->get_options();
74
+ }
75
+
76
+ public static function save_options($new_options) {
77
+ $new_options['terms'] = self::sanitize_terms($new_options['terms']);
78
+ return self::$options->save_options( $new_options) ;
79
+ }
80
+
81
+ private static function sanitize_terms($new_terms) {
82
+ $new_terms = wp_parse_args($new_terms, self::$defaults['terms']); //ensure terms are complete
83
+ $new_terms['site'] = self::get_default_site();
84
+ $new_terms['copyright'] = self::get_copyright($new_terms['copyright_start_year']); //generate copyright
85
+ return $new_terms;
86
+ }
87
+
88
+ private static function get_default_site() {
89
+ $domain = strtolower(parse_url(site_url(),PHP_URL_HOST));
90
+ $p = strpos($domain,'www.') ;
91
+ if (($p !== FALSE) && ($p == 0)) $domain = substr($domain,4);
92
+ return $domain;
93
+ }
94
+
95
+ public static function get_copyright($startyear='') {
96
+ $thisyear = date("Y");
97
+ $format = (empty( $startyear) || ($startyear==$thisyear)) ? '%1$s %3$s' : '%1$s %2$s-%3$s';
98
+ return sprintf($format, self::get_term('copyright_preamble'), $startyear, $thisyear);
99
+ }
100
+
101
+ public static function get_terms() {
102
+ return self::get_option('terms');
103
+ }
104
+
105
+ public static function get_term($term_name) {
106
+ $options = self::get_options();
107
+ $terms = is_array($options) && array_key_exists('terms',$options) ? $options['terms'] : false;
108
+ if ($term_name && $terms && array_key_exists($term_name,$terms) && $terms[$term_name])
109
+ return $terms[$term_name];
110
+ else
111
+ return self::get_default_term($term_name);
112
+ }
113
+
114
+ private static function get_default_term($key) {
115
+ $default='';
116
+ switch ($key) {
117
+ case 'owner' : $default = self::get_term('site'); break;
118
+ case 'copyright' : $default = self::get_copyright(self::get_term('copyright_start_year')); break;
119
+ case 'copyright_start_year': $default = date('Y'); break;
120
+ case 'copyright_preamble': $default = 'Copyright &copy;'; break;
121
+ case 'country' : $default = 'The United States'; break;
122
+ case 'courts' : $default = ucwords(sprintf('the courts of %1$s',self::get_term('country'))); break;
123
+ case 'email' : $default = 'privacy@'.strtolower(self::get_term('site')); break;
124
+ case 'site' : $default = self::get_default_site(); break;
125
+ case 'updated' : $default = date('d M Y'); break;
126
+ default: $default=''; //default is blank for others
127
+ }
128
+ return $default;
129
+ }
130
+
131
+ private static function theme_specific_defaults() {
132
+ switch (basename( TEMPLATEPATH ) ) {
133
+ case 'twentyten':
134
+ self::$defaults['footer_hook'] = 'twentyten_credits'; break;
135
+ case 'twentyeleven':
136
+ self::$defaults['footer_hook'] = 'twentyeleven_credits'; break;
137
+ case 'twentytwelve':
138
+ self::$defaults['footer_hook'] = 'twentytwelve_credits'; break;
139
+ case 'twentythirteen':
140
+ self::$defaults['footer_hook'] = 'twentythirteen_credits'; break;
141
+ case 'twentyfourteen':
142
+ self::$defaults['footer_hook'] = 'twentyfourteen_credits'; break;
143
+ case 'delicate':
144
+ self::$defaults['footer_hook'] = 'get_footer'; break;
145
+ case 'genesis':
146
+ self::$defaults['footer_hook'] = 'genesis_footer';
147
+ self::$defaults['footer_filter_hook'] = 'genesis_footer_output';
148
+ break;
149
+ case 'graphene':
150
+ self::$defaults['footer_hook'] = 'graphene_footer'; break;
151
+ case 'pagelines':
152
+ self::$defaults['footer_hook'] = 'pagelines_leaf'; break;
153
+ default:
154
+ self::$defaults['footer_hook'] = 'wp_footer';
155
+ self::$defaults['footer_remove'] = false;
156
+ break;
157
+ }
158
+ }
159
+
160
+ }
classes/class-plugin.php CHANGED
@@ -1,26 +1,23 @@
1
<?php
2
- class Footer_Credits_Plugin {
3
4
- private static $path = FOOTER_PUTTER_PATH;
5
- private static $slug = FOOTER_PUTTER_PLUGIN_NAME;
6
- private static $version = FOOTER_PUTTER_VERSION;
7
-
8
- public static function get_path(){
9
- return self::$path;
10
- }
11
12
- public static function get_slug(){
13
- return self::$slug;
14
- }
15
-
16
- public static function get_version(){
17
- return self::$version;
18
}
19
20
- public static function init() {
21
$dir = dirname(__FILE__) . '/';
22
require_once($dir . 'class-footer.php');
23
require_once($dir . 'class-footer-widgets.php');
24
Footer_Credits::init();