Version Description
- Added error handling to prevent blank custom links from being inserted on the sidebar.
- Cleaned up code formatting.
Download this release
Release Info
Developer | bitacre |
Plugin | Custom Meta Widget |
Version | 1.3.1 |
Comparing to | |
See all releases |
Code changes from version 1.3 to 1.3.1
- customMeta.php +152 -77
- readme.txt +8 -1
customMeta.php
CHANGED
@@ -3,7 +3,7 @@
|
|
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 hide log in/out, admin, feed and WordPress/custom links.
|
6 |
-
Version: 1.3
|
7 |
Author: bitacre
|
8 |
Author URI: http://wikiduh.com/
|
9 |
License: GPLv2
|
@@ -12,96 +12,171 @@ License: GPLv2
|
|
12 |
|
13 |
class customMetaWidget extends WP_Widget {
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
|
|
|
|
|
34 |
|
35 |
-
|
36 |
-
|
|
|
|
|
37 |
|
38 |
-
|
39 |
-
|
|
|
|
|
40 |
|
41 |
-
|
42 |
-
|
|
|
43 |
|
44 |
-
|
45 |
-
|
|
|
|
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
51 |
|
52 |
-
<?php
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
return $instance;
|
66 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
echo $before_widget; // pre-widget code from themes
|
71 |
-
echo '
|
72 |
<!-- Custom Meta Widget. Plugin URL: http://wikiduh.com/plugins/custom-meta-widget -->
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
echo '<ul>'; // start meta widget unordered list
|
79 |
-
|
80 |
-
if(esc_attr($instance['register'])) wp_register('<li>', '</li>'); // 1. register link
|
81 |
-
|
82 |
-
if(esc_attr($instance['login'])) echo '<li>' . wp_loginout(NULL,FALSE) . '</li>'; // 2. login link
|
83 |
-
|
84 |
-
if(esc_attr($instance['entryrss'])) { // 3. entries rss link
|
85 |
-
echo '<li><a href="';
|
86 |
-
bloginfo('rss2_url');
|
87 |
-
echo '" title="Syndicate this site using RSS 2.0">Entries <abbr title="Really Simple Syndication">RSS</abbr></a></li>';
|
88 |
-
}
|
89 |
-
|
90 |
-
if(esc_attr($instance['commentrss'])) { // 4. comments rss
|
91 |
-
echo '<li><a href="';
|
92 |
-
bloginfo('comments_rss2_url');
|
93 |
-
echo '" title="Syndicate this site using RSS 2.0">Comments <abbr title="Really Simple Syndication">RSS</abbr></a></li>';
|
94 |
-
}
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
|
107 |
-
|
|
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 hide log in/out, admin, feed and WordPress/custom links.
|
6 |
+
Version: 1.3.1
|
7 |
Author: bitacre
|
8 |
Author URI: http://wikiduh.com/
|
9 |
License: GPLv2
|
12 |
|
13 |
class customMetaWidget extends WP_Widget {
|
14 |
|
15 |
+
// PLUGIN STRUCTURE
|
16 |
+
function customMetaWidget() {
|
17 |
+
// as shown on the Dashboard > Appearance > Widgets page
|
18 |
+
$widget_ops = array (
|
19 |
+
'classname' => 'customMetaWidget',
|
20 |
+
'description' => 'Clone of the standard Meta widget with options to show or hide log in/out, admin, feed, WordPress/custom links.'
|
21 |
+
);
|
22 |
|
23 |
+
$this->WP_Widget('customMetaWidget', 'Custom Meta', $widget_ops);
|
24 |
+
}
|
25 |
+
|
26 |
+
// WIDGET'S OPTIONS FORM
|
27 |
+
function form( $instance ) {
|
28 |
+
// set default form values
|
29 |
+
$instance = wp_parse_args( ( array ) $instance, array (
|
30 |
+
'title' => 'Meta',
|
31 |
+
'register'=>1,
|
32 |
+
'login'=>1,
|
33 |
+
'entryrss'=>1,
|
34 |
+
'commentrss'=>1,
|
35 |
+
'wordpress'=>1,
|
36 |
+
'showcustom'=>0,
|
37 |
+
'customurl'=>NULL,
|
38 |
+
'customtext'=>NULL
|
39 |
+
) );
|
40 |
+
|
41 |
+
// output HTML for the options form ?>
|
42 |
+
<p>
|
43 |
+
<label for="<?php echo $this->get_field_id('title'); ?>">Display title: </label>
|
44 |
+
<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']); ?>" />
|
45 |
+
</p>
|
46 |
|
47 |
+
<p>
|
48 |
+
<label for="<?php echo $this->get_field_id('register'); ?>">Show 'Register/Admin' link? </label>
|
49 |
+
<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" />
|
50 |
+
</p>
|
51 |
+
|
52 |
+
<p>
|
53 |
+
<label for="<?php echo $this->get_field_id('login'); ?>">Show 'Log in/out' link? </label>
|
54 |
+
<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" />
|
55 |
+
</p>
|
56 |
|
57 |
+
<p>
|
58 |
+
<label for="<?php echo $this->get_field_id('entryrss'); ?>">Show 'Entries RSS' link? </label>
|
59 |
+
<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" />
|
60 |
+
</p>
|
61 |
|
62 |
+
<p>
|
63 |
+
<label for="<?php echo $this->get_field_id('commentrss'); ?>">Show 'Comments RSS' link? </label>
|
64 |
+
<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" />
|
65 |
+
</p>
|
66 |
|
67 |
+
<p>
|
68 |
+
<label for="<?php echo $this->get_field_id('wordpress'); ?>">Show 'Wordpress' link? </label>
|
69 |
+
<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" />
|
70 |
+
</p>
|
71 |
|
72 |
+
<p>
|
73 |
+
<label for="<?php echo $this->get_field_id('showcustom'); ?>">Show Custom link? </label>
|
74 |
+
<input id="<?php echo $this->get_field_id('showcustom'); ?>" name="<?php echo $this->get_field_name('showcustom'); ?>" type="checkbox" <?php if(esc_attr($instance['showcustom'])) echo 'checked="yes"'; ?> value="1" />
|
75 |
|
76 |
+
<div style="margin-left:20px;">
|
77 |
+
<label for="<?php echo $this->get_field_id('customurl'); ?>">URL: </label>
|
78 |
+
<input id="<?php echo $this->get_field_id('customurl'); ?>" name="<?php echo $this->get_field_name('customurl'); ?>" type="text" value="<?php echo esc_attr($instance['customurl']); ?>" />
|
79 |
+
</div>
|
80 |
|
81 |
+
<div style="margin-left:20px;">
|
82 |
+
<label for="<?php echo $this->get_field_id('customtext'); ?>">Text: </label>
|
83 |
+
<input id="<?php echo $this->get_field_id('customtext'); ?>" name="<?php echo $this->get_field_name('customtext'); ?>" type="text" value="<?php echo esc_attr($instance['customtext']); ?>" />
|
84 |
+
</div>
|
85 |
+
</p>
|
86 |
|
87 |
+
<?php // check for errors
|
88 |
+
if ( esc_attr($instance['showcustom']) ) { // IF 'showcustom' is checked, AND
|
89 |
+
|
90 |
+
// 1. no link and no URL
|
91 |
+
if( empty($instance['customtext']) && empty($instance['customurl']) )
|
92 |
+
echo '<p style="color:#FF0000; font-weight:bold;" >You have a custom link with no URL or text!</p>';
|
93 |
+
// 2. no link
|
94 |
+
else if ( empty($instance['customtext']) )
|
95 |
+
echo '<p style="color:#FF0000; font-weight:bold;" >You have a custom link with no text!</p>';
|
96 |
+
|
97 |
+
// 3. no url
|
98 |
+
else if ( empty($instance['customurl']) )
|
99 |
+
echo '<p style="color:#FF0000; font-weight:bold;" >You have a custom link with no URL!</p>';
|
|
|
100 |
}
|
101 |
+
}
|
102 |
+
// SAVE WIDGET OPTIONS
|
103 |
+
function update($new_instance, $old_instance) {
|
104 |
+
$instance = $old_instance;
|
105 |
+
// should probably do this with a loop...
|
106 |
+
$instance['title'] = $new_instance['title'];
|
107 |
+
$instance['register'] = $new_instance['register'];
|
108 |
+
$instance['login'] = $new_instance['login'];
|
109 |
+
$instance['entryrss'] = $new_instance['entryrss'];
|
110 |
+
$instance['commentrss'] = $new_instance['commentrss'];
|
111 |
+
$instance['wordpress'] = $new_instance['wordpress'];
|
112 |
+
$instance['showcustom'] = $new_instance['showcustom'];
|
113 |
+
$instance['customurl'] = $new_instance['customurl'];
|
114 |
+
$instance['customtext'] = $new_instance['customtext'];
|
115 |
+
return $instance;
|
116 |
+
}
|
117 |
+
|
118 |
+
// ACTUAL WIDGET OUTPUT
|
119 |
+
function widget($args, $instance) {
|
120 |
+
extract($args, EXTR_SKIP); // extract arguments
|
121 |
+
$title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); // if no title, use default
|
122 |
|
123 |
+
// insert start of widget HTML comment
|
124 |
+
echo '
|
|
|
|
|
125 |
<!-- Custom Meta Widget. Plugin URL: http://wikiduh.com/plugins/custom-meta-widget -->
|
126 |
+
';
|
127 |
+
|
128 |
+
// insert pre-widget code (from theme)
|
129 |
+
echo $before_widget;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
+
// insert widget title
|
132 |
+
echo $before_title . esc_attr($instance['title']) . $after_title; // echo title (inside theme tags)
|
133 |
+
|
134 |
+
// start unordered list
|
135 |
+
echo '
|
136 |
+
<ul>
|
137 |
+
';
|
138 |
+
// ADD LINKS
|
139 |
+
// 1. register link
|
140 |
+
if(esc_attr($instance['register'])) wp_register('<li>', '</li>');
|
141 |
+
|
142 |
+
// 2. login link
|
143 |
+
if(esc_attr($instance['login'])) echo '<li>' . wp_loginout(NULL,FALSE) . '</li>';
|
144 |
+
|
145 |
+
// 3. entries RSS link
|
146 |
+
if(esc_attr($instance['entryrss'])) {
|
147 |
+
echo '<li><a href="';
|
148 |
+
bloginfo('rss2_url');
|
149 |
+
echo '" title="Syndicate this site using RSS 2.0">Entries <abbr title="Really Simple Syndication">RSS</abbr></a></li>';
|
150 |
+
}
|
151 |
+
|
152 |
+
// 4. comments RSS link
|
153 |
+
if(esc_attr($instance['commentrss'])) {
|
154 |
+
echo '<li><a href="';
|
155 |
+
bloginfo('comments_rss2_url');
|
156 |
+
echo '" title="Syndicate this site using RSS 2.0">Comments <abbr title="Really Simple Syndication">RSS</abbr></a></li>';
|
157 |
+
}
|
158 |
+
|
159 |
+
// 5. wordpress.org link
|
160 |
+
if(esc_attr($instance['wordpress'])) echo '<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress.org</a></li>';
|
161 |
|
162 |
+
// 6. custom link
|
163 |
+
if( esc_attr($instance['showcustom']) ) {
|
164 |
+
// make sure link text & url are set
|
165 |
+
if( !empty($instance['customtext']) && !empty($instance['customurl']) ) echo '<li><a href="' . esc_attr($instance['customurl']) . '">' . esc_attr($instance['customtext']) . '</a></li>';
|
166 |
+
// otherwise insert error comment
|
167 |
+
else echo '
|
168 |
+
<!-- Error: \'Show Custom Link\' is checked, but either the text or URL for that link are not specified.
|
169 |
+
The link was not displayed because it would be broken. Check the settings for your Custom Meta widget. -->
|
170 |
+
';
|
171 |
}
|
172 |
+
|
173 |
+
// end unordered list tag
|
174 |
+
echo '</ul>';
|
175 |
+
|
176 |
+
// insert post-widget code (from theme)
|
177 |
+
echo $after_widget;
|
178 |
+
}
|
179 |
}
|
180 |
|
181 |
+
// ADD HOOKS AND FILTERS
|
182 |
+
add_action( 'widgets_init', create_function('', 'return register_widget("customMetaWidget");') ); ?>
|
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.3.1
|
8 |
-
Stable tag: 1.3
|
9 |
|
10 |
Clone of the standard Meta widget plus options to hide log in/out, admin, feed and WordPress/custom links.
|
11 |
|
@@ -48,6 +48,10 @@ Can I? Yes. Will I? Yes, if I think it would be a helpful addition. I'm trying t
|
|
48 |
|
49 |
== Changelog ==
|
50 |
|
|
|
|
|
|
|
|
|
51 |
= 1.3 =
|
52 |
* Added a custom link option (disabled by default).
|
53 |
* Updated screenshots 1-3.
|
@@ -68,6 +72,9 @@ Can I? Yes. Will I? Yes, if I think it would be a helpful addition. I'm trying t
|
|
68 |
|
69 |
== Upgrade Notice ==
|
70 |
|
|
|
|
|
|
|
71 |
= 1.3 =
|
72 |
Adds new custom link functionality.
|
73 |
|
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.3.1
|
8 |
+
Stable tag: 1.3.1
|
9 |
|
10 |
Clone of the standard Meta widget plus options to hide log in/out, admin, feed and WordPress/custom links.
|
11 |
|
48 |
|
49 |
== Changelog ==
|
50 |
|
51 |
+
= 1.3.1 =
|
52 |
+
* Added error handling to prevent blank custom links from being inserted on the sidebar.
|
53 |
+
* Cleaned up code formatting.
|
54 |
+
|
55 |
= 1.3 =
|
56 |
* Added a custom link option (disabled by default).
|
57 |
* Updated screenshots 1-3.
|
72 |
|
73 |
== Upgrade Notice ==
|
74 |
|
75 |
+
= 1.3.1 =
|
76 |
+
Adds error handling if a custom link with no url/text is added.
|
77 |
+
|
78 |
= 1.3 =
|
79 |
Adds new custom link functionality.
|
80 |
|