PluginProbe
Hide/Remove Metadata / 1.1
Hide/Remove Metadata v1.1
trunk 1.0.0 1.0.1 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.1
← All changes | hide-metadata.php +59 -66 1.2.21.1 View file →
@@ -4,9 +4,9 @@
4 4 * Description: Hide/Remove Metadata is a free, simple yet extremely handy WordPress plugin that helps you hide author and published date either by CSS or PHP from your website effortlessly.
5 5 * Plugin URI: http://catchplugins.com/plugins/hide-metadata
6 6 * Author: Catch Plugins
7 7 * Author URI: http://catchplugins.com/
8 - * Version: 1.2.2
8 + * Version: 1.1
9 9 * License: GPL2
10 10 * Text Domain: hide-metadata
11 11 * Domain Path: /languages
12 12 */
@@ -27,10 +27,9 @@
27 27 along with this program; if not, write to the Free Software
28 28 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 29 */
30 30
31 -define( 'HIDE_METADATA_VERSION', '1.2.2' );
32 -define( 'HIDE_METADATA_BASENAME', plugin_basename( __FILE__ ) );
31 +define( 'HIDE_METADATA_VERSION', '1.1' );
33 32
34 33 class Hide_Metadata {
35 34 private $plugin_name;
36 35 private $version;
@@ -49,11 +48,10 @@
49 48 add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2 );
50 49
51 50 add_filter( 'plugin_action_links', array( $this, 'action_links' ), 10, 2 );
52 51
53 - if ( 'php' === $this->options['hide_by'] ) {
52 + if ( 'php' == $this->options['hide_by'] ) {
54 53 add_action( 'loop_start', array( $this, 'remove_php' ) );
55 - add_action( 'init', array( $this, 'remove_php' ) );
56 54 }
57 55 add_action( 'wp_head', array( $this, 'css_filter_option' ) );
58 56 }
59 57
@@ -62,9 +60,9 @@
62 60 *
63 61 * @since 1.0.0
64 62 */
65 63 function enqueue_styles() {
66 - if ( isset( $_GET['page'] ) && 'hide-metadata' === $_GET['page'] ) {
64 + if ( isset( $_GET['page'] ) && 'hide-metadata' == $_GET['page'] ) {
67 65 wp_enqueue_style( $this->plugin_name . '-display-dashboard', plugin_dir_url( __FILE__ ) . 'css/admin-dashboard.css', array(), $this->version, 'all' );
68 66 }
69 67 }
70 68
@@ -73,9 +71,9 @@
73 71 *
74 72 * @since 1.0.0
75 73 */
76 74 function enqueue_scripts() {
77 - if ( isset( $_GET['page'] ) && 'hide-metadata' === $_GET['page'] ) {
75 + if ( isset( $_GET['page'] ) && 'hide-metadata' == $_GET['page'] ) {
78 76 wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/hide-metadata-admin.js', array( 'jquery', 'matchHeight', 'jquery-ui-tooltip' ), $this->version, false );
79 77
80 78 wp_enqueue_script( 'matchHeight', plugin_dir_url( __FILE__ ) . 'js/jquery-matchHeight.min.js', array( 'jquery' ), $this->version, false );
81 79
@@ -102,16 +100,17 @@
102 100 /**
103 101 * Add settings menu
104 102 */
105 103 function add_plugin_settings_menu() {
106 - // Add menu under tools
107 - add_submenu_page(
108 - 'tools.php',
104 + // Add Main Menu
105 + add_menu_page(
109 106 esc_html__( 'Hide/Remove Metadata', 'hide-metadata' ),
110 107 esc_html__( 'Hide/Remove Metadata', 'hide-metadata' ),
111 108 'manage_options',
112 109 'hide-metadata',
113 - array( $this, 'settings_page' )
110 + array( $this, 'settings_page' ),
111 + 'dashicons-visibility',
112 + '99.01564'
114 113 );
115 114 }
116 115
117 116 /**
@@ -134,9 +133,8 @@
134 133 );
135 134 }
136 135
137 136 public function sanitize_callback( $input ) {
138 -
139 137 if ( isset( $input['reset'] ) && $input['reset'] ) {
140 138 //If reset, restore defaults
141 139 return hide_metadata_default_options();
142 140 }
@@ -144,23 +142,20 @@
144 142 $type = null;
145 143
146 144 // Verify the nonce before proceeding.
147 145 if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
148 - || ( ! isset( $_POST['hide_metadata_nonce'] )
149 - || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['hide_metadata_nonce'] ) ), HIDE_METADATA_BASENAME ) )
150 - || ( ! check_admin_referer( HIDE_METADATA_BASENAME, 'hide_metadata_nonce' ) ) ) {
151 -
152 - return esc_html__( 'Invalid Nonce', 'hide-metadata' );
153 -
154 - } else {
146 + || ( ! isset( $_POST['hide_metadata_nounce'] )
147 + || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['hide_metadata_nounce'] ) ), basename( __FILE__ ) ) )
148 + || ( ! check_admin_referer( basename( __FILE__ ), 'hide_metadata_nounce' ) ) ) {
155 149 if ( null !== $input ) {
156 150
157 151 $input['hide_by'] = sanitize_key( $input['hide_by'] );
158 - $input['hide_author'] = ( isset( $input['hide_author'] ) && '1' === $input['hide_author'] ) ? '1' : '0';
159 - $input['hide_date'] = ( isset( $input['hide_date'] ) && '1' === $input['hide_date'] ) ? '1' : '0';
152 + $input['hide_author'] = ( isset( $input['hide_author'] ) && 'on' == $input['hide_author'] ) ? '1' : '0';
153 + $input['hide_date'] = ( isset( $input['hide_date'] ) && 'on' == $input['hide_date'] ) ? '1' : '0';
160 154
155 + return $input;
161 156 }
162 - return $input;
157 + return 'Invalid Nonce';
163 158 }
164 159 }
165 160
166 161 function hide_by_css() {
@@ -168,51 +163,50 @@
168 163 $css = '';
169 164 $options = hide_metadata_get_options();
170 165
171 166 // Hide author CSS
172 - if ( '1' === $options['hide_author'] && 'css' === $options['hide_by'] ) {
173 - $css .= ".entry-meta .byline,
174 - .entry-meta .by-author,
175 - .entry-header .entry-meta > span.byline {
176 - display: none;
177 - }\n";
167 + if ( 1 == $options['hide_author'] && 'css' == $options['hide_by'] ) {
168 + $css .= '.entry-meta .byline,
169 + .entry-header .entry-meta > span.byline {
170 + display: none;
171 + }';
178 172 }
179 173
180 174 // Hide date CSS
181 - if ( '1' === $options['hide_date'] && 'css' === $options['hide_by'] ) {
182 - $css .= ".entry-meta .posted-on,
183 - .entry-header .entry-meta > span.posted-on {
184 - display: none;
185 - }\n";
175 + if ( 1 == $options['hide_date'] && 'css' == $options['hide_by'] ) {
176 + $css .= '.entry-meta .posted-on,
177 + .entry-header .entry-meta > span.posted-on {
178 + display: none;
179 + }';
186 180 }
187 181
188 182 // Hide author
189 - if ( '1' === $options['hide_author'] && 'php' === $options['hide_by'] ) {
190 - $css .= ".entry-meta .byline:before,
191 - .entry-header .entry-meta span.byline:before,
192 - .entry-meta .byline:after,
193 - .entry-header .entry-meta span.byline:after,
194 - .single .byline, .group-blog .byline,
195 - .entry-meta .byline,
196 - .entry-header .entry-meta > span.byline {
197 - content: '';
198 - display: none;
199 - margin: 0;
200 - }\n";
183 + if ( 1 == $options['hide_author'] && 'php' == $options['hide_by'] ) {
184 + $css .= '.entry-meta .byline:before,
185 + .entry-header .entry-meta span.byline:before,
186 + .entry-meta .byline:after,
187 + .entry-header .entry-meta span.byline:after,
188 + .single .byline, .group-blog .byline,
189 + .entry-meta .byline,
190 + .entry-header .entry-meta > span.byline {
191 + content: "";
192 + display: none;
193 + margin: 0;
194 + }';
201 195 }
202 196
203 197 // Hide date
204 - if ( '1' === $options['hide_date'] && 'php' === $options['hide_by'] ) {
205 - $css .= ".entry-meta .posted-on:before,
206 - .entry-header .entry-meta > span.posted-on:before,
207 - .entry-meta .posted-on:after,
208 - .entry-header .entry-meta > span.posted-on:after,
209 - .entry-meta .posted-on,
210 - .entry-header .entry-meta > span.posted-on {
211 - content: '';
212 - display: none;
213 - margin: 0;
214 - }\n";
198 + if ( 1 == $options['hide_date'] && 'php' == $options['hide_by'] ) {
199 + $css .= '.entry-meta .posted-on:before,
200 + .entry-header .entry-meta > span.posted-on:before,
201 + .entry-meta .posted-on:after,
202 + .entry-header .entry-meta > span.posted-on:after,
203 + .entry-meta .posted-on,
204 + .entry-header .entry-meta > span.posted-on {
205 + content: "";
206 + display: none;
207 + margin: 0;
208 + }';
215 209 }
216 210
217 211 return $css;
218 212 }
@@ -219,11 +213,10 @@
219 213
220 214 //Removal using css
221 215
222 216 function inline_style() {
223 - $css = $this->hide_by_css();
224 - if ( ! empty( $css ) ) {
225 - echo "<style>\n\n/* CSS added by Hide Metadata Plugin */\n\n" . wp_strip_all_tags( $css ) . "</style>\n";
217 + if ( ! empty( $this->hide_by_css() ) ) {
218 + echo '<style>/* CSS added by Hide Metadata Plugin */' . $this->hide_by_css() . '</style>';
226 219 }
227 220 }
228 221
229 222 function remove_php() {
@@ -228,15 +221,15 @@
228 221
229 222 function remove_php() {
230 223 $options = hide_metadata_get_options();
231 224
232 - if ( '1' === $options['hide_author'] ) {
225 + if ( 1 == $options['hide_author'] ) {
233 226 add_filter( 'the_author', '__return_false' );
234 227 add_filter( 'get_the_author', '__return_false' );
235 228 add_filter( 'author_link', '__return_false' );
236 229 }
237 230
238 - if ( '1' === $options['hide_date'] ) {
231 + if ( 1 == $options['hide_date'] ) {
239 232 add_filter( 'the_date', '__return_false' );
240 233 add_filter( 'the_time', '__return_false' );
241 234 add_filter( 'the_modified_date', '__return_false' );
242 235 add_filter( 'get_the_date', '__return_false' );
@@ -246,14 +239,14 @@
246 239 }
247 240 }
248 241
249 242 function css_filter_option() {
250 - $this->inline_style();
243 + $this->inline_style();
251 244 }
252 245
253 246 function add_plugin_meta_links( $meta_fields, $file ) {
254 247
255 - if ( plugin_basename( __FILE__ ) === $file ) {
248 + if ( $file == plugin_basename( __FILE__ ) ) {
256 249
257 250 $meta_fields[] = "<a href='https://catchplugins.com/support-forum/forum/hide-metadata/' target='_blank'>Support Forum</a>";
258 251 $meta_fields[] = "<a href='https://wordpress.org/support/plugin/hide-metadata/reviews#new-post' target='_blank' title='Rate'>
259 252 <i class='ct-rate-stars'>"
@@ -284,13 +277,13 @@
284 277
285 278 function hide_metadata_default_options( $option = null ) {
286 279 $default_options = array(
287 280 'hide_by' => 'css',
288 - 'hide_author' => '0',
289 - 'hide_date' => '0',
281 + 'hide_author' => 0,
282 + 'hide_date' => 0,
290 283 );
291 284
292 - if ( null === $option ) {
285 + if ( null == $option ) {
293 286 return apply_filters( 'hide_metadata_options', $default_options );
294 287 } else {
295 288 return $default_options[ $option ];
296 289 }