| @@ -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.7 | |
| 8 | + * Version: 1.2 | |
| 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.7' ); | |
| 32 | -define( 'HIDE_METADATA_BASENAME', plugin_basename( __FILE__ ) ); | |
| 31 | +define( 'HIDE_METADATA_VERSION', '1.2' ); | |
| 33 | 32 | |
| 34 | 33 | class Hide_Metadata { |
| 35 | 34 | private $plugin_name; |
| 36 | 35 | private $version; |
| @@ -51,9 +50,8 @@ | ||
| 51 | 50 | add_filter( 'plugin_action_links', array( $this, 'action_links' ), 10, 2 ); |
| 52 | 51 | |
| 53 | 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 | |
| @@ -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,11 +133,10 @@ | ||
| 134 | 133 | ); |
| 135 | 134 | } |
| 136 | 135 | |
| 137 | 136 | public function sanitize_callback( $input ) { |
| 138 | - | |
| 139 | 137 | if ( isset( $input['reset'] ) && $input['reset'] ) { |
| 140 | - // If reset, restore defaults | |
| 138 | + //If reset, restore defaults | |
| 141 | 139 | return hide_metadata_default_options(); |
| 142 | 140 | } |
| 143 | 141 | $message = null; |
| 144 | 142 | $type = null; |
| @@ -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() { |
| @@ -166,60 +161,58 @@ | ||
| 166 | 161 | function hide_by_css() { |
| 167 | 162 | |
| 168 | 163 | $css = ''; |
| 169 | 164 | $options = hide_metadata_get_options(); |
| 165 | + | |
| 170 | 166 | // Hide author CSS |
| 171 | - if ( '1' === $options['hide_author'] && 'css' === $options['hide_by'] ) { | |
| 167 | + if ( 1 == $options['hide_author'] && 'css' === $options['hide_by'] ) { | |
| 172 | 168 | $css .= ".entry-meta .byline, |
| 173 | - .entry-meta .by-author, | |
| 174 | - .entry-header .entry-meta > span.byline, | |
| 175 | - .entry-meta .author.vcard { | |
| 176 | - display: none; | |
| 177 | - }\n"; | |
| 169 | +.entry-header .entry-meta > span.byline { | |
| 170 | + display: none; | |
| 171 | +}\n"; | |
| 178 | 172 | } |
| 179 | 173 | |
| 180 | 174 | // Hide date CSS |
| 181 | - if ( '1' === $options['hide_date'] && 'css' === $options['hide_by'] ) { | |
| 175 | + if ( 1 == $options['hide_date'] && 'css' === $options['hide_by'] ) { | |
| 182 | 176 | $css .= ".entry-meta .posted-on, |
| 183 | - .entry-header .entry-meta > span.posted-on { | |
| 184 | - display: none; | |
| 185 | - }\n"; | |
| 177 | +.entry-header .entry-meta > span.posted-on { | |
| 178 | + display: none; | |
| 179 | +}\n"; | |
| 186 | 180 | } |
| 187 | 181 | |
| 188 | 182 | // Hide author |
| 189 | - if ( '1' === $options['hide_author'] && 'php' === $options['hide_by'] ) { | |
| 183 | + if ( 1 == $options['hide_author'] && 'php' === $options['hide_by'] ) { | |
| 190 | 184 | $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 | - .entry-meta .author.vcard { | |
| 198 | - content: ''; | |
| 199 | - display: none; | |
| 200 | - margin: 0; | |
| 201 | - }\n"; | |
| 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 | +}\n"; | |
| 202 | 195 | } |
| 203 | 196 | |
| 204 | 197 | // Hide date |
| 205 | - if ( '1' === $options['hide_date'] && 'php' === $options['hide_by'] ) { | |
| 198 | + if ( 1 == $options['hide_date'] && 'php' === $options['hide_by'] ) { | |
| 206 | 199 | $css .= ".entry-meta .posted-on:before, |
| 207 | - .entry-header .entry-meta > span.posted-on:before, | |
| 208 | - .entry-meta .posted-on:after, | |
| 209 | - .entry-header .entry-meta > span.posted-on:after, | |
| 210 | - .entry-meta .posted-on, | |
| 211 | - .entry-header .entry-meta > span.posted-on { | |
| 212 | - content: ''; | |
| 213 | - display: none; | |
| 214 | - margin: 0; | |
| 215 | - }\n"; | |
| 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 | +}\n"; | |
| 216 | 209 | } |
| 217 | 210 | |
| 218 | 211 | return $css; |
| 219 | 212 | } |
| 220 | 213 | |
| 221 | - // Removal using css | |
| 214 | + //Removal using css | |
| 222 | 215 | |
| 223 | 216 | function inline_style() { |
| 224 | 217 | $css = $this->hide_by_css(); |
| 225 | 218 | if ( ! empty( $css ) ) { |
| @@ -229,15 +222,15 @@ | ||
| 229 | 222 | |
| 230 | 223 | function remove_php() { |
| 231 | 224 | $options = hide_metadata_get_options(); |
| 232 | 225 | |
| 233 | - if ( '1' === $options['hide_author'] ) { | |
| 226 | + if ( 1 == $options['hide_author'] ) { | |
| 234 | 227 | add_filter( 'the_author', '__return_false' ); |
| 235 | 228 | add_filter( 'get_the_author', '__return_false' ); |
| 236 | 229 | add_filter( 'author_link', '__return_false' ); |
| 237 | 230 | } |
| 238 | 231 | |
| 239 | - if ( '1' === $options['hide_date'] ) { | |
| 232 | + if ( 1 == $options['hide_date'] ) { | |
| 240 | 233 | add_filter( 'the_date', '__return_false' ); |
| 241 | 234 | add_filter( 'the_time', '__return_false' ); |
| 242 | 235 | add_filter( 'the_modified_date', '__return_false' ); |
| 243 | 236 | add_filter( 'get_the_date', '__return_false' ); |
| @@ -247,14 +240,14 @@ | ||
| 247 | 240 | } |
| 248 | 241 | } |
| 249 | 242 | |
| 250 | 243 | function css_filter_option() { |
| 251 | - $this->inline_style(); | |
| 244 | + $this->inline_style(); | |
| 252 | 245 | } |
| 253 | 246 | |
| 254 | 247 | function add_plugin_meta_links( $meta_fields, $file ) { |
| 255 | 248 | |
| 256 | - if ( plugin_basename( __FILE__ ) === $file ) { | |
| 249 | + if ( $file === plugin_basename( __FILE__ ) ) { | |
| 257 | 250 | |
| 258 | 251 | $meta_fields[] = "<a href='https://catchplugins.com/support-forum/forum/hide-metadata/' target='_blank'>Support Forum</a>"; |
| 259 | 252 | $meta_fields[] = "<a href='https://wordpress.org/support/plugin/hide-metadata/reviews#new-post' target='_blank' title='Rate'> |
| 260 | 253 | <i class='ct-rate-stars'>" |
| @@ -285,10 +278,10 @@ | ||
| 285 | 278 | |
| 286 | 279 | function hide_metadata_default_options( $option = null ) { |
| 287 | 280 | $default_options = array( |
| 288 | 281 | 'hide_by' => 'css', |
| 289 | - 'hide_author' => '0', | |
| 290 | - 'hide_date' => '0', | |
| 282 | + 'hide_author' => 0, | |
| 283 | + 'hide_date' => 0, | |
| 291 | 284 | ); |
| 292 | 285 | |
| 293 | 286 | if ( null === $option ) { |
| 294 | 287 | return apply_filters( 'hide_metadata_options', $default_options ); |