Footer Putter - Version 1.3

Version Description

Pre-configure according to the WordPress theme

Download this release

Release Info

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

Code changes from version 1.2 to 1.3

admin.php → classes/admin.php RENAMED
@@ -1,44 +1,67 @@
1
<?php
2
class FooterPutterAdmin {
3
- const CREDITS = 'FooterCreditsAdmin';
4
- private $pagehook;
5
-
6
- function __construct() {
7
- add_filter('screen_layout_columns', array(&$this, 'screen_layout_columns'), 10, 2);
8
- add_filter('plugin_action_links',array(&$this, 'plugin_action_links'), 10, 2 );
9
- add_action('admin_menu', array(&$this,'admin_menu'));
10
- call_user_func (array(self::CREDITS,'init'),FOOTER_PUTTER_PLUGIN_NAME,FOOTER_PUTTER_VERSION);
11
}
12
13
- function screen_layout_columns($columns, $screen) {
14
if (!defined( 'WP_NETWORK_ADMIN' ) && !defined( 'WP_USER_ADMIN' )) {
15
- if ($screen == $this->pagehook) {
16
- $columns[$this->pagehook] = 2;
17
}
18
}
19
return $columns;
20
}
21
22
- function plugin_action_links( $links, $file ) {
23
- if ( is_array($links) && (FOOTER_PUTTER_PATH == $file )) {
24
$settings_link = '<a href="' . admin_url( 'admin.php?page='.FOOTER_PUTTER_PLUGIN_NAME) . '">Settings</a>';
25
array_unshift( $links, $settings_link );
26
}
27
return $links;
28
}
29
30
- function admin_menu() {
31
- $this->pagehook = add_menu_page(FOOTER_PUTTER_FRIENDLY_NAME, FOOTER_PUTTER_FRIENDLY_NAME, 'manage_options',
32
- FOOTER_PUTTER_PLUGIN_NAME, array(&$this,'resources_panel'),plugins_url('/menu-icon.png',__FILE__) );
33
}
34
35
- function resources_panel() {
36
- $footer_url = call_user_func(array(self::CREDITS, 'get_url'));
37
$home_url = FOOTER_PUTTER_HOME_URL;
38
$version = FOOTER_PUTTER_VERSION;
39
$plugin = FOOTER_PUTTER_FRIENDLY_NAME;
40
- $screenshot = plugins_url('screenshot-1.jpg',__FILE__);
41
- $logo = plugins_url('logo.png',__FILE__);
42
print <<< ADMIN_PANEL
43
<div class="wrap">
44
<h2>{$plugin} {$version} Overview</h2>
@@ -95,5 +118,5 @@ or use a theme-specific hook such as <i>twentyten_credits</i>, <i>twentyeleven_c
95
ADMIN_PANEL;
96
}
97
}
98
- $footer_putter_admin = new FooterPutterAdmin();
99
?>
1
<?php
2
class FooterPutterAdmin {
3
+ const CLASSNAME = 'FooterPutterAdmin'; //this class
4
+ const CODE = 'footer-putter';
5
+ const DOMAIN = 'FooterPutter';
6
+
7
+ private static $plugin = FOOTER_PUTTER_PLUGIN_NAME;
8
+ private static $path = FOOTER_PUTTER_PATH;
9
+ private static $slug = FOOTER_PUTTER_PLUGIN_NAME;
10
+ private static $screen_id;
11
+ private static $initialized = false;
12
+
13
+ private static function get_slug(){
14
+ return self::$slug;
15
+ }
16
+
17
+ private static function get_screen_id(){
18
+ return self::$screen_id;
19
}
20
21
+ static function init() {
22
+ if (self::$initialized) return true;
23
+ self::$initialized = true;
24
+ add_filter('plugin_action_links',array(self::CLASSNAME, 'plugin_action_links'), 10, 2 );
25
+ add_filter('screen_layout_columns', array(self::CLASSNAME, 'screen_layout_columns'), 10, 2);
26
+ add_action('admin_menu',array(self::CLASSNAME, 'admin_menu'));
27
+ add_filter('pre_option_link_manager_enabled', '__return_true' );
28
+ }
29
+
30
+ static function screen_layout_columns($columns, $screen) {
31
if (!defined( 'WP_NETWORK_ADMIN' ) && !defined( 'WP_USER_ADMIN' )) {
32
+ if ($screen == self::get_screen_id()) {
33
+ $columns[self::get_screen_id()] = 2;
34
}
35
}
36
return $columns;
37
}
38
39
+ static function plugin_action_links( $links, $file ) {
40
+ if ( is_array($links) && (self::$path == $file )) {
41
$settings_link = '<a href="' . admin_url( 'admin.php?page='.FOOTER_PUTTER_PLUGIN_NAME) . '">Settings</a>';
42
array_unshift( $links, $settings_link );
43
}
44
return $links;
45
}
46
47
+ static function admin_menu() {
48
+ self::$screen_id = add_menu_page(FOOTER_PUTTER_FRIENDLY_NAME, FOOTER_PUTTER_FRIENDLY_NAME, 'manage_options',
49
+ FOOTER_PUTTER_PLUGIN_NAME, array(self::CLASSNAME,'settings_panel'),plugins_url('images/icon-16.png',dirname(__FILE__)) );
50
+ add_submenu_page(FOOTER_PUTTER_PLUGIN_NAME, FOOTER_PUTTER_FRIENDLY_NAME, 'Intro', 'manage_options', FOOTER_PUTTER_PLUGIN_NAME,array(self::CLASSNAME,'settings_panel') );
51
+ add_action ('admin_enqueue_scripts',array(self::CLASSNAME, 'enqueue_styles'));
52
}
53
+
54
+ static function enqueue_styles() {
55
+ wp_enqueue_style(self::CODE.'-admin', plugins_url('styles/admin.css', dirname(__FILE__)), array(),FOOTER_PUTTER_VERSION);
56
+ }
57
58
+ static function settings_panel() {
59
+ $footer_url = FooterCreditsAdmin::get_url();
60
$home_url = FOOTER_PUTTER_HOME_URL;
61
$version = FOOTER_PUTTER_VERSION;
62
$plugin = FOOTER_PUTTER_FRIENDLY_NAME;
63
+ $screenshot = plugins_url('screenshot-1.jpg',dirname(__FILE__));
64
+ $logo = plugins_url('images/logo.png', dirname(__FILE__));
65
print <<< ADMIN_PANEL
66
<div class="wrap">
67
<h2>{$plugin} {$version} Overview</h2>
118
ADMIN_PANEL;
119
}
120
}
121
+ FooterPutterAdmin::init();
122
?>
footer-credits-admin.php → classes/footer-credits-admin.php RENAMED
@@ -12,7 +12,7 @@ class FooterCreditsAdmin {
12
private static $initialized = false;
13
private static $keys = array('owner', 'site', 'address', 'country', 'telephone',
14
'email', 'courts', 'updated', 'copyright_start_year', 'return_text', 'return_href', 'return_class',
15
- 'footer_class','footer_hook');
16
private static $tips = array(
17
'owner' => array('heading' => 'Owner or Business Name', 'tip' => 'Enter the name of the legal entity that owns and operates the site.'),
18
'address' => array('heading' => 'Full Address', 'tip' => 'Enter the full address that you want to appear in the footer and the privacy and terms pages.'),
@@ -26,14 +26,16 @@ class FooterCreditsAdmin {
26
'return_href' => array('heading' => 'Link Anchor' , 'tip' => 'The destination of the Return To Top link. This depends on our theme and also whether you want to go to the top of the page or the top of the content section. Typical values are #content, #header, #top, #page, #wrap or #container.'),
27
'return_class' => array('heading' => 'Return To Top Class' , 'tip' => 'Add any custom class you want to apply to the Return To Top link.'),
28
'footer_class' => array('heading' => 'Footer Class' , 'tip' => 'Add any custom class you want to apply to the footer. The plugin comes with a class <i>white</i> that marks the text in the footer white. This is useful where the footer background is a dark color.'),
29
- 'footer_hook' => array('heading' => 'Footer Hook' , 'tip' => 'The hook where the footer widget area is added to the page. This field is only required if the theme does not already provide a suitable widget area where the footer widgets can be added.')
30
);
31
private static $tooltips;
32
33
- public static function init($parent,$version) {
34
if (self::$initialized) return true;
35
self::$initialized = true;
36
- self::$version = $version;
37
self::$parenthook = $parent;
38
self::$slug = self::$parenthook . '-' . self::SLUG;
39
add_filter('screen_layout_columns', array(self::CLASSNAME, 'screen_layout_columns'), 10, 2);
@@ -85,20 +87,23 @@ class FooterCreditsAdmin {
85
self::$screen_id = add_submenu_page(self::get_parenthook(), __('Footer Credits'), __('Footer Credits'), 'manage_options',
86
self::get_slug(), array(self::CLASSNAME,'settings_panel'));
87
add_action('load-'.self::get_screen_id(), array(self::CLASSNAME, 'load_page'));
88
- add_action('admin_print_styles-'.self::get_screen_id(), array(self::CLASSNAME, 'print_styles'));
89
- add_action('admin_footer-'.self::get_screen_id(), array(self::CLASSNAME, 'toggle_postboxes'));
90
}
91
92
- public static function print_styles() {
93
- wp_enqueue_style(self::CODE, plugins_url('style.css', __FILE__), array(),self::get_version());
94
- wp_enqueue_style(self::CODE.'-admin', plugins_url('admin.css', __FILE__), array(),self::get_version());
95
}
96
97
- public static function load_page() {
98
- $message = isset($_POST['options_update']) ? self::save() : '';
99
wp_enqueue_script('common');
100
wp_enqueue_script('wp-lists');
101
wp_enqueue_script('postbox');
102
$options = call_user_func(array(self::FOOTER, 'get_options'));
103
$callback_params = array ('options' => $options, 'message' => $message);
104
add_meta_box(self::CODE.'-intro', __('Introduction',self::DOMAIN), array(self::CLASSNAME, 'intro_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
@@ -106,15 +111,9 @@ class FooterCreditsAdmin {
106
add_meta_box(self::CODE.'-contact', __('Contact Details',self::DOMAIN), array(self::CLASSNAME, 'contact_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
107
add_meta_box(self::CODE.'-legal', __('Legal Details',self::DOMAIN), array(self::CLASSNAME, 'legal_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
108
add_meta_box(self::CODE.'-return', __('Return To Top',self::DOMAIN), array(self::CLASSNAME, 'return_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
109
- add_meta_box(self::CODE.'-classes', __('Custom Classes (Optional)',self::DOMAIN), array(self::CLASSNAME, 'classes_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
110
add_meta_box(self::CODE.'-example', __('Preview Footer',self::DOMAIN), array(self::CLASSNAME, 'preview_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
111
- add_meta_box(self::CODE.'-advanced', __('Advanced',self::DOMAIN), array(self::CLASSNAME, 'advanced_panel'), self::get_screen_id(), 'normal', 'core');
112
-
113
- $current_screen = get_current_screen();
114
- if (method_exists($current_screen,'add_help_tab')) {
115
- $current_screen->add_help_tab(
116
- array( 'id' => self::CODE.'-overview', 'title' => 'Overview', 'content' => self::help_panel()));
117
- }
118
}
119
120
public static function save() {
@@ -124,14 +123,17 @@ class FooterCreditsAdmin {
124
$options = call_user_func(array(self::FOOTER, 'get_options'));
125
foreach ($page_options as $option) {
126
$val = array_key_exists($option, $_POST) ? trim(stripslashes($_POST[$option])) : '';
127
- if (array_key_exists($option,$options['terms']))
128
- $options['terms'][$option] = $val;
129
else switch($option) {
130
- case 'return_href': $val = '#'.preg_replace('/\W/','',$val);
131
- default: $options[$option] = $val;
132
}
133
} //end for
134
- $class='updated fade';
135
$saved = call_user_func(array(self::FOOTER, 'save'), $options) ;
136
if ($saved) {
137
$message = 'Footer Settings saved.';
@@ -159,31 +161,11 @@ class FooterCreditsAdmin {
159
</script>
160
SCRIPT;
161
}
162
-
163
- public static function help_panel(){
164
- $result = <<< HELP_PANEL
165
- <p>This admin screen is used to set up the values that appear in the footer, and in the Terms and Conditions and Privacy pages.</p>
166
- <p>This information supplied here is substituted automatically into the Privacy and Terms pages and footer in the appropriate places.</p>
167
- <h4>Copyright Footer</h4>
168
- <p>You can set up as many of the following items as you want to appear on a single line in a footer widget:</p>
169
- <ul>
170
- <li>- Link to About Us page</li>
171
- <li>- Link to Contact Us page</li>
172
- <li>- Link to Privacy page</li>
173
- <li>- Link to Terms page</li>
174
- <li>- Copyright sSatement</li>
175
- <li>- Business Owner</li>
176
- <li>- Telephone</li>
177
- <li>- Address</li>
178
- </ul>
179
- HELP_PANEL;
180
- return $result;
181
- }
182
183
public static function intro_panel($post,$metabox){
184
$message = $metabox['args']['message'];
185
print <<< INTRO_PANEL
186
- <p>The following information can be used in both the footer widget and on the Privacy and Terms pages. See the Help section above for more information.</p>
187
{$message}
188
INTRO_PANEL;
189
}
@@ -232,32 +214,29 @@ LEGAL_PANEL;
232
RETURN_PANEL;
233
}
234
235
- public static function classes_panel(){
236
- $options = call_user_func(array(self::FOOTER, 'get_options'));
237
- $tip1 = self::$tooltips->tip('footer_class');
238
- $tip2 = self::$tooltips->tip('return_class');
239
- print <<< CLASSES_PANEL
240
- <label>{$tip1}</label><input type="text" name="footer_class" size="30" value="{$options['footer_class']}" /><br/>
241
- <label>{$tip2}</label><input type="text" name="return_class" size="30" value="{$options['return_class']}" /><br/>
242
- CLASSES_PANEL;
243
- }
244
-
245
public static function preview_panel($post,$metabox){
246
$options = $metabox['args']['options'];
247
echo call_user_func(array(self::FOOTER, 'footer'),array('nav_menu' => 'Footer Menu'));
248
}
249
250
- public static function advanced_panel(){
251
- $options = call_user_func(array(self::FOOTER, 'get_options'));
252
$tip1 = self::$tooltips->tip('footer_hook');
253
print <<< ADVANCED_PANEL
254
- <p>You can place the Copyright and Trademark widgets in any existing Widget area.</p>
255
- <p>However, if your theme does not have a suitably located Widget Area in the footer then you can create one by specifying the hook
256
where the Widget Area will be located.</p>
257
<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>,
258
- <i>twentyeleven_credits</i> or <i>pagelines_leaf</i>.</p>
259
- <p>If you using a Genesis child theme and the theme does not have a suitable widget area then use the hook <i>genesis_footer</i>.</p>
260
<label>{$tip1}</label><input type="text" name="footer_hook" size="30" value="{$options['footer_hook']}" /><br/>
261
ADVANCED_PANEL;
262
}
263
12
private static $initialized = false;
13
private static $keys = array('owner', 'site', 'address', 'country', 'telephone',
14
'email', 'courts', 'updated', 'copyright_start_year', 'return_text', 'return_href', 'return_class',
15
+ 'footer_class','footer_hook','footer_remove','footer_filter_hook');
16
private static $tips = array(
17
'owner' => array('heading' => 'Owner or Business Name', 'tip' => 'Enter the name of the legal entity that owns and operates the site.'),
18
'address' => array('heading' => 'Full Address', 'tip' => 'Enter the full address that you want to appear in the footer and the privacy and terms pages.'),
26
'return_href' => array('heading' => 'Link Anchor' , 'tip' => 'The destination of the Return To Top link. This depends on our theme and also whether you want to go to the top of the page or the top of the content section. Typical values are #content, #header, #top, #page, #wrap or #container.'),
27
'return_class' => array('heading' => 'Return To Top Class' , 'tip' => 'Add any custom class you want to apply to the Return To Top link.'),
28
'footer_class' => array('heading' => 'Footer Class' , 'tip' => 'Add any custom class you want to apply to the footer. The plugin comes with a class <i>white</i> that marks the text in the footer white. This is useful where the footer background is a dark color.'),
29
+ 'footer_hook' => array('heading' => 'Footer Action Hook' , 'tip' => 'The hook where the footer widget area is added to the page. This field is only required if the theme does not already provide a suitable widget area where the footer widgets can be added.'),
30
+ 'footer_remove' => array('heading' => 'Remove Existing Actions?' , 'tip' => 'Click the checkbox to remove any other actions at the above footer hook. This may stop you getting two footers; one created by your theme and another created by this plugin. For some themes you will check this option as you will typically want to replace the theme footer by the plugin footer.'),
31
+ 'footer_filter_hook' => array('heading' => 'Footer Filter Hook' , 'tip' => 'If you want to kill off the footer created by your theme, and your theme allows you to filter the content of the footer, then enter the hook where the theme filters the footer. This may stop you getting two footers; one created by your theme and another created by this plugin.')
32
);
33
private static $tooltips;
34
35
+ public static function init($parent) {
36
if (self::$initialized) return true;
37
self::$initialized = true;
38
+ self::$version = FooterCredits::VERSION;
39
self::$parenthook = $parent;
40
self::$slug = self::$parenthook . '-' . self::SLUG;
41
add_filter('screen_layout_columns', array(self::CLASSNAME, 'screen_layout_columns'), 10, 2);
87
self::$screen_id = add_submenu_page(self::get_parenthook(), __('Footer Credits'), __('Footer Credits'), 'manage_options',
88
self::get_slug(), array(self::CLASSNAME,'settings_panel'));
89
add_action('load-'.self::get_screen_id(), array(self::CLASSNAME, 'load_page'));
90
+ add_action('admin_print_styles-'.self::get_screen_id(), array(self::CLASSNAME, 'enqueue_styles'));
91
}
92
93
+ public static function enqueue_styles() {
94
+ wp_enqueue_style(self::CODE, plugins_url('styles/footer-credits.css', dirname(__FILE__)), array(),self::get_version());
95
+ wp_enqueue_style(self::CODE.'-admin', plugins_url('styles/admin.css', dirname(__FILE__)), array(),self::get_version());
96
}
97
98
+ public static function enqueue_scripts() {
99
wp_enqueue_script('common');
100
wp_enqueue_script('wp-lists');
101
wp_enqueue_script('postbox');
102
+ add_action('admin_footer-'.self::get_screen_id(), array(self::CLASSNAME, 'toggle_postboxes'));
103
+ }
104
+
105
+ public static function load_page() {
106
+ $message = isset($_POST['options_update']) ? self::save() : '';
107
$options = call_user_func(array(self::FOOTER, 'get_options'));
108
$callback_params = array ('options' => $options, 'message' => $message);
109
add_meta_box(self::CODE.'-intro', __('Introduction',self::DOMAIN), array(self::CLASSNAME, 'intro_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
111
add_meta_box(self::CODE.'-contact', __('Contact Details',self::DOMAIN), array(self::CLASSNAME, 'contact_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
112
add_meta_box(self::CODE.'-legal', __('Legal Details',self::DOMAIN), array(self::CLASSNAME, 'legal_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
113
add_meta_box(self::CODE.'-return', __('Return To Top',self::DOMAIN), array(self::CLASSNAME, 'return_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
114
add_meta_box(self::CODE.'-example', __('Preview Footer',self::DOMAIN), array(self::CLASSNAME, 'preview_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
115
+ add_meta_box(self::CODE.'-advanced', __('Advanced',self::DOMAIN), array(self::CLASSNAME, 'advanced_panel'), self::get_screen_id(), 'normal', 'core', $callback_params);
116
+ add_action ('admin_enqueue_scripts',array(self::CLASSNAME, 'enqueue_scripts'));
117
}
118
119
public static function save() {
123
$options = call_user_func(array(self::FOOTER, 'get_options'));
124
foreach ($page_options as $option) {
125
$val = array_key_exists($option, $_POST) ? trim(stripslashes($_POST[$option])) : '';
126
+ if (call_user_func(array(self::FOOTER, 'is_terms_key'),$option))
127
+ $options['terms'][$option] = $val;
128
else switch($option) {
129
+ case 'return_href': $options[$option] = '#'.preg_replace('/\W/','',$val); break;
130
+ case 'footer_remove' : $options[$option] = !empty($val); break;
131
+ case 'footer_hook':
132
+ case 'footer_filter_hook': $options[$option] = preg_replace('/\W/','',$val); break;
133
+ default: $options[$option] = trim($val);
134
}
135
} //end for
136
+ $class='updated fade';
137
$saved = call_user_func(array(self::FOOTER, 'save'), $options) ;
138
if ($saved) {
139
$message = 'Footer Settings saved.';
161
</script>
162
SCRIPT;
163
}
164
165
public static function intro_panel($post,$metabox){
166
$message = $metabox['args']['message'];
167
print <<< INTRO_PANEL
168
+ <p>The following information is in the Footer Copyright Widget and if this is a <a target="_blank" href="http://www.wpwhoosh.com">whooshed site</a> on the Privacy Statement and Terms and Conditions pages.</p>
169
{$message}
170
INTRO_PANEL;
171
}
214
RETURN_PANEL;
215
}
216
217
public static function preview_panel($post,$metabox){
218
$options = $metabox['args']['options'];
219
echo call_user_func(array(self::FOOTER, 'footer'),array('nav_menu' => 'Footer Menu'));
220
}
221
222
+ public static function advanced_panel($post,$metabox){
223
+ $options = $metabox['args']['options'];
224
$tip1 = self::$tooltips->tip('footer_hook');
225
+ $tip2 = self::$tooltips->tip('footer_remove');
226
+ $tip3 = self::$tooltips->tip('footer_filter_hook');
227
+ $url = 'http://www.diywebmastery.com/footer-credits-compatible-themes-and-hooks';
228
+ $footer_remove = $options['footer_remove'] ? 'checked="checked" ' : '';
229
print <<< ADVANCED_PANEL
230
+ <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
231
where the Widget Area will be located.</p>
232
<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>,
233
+ <i>twentyeleven_credits</i> or <i>twentytwelve_credits</i>. If you using a Genesis child theme and the theme does not have a suitable widget area then use
234
+ 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>
235
<label>{$tip1}</label><input type="text" name="footer_hook" size="30" value="{$options['footer_hook']}" /><br/>
236
+ <label>{$tip2}</label><input type="checkbox" name="footer_remove" {$footer_remove}value="1" /><br/>
237
+ <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,
238
+ then specify the hook below. For example, entering <i>genesis_footer_output</i> will suppress the standard Genesis child theme footer.</p>
239
+ <label>{$tip3}</label><input type="text" name="footer_filter_hook" size="30" value="{$options['footer_filter_hook']}" /><br/>
240
ADVANCED_PANEL;
241
}
242
footer-credits.php → classes/footer-credits.php RENAMED
@@ -5,6 +5,7 @@ class FooterCredits {
5
const CODE = 'footer-credits'; //shortcode
6
const OPTIONS_NAME = 'footer_credits_options';
7
const SIDEBAR_ID = 'last-footer';
8
private static $version;
9
protected static $options = array();
10
protected static $defaults = array(
@@ -22,6 +23,7 @@ class FooterCredits {
22
'nav_menu' => 0,
23
'separator' => '&nbsp;&middot;&nbsp;',
24
'center' => true,
25
'show_copyright' => true,
26
'show_telephone' => true,
27
'show_address' => true,
@@ -30,14 +32,18 @@ class FooterCredits {
30
'return_href' => '#header',
31
'return_class' => '',
32
'footer_class' => '',
33
- 'footer_hook' => ''
34
);
35
36
private static function get_version(){
37
return self::$version;
38
}
39
- static function init($version) {
40
- self::$version = $version;
41
add_action('widgets_init',array(self::CLASSNAME,'register'),20);
42
add_filter( 'wp_nav_menu_items', array(self::CLASSNAME, 'fix_home_link'), 10, 2 );
43
if (!is_admin()) add_action('wp',array(self::CLASSNAME,'prepare'));
@@ -59,9 +65,16 @@ class FooterCredits {
59
add_action('wp_enqueue_scripts',array(self::CLASSNAME, 'add_styles' ));
60
61
//insert custom footer at specified hook
62
- if ($footer_hook = self::get_option('footer_hook')) add_action( $footer_hook, array(self::CLASSNAME, 'custom_footer'));
63
64
- if (is_page('terms') || is_page('privacy'))
65
add_filter('the_content', array(self::CLASSNAME, 'terms_filter') );
66
}
67
}
@@ -84,13 +97,16 @@ class FooterCredits {
84
85
86
static function add_styles() {
87
- wp_enqueue_style(self::CLASSNAME, plugins_url('style.css',__FILE__), array(), self::get_version());
88
}
89
90
static function fix_home_link( $content, $args) {
91
- if (strpos($content, '<a>Home</a>') !== FALSE) {
92
- $class = is_front_page()? ' class="current_page_item"' : '';
93
- $content = str_replace ('<a>Home</a>',sprintf('<a href="%1$s"%2$s>Home</a>',home_url(),$class),$content);
94
}
95
return $content;
96
}
@@ -98,7 +114,7 @@ class FooterCredits {
98
static function sanitize_terms($new_terms) {
99
$new_terms = wp_parse_args($new_terms, self::$defaults['terms']); //ensure terms are complete
100
$new_terms['site'] = self::get_default_site();
101
- $new_terms['copyright'] = self::get_copyright($new_terms); //generate copyright
102
return $new_terms;
103
}
104
@@ -129,7 +145,7 @@ class FooterCredits {
129
if ($option_name && $options && array_key_exists($option_name,$options))
130
return $options[$option_name];
131
else
132
- return false;
133
}
134
135
static function get_terms() {
@@ -165,7 +181,7 @@ class FooterCredits {
165
$domain = strtolower(parse_url(site_url(),PHP_URL_HOST));
166
$p = strpos($domain,'www.') ;
167
if (($p !== FALSE) && ($p == 0)) $domain = substr($domain,4);
168
- return ucwords($domain);
169
}
170
171
static function get_copyright($startyear){
@@ -205,12 +221,14 @@ class FooterCredits {
205
static function footer($atts = array()) {
206
$params = shortcode_atts( self::get_options(), $atts ); //apply plugin defaults
207
if ($params['center']) {
208
- $line_separator = $params['separator'];
209
$params['return_class'] .= ' return-center';
210
$params['footer_class'] .= ' footer-center';
211
$clear = '';
212
} else {
213
- $line_separator = '<br/>';
214
$params['return_class'] .= ' return-left';
215
$params['footer_class'] .= ' footer-right';
216
$clear = '<div class="clear"></div>';
@@ -224,9 +242,9 @@ class FooterCredits {
224
self::CODE,
225
$params['footer_class'],
226
(empty($params['nav_menu']) ? '' : self::footer_menu($params['nav_menu'])),
227
- (empty($params['show_copyright']) ? '' : sprintf('%1$s%2$s', $line_separator, $copyright)),
228
- ((empty($telephone) || empty($params['show_telephone'])) ? '' : sprintf('%1$s<span class="telephone">%2$s</span>', $line_separator, $telephone) ),
229
- ((empty($address) || empty($params['show_address'])) ? '' : sprintf('%1$s<span class="address">%2$s%3$s</span>', $line_separator, self::format_address($address, $params['separator']), self::get_term('country')) ),
230
$clear
231
);
232
}
@@ -251,6 +269,8 @@ class FooterCredits {
251
echo '</div><!-- end .custom-footer -->';
252
}
253
}
254
255
static function add_footer_filter() {
256
add_filter('wp_list_bookmarks', array(self::CLASSNAME,'filter_links'),20); //nofollow links in custom footer widgets
@@ -268,6 +288,35 @@ class FooterCredits {
268
$atts = substr( $atts, 0, -1 );
269
return sprintf('<a rel="nofollow" %1$s>%2$s</a>', $atts, $matches[ 2 ]);
270
}
271
}
272
273
class Footer_Putter_Copyright_Widget extends WP_Widget {
@@ -283,7 +332,7 @@ class Footer_Putter_Copyright_Widget extends WP_Widget {
283
extract( $args );
284
$footer_args=array();
285
echo $before_widget;
286
- echo call_user_func(array(FOOTER_CREDITS,'footer'),$instance);
287
echo $after_widget;
288
}
289
@@ -293,26 +342,31 @@ class Footer_Putter_Copyright_Widget extends WP_Widget {
293
$instance['show_copyright'] = !empty($new_instance['show_copyright']) ? 1 : 0;
294
$instance['show_telephone'] = !empty($new_instance['show_telephone']) ? 1 : 0;
295
$instance['show_address'] = !empty($new_instance['show_address']) ? 1 : 0;
296
- $instance['center'] = !empty($new_instance['center']) ? 1 : 0;;
297
$instance['show_return'] = !empty($new_instance['show_return']) ? 1 : 0;
298
return $instance;
299
}
300
301
function form( $instance ) {
302
- $instance = wp_parse_args( (array) $instance,
303
- array( 'show_return' => true,'nav_menu' => 0,'show_copyright' => true,'show_telephone' => true,'show_address' => true,'center' => true ) );
304
- $nav_menu = isset( $instance['nav_menu'] ) ? (int) $instance['nav_menu'] : 0;
305
- $show_return = isset( $instance['show_return'] ) ? (bool) $instance['show_return'] : false;
306
- $show_copyright = isset( $instance['show_copyright'] ) ? (bool) $instance['show_copyright'] : false;
307
- $show_telephone = isset( $instance['show_telephone'] ) ? (bool) $instance['show_telephone'] : false;
308
- $show_address = isset( $instance['show_address'] ) ? (bool) $instance['show_address'] : false;
309
- $center = isset( $instance['center'] ) ? (bool) $instance['center'] : false;
310
-
311
$menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
312
if ( !$menus ) {
313
echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.', self::DOMAIN ), admin_url('nav-menus.php') ) .'</p>';
314
return;
315
}
316
?>
317
<p>
318
<label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Footer Menu:', self::DOMAIN ); ?></label>
@@ -327,93 +381,27 @@ class Footer_Putter_Copyright_Widget extends WP_Widget {
327
?>
328
</select>
329
</p>
330
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_copyright', self::DOMAIN ); ?>" name="<?php echo $this->get_field_name('show_copyright'); ?>"<?php checked( $show_copyright ); ?> />
331
<label for="<?php echo $this->get_field_id('show_copyright'); ?>"><?php _e( 'Show Copyright' ); ?></label><br />
332
- <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_telephone', self::DOMAIN ); ?>" name="<?php echo $this->get_field_name('show_telephone'); ?>"<?php checked( $show_telephone ); ?> />
333
- <label for="<?php echo $this->get_field_id('show_telephone'); ?>"><?php _e( 'Show Telephone number', self::DOMAIN ); ?></label><br />
334
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_address', self::DOMAIN ); ?>" name="<?php echo $this->get_field_name('show_address'); ?>"<?php checked( $show_address ); ?> />
335
<label for="<?php echo $this->get_field_id('show_address'); ?>"><?php _e( 'Show Address', self::DOMAIN ); ?></label><br />
336
- <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('center', self::DOMAIN ); ?>" name="<?php echo $this->get_field_name('center'); ?>"<?php checked( $center ); ?> />
337
- <label for="<?php echo $this->get_field_id('center'); ?>"><?php _e( 'Center Menu',self::DOMAIN ); ?></label><br/>
338
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_return', self::DOMAIN ); ?>" name="<?php echo $this->get_field_name('show_return'); ?>"<?php checked( $show_return ); ?> />
339
<label for="<?php echo $this->get_field_id('show_return'); ?>"><?php _e( 'Show Return To Top Link' ); ?></label><br />
340
<?php
341
}
342
}
343
-
344
- class Footer_Putter_TradeMark_Widget extends WP_Widget {
345
- const DOMAIN = 'FooterCredits';
346
-
347
- function __construct() {
348
- $widget_ops = array('description' => __( "Trademarks, Service Marks and Kitemarks" ) );
349
- parent::__construct('footer_trademarks', __('TradeMarks Widget'), $widget_ops);
350
- }
351
-
352
- function widget( $args, $instance ) {
353
- extract($args, EXTR_SKIP);
354
-
355
- $category = isset($instance['category']) ? $instance['category'] : false;
356
- $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';
357
- $order = $orderby == 'rating' ? 'DESC' : 'ASC';
358
- $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1;
359
-
360
- $links = wp_list_bookmarks(apply_filters('widget_links_args', array(
361
- 'echo' => 0,
362
- 'title_before' => $before_title, 'title_after' => $after_title,
363
- 'title_li' => '', 'categorize' => false,
364
- 'before' => '', 'after' => '',
365
- 'category_before' => '', 'category_after' => '',
366
- 'show_images' => true, 'show_description' => false,
367
- 'show_name' => false, 'show_rating' => false,
368
- 'category' => $category, 'class' => 'trademark widget',
369
- 'orderby' => $orderby, 'order' => $order,
370
- 'limit' => $limit,
371
- )));
372
- echo $before_widget;
373
- echo call_user_func(array(FOOTER_CREDITS,'filter_links'),$links);
374
- echo $after_widget;
375
- }
376
-
377
- function update( $new_instance, $old_instance ) {
378
- $new_instance = (array) $new_instance;
379
-
380
- $instance['orderby'] = 'name';
381
- if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) )
382
- $instance['orderby'] = $new_instance['orderby'];
383
-
384
- $instance['category'] = intval( $new_instance['category'] );
385
- $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1;
386
-
387
- return $instance;
388
- }
389
-
390
- function form( $instance ) {
391
- $instance = wp_parse_args( (array) $instance, array( 'category' => false, 'orderby' => 'name', 'limit' => -1 ) );
392
- $link_cats = get_terms( 'link_category' );
393
- if ( ! $limit = intval( $instance['limit'] ) ) { $limit = -1; } ?>
394
- <p>
395
- <label for="<?php echo $this->get_field_id('category'); ?>"><?php _e( 'Select Link Category for Your Trademarks:', self::DOMAIN ); ?></label>
396
- <select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
397
- <?php
398
- foreach ( $link_cats as $link_cat ) {
399
- echo '<option value="' . intval($link_cat->term_id) . '"'
400
- . ( $link_cat->term_id == $instance['category'] ? ' selected="selected"' : '' )
401
- . '>' . $link_cat->name . "</option>\n";
402
- }
403
- ?>
404
- </select>
405
- <label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Sort by:', self::DOMAIN ); ?></label>
406
- <select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">
407
- <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title', self::DOMAIN); ?></option>
408
- <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating', self::DOMAIN ); ?></option>
409
- <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID', self::DOMAIN ); ?></option>
410
- <option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _e( 'Random', self::DOMAIN ); ?></option>
411
- </select>
412
- </p>
413
- <p>
414
- <label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e( 'Number of links to show:', self::DOMAIN ); ?></label>
415
- <input id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit == -1 ? '' : intval( $limit ); ?>" size="3" />
416
- </p>
417
- <?php
418
- }
419
- }
5
const CODE = 'footer-credits'; //shortcode
6
const OPTIONS_NAME = 'footer_credits_options';
7
const SIDEBAR_ID = 'last-footer';
8
+ const VERSION = '1.3';
9
private static $version;
10
protected static $options = array();
11
protected static $defaults = array(
23
'nav_menu' => 0,
24
'separator' => '&nbsp;&middot;&nbsp;',
25
'center' => true,
26
+ 'two_lines' => true,
27
'show_copyright' => true,
28
'show_telephone' => true,
29
'show_address' => true,
32
'return_href' => '#header',
33
'return_class' => '',
34
'footer_class' => '',
35
+ 'footer_hook' => '',
36
+ 'footer_remove' => true,
37
+ 'footer_filter_hook' => ''
38
);
39
40
private static function get_version(){
41
return self::$version;
42
}
43
+
44
+ static function init() {
45
+ self::$version = self::VERSION;
46
+ self::theme_specific_defaults();
47
add_action('widgets_init',array(self::CLASSNAME,'register'),20);
48
add_filter( 'wp_nav_menu_items', array(self::CLASSNAME, 'fix_home_link'), 10, 2 );
49
if (!is_admin()) add_action('wp',array(self::CLASSNAME,'prepare'));
65
add_action('wp_enqueue_scripts',array(self::CLASSNAME, 'add_styles' ));
66
67
//insert custom footer at specified hook
68
+ if ($footer_hook = self::get_option('footer_hook')) {
69
+ if (self::get_option('footer_remove')) remove_all_actions( $footer_hook);
70
+ add_action( $footer_hook, array(self::CLASSNAME, 'custom_footer'));
71
+ }
72
73
+ //suppress footer output
74
+ if ($ffs = self::get_option('footer_filter_hook'))
75
+ add_filter($ffs, array(self::CLASSNAME, 'no_footer'),100);
76
+
77
+ if (is_page('terms') || is_page('privacy') || is_page('affiliates') || is_page('disclaimer'))
78
add_filter('the_content', array(self::CLASSNAME, 'terms_filter') );
79
}
80
}
97
98
99
static function add_styles() {
100
+ wp_enqueue_style(self::CLASSNAME, plugins_url('styles/footer-credits.css',dirname(__FILE__)), array(), self::get_version());
101
}
102
103
static function fix_home_link( $content, $args) {
104
+ $class = is_front_page()? ' class="current_page_item"' : '';
105
+ $home_linktexts = array('Home','<span>Home</span>');
106
+ foreach ($home_linktexts as $home_linktext) {
107
+ $home_link = sprintf('<a>%1$s</a>',$home_linktext);
108
+ if (strpos($content, $home_link) !== FALSE)
109
+ $content = str_replace ($home_link,sprintf('<a href="%1$s"%2$s>%3$s</a>',home_url(),$class,$home_linktext),$content);
110
}
111
return $content;
112
}
114
static function sanitize_terms($new_terms) {
115
$new_terms = wp_parse_args($new_terms, self::$defaults['terms']); //ensure terms are complete
116
$new_terms['site'] = self::get_default_site();
117
+ $new_terms['copyright'] = self::get_copyright($new_terms['copyright_start_year']); //generate copyright
118
return $new_terms;
119
}
120
145
if ($option_name && $options && array_key_exists($option_name,$options))
146
return $options[$option_name];
147
else
148
+ return false;
149
}
150
151
static function get_terms() {
181
$domain = strtolower(parse_url(site_url(),PHP_URL_HOST));
182
$p = strpos($domain,'www.') ;
183
if (($p !== FALSE) && ($p == 0)) $domain = substr($domain,4);
184
+ return $domain;
185
}
186
187
static function get_copyright($startyear){
221
static function footer($atts = array()) {
222
$params = shortcode_atts( self::get_options(), $atts ); //apply plugin defaults
223
if ($params['center']) {
224
+ $section_separator = '&nbsp;';
225
+ $item_separator = $params['two_lines'] ? '<br/>' : $params['separator'];
226
$params['return_class'] .= ' return-center';
227
$params['footer_class'] .= ' footer-center';
228
$clear = '';
229
} else {
230
+ $section_separator = $params['two_lines'] ? $params['separator'] : '<br/>' ;
231
+ $item_separator = '<br/>';
232
$params['return_class'] .= ' return-left';
233
$params['footer_class'] .= ' footer-right';
234
$clear = '<div class="clear"></div>';
242
self::CODE,
243
$params['footer_class'],
244
(empty($params['nav_menu']) ? '' : self::footer_menu($params['nav_menu'])),
245
+ (empty($params['show_copyright']) ? '' : sprintf('%1$s%2$s', $section_separator, $copyright)),
246
+ ((empty($address) || empty($params['show_address'])) ? '' : sprintf('%1$s<span class="address">%2$s%3$s</span>', $item_separator, self::format_address($address, $params['separator']), self::get_term('country')) ),
247
+ ((empty($telephone) || empty($params['show_telephone'])) ? '' : sprintf('%1$s<span class="telephone">%2$s</span>', $section_separator, $telephone) ),
248
$clear
249
);
250
}
269
echo '</div><!-- end .custom-footer -->';
270
}
271
}
272
+
273
+ static function no_footer($content) { return ''; }
274
275
static function add_footer_filter() {
276
add_filter('wp_list_bookmarks', array(self::CLASSNAME,'filter_links'),20); //nofollow links in custom footer widgets
288
$atts = substr( $atts, 0, -1 );
289
return sprintf('<a rel="nofollow" %1$s>%2$s</a>', $atts, $matches[ 2 ]);
290
}
291
+
292
+ static function is_terms_key($key) {
293
+ return array_key_exists($key, self::$defaults['terms']);
294
+ }
295
+
296
+ static function theme_specific_defaults() {
297
+ switch (basename( TEMPLATEPATH ) ) {
298
+ case 'twentyten':
299
+ self::$defaults['footer_hook'] = 'twentyten_credits'; break;
300
+ case 'twentyeleven':
301
+ self::$defaults['footer_hook'] = 'twentyeleven_credits'; break;
302
+ case 'twentytwelve':
303
+ self::$defaults['footer_hook'] = 'twentytwelve_credits'; break;
304
+ case 'delicate':
305
+ self::$defaults['footer_hook'] = 'get_footer'; break;
306
+ case 'genesis':
307
+ self::$defaults['footer_hook'] = 'genesis_footer';
308
+ self::$defaults['footer_filter_hook'] = 'genesis_footer_output';
309
+ break;
310
+ case 'graphene':
311
+ self::$defaults['footer_hook'] = 'graphene_footer'; break;
312
+ case 'pagelines':
313
+ self::$defaults['footer_hook'] = 'pagelines_leaf'; break;
314
+ default:
315
+ self::$defaults['footer_hook'] = 'wp_footer';
316
+ self::$defaults['footer_remove'] = false;
317
+ break;
318
+ }
319
+ }
320
}
321
322
class Footer_Putter_Copyright_Widget extends WP_Widget {
332
extract( $args );
333
$footer_args=array();
334
echo $before_widget;
335
+ echo FooterCredits::footer($instance);
336
echo $after_widget;
337
}
338
342
$instance['show_copyright'] = !empty($new_instance['show_copyright']) ? 1 : 0;
343
$instance['show_telephone'] = !empty($new_instance['show_telephone']) ? 1 : 0;
344
$instance['show_address'] = !empty($new_instance['show_address']) ? 1 : 0;
345
+ $instance['center'] = !empty($new_instance['center']) ? 1 : 0;
346
+ $instance['two_lines'] = !empty($new_instance['two_lines']) ? 1 : 0;
347
$instance['show_return'] = !empty($new_instance['show_return']) ? 1 : 0;
348
+ $instance['return_class'] = trim($new_instance['return_class']);
349
+ $instance['footer_class'] = trim($new_instance['footer_class']);
350
return $instance;
351
}
352
353
function form( $instance ) {
354
$menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
355
if ( !$menus ) {
356
echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.', self::DOMAIN ), admin_url('nav-menus.php') ) .'</p>';
357
return;
358
}
359
+ $instance = wp_parse_args( (array) $instance,
360
+ array( 'nav_menu' => 0, 'center' => true, 'two_lines' => true, 'show_copyright' => true, 'show_address' => true, 'show_telephone' => true, 'show_return' => true ) );
361
+ $nav_menu = isset( $instance['nav_menu'] ) ? (int) $instance['nav_menu'] : 0;
362
+ $center = isset( $instance['center'] ) ? (bool) $instance['center'] : false;
363
+ $two_lines = isset( $instance['two_lines'] ) ? (bool) $instance['two_lines'] : false;
364
+ $show_copyright = isset( $instance['show_copyright'] ) ? (bool) $instance['show_copyright'] : false;
365
+ $show_address = isset( $instance['show_address'] ) ? (bool) $instance['show_address'] : false;
366
+ $show_telephone = isset( $instance['show_telephone'] ) ? (bool) $instance['show_telephone'] : false;
367
+ $show_return = isset( $instance['show_return'] ) ? (bool) $instance['show_return'] : false;
368
+ $return_class = isset( $instance['return_class'] ) ? $instance['return_class'] : '';
369
+ $footer_class = isset( $instance['footer_class'] ) ? $instance['footer_class'] : '';
370
?>
371
<p>
372
<label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Footer Menu:', self::DOMAIN ); ?></label>
381
?>
382
</select>
383
</p>
384
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('center', self::DOMAIN ); ?>" name="<?php echo $this->get_field_name('center'); ?>"<?php checked( $center ); ?> />
385
+ <label for="<?php echo $this->get_field_id('center'); ?>"><?php _e( 'Center Menu',self::DOMAIN ); ?></label><br/>
386
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('two_lines', self::DOMAIN ); ?>" name="<?php echo $this->get_field_name('two_lines'); ?>"<?php checked( $two_lines ); ?> />
387
+ <label for="<?php echo $this->get_field_id('two_lines'); ?>"><?php _e( 'Spread Over Two Lines',self::DOMAIN ); ?></label><br/>
388
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_copyright', self::DOMAIN ); ?>" name="<?php echo $this->get_field_name('show_copyright'); ?>"<?php checked( $show_copyright ); ?> />
389
<label for="<?php echo $this->get_field_id('show_copyright'); ?>"><?php _e( 'Show Copyright' ); ?></label><br />
390
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_address', self::DOMAIN ); ?>" name="<?php echo $this->get_field_name('show_address'); ?>"<?php checked( $show_address ); ?> />
391
<label for="<?php echo $this->get_field_id('show_address'); ?>"><?php _e( 'Show Address', self::DOMAIN ); ?></label><br />
392
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_telephone', self::DOMAIN ); ?>" name="<?php echo $this->get_field_name('show_telephone'); ?>"<?php checked( $show_telephone ); ?> />
393
+ <label for="<?php echo $this->get_field_id('show_telephone'); ?>"><?php _e( 'Show Telephone number', self::DOMAIN ); ?></label><br />
394
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_return', self::DOMAIN ); ?>" name="<?php echo $this->get_field_name('show_return'); ?>"<?php checked( $show_return ); ?> />
395
<label for="<?php echo $this->get_field_id('show_return'); ?>"><?php _e( 'Show Return To Top Link' ); ?></label><br />
396
+ <h4>Custom Classes (Optional)</h4>
397
+ <p>Add any custom CSS classes you want apply to the footer section content to change the font color and size.</p>
398
+ <p>For your convenience we have defined 3 classes <i>dark</i>, <i>light</i> and <i>white</i> but feel free
399
+ to define and use your own custom CSS classes.</p>
400
+ <label for="<?php echo $this->get_field_id('return_class'); ?>"><?php _e( 'Return To Top:', self::DOMAIN ); ?></label>
401
+ <input id="<?php echo $this->get_field_id('return_class'); ?>" name="<?php echo $this->get_field_name('return_class'); ?>" type="text" value="<?php echo $return_class; ?>" size="10" /><br/>
402
+ <label for="<?php echo $this->get_field_id('footer_class'); ?>"><?php _e( 'Footer Credits:', self::DOMAIN ); ?></label>
403
+ <input id="<?php echo $this->get_field_id('footer_class'); ?>" name="<?php echo $this->get_field_name('footer_class'); ?>" type="text" value="<?php echo $footer_class; ?>" size="10" />
404
<?php
405
}
406
}
407
+ FooterCredits::init();
classes/footer-trademarks-admin.php ADDED
@@ -0,0 +1,102 @@
1
+ <?php
2
+ class FooterTrademarksAdmin {
3
+ const CLASSNAME = 'FooterTrademarksAdmin'; //this class
4
+ const CODE = 'footer-putter'; //prefix ID of CSS elements
5
+ const DOMAIN = 'FooterPutter'; //text domain for translation
6
+ const SLUG = 'trademarks';
7
+ const FIELDNAME = 'not_on_404';
8
+
9
+ private static $initialized = false;
10
+ private static $parenthook;
11
+ private static $slug;
12
+ private static $screen_id;
13
+
14
+ public static function init($parent) {
15
+ if (self::$initialized) return true;
16
+ self::$initialized = true;
17
+ self::$parenthook = $parent;
18
+ self::$slug = self::$parenthook . '-' . self::SLUG;
19
+ self::$screen_id = self::$parenthook.'_page_' . self::$slug;
20
+ add_filter('screen_layout_columns', array(self::CLASSNAME, 'screen_layout_columns'), 10, 2);
21
+ add_action('admin_menu',array(self::CLASSNAME, 'admin_menu'));
22
+ }
23
+
24
+ private static function get_parenthook(){
25
+ return self::$parenthook;
26
+ }
27
+
28
+ public static function get_slug(){
29
+ return self::$slug;
30
+ }
31
+
32
+ private static function get_screen_id(){
33
+ return self::$screen_id;
34
+ }
35
+
36
+ public static function enable_screen($show_screen,$screen) {
37
+ if ($screen->id == self::get_screen_id())
38
+ return true;
39
+ else
40
+ return $show_screen;
41
+ }
42
+
43
+ public static function screen_layout_columns($columns, $screen) {
44
+ if (!defined( 'WP_NETWORK_ADMIN' ) && !defined( 'WP_USER_ADMIN' )) {
45
+ if ($screen == self::get_screen_id()) {
46
+ $columns[self::get_screen_id()] = 2;
47
+ }
48
+ }
49
+ return $columns;
50
+ }
51
+
52
+ public static function admin_menu() {
53
+ add_submenu_page(self::get_parenthook(), __('Trademarks'), __('Trademarks'), 'manage_options',
54
+ self::get_slug(), array(self::CLASSNAME,'settings_panel'));
55
+ add_action('load-'.self::get_screen_id(), array(self::CLASSNAME, 'load_page'));
56
+ }
57
+
58
+ public static function load_page() {
59
+ add_action ('admin_enqueue_scripts',array(self::CLASSNAME, 'enqueue_styles'));
60
+ }
61
+
62
+ public static function enqueue_styles() {
63
+ wp_enqueue_style(self::CODE.'-admin', plugins_url('styles/admin.css', dirname(__FILE__)), array(),GENESIS_CLUB_VERSION);
64
+ }
65
+
66
+ public static function settings_panel() {
67
+ $this_url = $_SERVER['REQUEST_URI'];
68
+ $title = sprintf('<h2>%1$s</h2>', __('Footer Trademarks', self::DOMAIN));
69
+ $screenshot2 = plugins_url('images/add-link-category.jpg',dirname(__FILE__));
70
+ $screenshot3 = plugins_url('images/add-link.jpg',dirname(__FILE__));
71
+ $linkcat = admin_url('edit-tags.php?taxonomy=link_category');
72
+ $linkcat = admin_url('link-add.php');
73
+ $widgets = admin_url('widgets.php');
74
+ ?>
75
+ <div class="wrap">
76
+ <?php screen_icon(); echo $title; ?>
77
+ <div id="poststuff" class="metabox-holder"><div id="post-body"><div id="post-body-content">
78
+ <p class="notice">There are no settings on this page.</p>
79
+ <p class="notice">However, links are provided to where you set up trademarks or other symbols you want to appear in the footer.</p>
80
+
81
+ <p class="important">Firstly go to the <a href="<?php echo $linkcat;?>">Link Categories</a> and set up a link category called <i>Trademarks</i> or something similar.</p>
82
+ <p class="important">Next go to the <a href="<?php echo $addlink;?>">Add Link</a> and add a link for each trademark
83
+ specifying the Image URL, and optionally the link URL and of course adding each link to your chosen link category.</p>
84
+ <p class="important">Finally go to the <a href="<?php echo $widgets;?>">Appearance | Widgets</a> and drag a trademark widget into the custom footer widget
85
+ area and select <i>Trademarks</i> as the link category.</p>
86
+
87
+ <h2>Help On Trademarks</h2>
88
+ <p>Below are annotated screenshots of creating the link category and adding a link .
89
+ <p><img src="<?php echo $screenshot2;?>" alt="Screenshot of adding a trademark link category" /></p>
90
+ <p><img src="<?php echo $screenshot3;?>" alt="Screenshot of adding a trademark link " /></p>
91
+ <form id="misc_options" method="post" action="<?php echo $this_url; ?>">
92
+ <p>
93
+ <?php wp_nonce_field(self::CLASSNAME); ?>
94
+ <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
95
+ <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
96
+ </p>
97
+ </form>
98
+ </div></div><br class="clear"/></div></div>
99
+ <?php
100
+ }
101
+ }
102
+ ?>
classes/footer-trademarks.php ADDED
@@ -0,0 +1,77 @@
1
+ <?php
2
+ class Footer_Putter_TradeMark_Widget extends WP_Widget {
3
+ const DOMAIN = 'FooterPutter';
4
+
5
+ function __construct() {
6
+ $widget_ops = array('description' => __( 'Trademarks, Service Marks and Kitemarks', self::DOMAIN) );
7
+ parent::__construct('footer_trademarks', __('TradeMarks Widget', self::DOMAIN), $widget_ops);
8
+ }
9
+
10
+ function widget( $args, $instance ) {
11
+ extract($args, EXTR_SKIP);
12
+
13
+ $category = isset($instance['category']) ? $instance['category'] : false;
14
+ $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';
15
+ $order = $orderby == 'rating' ? 'DESC' : 'ASC';
16
+ $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1;
17
+
18
+ $links = wp_list_bookmarks(apply_filters('widget_links_args', array(
19
+ 'echo' => 0,
20
+ 'title_before' => $before_title, 'title_after' => $after_title,
21
+ 'title_li' => '', 'categorize' => false,
22
+ 'before' => '', 'after' => '',
23
+ 'category_before' => '', 'category_after' => '',
24
+ 'show_images' => true, 'show_description' => false,
25
+ 'show_name' => false, 'show_rating' => false,
26
+ 'category' => $category, 'class' => 'trademark widget',
27
+ 'orderby' => $orderby, 'order' => $order,
28
+ 'limit' => $limit,
29
+ )));
30
+ echo $before_widget;
31
+ echo FooterCredits::filter_links($links);
32
+ echo $after_widget;
33
+ }
34
+
35
+ function update( $new_instance, $old_instance ) {
36
+ $new_instance = (array) $new_instance;
37
+
38
+ $instance['orderby'] = 'name';
39
+ if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) )
40
+ $instance['orderby'] = $new_instance['orderby'];
41
+
42
+ $instance['category'] = intval( $new_instance['category'] );
43
+ $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1;
44
+
45
+ return $instance;
46
+ }
47
+
48
+ function form( $instance ) {
49
+ $instance = wp_parse_args( (array) $instance, array( 'category' => false, 'orderby' => 'name', 'limit' => -1 ) );
50
+ $link_cats = get_terms( 'link_category' );
51
+ if ( ! $limit = intval( $instance['limit'] ) ) { $limit = -1; } ?>
52
+ <p>
53
+ <label for="<?php echo $this->get_field_id('category'); ?>"><?php _e( 'Select Link Category for Your Trademarks:', self::DOMAIN ); ?></label>
54
+ <select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
55
+ <?php
56
+ foreach ( $link_cats as $link_cat ) {
57
+ echo '<option value="' . intval($link_cat->term_id) . '"'
58
+ . ( $link_cat->term_id == $instance['category'] ? ' selected="selected"' : '' )
59
+ . '>' . $link_cat->name . "</option>\n";
60
+ }
61
+ ?>
62
+ </select>
63
+ <label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Sort by:', self::DOMAIN ); ?></label>
64
+ <select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">
65
+ <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title', self::DOMAIN); ?></option>
66
+ <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating', self::DOMAIN ); ?></option>
67
+ <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID', self::DOMAIN ); ?></option>
68
+ <option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _e( 'Random', self::DOMAIN ); ?></option>
69
+ </select>
70
+ </p>
71
+ <p>
72
+ <label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e( 'Number of links to show:', self::DOMAIN ); ?></label>
73
+ <input id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit == -1 ? '' : intval( $limit ); ?>" size="3" />
74
+ </p>
75
+ <?php
76
+ }
77
+ }
images/add-link-category.jpg ADDED
Binary file
images/add-link.jpg ADDED
Binary file
menu-icon.png → images/icon-16.png RENAMED
File without changes
icon-32.png → images/icon-32.png RENAMED
File without changes
logo.png → images/logo.png RENAMED
File without changes
main.php CHANGED
@@ -3,22 +3,25 @@
3
* Plugin Name: Footer Putter
4
* Plugin URI: http://www.diywebmastery.com/plugins/footer-putter/
5
* Description: Put a footer on your site that boosts your credibility with both search engines and human visitors.
6
- * Version: 1.2
7
* Author: Russell Jamieson
8
* Author URI: http://www.diywebmastery.com/about/
9
* License: GPLv2+
10
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
*/
12
- define('FOOTER_PUTTER_VERSION','1.2');
13
define('FOOTER_PUTTER_FRIENDLY_NAME', 'Footer Putter') ;
14
define('FOOTER_PUTTER_PLUGIN_NAME', 'footer-putter') ;
15
define('FOOTER_PUTTER_HOME_URL','http://www.diywebmastery.com/plugins/footer-putter/');
16
define('FOOTER_CREDITS','FooterCredits');
17
- $dir = dirname(__FILE__) . '/';
18
require_once($dir . 'footer-credits.php');
19
- call_user_func(array(FOOTER_CREDITS,'init'),FOOTER_PUTTER_VERSION);
20
if (is_admin()) {
21
- require_once($dir . 'footer-credits-admin.php');
22
require_once($dir . 'admin.php');
23
}
24
?>
3
* Plugin Name: Footer Putter
4
* Plugin URI: http://www.diywebmastery.com/plugins/footer-putter/
5
* Description: Put a footer on your site that boosts your credibility with both search engines and human visitors.
6
+ * Version: 1.3
7
* Author: Russell Jamieson
8
* Author URI: http://www.diywebmastery.com/about/
9
* License: GPLv2+
10
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
*/
12
+ define('FOOTER_PUTTER_VERSION','1.3');
13
define('FOOTER_PUTTER_FRIENDLY_NAME', 'Footer Putter') ;
14
define('FOOTER_PUTTER_PLUGIN_NAME', 'footer-putter') ;
15
define('FOOTER_PUTTER_HOME_URL','http://www.diywebmastery.com/plugins/footer-putter/');
16
define('FOOTER_CREDITS','FooterCredits');
17
+ $dir = dirname(__FILE__) . '/classes/';
18
require_once($dir . 'footer-credits.php');
19
+ require_once($dir . 'footer-trademarks.php');
20
if (is_admin()) {
21
require_once($dir . 'admin.php');
22
+ require_once($dir . 'footer-credits-admin.php');
23
+ require_once($dir . 'footer-trademarks-admin.php');
24
+ FooterCreditsAdmin::init(FOOTER_PUTTER_PLUGIN_NAME);
25
+ FooterTrademarksAdmin::init(FOOTER_PUTTER_PLUGIN_NAME);
26
}
27
?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.diywebmastery.com/donate/
4
Tags: footer, copyright, rel=nofollow
5
Requires at least: 3.0
6
Tested up to: 3.5
7
- Stable tag: 1.2
8
License: GPLv2+
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -37,14 +37,15 @@ Put a footer on your site that boosts your credibility with both search engines
37
38
== Changelog ==
39
40
= 1.2 = Fix display of telephone number
41
= 1.1 = Fix link in admin.php from screenshot1.jpg to screenshot-1.jpg
42
= 1.0 = Initial release
43
44
== Upgrade Notice ==
45
46
- = 1.2 =
47
- * Mandatory - fix display of telephone number in footer
48
49
== Links ==
50
4
Tags: footer, copyright, rel=nofollow
5
Requires at least: 3.0
6
Tested up to: 3.5
7
+ Stable tag: 1.3
8
License: GPLv2+
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
37
38
== Changelog ==
39
40
+ = 1.3 = Pre-configure according to the WordPress theme
41
= 1.2 = Fix display of telephone number
42
= 1.1 = Fix link in admin.php from screenshot1.jpg to screenshot-1.jpg
43
= 1.0 = Initial release
44
45
== Upgrade Notice ==
46
47
+ = 1.3 =
48
+ * Optional - Pre-configure settings to make it work with more themes out of the box.
49
50
== Links ==
51
admin.css → styles/admin.css RENAMED
@@ -1,10 +1,13 @@
1
- div.icon32 { background-image : url(icon-32.png); background-repeat: no-repeat;}
2
#poststuff { margin-right: 20px; }
3
#poststuff input.error, #poststuff select.error { border: 1px solid red; background-color : #FEE; }
4
#poststuff div#message { margin-left: 10px; display: inline; padding: 10px; }
5
#poststuff div#message div.updated { margin-left: 30px; padding: 8px; display: inline; }
6
#poststuff label { display: inline-block; min-width: 200px; margin-right: 10px;}
7
8
/* tooltips */
9
.tooltip {position: relative; cursor: help; display: inline-block; text-decoration: none;
10
color: #222; outline: none; }
1
+ div.icon32 { background-image : url(../images/icon-32.png); background-repeat: no-repeat;}
2
#poststuff { margin-right: 20px; }
3
#poststuff input.error, #poststuff select.error { border: 1px solid red; background-color : #FEE; }
4
#poststuff div#message { margin-left: 10px; display: inline; padding: 10px; }
5
#poststuff div#message div.updated { margin-left: 30px; padding: 8px; display: inline; }
6
#poststuff label { display: inline-block; min-width: 200px; margin-right: 10px;}
7
8
+ .trademark { vertical-align: top; border: 1px dashed whitesmoke; }
9
+ .trademark:hover { cursor: move; }
10
+
11
/* tooltips */
12
.tooltip {position: relative; cursor: help; display: inline-block; text-decoration: none;
13
color: #222; outline: none; }
style.css → styles/footer-credits.css RENAMED
@@ -14,6 +14,11 @@
14
#footer-credits span.copyright, #footer-credits span.telephone, #footer-credits span.address {
15
font-weight: normal; letter-spacing : normal; text-transform: none; margin: 0 10px; vertical-align: middle;
16
background: inherit; border : none; float: none; display: inline; }
17
- .custom-footer .white a, #footer-credits.white { color : white; }
18
- .custom-footer, .widget_footer_trademarks { text-align: center; margin: 10px 0;}
19
- .custom-footer .widget_footer_trademarks a, .widget_footer_trademarks a { margin: 10px; }
14
#footer-credits span.copyright, #footer-credits span.telephone, #footer-credits span.address {
15
font-weight: normal; letter-spacing : normal; text-transform: none; margin: 0 10px; vertical-align: middle;
16
background: inherit; border : none; float: none; display: inline; }
17
+ #footer-credits.dark, #footer-credits.dark a, .dark a , .dark a:visited { color : #222222; }
18
+ #footer-credits.light, #footer-credits.light a, .light a, .light a:visited { color : #DDDDDD; }
19
+ #footer-credits.white, #footer-credits.white a, .white a, .white a:visited { color : white; }
20
+
21
+ .widget_footer_trademarks { text-align: center; margin: 10px 0;}
22
+ .widget_footer_trademarks a { margin: 10px; }
23
+ .widget_footer_trademarks img { border: 0 !important; }
24
+