Custom Meta Widget - Version 1.1

Version Description

  • Minor improvements to code architechture.
  • Increased compliance with WordPress style standards.
  • Significantly more code commenting.
Download this release

Release Info

Developer bitacre
Plugin Icon wp plugin Custom Meta Widget
Version 1.1
Comparing to
See all releases

Code changes from version 1.0 to 1.1

Files changed (2) hide show
  1. customMeta.php +44 -78
  2. readme.txt +3 -3
customMeta.php CHANGED
@@ -2,116 +2,82 @@
2
  /*
3
  Plugin Name: Custom Meta Widget
4
  Plugin URI: http://wikiduh.com/plugins/custom-meta-widget
5
- Description: Clone of the standard Meta widget PLUS options to show or hide: log in/out, admin, feed and WordPress links.
6
- Version: 1.0
7
  Author: bitacre
8
- Author URI: http://codex.wordpress.org/User:Bitacre
9
  Acknowledgements:
10
  This code is largely derived from one of the many freely available
11
  and tremendously helpful tutoials on the Azulia Designs website
12
  (http://azuliadesigns.com) created by the heroic Tim Trott.
13
- License: CC BY-SA 3.0 (GPLv2 complaiant)
14
- Copyright 2011 bitacre (email : wp@wikiduh.com)
15
-
16
- This program is distributed under the Creative Commons
17
- Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) licence. You
18
- may copy, distribute, transmit, adapt, and make commercial use
19
- of this work so long as you attribute the original author by
20
- including the URL http://wikiduh.com/plugin/wp/custom_meta
21
- in your project's source.
22
-
23
- This program is distributed in the hope that it will be useful,
24
- but without ANY warranty; without even the implied warranty of
25
- merchantability or fitness for a particular purpose.
26
 
27
- See license.txt for more information.
28
-
29
-
30
  */
 
31
  class customMetaWidget extends WP_Widget {
32
 
33
- function customMetaWidget() {
34
- $widget_ops = array('classname' => 'customMetaWidget', 'description' => 'A simple alternative to the vanilla Meta widget allowing you to chose which links are shown.' );
35
- $this->WP_Widget('customMetaWidget', 'Custom Meta Widget', $widget_ops);
36
  }
37
 
38
- function form($instance) {
39
- $instance = wp_parse_args( (array) $instance, array( 'title' => 'Meta', 'register'=>'true', 'login'=>'true','entriesrss'=>'true', 'commentsrss'=>'true', 'wordpress'=>'true' ) ); // set default values
40
- $title = $instance['title'];
41
- $register = $instance['register'];
42
- $login = $instance['login'];
43
- $entriesrss = $instance['entriesrss'];
44
- $commentsrss = $instance['commentsrss'];
45
- $wordpress = $instance['wordpress'];
46
- ?>
47
- <p><label for="<?php echo $this->get_field_id('title'); ?>">Display title:&nbsp;
48
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" />
49
- </label></p>
50
 
51
- <p><label for="<?php echo $this->get_field_id('register'); ?>">
52
- <input id="<?php echo $this->get_field_id('register'); ?>" name="<?php echo $this->get_field_name('register'); ?>" type="checkbox" <?php if(attribute_escape($register)=='true') echo 'checked="yes"'; ?> value="true" />
53
- Show 'Register/Admin' link?&nbsp;</label></p>
54
 
55
- <p><label for="<?php echo $this->get_field_id('login'); ?>">
56
- <input id="<?php echo $this->get_field_id('login'); ?>" name="<?php echo $this->get_field_name('login'); ?>" type="checkbox" <?php if(attribute_escape($login)=='true') echo 'checked="yes"'; ?> value="true" />
57
- Show 'Log in/out' link?&nbsp;</label></p>
58
 
59
- <p><label for="<?php echo $this->get_field_id('entriesrss'); ?>">
60
- <input id="<?php echo $this->get_field_id('entriesrss'); ?>" name="<?php echo $this->get_field_name('entriesrss'); ?>" type="checkbox" <?php if(attribute_escape($entriesrss)=='true') echo 'checked="yes"'; ?> value="true" />
61
- Show 'Entries RSS' link?&nbsp;</label></p>
62
-
63
- <p><label for="<?php echo $this->get_field_id('commentsrss'); ?>">
64
- <input id="<?php echo $this->get_field_id('commentsrss'); ?>" name="<?php echo $this->get_field_name('commentsrss'); ?>" type="checkbox" <?php if(attribute_escape($commentsrss)=='true') echo 'checked="yes"'; ?> value="true" />
65
- Show 'Comments RSS' link?&nbsp;</label></p>
66
-
67
- <p><label for="<?php echo $this->get_field_id('wordpress'); ?>">
68
- <input id="<?php echo $this->get_field_id('wordpress'); ?>" name="<?php echo $this->get_field_name('wordpress'); ?>" type="checkbox" <?php if(attribute_escape($wordpress)=='true') echo 'checked="yes"'; ?> value="true" />
69
- Show 'Wordpress' link?&nbsp;</label></p>
70
-
71
- <?php
72
- }
73
 
74
- function update($new_instance, $old_instance) {
75
  $instance = $old_instance;
76
  $instance['title'] = $new_instance['title'];
77
  $instance['register'] = $new_instance['register'];
78
  $instance['login'] = $new_instance['login'];
79
- $instance['entriesrss'] = $new_instance['entriesrss'];
80
- $instance['commentsrss'] = $new_instance['commentsrss'];
81
  $instance['wordpress'] = $new_instance['wordpress'];
82
  return $instance;
83
  }
84
-
85
- function widget($args, $instance) {
86
- extract($args, EXTR_SKIP); // extract values
87
- $register = $instance['register'];
88
- $login = $instance['login'];
89
- $entriesrss = $instance['entriesrss'];
90
- $commentsrss = $instance['commentsrss'];
91
- $wordpress = $instance['wordpress'];
92
- echo $before_widget;
93
- $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
94
- if (!empty($title))
95
- echo $before_title . $title . $after_title;
96
-
97
- // main widget code
98
  echo '<ul>';
99
- if($register=='true') wp_register('<li>', '</li>');
100
- if($login=='true') echo '<li>' . wp_loginout(NULL,FALSE) . '</li>';
101
- if($entriesrss=='true') {
102
  echo '<li><a href="';
103
  bloginfo('rss2_url');
104
  echo '" title="Syndicate this site using RSS 2.0">Entries <abbr title="Really Simple Syndication">RSS</abbr></a></li>';
105
  }
106
- if($commentsrss=='true') {
107
  echo '<li><a href="';
108
  bloginfo('comments_rss2_url');
109
  echo '" title="Syndicate this site using RSS 2.0">Comments <abbr title="Really Simple Syndication">RSS</abbr></a></li>';
110
  }
111
- if($wordpress=='true') echo '<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress.org</a></li>';
112
  echo '</ul>';
113
- echo $after_widget;
114
  }
115
  }
116
 
117
- add_action( 'widgets_init', create_function('', 'return register_widget("customMetaWidget");') );?>
2
  /*
3
  Plugin Name: Custom Meta Widget
4
  Plugin URI: http://wikiduh.com/plugins/custom-meta-widget
5
+ Description: Clone of the standard Meta widget plus option to hide log in/out, admin, feed and WordPress links.
6
+ Version: 1.1
7
  Author: bitacre
8
+ Author URI: http://wikiduh.com/
9
  Acknowledgements:
10
  This code is largely derived from one of the many freely available
11
  and tremendously helpful tutoials on the Azulia Designs website
12
  (http://azuliadesigns.com) created by the heroic Tim Trott.
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ License: GPLv2
15
+ Copyright 2011 bitacre (plugins@wikiduh.com)
 
16
  */
17
+
18
  class customMetaWidget extends WP_Widget {
19
 
20
+ function customMetaWidget() { // plugin structure:
21
+ $widget_ops = array('classname' => 'customMetaWidget', 'description' => 'Clone of the standard Meta widget PLUS options to show or hide: log in/out, admin, feed and WordPress links.');
22
+ $this->WP_Widget('customMetaWidget', 'Custom Meta Widget', $widget_ops);
23
  }
24
 
25
+ function form($instance) { // form print function:
26
+ $instance = wp_parse_args( (array) $instance, array( 'title' => 'Meta', 'register'=>1, 'login'=>1,'entryrss'=>1, 'commentrss'=>1, 'wordpress'=>1 ) ); // set default values ?>
27
+
28
+ <p><label for="<?php echo $this->get_field_id('title'); ?>">Display title:&nbsp;</label></p>
29
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" />
30
+
31
+ <p><label for="<?php echo $this->get_field_id('register'); ?>">Show 'Register/Admin' link?&nbsp;</label>
32
+ <input id="<?php echo $this->get_field_id('register'); ?>" name="<?php echo $this->get_field_name('register'); ?>" type="checkbox" <?php if(esc_attr($instance['register'])) echo 'checked="yes"'; ?> value="1" /></p>
 
 
 
 
33
 
34
+ <p><label for="<?php echo $this->get_field_id('login'); ?>">Show 'Log in/out' link?&nbsp;</label>
35
+ <input id="<?php echo $this->get_field_id('login'); ?>" name="<?php echo $this->get_field_name('login'); ?>" type="checkbox" <?php if(esc_attr($instance['login'])) echo 'checked="yes"'; ?> value="1" /></p>
 
36
 
37
+ <p><label for="<?php echo $this->get_field_id('entryrss'); ?>">Show 'Entries RSS' link?&nbsp;</label>
38
+ <input id="<?php echo $this->get_field_id('entryrss'); ?>" name="<?php echo $this->get_field_name('entryrss'); ?>" type="checkbox" <?php if(esc_attr($instance['entryrss'])) echo 'checked="yes"'; ?> value="1" /></p>
 
39
 
40
+ <p><label for="<?php echo $this->get_field_id('commentrss'); ?>">Show 'Comments RSS' link?&nbsp;</label>
41
+ <input id="<?php echo $this->get_field_id('commentrss'); ?>" name="<?php echo $this->get_field_name('commentrss'); ?>" type="checkbox" <?php if(esc_attr($instance['commentrss'])) echo 'checked="yes"'; ?> value="1" /></p>
42
+
43
+ <p><label for="<?php echo $this->get_field_id('wordpress'); ?>">Show 'Wordpress' link?&nbsp;</label>
44
+ <input id="<?php echo $this->get_field_id('wordpress'); ?>" name="<?php echo $this->get_field_name('wordpress'); ?>" type="checkbox" <?php if(esc_attr($instance['wordpress'])) echo 'checked="yes"'; ?> value="1" /></p>
45
+ <?php }
 
 
 
 
 
 
 
 
46
 
47
+ function update($new_instance, $old_instance) { // save widget options:
48
  $instance = $old_instance;
49
  $instance['title'] = $new_instance['title'];
50
  $instance['register'] = $new_instance['register'];
51
  $instance['login'] = $new_instance['login'];
52
+ $instance['entryrss'] = $new_instance['entryrss'];
53
+ $instance['commentrss'] = $new_instance['commentrss'];
54
  $instance['wordpress'] = $new_instance['wordpress'];
55
  return $instance;
56
  }
57
+
58
+ function widget($args, $instance) { // widget sidebar output
59
+ extract($args, EXTR_SKIP);
60
+ echo $before_widget; // pre-widget code from themes
61
+ echo '<!-- Custom Meta Widget. Plugin URL: http://wikiduh.com/plugins/custom-meta-widget -->';
62
+ $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); // if no title, use default
63
+ if (!empty($title)) echo $before_title . esc_attr($instance['title']) . $after_title; // echo title
 
 
 
 
 
 
 
64
  echo '<ul>';
65
+ if(esc_attr($instance['register'])) wp_register('<li>', '</li>'); // 1. register link
66
+ if(esc_attr($instance['login'])) echo '<li>' . wp_loginout(NULL,FALSE) . '</li>'; // 2. login link
67
+ if(esc_attr($instance['entryrss'])) { // 3. entries rss link
68
  echo '<li><a href="';
69
  bloginfo('rss2_url');
70
  echo '" title="Syndicate this site using RSS 2.0">Entries <abbr title="Really Simple Syndication">RSS</abbr></a></li>';
71
  }
72
+ if(esc_attr($instance['commentrss'])) { // 4. comments rss
73
  echo '<li><a href="';
74
  bloginfo('comments_rss2_url');
75
  echo '" title="Syndicate this site using RSS 2.0">Comments <abbr title="Really Simple Syndication">RSS</abbr></a></li>';
76
  }
77
+ if(esc_attr($instance['wordpresslink'])) echo '<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress.org</a></li>'; // 5. wordpress.org link
78
  echo '</ul>';
79
+ echo $after_widget; // after widget code from themes
80
  }
81
  }
82
 
83
+ add_action( 'widgets_init', create_function('', 'return register_widget("customMetaWidget");') ); // register widget ?>
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: http://wikiduh.com/donate
5
  Tags: meta, hide, link, admin, simple, widget, default, wordpress.org, change, rss, remove, login
6
  Requires at least: 2.8
7
  Tested up to: 3.2.1
8
- Stable tag: 1.0
9
 
10
  Clone of the standard Meta widget plus option to hide log in/out, admin, feed and WordPress links.
11
 
@@ -17,8 +17,8 @@ This plugin acts in exactly the same way as the standard Meta widget EXCEPT that
17
 
18
  == Installation ==
19
 
20
- 1. Download the latest zip file and extract the 'custom-meta-widget' directory.
21
- 2. Upload the 'custom-meta-widget' directory inside your '/wp-content/plugins/' directory.
22
  3. Activate the 'Custom Meta Widget' on the 'Plugins' menu in WordPress.
23
  4. Add the 'Custom Meta' widget to your sidebar (using the Appearance > Widgets menu) and choose which links you want hidden from the sidebar.
24
 
5
  Tags: meta, hide, link, admin, simple, widget, default, wordpress.org, change, rss, remove, login
6
  Requires at least: 2.8
7
  Tested up to: 3.2.1
8
+ Stable tag: 1.1
9
 
10
  Clone of the standard Meta widget plus option to hide log in/out, admin, feed and WordPress links.
11
 
17
 
18
  == Installation ==
19
 
20
+ 1. Download the latest zip file and extract the `custom-meta-widget` directory.
21
+ 2. Upload this directory inside your `/wp-content/plugins/` directory.
22
  3. Activate the 'Custom Meta Widget' on the 'Plugins' menu in WordPress.
23
  4. Add the 'Custom Meta' widget to your sidebar (using the Appearance > Widgets menu) and choose which links you want hidden from the sidebar.
24