| @@ -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 | |
| 8 | + * Version: 2.0 | |
| 9 | 9 | * License: GPL2 |
| 10 | 10 | * Text Domain: hide-metadata |
| 11 | 11 | * Domain Path: /languages |
| 12 | 12 | */ |
| @@ -27,57 +27,81 @@ | ||
| 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' ); | |
| 31 | +if (! defined('ABSPATH')) { | |
| 32 | + exit; // Exit if accessed directly | |
| 33 | +} | |
| 32 | 34 | |
| 33 | -class Hide_Metadata { | |
| 35 | +// Define Version | |
| 36 | +if ( ! defined( 'HIDE_METADATA_VERSION' ) ) { | |
| 37 | + define( 'HIDE_METADATA_VERSION', '2.0' ); | |
| 38 | +} | |
| 39 | + | |
| 40 | +if ( ! defined( 'HIDE_METADATA_BASENAME' ) ) { | |
| 41 | + define('HIDE_METADATA_BASENAME', plugin_basename(__FILE__)); | |
| 42 | +} | |
| 43 | + | |
| 44 | +class Hide_Metadata | |
| 45 | +{ | |
| 34 | 46 | private $plugin_name; |
| 35 | 47 | private $version; |
| 36 | 48 | private $options; |
| 37 | 49 | |
| 38 | - function __construct() { | |
| 50 | + function __construct() | |
| 51 | + { | |
| 39 | 52 | $this->plugin_name = 'hide-metadata'; |
| 40 | 53 | $this->version = HIDE_METADATA_VERSION; |
| 41 | 54 | $this->options = hide_metadata_get_options(); |
| 42 | 55 | |
| 43 | - add_action( 'admin_init', array( $this, 'register_settings' ) ); | |
| 44 | - add_action( 'admin_menu', array( $this, 'add_plugin_settings_menu' ) ); | |
| 45 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) ); | |
| 46 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); | |
| 56 | + add_filter('body_class', array($this, 'hide_metadata_body_class')); | |
| 57 | + add_action('admin_init', array($this, 'register_settings')); | |
| 58 | + add_action('admin_menu', array($this, 'add_plugin_settings_menu')); | |
| 59 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles')); | |
| 60 | + add_action('wp_enqueue_scripts', array($this, 'plugin_styles')); | |
| 61 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); | |
| 47 | 62 | |
| 48 | - add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2 ); | |
| 63 | + add_filter('plugin_row_meta', array($this, 'add_plugin_meta_links'), 10, 2); | |
| 49 | 64 | |
| 50 | - add_filter( 'plugin_action_links', array( $this, 'action_links' ), 10, 2 ); | |
| 65 | + add_filter('plugin_action_links', array($this, 'action_links'), 10, 2); | |
| 51 | 66 | |
| 52 | - if ( 'php' === $this->options['hide_by'] ) { | |
| 53 | - add_action( 'loop_start', array( $this, 'remove_php' ) ); | |
| 67 | + if ('php' === $this->options['hide_by']) { | |
| 68 | + add_action('loop_start', array($this, 'remove_php')); | |
| 69 | + add_action('init', array($this, 'remove_php')); | |
| 54 | 70 | } |
| 55 | - add_action( 'wp_head', array( $this, 'css_filter_option' ) ); | |
| 56 | 71 | } |
| 57 | 72 | |
| 73 | + | |
| 58 | 74 | /** |
| 59 | 75 | * Register the stylesheets for the admin area. |
| 60 | 76 | * |
| 61 | 77 | * @since 1.0.0 |
| 62 | 78 | */ |
| 63 | - function enqueue_styles() { | |
| 64 | - if ( isset( $_GET['page'] ) && 'hide-metadata' === $_GET['page'] ) { | |
| 65 | - wp_enqueue_style( $this->plugin_name . '-display-dashboard', plugin_dir_url( __FILE__ ) . 'css/admin-dashboard.css', array(), $this->version, 'all' ); | |
| 79 | + function enqueue_styles() | |
| 80 | + { | |
| 81 | + if (isset($_GET['page']) && 'hide-metadata' === $_GET['page']) { | |
| 82 | + wp_enqueue_style($this->plugin_name . '-display-dashboard', plugin_dir_url(__FILE__) . 'css/admin-dashboard.css', array(), $this->version, 'all'); | |
| 66 | 83 | } |
| 67 | 84 | } |
| 68 | 85 | |
| 86 | + | |
| 87 | + function plugin_styles() | |
| 88 | + { | |
| 89 | + wp_enqueue_style($this->plugin_name . '-style', plugin_dir_url(__FILE__) . 'css/style.css', array(), $this->version, 'all'); | |
| 90 | + } | |
| 91 | + | |
| 92 | + | |
| 69 | 93 | /** |
| 70 | 94 | * Register the scripts for the admin area. |
| 71 | 95 | * |
| 72 | 96 | * @since 1.0.0 |
| 73 | 97 | */ |
| 74 | - function enqueue_scripts() { | |
| 75 | - if ( isset( $_GET['page'] ) && 'hide-metadata' === $_GET['page'] ) { | |
| 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 ); | |
| 98 | + function enqueue_scripts() | |
| 99 | + { | |
| 100 | + if (isset($_GET['page']) && 'hide-metadata' === $_GET['page']) { | |
| 101 | + wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/hide-metadata-admin.js', array('jquery', 'matchHeight', 'jquery-ui-tooltip'), $this->version, false); | |
| 77 | 102 | |
| 78 | - wp_enqueue_script( 'matchHeight', plugin_dir_url( __FILE__ ) . 'js/jquery-matchHeight.min.js', array( 'jquery' ), $this->version, false ); | |
| 79 | - | |
| 103 | + wp_enqueue_script('matchHeight', plugin_dir_url(__FILE__) . 'js/jquery-matchHeight.min.js', array('jquery'), $this->version, false); | |
| 80 | 104 | } |
| 81 | 105 | } |
| 82 | 106 | |
| 83 | 107 | /** |
| @@ -87,13 +111,14 @@ | ||
| 87 | 111 | * @param arrray $links Link url. |
| 88 | 112 | * |
| 89 | 113 | * @param arrray $file File name. |
| 90 | 114 | */ |
| 91 | - function action_links( $links, $file ) { | |
| 92 | - if ( $file === $this->plugin_name . '/' . $this->plugin_name . '.php' ) { | |
| 93 | - $settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=hide-metadata' ) ) . '">' . esc_html__( 'Settings', 'hide-metadata' ) . '</a>'; | |
| 115 | + function action_links($links, $file) | |
| 116 | + { | |
| 117 | + if ($file === $this->plugin_name . '/' . $this->plugin_name . '.php') { | |
| 118 | + $settings_link = '<a href="' . esc_url(admin_url('admin.php?page=hide-metadata')) . '">' . esc_html__('Settings', 'hide-metadata') . '</a>'; | |
| 94 | 119 | |
| 95 | - array_unshift( $links, $settings_link ); | |
| 120 | + array_unshift($links, $settings_link); | |
| 96 | 121 | } |
| 97 | 122 | return $links; |
| 98 | 123 | } |
| 99 | 124 | |
| @@ -99,18 +124,18 @@ | ||
| 99 | 124 | |
| 100 | 125 | /** |
| 101 | 126 | * Add settings menu |
| 102 | 127 | */ |
| 103 | - function add_plugin_settings_menu() { | |
| 104 | - // Add Main Menu | |
| 105 | - add_menu_page( | |
| 106 | - esc_html__( 'Hide/Remove Metadata', 'hide-metadata' ), | |
| 107 | - esc_html__( 'Hide/Remove Metadata', 'hide-metadata' ), | |
| 128 | + function add_plugin_settings_menu() | |
| 129 | + { | |
| 130 | + // Add menu under tools | |
| 131 | + add_submenu_page( | |
| 132 | + 'tools.php', | |
| 133 | + esc_html__('Hide/Remove Metadata', 'hide-metadata'), | |
| 134 | + esc_html__('Hide/Remove Metadata', 'hide-metadata'), | |
| 108 | 135 | 'manage_options', |
| 109 | 136 | 'hide-metadata', |
| 110 | - array( $this, 'settings_page' ), | |
| 111 | - 'dashicons-visibility', | |
| 112 | - '99.01564' | |
| 137 | + array($this, 'settings_page') | |
| 113 | 138 | ); |
| 114 | 139 | } |
| 115 | 140 | |
| 116 | 141 | /** |
| @@ -116,27 +141,31 @@ | ||
| 116 | 141 | /** |
| 117 | 142 | * Hide/Remove MetaData: settings_page |
| 118 | 143 | * Hide/Remove MetaData Setting function |
| 119 | 144 | */ |
| 120 | - function settings_page() { | |
| 121 | - if ( ! current_user_can( 'manage_options' ) ) { | |
| 122 | - wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) ); | |
| 145 | + function settings_page() | |
| 146 | + { | |
| 147 | + if (! current_user_can('manage_options')) { | |
| 148 | + wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'hide-metadata')); | |
| 123 | 149 | } |
| 124 | 150 | |
| 125 | - require plugin_dir_path( __FILE__ ) . 'partials/admin-display.php'; | |
| 151 | + require plugin_dir_path(__FILE__) . 'partials/admin-display.php'; | |
| 126 | 152 | } |
| 127 | 153 | |
| 128 | - function register_settings() { | |
| 154 | + function register_settings() | |
| 155 | + { | |
| 129 | 156 | register_setting( |
| 130 | 157 | 'hide-metadata-group', |
| 131 | 158 | 'hide_metadata_options', |
| 132 | - array( $this, 'sanitize_callback' ) | |
| 159 | + array($this, 'sanitize_callback') | |
| 133 | 160 | ); |
| 134 | 161 | } |
| 135 | 162 | |
| 136 | - public function sanitize_callback( $input ) { | |
| 137 | - if ( isset( $input['reset'] ) && $input['reset'] ) { | |
| 138 | - //If reset, restore defaults | |
| 163 | + public function sanitize_callback($input) | |
| 164 | + { | |
| 165 | + | |
| 166 | + if (isset($input['reset']) && $input['reset']) { | |
| 167 | + // If reset, restore defaults | |
| 139 | 168 | return hide_metadata_default_options(); |
| 140 | 169 | } |
| 141 | 170 | $message = null; |
| 142 | 171 | $type = null; |
| @@ -141,130 +170,95 @@ | ||
| 141 | 170 | $message = null; |
| 142 | 171 | $type = null; |
| 143 | 172 | |
| 144 | 173 | // Verify the nonce before proceeding. |
| 145 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) | |
| 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' ) ) ) { | |
| 149 | - if ( null !== $input ) { | |
| 174 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) | |
| 175 | + || (! isset($_POST['hide_metadata_nonce']) | |
| 176 | + || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['hide_metadata_nonce'])), HIDE_METADATA_BASENAME)) | |
| 177 | + || (! check_admin_referer(HIDE_METADATA_BASENAME, 'hide_metadata_nonce')) | |
| 178 | + ) { | |
| 150 | 179 | |
| 151 | - $input['hide_by'] = sanitize_key( $input['hide_by'] ); | |
| 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'; | |
| 180 | + return esc_html__('Invalid Nonce', 'hide-metadata'); | |
| 181 | + } else { | |
| 182 | + if (null !== $input) { | |
| 154 | 183 | |
| 155 | - return $input; | |
| 184 | + $input['hide_by'] = sanitize_key($input['hide_by']); | |
| 185 | + $input['hide_author'] = (isset($input['hide_author']) && '1' === $input['hide_author']) ? '1' : '0'; | |
| 186 | + $input['hide_date'] = (isset($input['hide_date']) && '1' === $input['hide_date']) ? '1' : '0'; | |
| 156 | 187 | } |
| 157 | - return 'Invalid Nonce'; | |
| 188 | + return $input; | |
| 158 | 189 | } |
| 159 | 190 | } |
| 160 | 191 | |
| 161 | - function hide_by_css() { | |
| 162 | 192 | |
| 163 | - $css = ''; | |
| 193 | + // Removal using css | |
| 194 | + | |
| 195 | + public function hide_metadata_body_class($classes) | |
| 196 | + { | |
| 197 | + | |
| 164 | 198 | $options = hide_metadata_get_options(); |
| 165 | 199 | |
| 166 | - // Hide author CSS | |
| 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 | -}\n"; | |
| 200 | + if ('1' === $options['hide_author'] && 'css' === $options['hide_by']) { | |
| 201 | + $classes[] = 'hide-meta-author'; | |
| 172 | 202 | } |
| 173 | - | |
| 174 | - // Hide date CSS | |
| 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 | -}\n"; | |
| 203 | + if ('1' === $options['hide_date'] && 'css' === $options['hide_by']) { | |
| 204 | + $classes[] = 'hide-meta-date'; | |
| 180 | 205 | } |
| 181 | - | |
| 182 | - // Hide author | |
| 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 | -}\n"; | |
| 206 | + if ('1' === $options['hide_date'] && 'php' === $options['hide_by']) { | |
| 207 | + $classes[] = 'hide-meta-date-php'; | |
| 195 | 208 | } |
| 196 | - | |
| 197 | - // Hide date | |
| 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 | -}\n"; | |
| 209 | + if ('1' === $options['hide_author'] && 'php' === $options['hide_by']) { | |
| 210 | + $classes[] = 'hide-meta-author-php'; | |
| 209 | 211 | } |
| 210 | 212 | |
| 211 | - return $css; | |
| 213 | + return $classes; | |
| 212 | 214 | } |
| 213 | 215 | |
| 214 | - //Removal using css | |
| 215 | 216 | |
| 216 | - function inline_style() { | |
| 217 | - $css = $this->hide_by_css(); | |
| 218 | - if ( ! empty( $css ) ) { | |
| 219 | - echo "<style>\n\n/* CSS added by Hide Metadata Plugin */\n\n" . wp_strip_all_tags( $css ) . "</style>\n"; | |
| 220 | - } | |
| 221 | - } | |
| 222 | 217 | |
| 223 | - function remove_php() { | |
| 218 | + function remove_php() | |
| 219 | + { | |
| 224 | 220 | $options = hide_metadata_get_options(); |
| 225 | 221 | |
| 226 | - if ( 1 == $options['hide_author'] ) { | |
| 227 | - add_filter( 'the_author', '__return_false' ); | |
| 228 | - add_filter( 'get_the_author', '__return_false' ); | |
| 229 | - add_filter( 'author_link', '__return_false' ); | |
| 222 | + if ('1' === $options['hide_author']) { | |
| 223 | + add_filter('the_author', '__return_false'); | |
| 224 | + add_filter('get_the_author', '__return_false'); | |
| 225 | + add_filter('author_link', '__return_false'); | |
| 230 | 226 | } |
| 231 | 227 | |
| 232 | - if ( 1 == $options['hide_date'] ) { | |
| 233 | - add_filter( 'the_date', '__return_false' ); | |
| 234 | - add_filter( 'the_time', '__return_false' ); | |
| 235 | - add_filter( 'the_modified_date', '__return_false' ); | |
| 236 | - add_filter( 'get_the_date', '__return_false' ); | |
| 237 | - add_filter( 'get_the_title', '__return_false' ); | |
| 238 | - add_filter( 'get_the_time', '__return_false' ); | |
| 239 | - add_filter( 'get_the_modified_date', '__return_false' ); | |
| 228 | + if ('1' === $options['hide_date']) { | |
| 229 | + add_filter('the_date', '__return_false'); | |
| 230 | + add_filter('the_time', '__return_false'); | |
| 231 | + add_filter('the_modified_date', '__return_false'); | |
| 232 | + add_filter('get_the_date', '__return_false'); | |
| 233 | + add_filter('get_the_title', '__return_false'); | |
| 234 | + add_filter('get_the_time', '__return_false'); | |
| 235 | + add_filter('get_the_modified_date', '__return_false'); | |
| 240 | 236 | } |
| 241 | 237 | } |
| 242 | 238 | |
| 243 | - function css_filter_option() { | |
| 244 | - $this->inline_style(); | |
| 245 | - } | |
| 246 | 239 | |
| 247 | - function add_plugin_meta_links( $meta_fields, $file ) { | |
| 240 | + function add_plugin_meta_links($meta_fields, $file) | |
| 241 | + { | |
| 248 | 242 | |
| 249 | - if ( $file === plugin_basename( __FILE__ ) ) { | |
| 243 | + if (plugin_basename(__FILE__) === $file) { | |
| 250 | 244 | |
| 251 | 245 | $meta_fields[] = "<a href='https://catchplugins.com/support-forum/forum/hide-metadata/' target='_blank'>Support Forum</a>"; |
| 252 | 246 | $meta_fields[] = "<a href='https://wordpress.org/support/plugin/hide-metadata/reviews#new-post' target='_blank' title='Rate'> |
| 253 | 247 | <i class='ct-rate-stars'>" |
| 254 | - . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>" | |
| 255 | - . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>" | |
| 256 | - . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>" | |
| 257 | - . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>" | |
| 258 | - . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>" | |
| 259 | - . '</i></a>'; | |
| 248 | + . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>" | |
| 249 | + . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>" | |
| 250 | + . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>" | |
| 251 | + . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>" | |
| 252 | + . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>" | |
| 253 | + . '</i></a>'; | |
| 260 | 254 | |
| 261 | 255 | $stars_color = '#ffb900'; |
| 262 | 256 | |
| 263 | 257 | echo '<style>' |
| 264 | - . '.ct-rate-stars{display:inline-block;color:' . $stars_color . ';position:relative;top:3px;}' | |
| 265 | - . '.ct-rate-stars svg{fill:' . $stars_color . ';}' | |
| 266 | - . '.ct-rate-stars svg:hover{fill:' . $stars_color . '}' | |
| 258 | + . '.ct-rate-stars{display:inline-block;color:' . esc_html($stars_color) . ';position:relative;top:3px;}' | |
| 259 | + . '.ct-rate-stars svg{fill:' . esc_html($stars_color) . ';}' | |
| 260 | + . '.ct-rate-stars svg:hover{fill:' . esc_html($stars_color) . '}' | |
| 267 | 261 | . '.ct-rate-stars svg:hover ~ svg{fill:none;}' |
| 268 | 262 | . '</style>'; |
| 269 | 263 | } |
| 270 | 264 | |
| @@ -269,30 +263,31 @@ | ||
| 269 | 263 | } |
| 270 | 264 | |
| 271 | 265 | return $meta_fields; |
| 272 | 266 | } |
| 273 | - | |
| 274 | 267 | } |
| 275 | 268 | |
| 276 | 269 | new Hide_Metadata(); |
| 277 | 270 | |
| 278 | 271 | |
| 279 | -function hide_metadata_default_options( $option = null ) { | |
| 272 | +function hide_metadata_default_options($option = null) | |
| 273 | +{ | |
| 280 | 274 | $default_options = array( |
| 281 | 275 | 'hide_by' => 'css', |
| 282 | - 'hide_author' => 0, | |
| 283 | - 'hide_date' => 0, | |
| 276 | + 'hide_author' => '0', | |
| 277 | + 'hide_date' => '0', | |
| 284 | 278 | ); |
| 285 | 279 | |
| 286 | - if ( null === $option ) { | |
| 287 | - return apply_filters( 'hide_metadata_options', $default_options ); | |
| 280 | + if (null === $option) { | |
| 281 | + return apply_filters('hide_metadata_options', $default_options); | |
| 288 | 282 | } else { |
| 289 | - return $default_options[ $option ]; | |
| 283 | + return $default_options[$option]; | |
| 290 | 284 | } |
| 291 | 285 | } |
| 292 | 286 | |
| 293 | -function hide_metadata_get_options() { | |
| 287 | +function hide_metadata_get_options() | |
| 288 | +{ | |
| 294 | 289 | $defaults = hide_metadata_default_options(); |
| 295 | - $options = get_option( 'hide_metadata_options', $defaults ); | |
| 290 | + $options = get_option('hide_metadata_options', $defaults); | |
| 296 | 291 | |
| 297 | - return wp_parse_args( $options, $defaults ); | |
| 292 | + return wp_parse_args($options, $defaults); | |
| 298 | 293 | } |