Version Description
- Code efficiency improvements (better loops)
- Now removes default Meta Widget (to avoid confusion)
Download this release
Release Info
Developer | bitacre |
Plugin | Custom Meta Widget |
Version | 1.4.0 |
Comparing to | |
See all releases |
Code changes from version 1.3.5_a to 1.4.0
- customMeta.php +105 -132
- readme.txt +6 -1
customMeta.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
3 |
Plugin Name: Custom Meta Widget
|
4 |
Plugin URI: http://bitacre.com/plugins/custom-meta-widget
|
5 |
-
Description: Clone of the standard Meta widget
|
6 |
-
Version: 1.
|
7 |
Author: bitacre
|
8 |
Author URI: http://bitacre.com/
|
9 |
License: GPLv2
|
@@ -12,192 +12,165 @@ License: GPLv2
|
|
12 |
|
13 |
class customMetaWidget extends WP_Widget {
|
14 |
|
15 |
-
//
|
16 |
function customMetaWidget() {
|
17 |
-
//
|
18 |
$widget_ops = array (
|
19 |
'classname' => 'customMetaWidget',
|
20 |
-
'description' => __( '
|
21 |
);
|
22 |
-
|
23 |
$this->WP_Widget( 'customMetaWidget', 'Custom Meta', $widget_ops );
|
24 |
}
|
25 |
|
26 |
-
//
|
27 |
-
function
|
28 |
-
|
29 |
-
|
30 |
-
'
|
31 |
-
'
|
32 |
-
'
|
33 |
-
'
|
34 |
-
'
|
35 |
-
'
|
36 |
-
'
|
37 |
-
'
|
38 |
-
'
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
// output HTML for the options form ?>
|
43 |
-
<!-- title -->
|
44 |
-
<p>
|
45 |
-
<label for="<?php echo $this->get_field_name( 'title' ); ?>"><?php _e( 'Title', 'customMetaWidget' ); ?>:</label>
|
46 |
-
<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'] ); ?>" />
|
47 |
-
</p>
|
48 |
-
|
49 |
-
<!-- register -->
|
50 |
-
<p>
|
51 |
-
<label for="<?php echo $this->get_field_name( 'register' ); ?>"><?php _e( 'Show "Register/Admin" link?', 'customMetaWidget' ); ?></label>
|
52 |
-
<input id="<?php echo $this->get_field_id( 'register' ); ?>" name="<?php echo $this->get_field_name( 'register' ); ?>" type="checkbox" value="1" <?php checked( $instance['register'] ); ?> />
|
53 |
-
</p>
|
54 |
-
|
55 |
-
<!-- login -->
|
56 |
-
<p>
|
57 |
-
<label for="<?php echo $this ->get_field_name( 'login' ); ?>"><?php _e( 'Show "Log in/out" link?', 'customMetaWidget' ); ?></label>
|
58 |
-
<input id="<?php echo $this->get_field_id( 'login' ); ?>" name="<?php echo $this->get_field_name( 'login' ); ?>" type="checkbox" value="1" <?php checked( $instance['login'] ); ?> />
|
59 |
-
</p>
|
60 |
-
|
61 |
-
<!-- entry RSS -->
|
62 |
-
<p>
|
63 |
-
<label for="<?php echo $this->get_field_name( 'entryrss' ); ?>"><?php _e( 'Show "Entries RSS" link?', 'customMetaWidget' ); ?></label>
|
64 |
-
<input id="<?php echo $this->get_field_id( 'entryrss' ); ?>" name="<?php echo $this->get_field_name( 'entryrss' ); ?>" type="checkbox" value="1" <?php checked( $instance['entryrss'] ); ?> />
|
65 |
-
</p>
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
<label for="<?php echo $this->get_field_name( 'wordpress' ); ?>"><?php _e( 'Show "Wordpress" link?', 'customMetaWidget' ); ?></label>
|
76 |
-
<input id="<?php echo $this->get_field_id( 'wordpress' ); ?>" name="<?php echo $this->get_field_name( 'wordpress' ); ?>" type="checkbox" value="1" <?php checked( $instance['wordpress'] ); ?> />
|
77 |
-
</p>
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
<
|
85 |
-
<label for="
|
86 |
-
<input id="
|
87 |
-
</
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
-
|
96 |
-
<p>
|
97 |
-
<label for="<?php echo $this->get_field_name( 'linklove' ); ?>"><?php _e( 'Show Plugin link?', 'customMetaWidget' ); ?> </label>
|
98 |
-
<input id="<?php echo $this->get_field_id( 'linklove' ); ?>" name="<?php echo $this->get_field_name( 'linklove' ); ?>" type="checkbox" value="1" <?php checked( $instance['linklove'] ); ?> />
|
99 |
-
<br />
|
100 |
-
<small>(<?php _e( 'An awesome way to support this free plugin!', 'customMetaWidget' ); ?>)</small></p>
|
101 |
|
102 |
-
|
103 |
-
if ( esc_attr($instance['showcustom']) ) { // IF 'showcustom' is checked, AND
|
104 |
|
105 |
// 1. no link and no URL
|
106 |
-
if( empty($instance['customtext']) && empty($instance['customurl']) )
|
107 |
echo '<p style="color:#FF0000; font-weight:bold;" >' . __( 'You have a custom link with no URL or text!', 'customMetaWidget' ) . '</p>';
|
108 |
// 2. no link
|
109 |
-
|
110 |
echo '<p style="color:#FF0000; font-weight:bold;" >' . __( 'You have a custom link with no text!', 'customMetaWidget' ) . '</p>';
|
111 |
|
112 |
// 3. no url
|
113 |
-
|
114 |
echo '<p style="color:#FF0000; font-weight:bold;" >' . __( 'You have a custom link with no URL!', 'customMetaWidget' ) . '</p>';
|
115 |
}
|
116 |
}
|
117 |
|
118 |
// SAVE WIDGET OPTIONS
|
119 |
-
function update($new_instance, $old_instance) {
|
120 |
$instance = $old_instance;
|
121 |
-
|
122 |
-
|
123 |
-
$
|
124 |
-
|
125 |
-
|
126 |
-
$instance['commentrss'] = $new_instance['commentrss'];
|
127 |
-
$instance['wordpress'] = $new_instance['wordpress'];
|
128 |
-
$instance['showcustom'] = $new_instance['showcustom'];
|
129 |
-
$instance['customurl'] = $new_instance['customurl'];
|
130 |
-
$instance['customtext'] = $new_instance['customtext'];
|
131 |
-
$instance['linklove'] = $new_instance['linklove'];
|
132 |
return $instance;
|
133 |
}
|
134 |
|
135 |
// ACTUAL WIDGET OUTPUT
|
136 |
function widget( $args, $instance ) {
|
137 |
extract( $args, EXTR_SKIP ); // extract arguments
|
138 |
-
$title = empty($instance['title']) ? '
|
139 |
|
140 |
// insert start of widget HTML comment
|
141 |
echo '
|
142 |
<!--
|
143 |
' . __( 'Plugin: Custom Meta Widget', 'customMetaWidget' ) . '
|
144 |
-
' . __( 'Plugin URL', 'customMetaWidget' ) . ': http://
|
145 |
-->
|
146 |
';
|
147 |
|
148 |
-
// insert pre-widget code (from theme)
|
149 |
-
echo $before_widget;
|
150 |
-
|
151 |
-
// insert widget title
|
152 |
echo $before_title . esc_attr( $instance['title'] ) . $after_title; // echo title (inside theme tags)
|
|
|
153 |
|
154 |
-
// start unordered list
|
155 |
-
echo '
|
156 |
-
<ul>
|
157 |
-
';
|
158 |
// ADD LINKS
|
159 |
-
// 1. register link
|
160 |
-
if( esc_attr( $instance['register'] ) ) wp_register( '<li>', '</li>' );
|
161 |
|
162 |
-
// 2. login link
|
163 |
-
if( esc_attr( $instance['login'] ) ) echo '<li>' . wp_loginout( NULL, FALSE ) . '</li>';
|
164 |
|
165 |
-
// 3. entries RSS link
|
166 |
-
|
167 |
-
|
|
|
|
|
168 |
|
169 |
-
// 4. comments RSS link
|
170 |
if( esc_attr( $instance['commentrss'] ) )
|
171 |
-
printf( __( '%1$sSyndicate this site using RSS 2.0%2$sComments %3$sRSS%4$s', 'customMetaWidget' ),
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
//
|
177 |
-
|
178 |
-
|
179 |
-
if( !empty( $instance['customtext'] )
|
|
|
|
|
180 |
// otherwise insert error comment
|
181 |
-
else
|
|
|
182 |
<!-- ' . __( 'Error: "Show Custom Link" is checked, but either the text or URL for that link are not specified. The link was not displayed because it would be broken. Check the settings for your Custom Meta widget.', 'customMetaWidget' ) . ' -->
|
183 |
';
|
184 |
}
|
185 |
|
186 |
-
// 7. link love
|
187 |
-
|
188 |
-
echo '<li><a href="http://wikiduh.com/plugins/custom-meta-widget" title="' . __( 'WordPress Plugin Homepage', 'customMetaWidget' ) . '">' . __( 'Custom Meta' ) . '</a></li>';
|
189 |
}
|
190 |
|
191 |
-
|
192 |
-
echo '</ul>';
|
193 |
-
|
194 |
-
// insert post-widget code (from theme)
|
195 |
echo $after_widget;
|
196 |
}
|
|
|
197 |
}
|
198 |
|
199 |
// ADD HOOKS AND FILTERS
|
200 |
-
add_action( 'widgets_init', create_function('', '
|
201 |
-
|
202 |
-
load_plugin_textdomain( 'customMetaWidget', null, $plugin_dir );
|
203 |
?>
|
2 |
/*
|
3 |
Plugin Name: Custom Meta Widget
|
4 |
Plugin URI: http://bitacre.com/plugins/custom-meta-widget
|
5 |
+
Description: Clone of the standard Meta widget with options to hide thlogin, admin, entry and comment feed, WordPress.org and /custom links.
|
6 |
+
Version: 1.4.0
|
7 |
Author: bitacre
|
8 |
Author URI: http://bitacre.com/
|
9 |
License: GPLv2
|
12 |
|
13 |
class customMetaWidget extends WP_Widget {
|
14 |
|
15 |
+
// constructor
|
16 |
function customMetaWidget() {
|
17 |
+
// set widget options
|
18 |
$widget_ops = array (
|
19 |
'classname' => 'customMetaWidget',
|
20 |
+
'description' => __( 'Hide the individual log in/out, admin, feed and WordPress links ', 'customMetaWidget' )
|
21 |
);
|
22 |
+
// extend class
|
23 |
$this->WP_Widget( 'customMetaWidget', 'Custom Meta', $widget_ops );
|
24 |
}
|
25 |
|
26 |
+
// declare form options (not part of WP_Widget)
|
27 |
+
function get_options() {
|
28 |
+
$options = array (
|
29 |
+
'title' => array( 'slug' => 'title', 'type' => 'text', 'default' => 'Meta', 'label' => 'Title', 'before' => '' ),
|
30 |
+
'register' => array('slug' => 'register', 'type' => 'checkbox', 'default' => 1,'label' => 'Show "Register/Admin" link?', 'before' => '' ),
|
31 |
+
'login' => array('slug' => 'login', 'type' => 'checkbox', 'default' => 1,'label' => 'Show "Log in/out" link?', 'before' => '' ),
|
32 |
+
'entryrss' => array('slug' => 'entryrss', 'type' => 'checkbox', 'default' => 1,'label' => 'Show "Entries RSS" link?', 'before' => '' ),
|
33 |
+
'commentrss' => array( 'slug' => 'commentrss', 'type' => 'checkbox', 'default' => 1,'label' => 'Show "Comments RSS" link?', 'before' => '' ),
|
34 |
+
'wordpress' => array( 'slug' => 'wordpress', 'type' => 'checkbox', 'default' => 1,'label' => 'Show "WordPress.org" link?', 'before' => '' ),
|
35 |
+
'showcustom' => array( 'slug' => 'showcustom', 'type' => 'checkbox', 'default' => 0,'label' => 'Show the custom link?', 'before' => '' ),
|
36 |
+
'customurl' => array('slug' => 'customurl', 'type' => 'text', 'default' => '', 'label' => 'URL', 'before' => ' style="margin-left:20px;"' ),
|
37 |
+
'customtext' => array('slug' => 'customtext', 'type' => 'text', 'default' => '', 'label' => 'Text', 'before' => ' style="margin-left:20px;"' ),
|
38 |
+
'linklove' => array( 'slug' => 'linklove', 'type' => 'checkbox', 'default' => 0,'label' => 'Show Plugin link?' )
|
39 |
+
);
|
40 |
+
return $options;
|
41 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
// draw widget options
|
44 |
+
function form( $instance ) {
|
45 |
+
$options = $this->get_options();
|
46 |
+
|
47 |
+
// get defaults array
|
48 |
+
$defaults = array();
|
49 |
+
foreach( $options as $key=>$value )
|
50 |
+
$defaults = array_merge( $defaults, array( $key => $value['default'] ) );
|
51 |
|
52 |
+
// parse instance values over defaults
|
53 |
+
$instance = wp_parse_args( ( array ) $instance, $defaults );
|
|
|
|
|
|
|
54 |
|
55 |
+
// loop through text boxes
|
56 |
+
foreach( $options as $slug=>$value ) {
|
57 |
+
|
58 |
+
if( $value['type'] == 'text' )
|
59 |
+
printf( '<!-- %1$s -->
|
60 |
+
<p%6$s>
|
61 |
+
<label for="%2$s">%3$s: </label>
|
62 |
+
<input class="widefat" id="%4$s" name="%2$s" type="text" value="%5$s" />
|
63 |
+
</p>',
|
64 |
+
$slug,
|
65 |
+
$this->get_field_name( $slug ),
|
66 |
+
__( $value['label'], 'customMetaWidget' ),
|
67 |
+
$this->get_field_id( $slug ),
|
68 |
+
esc_attr( $instance[$slug] ),
|
69 |
+
$value['before']
|
70 |
+
);
|
71 |
+
|
72 |
+
elseif( $value['type'] == 'checkbox' )
|
73 |
+
printf( '<!-- %1$s -->
|
74 |
+
<p%6$s>
|
75 |
+
<label for="%2$s">%3$s</label>
|
76 |
+
<input id="%4$s" name="%2$s" type="checkbox" value="1" %5$s />
|
77 |
+
</p>',
|
78 |
+
$slug,
|
79 |
+
$this->get_field_name( $slug ),
|
80 |
+
__( $value['label'], 'customMetaWidget' ),
|
81 |
+
$this->get_field_id( $slug ),
|
82 |
+
checked( $instance[$slug], 1, false ),
|
83 |
+
$value['before']
|
84 |
+
);
|
85 |
+
}
|
86 |
|
87 |
+
echo '<small>(' . __( 'An awesome way to support this free plugin!', 'customMetaWidget' ) . ')</small></p>';
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
+
// check for errors
|
90 |
+
if ( esc_attr( $instance['showcustom'] ) ) { // IF 'showcustom' is checked, AND
|
91 |
|
92 |
// 1. no link and no URL
|
93 |
+
if( empty( $instance['customtext']) && empty($instance['customurl'] ) )
|
94 |
echo '<p style="color:#FF0000; font-weight:bold;" >' . __( 'You have a custom link with no URL or text!', 'customMetaWidget' ) . '</p>';
|
95 |
// 2. no link
|
96 |
+
elseif( empty( $instance['customtext'] ) )
|
97 |
echo '<p style="color:#FF0000; font-weight:bold;" >' . __( 'You have a custom link with no text!', 'customMetaWidget' ) . '</p>';
|
98 |
|
99 |
// 3. no url
|
100 |
+
elseif( empty($instance['customurl' ]) )
|
101 |
echo '<p style="color:#FF0000; font-weight:bold;" >' . __( 'You have a custom link with no URL!', 'customMetaWidget' ) . '</p>';
|
102 |
}
|
103 |
}
|
104 |
|
105 |
// SAVE WIDGET OPTIONS
|
106 |
+
function update( $new_instance, $old_instance) {
|
107 |
$instance = $old_instance;
|
108 |
+
$options = $this->get_options();
|
109 |
+
|
110 |
+
foreach( $options as $key=>$value )
|
111 |
+
$instance[$key] = $new_instance[$key];
|
112 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
return $instance;
|
114 |
}
|
115 |
|
116 |
// ACTUAL WIDGET OUTPUT
|
117 |
function widget( $args, $instance ) {
|
118 |
extract( $args, EXTR_SKIP ); // extract arguments
|
119 |
+
$title = empty( $instance['title'] ) ? 'Meta' : apply_filters( 'widget_title', $instance['title'] ); // if no title, use default
|
120 |
|
121 |
// insert start of widget HTML comment
|
122 |
echo '
|
123 |
<!--
|
124 |
' . __( 'Plugin: Custom Meta Widget', 'customMetaWidget' ) . '
|
125 |
+
' . __( 'Plugin URL', 'customMetaWidget' ) . ': http://bitacre.com/plugins/custom-meta-widget
|
126 |
-->
|
127 |
';
|
128 |
|
129 |
+
echo $before_widget; // insert pre-widget code (from theme)
|
|
|
|
|
|
|
130 |
echo $before_title . esc_attr( $instance['title'] ) . $after_title; // echo title (inside theme tags)
|
131 |
+
echo '<ul>' . "\r\n";
|
132 |
|
|
|
|
|
|
|
|
|
133 |
// ADD LINKS
|
134 |
+
if( esc_attr( $instance['register'] ) ) wp_register( '<li>', '</li>' ); // 1. register link
|
|
|
135 |
|
136 |
+
if( esc_attr( $instance['login'] ) ) echo '<li>' . wp_loginout( NULL, FALSE ) . '</li>'; // 2. login link
|
|
|
137 |
|
138 |
+
if( esc_attr( $instance['entryrss'] ) ) // 3. entries RSS link
|
139 |
+
printf( __( '%1$sSyndicate this site using RSS 2.0%2$sEntries %3$sRSS%4$s', 'customMetaWidget'),
|
140 |
+
'<li><a href="' . get_bloginfo( 'rss2_url' ) . '" title="', '">',
|
141 |
+
'<abbr title="Really Simple Syndication">',
|
142 |
+
'</abbr></a></li>' ); // 4. comments RSS link
|
143 |
|
|
|
144 |
if( esc_attr( $instance['commentrss'] ) )
|
145 |
+
printf( __( '%1$sSyndicate this site using RSS 2.0%2$sComments %3$sRSS%4$s', 'customMetaWidget' ),
|
146 |
+
'<li><a href="' . get_bloginfo( 'comments_rss2_url' ) . '" title="', '">',
|
147 |
+
'<abbr title="Really Simple Syndication">',
|
148 |
+
'</abbr></a></li>' );// 4. entires RSS link
|
149 |
+
|
150 |
+
if( esc_attr( $instance['wordpress'] ) ) echo '<li><a href="http://wordpress.org/" title="' . __( 'Powered by WordPress, state-of-the-art semantic personal publishing platform.', 'customMetaWidget' ) . '">WordPress.org</a></li>'; // 5. wordpress.org link
|
151 |
+
|
152 |
+
if( esc_attr( $instance['showcustom'] ) ) { // 6. custom link
|
153 |
+
if( !empty( $instance['customtext'] )
|
154 |
+
&& !empty( $instance['customurl'] ) )
|
155 |
+
echo '<li><a href="' . esc_attr( $instance['customurl'] ) . '">' . esc_attr( $instance['customtext'] ) . '</a></li>';
|
156 |
// otherwise insert error comment
|
157 |
+
else
|
158 |
+
echo '
|
159 |
<!-- ' . __( 'Error: "Show Custom Link" is checked, but either the text or URL for that link are not specified. The link was not displayed because it would be broken. Check the settings for your Custom Meta widget.', 'customMetaWidget' ) . ' -->
|
160 |
';
|
161 |
}
|
162 |
|
163 |
+
if( esc_attr( $instance['linklove'] ) ) { // 7. link love
|
164 |
+
echo '<li><a href="http://bitacre.com/plugins/custom-meta-widget" title="' . __( 'WordPress Plugin Homepage', 'customMetaWidget' ) . '">' . __( 'Custom Meta' ) . '</a></li>';
|
|
|
165 |
}
|
166 |
|
167 |
+
echo "\r\n" . '</ul>';
|
|
|
|
|
|
|
168 |
echo $after_widget;
|
169 |
}
|
170 |
+
// end class
|
171 |
}
|
172 |
|
173 |
// ADD HOOKS AND FILTERS
|
174 |
+
add_action( 'widgets_init', create_function('', 'unregister_widget( "WP_Widget_Meta" ); register_widget("customMetaWidget" );' ) );
|
175 |
+
add_action( 'plugins_loaded', create_function( '', 'load_plugin_textdomain( "customMetaWidget", null, trailingslashit( basename(dirname(__FILE__) ) ) . "lang" );' ) );
|
|
|
176 |
?>
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Donate link: http://bitacre.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.4.1
|
8 |
-
Stable tag: 1.
|
9 |
|
10 |
Clone of the standard Meta widget plus options to hide log in/out, admin, feed and Wordpress.org/custom links.
|
11 |
|
@@ -47,6 +47,9 @@ Most people, myself included, are understandably reluctant to donate real curren
|
|
47 |
3. Comparison of options between the standard and Custom Meta Widget.
|
48 |
|
49 |
== Changelog ==
|
|
|
|
|
|
|
50 |
|
51 |
= 1.3.6 =
|
52 |
* Small metadata update
|
@@ -93,6 +96,8 @@ Most people, myself included, are understandably reluctant to donate real curren
|
|
93 |
* There may still be bugs, but I can't find any.
|
94 |
|
95 |
== Upgrade Notice ==
|
|
|
|
|
96 |
= 1.3.6 =
|
97 |
Updated metadata, not an essential upgrade.
|
98 |
|
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.4.1
|
8 |
+
Stable tag: 1.4.0
|
9 |
|
10 |
Clone of the standard Meta widget plus options to hide log in/out, admin, feed and Wordpress.org/custom links.
|
11 |
|
47 |
3. Comparison of options between the standard and Custom Meta Widget.
|
48 |
|
49 |
== Changelog ==
|
50 |
+
= 1.4.0 =
|
51 |
+
* Code efficiency improvements (better loops)
|
52 |
+
* Now removes default Meta Widget (to avoid confusion)
|
53 |
|
54 |
= 1.3.6 =
|
55 |
* Small metadata update
|
96 |
* There may still be bugs, but I can't find any.
|
97 |
|
98 |
== Upgrade Notice ==
|
99 |
+
= 1.4.0 =
|
100 |
+
Improves code efficiency, new features, recommended upgrade.
|
101 |
= 1.3.6 =
|
102 |
Updated metadata, not an essential upgrade.
|
103 |
|