Changeset 3255819
- Timestamp:
- 03/14/2025 10:46:57 AM (10 months ago)
- Location:
- add-custom-codes/trunk
- Files:
-
- 1 added
- 4 edited
- 2 moved
-
add-custom-codes.php (modified) (22 diffs)
-
css/style43.css (moved) (moved from add-custom-codes/trunk/css/style41.css) (4 diffs)
-
global-form.php (modified) (5 diffs)
-
js/scripts.js (moved) (moved from add-custom-codes/trunk/js/script.js)
-
readme.txt (modified) (3 diffs)
-
single-meta.php (modified) (3 diffs)
-
taxonomy-meta.php (added)
Legend:
- Unmodified
- Added
- Removed
-
add-custom-codes/trunk/add-custom-codes.php
r3019452 r3255819 3 3 * Plugin Name: Add Custom Codes - Insert Header, Footer, Custom Code Snippets 4 4 * Description: Light-weight plugin to add Custom CSS, Javascript, Google Analytics, Search console verification tags and other custom code snippets to your Wordpress website. Go to <em>Appearance -> Add Custom Codes</em> after installing the plugin. 5 * Version: 4. 65 * Version: 4.7 6 6 * Author: Saifudheen Mak 7 7 * Author URI: https://maktalseo.com … … 23 23 plugin links 'Plugins' page 24 24 ------------------*/ 25 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'a dd_action_links_accodes' );25 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'accodes_action_links' ); 26 26 27 function a dd_action_links_accodes ( $actions ) {27 function accodes_action_links ( $actions ) { 28 28 $mylinks = array( 29 29 '<a href="' . admin_url( 'themes.php?page=add-custom-codes' ) . '">Settings</a>', … … 33 33 } 34 34 35 add_filter( 'plugin_row_meta', ' plugin_row_meta_accodes', 10, 2 );36 37 function plugin_row_meta_accodes( $links, $file ) {35 add_filter( 'plugin_row_meta', 'accodes_row_meta', 10, 2 ); 36 37 function accodes_row_meta( $links, $file ) { 38 38 if ( plugin_basename( __FILE__ ) == $file ) { 39 39 $row_meta = array( 40 40 'wrt-review' => '<a href="' . esc_url( 'https://wordpress.org/support/plugin/add-custom-codes/reviews/#new-post' ) . '" target="_blank" style="">' . esc_html__( 'Rate this plugin', 'add-custom-codes' ) . '</a>', 41 'acc-buy-coffee' => '<a href="' . esc_url( 'https://maktalseo.com' ) . '" target="_blank" style="color:green;">' . esc_html__( 'Hire us!', 'add-custom-codes' ) . '</a>' 42 43 41 'acc-buy-coffee' => '<a href="' . esc_url( 'https://maktalseo.com' ) . '" target="_blank" style="color:green;">' . esc_html__( 'Hire us!', 'add-custom-codes' ) . '</a>' 44 42 ); 45 46 43 return array_merge( $links, $row_meta ); 47 44 } … … 53 50 -----------------------------------------*/ 54 51 55 add_action('admin_enqueue_scripts', ' codemirror_enqueue_scripts');52 add_action('admin_enqueue_scripts', 'accodes_codemirror_scripts'); 56 53 57 function codemirror_enqueue_scripts($hook) {54 function accodes_codemirror_scripts($hook) { 58 55 $cm_settings['codeEditor'] = wp_enqueue_code_editor(array('type' => 'htmlmixed')); 59 56 wp_localize_script('jquery', 'cm_settings', $cm_settings); … … 61 58 wp_enqueue_style('wp-codemirror'); 62 59 63 wp_register_style( 'accodes-css', plugins_url( 'add-custom-codes/css/style4 1.css' ), '', '4.192' );60 wp_register_style( 'accodes-css', plugins_url( 'add-custom-codes/css/style43.css' ), '', '4.193' ); 64 61 wp_enqueue_style( 'accodes-css' ); 65 62 66 wp_register_script( 'accodes-js', plugins_url( 'add-custom-codes/js/script .js' ), '', '4.1');67 wp_enqueue_script( 'accodes-js' );63 wp_register_script( 'accodes-js', plugins_url( 'add-custom-codes/js/scripts.js' ),array(),'4.32', true); 64 wp_enqueue_script( 'accodes-js' ); 68 65 69 66 } … … 72 69 add menu link for plugin settings page 73 70 ------------------------*/ 74 add_action('admin_menu', 'accodes_ menu');75 76 function accodes_ menu() {71 add_action('admin_menu', 'accodes_show_menu'); 72 73 function accodes_show_menu() { 77 74 add_theme_page('Add Custom Codes', 'Add Custom Codes', 'administrator', 'add-custom-codes', 'accodes_settings_page'); 78 75 } 79 76 80 77 function accodes_settings_page() { 81 include('global-form.php'); 78 if (!current_user_can('administrator')) { 79 wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'add-custom-codes')); 80 } 81 82 include('global-form.php'); 82 83 } 83 84 … … 85 86 define items in settings page 86 87 -------------------------------*/ 87 add_action( 'admin_init', 'accodes_settings' ); 88 89 function accodes_sanitize_raw_input($input) { 90 // Return raw input safely — meant for HTML, CSS, JS 91 //return is_string($input) ? wp_kses_post($input) : ''; 92 return $input; 93 } 94 95 // Register individual settings with static callbacks 96 add_action('admin_init', 'accodes_settings'); 88 97 89 98 function accodes_settings() { 90 register_setting( 'accodes-settings-group', 'custom-css-codes-input' ); 91 register_setting( 'accodes-settings-group', 'custom-footer-codes-input' ); 92 register_setting( 'accodes-settings-group', 'custom-header-codes-input' ); 93 register_setting( 'accodes-settings-group', 'accodes_global_css_on_footer' ); 99 // Custom CSS field 100 register_setting( 101 'accodes-settings-group', 102 'custom-css-codes-input', 103 [ 104 'type' => 'string', 105 'sanitize_callback' => 'accodes_sanitize_raw_input', 106 'default' => '' 107 ] 108 ); 109 110 // Custom footer codes field 111 register_setting( 112 'accodes-settings-group', 113 'custom-footer-codes-input', 114 [ 115 'type' => 'string', 116 'sanitize_callback' => 'accodes_sanitize_raw_input', 117 'default' => '' 118 ] 119 ); 120 121 // Custom header codes field 122 register_setting( 123 'accodes-settings-group', 124 'custom-header-codes-input', 125 [ 126 'type' => 'string', 127 'sanitize_callback' => 'accodes_sanitize_raw_input', 128 'default' => '' 129 ] 130 ); 131 132 // Boolean option for global CSS in footer 133 register_setting( 134 'accodes-settings-group', 135 'accodes_global_css_on_footer', 136 [ 137 'type' => 'boolean', 138 'sanitize_callback' => 'rest_sanitize_boolean', 139 'default' => false 140 ] 141 ); 94 142 } 95 143 … … 118 166 } 119 167 168 function get_current_taxonomy_id() { 169 if (is_tax() || is_category() || is_tag()) { 170 $term = get_queried_object(); 171 if (!empty($term) && !is_wp_error($term)) { 172 return $term->term_id; 173 } 174 } 175 return false; 176 } 177 120 178 /*--------------------------------- 121 179 output Global CSS … … 126 184 $options = get_option( 'custom-css-codes-input' ); 127 185 if($options!='') 128 { 129 $accodes_global_css = '<!-- Global CSS by Add Custom Codes -->'. PHP_EOL; 130 $accodes_global_css .= '<style type="text/css">'; 131 $accodes_global_css .= ''. PHP_EOL; 132 $accodes_global_css .= $options; 133 $accodes_global_css .= ''. PHP_EOL.'</style>'.PHP_EOL; 134 $accodes_global_css .= '<!-- End - Global CSS by Add Custom Codes -->'; 186 { 187 $accodes_global_css = $options; 135 188 } 136 189 return $accodes_global_css; … … 141 194 function accodes_css_output_header() { 142 195 //check if global css to be added before footer 143 $css_on_footer = esc_attr( get_option('accodes_global_css_on_footer') );196 $css_on_footer = (bool) get_option('accodes_global_css_on_footer', false); 144 197 //put css in footer not ticked 145 if( $css_on_footer != 'on')198 if(!$css_on_footer) 146 199 { 147 200 $accodes_global_css = get_global_custom_css(); 148 echo $accodes_global_css; 201 //escape 202 echo '<!-- Global CSS by Add Custom Codes --> <style type="text/css"> '.esc_html($accodes_global_css).' </style> <!-- End - Global CSS by Add Custom Codes -->'; 149 203 } 150 204 } … … 153 207 function accodes_css_output_footer() { 154 208 //check if global css to be added before footer 155 $css_on_footer = esc_attr( get_option('accodes_global_css_on_footer') );209 $css_on_footer = (bool) get_option('accodes_global_css_on_footer', false); 156 210 //put css in footer ticked 157 if($css_on_footer == 'on')211 if($css_on_footer) 158 212 { 159 213 $accodes_global_css = get_global_custom_css(); 160 echo $accodes_global_css; 214 //escape 215 echo '<!-- Global CSS by Add Custom Codes --> <style type="text/css"> '.esc_html($accodes_global_css).' </style> <!-- End - Global CSS by Add Custom Codes -->'; 161 216 } 162 217 } … … 169 224 $hide_global_header = ''; 170 225 $current_page_id = get_current_page_id(); 226 $current_taxonomy_id = get_current_taxonomy_id(); 171 227 $global_header_codes =''; 228 $get_single_header_codes = ''; 172 229 $single_header_codes = ''; 230 $get_taxonomy_header_codes = ''; 231 $taxonomy_header_codes = ''; 173 232 $output = ''; 174 233 234 //check if single page 175 235 if ( $current_page_id ) { 176 236 //value is 'on' if checked … … 186 246 } 187 247 248 //check if taxonomy page 249 if ( $current_taxonomy_id ) { 250 //value is 'on' if checked 251 $hide_global_header = get_term_meta( $current_taxonomy_id, 'accodes_hide_header', true ); 252 //get Single Header Codes 253 $get_taxonomy_header_codes = get_term_meta( $current_taxonomy_id , '_accodes_header_metabox', true ); 254 if($get_taxonomy_header_codes !='') 255 { 256 $taxonomy_header_codes = PHP_EOL.'<!-- Taxonomy header Scripts by Add Custom Codes -->'. PHP_EOL; 257 $taxonomy_header_codes .= $get_taxonomy_header_codes; 258 $taxonomy_header_codes .= PHP_EOL.'<!-- End of Taxonomy header Scripts by Add Custom Codes -->'. PHP_EOL; 259 } 260 } 261 188 262 //get global header - if not set to hide 189 263 if($hide_global_header != 'on') … … 193 267 if($get_global_header_codes!='') 194 268 { 195 $global_header_codes = PHP_EOL.'<!-- Global Header Scripts by Add Custom Codes -->'. PHP_EOL;269 $global_header_codes = ' <!-- Global Header Scripts by Add Custom Codes --> '; 196 270 $global_header_codes .= $get_global_header_codes; 197 $global_header_codes .= PHP_EOL.'<!-- End - Global Header Scripts by Add Custom Codes -->'. PHP_EOL;271 $global_header_codes .= ' <!-- End - Global Header Scripts by Add Custom Codes --> '; 198 272 } 199 273 } 200 274 $output .= $global_header_codes; 201 275 $output .= $single_header_codes; 276 $output .= $taxonomy_header_codes; 202 277 203 278 if($output !='') 204 279 { 280 //escape 205 281 echo $output; 206 282 } … … 218 294 $hide_global_footer = ''; 219 295 $current_page_id = get_current_page_id(); 296 $current_taxonomy_id = get_current_taxonomy_id(); 220 297 $global_footer_codes =''; 221 298 $single_footer_codes = ''; 299 $taxonomy_footer_codes = ''; 222 300 $output = ''; 223 301 … … 235 313 } 236 314 315 //check if taxonomy page 316 if ( $current_taxonomy_id ) { 317 //value is 'on' if checked 318 $hide_global_footer = get_term_meta( $current_taxonomy_id, 'accodes_hide_footer', true ); 319 //get Single Header Codes 320 $get_taxonomy_footer_codes = get_term_meta( $current_taxonomy_id , '_accodes_footer_metabox', true ); 321 if($get_taxonomy_footer_codes !='') 322 { 323 $taxonomy_footer_codes = PHP_EOL.'<!-- Taxonomy footer Scripts by Add Custom Codes -->'. PHP_EOL; 324 $taxonomy_footer_codes .= $get_taxonomy_footer_codes; 325 $taxonomy_footer_codes .= PHP_EOL.'<!-- End of Taxonomy footer Scripts by Add Custom Codes -->'. PHP_EOL; 326 } 327 } 328 237 329 //get global footer - if not set to hide 238 330 if($hide_global_footer != 'on') … … 249 341 $output .= $global_footer_codes; 250 342 $output .= $single_footer_codes; 343 $output .= $taxonomy_footer_codes; 251 344 252 345 if($output !='') 253 346 { 347 //escape 254 348 echo $output; 255 349 } … … 263 357 * -----------------------*/ 264 358 265 /** 359 /**----------------------------- 266 360 * Create the meta boxes for Single post, page, product any other custom post type 267 */361 ------------------------------------*/ 268 362 function _accodes_create_metabox_single() { 269 363 … … 272 366 273 367 foreach ( $post_types as $post_type ) { 274 add_meta_box( '_accodes_metabox', 'Add Custom Codes by Mak', '_accodes_render_metabox', $post_type, 275 'normal', 'default'); 368 add_meta_box( 369 '_accodes_metabox', 370 'Add Custom Codes by Mak', 371 '_accodes_render_metabox', 372 $post_type, 373 'normal', 374 'default' 375 ); 276 376 } 277 377 … … 294 394 $hide_footer = get_post_meta( $post->ID, 'accodes_hide_footer', true ); 295 395 296 include('single-meta.php'); 297 298 /* check if the submission come from actual server dashboard */ 299 wp_nonce_field( '_accodes_form_metabox_nonce', '_accodes_form_metabox_process' ); 396 include('single-meta.php'); 300 397 301 398 } … … 307 404 function _accodes_save_metabox_single( $post_id, $post ) { 308 405 309 // Verify data came from edit/dashboard screen 310 if ( !wp_verify_nonce( $_POST['_accodes_form_metabox_process'], '_accodes_form_metabox_nonce' ) ) { 311 return $post->ID; 312 } 313 406 407 // Verify nonce for security 408 if ( !isset($_POST['accodes_meta_nonce']) || !wp_verify_nonce($_POST['accodes_meta_nonce'], 'accodes_save_meta') ) { 409 return $post_id; 410 } 411 314 412 // Verify user has permission to edit post 315 413 if ( !current_user_can( 'edit_post', $post->ID )) { 316 414 return $post->ID; 317 415 } 318 319 //Get values of meta boxes 320 $accodes_header_metabox = isset( $_POST['_accodes_header_metabox'] ) ? $_POST['_accodes_header_metabox'] : ''; 321 $accodes_footer_metabox = isset( $_POST['_accodes_footer_metabox'] ) ? $_POST['_accodes_footer_metabox'] : ''; 416 417 // Check if we're in the WordPress REST API request (used by Gutenberg) 418 if (defined('REST_REQUEST') && REST_REQUEST) { 419 return $post_id; 420 } 421 422 // Check if it's an autosave or a revision. If so, return early. 423 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { 424 return $post_id; 425 } 426 427 428 $allowed_html = [ 429 'script' => ['type' => [], 'src' => [], 'async' => [], 'defer' => []], 430 'style' => ['type' => []], 431 'meta' => ['name' => [], 'content' => [], 'charset' => []], 432 'link' => ['rel' => [], 'href' => [], 'type' => []], 433 'div' => ['class' => [], 'id' => [], 'style' => []], 434 'span' => ['class' => [], 'style' => []], 435 'p' => ['class' => [], 'style' => []], 436 'a' => ['href' => [], 'title' => [], 'target' => []], 437 'img' => ['src' => [], 'alt' => [], 'width' => [], 'height' => []], 438 'iframe' => ['src' => [], 'width' => [], 'height' => [], 'frameborder' => [], 'allowfullscreen' => []], 439 ]; 440 441 442 $accodes_header_metabox = isset($_POST['_accodes_header_metabox']) 443 ? wp_kses(wp_unslash($_POST['_accodes_header_metabox']), $allowed_html) 444 : ''; 445 446 $accodes_footer_metabox = isset($_POST['_accodes_footer_metabox']) 447 ? wp_kses(wp_unslash($_POST['_accodes_footer_metabox']), $allowed_html) 448 : ''; 322 449 323 450 // Get values of checkbox 324 $hide_header = isset( $_POST['accodes_hide_header'] ) ? $_POST['accodes_hide_header']: '';325 $hide_footer = isset( $_POST['accodes_hide_footer'] ) ? $_POST['accodes_hide_footer']: '';451 $hide_header = isset( $_POST['accodes_hide_header'] ) ? sanitize_text_field(wp_unslash($_POST['accodes_hide_header']) ): ''; 452 $hide_footer = isset( $_POST['accodes_hide_footer'] ) ? sanitize_text_field(wp_unslash($_POST['accodes_hide_footer']) ): ''; 326 453 327 454 //Update values of meta boxes … … 335 462 } 336 463 add_action( 'save_post', '_accodes_save_metabox_single', 1, 2 ); 464 465 466 /* 467 * single meta end 468 * -----------------------------------------------*/ 469 470 function get_current_term_id() { 471 if (isset($_GET['tag_ID'])) { 472 return intval($_GET['tag_ID']); 473 } 474 return 0; 475 } 476 477 // Register meta box 478 function accodes_render_taxonomy_meta_box() { 479 $taxonomies = get_taxonomies(); 480 foreach ($taxonomies as $taxonomy) { 481 add_action("{$taxonomy}_edit_form", function($tag) use ($taxonomy) { 482 $term_id = get_current_term_id(); 483 $header_script = get_term_meta( $term_id, '_accodes_header_metabox', true ); 484 $footer_script = get_term_meta( $term_id, '_accodes_footer_metabox', true ); 485 $hide_header = get_term_meta( $term_id, 'accodes_hide_header', true ); 486 $hide_footer = get_term_meta( $term_id, 'accodes_hide_footer', true ); 487 include('taxonomy-meta.php'); 488 }); 489 } 490 491 } 492 add_action('admin_init', 'accodes_render_taxonomy_meta_box'); 493 494 // Save meta box data of taxonomies 495 function accodes_save_taxonomy_meta_data($term_id) { 496 497 // Verify nonce for security 498 if (!isset($_POST['accodes_tax_meta_nonce']) || !wp_verify_nonce($_POST['accodes_tax_meta_nonce'], 'accodes_save_tax_meta')) { 499 return $term_id; 500 } 501 502 $allowed_html = [ 503 'script' => ['type' => [], 'src' => [], 'async' => [], 'defer' => []], 504 'style' => ['type' => []], 505 'meta' => ['name' => [], 'content' => [], 'charset' => []], 506 'link' => ['rel' => [], 'href' => [], 'type' => []], 507 'div' => ['class' => [], 'id' => [], 'style' => []], 508 'span' => ['class' => [], 'style' => []], 509 'p' => ['class' => [], 'style' => []], 510 'a' => ['href' => [], 'title' => [], 'target' => []], 511 'img' => ['src' => [], 'alt' => [], 'width' => [], 'height' => []], 512 'iframe' => ['src' => [], 'width' => [], 'height' => [], 'frameborder' => [], 'allowfullscreen' => []], 513 ]; 514 515 516 //get value of meta boxes 517 $accodes_header_metabox = isset($_POST['_accodes_header_metabox']) 518 ? wp_kses(wp_unslash($_POST['_accodes_header_metabox']), $allowed_html) 519 : ''; 520 521 $accodes_footer_metabox = isset($_POST['_accodes_footer_metabox']) 522 ? wp_kses(wp_unslash($_POST['_accodes_footer_metabox']), $allowed_html) 523 : ''; 524 525 // Get values of checkbox 526 $hide_header = isset( $_POST['accodes_hide_header'] ) ? sanitize_text_field(wp_unslash($_POST['accodes_hide_header'])) : ''; 527 $hide_footer = isset( $_POST['accodes_hide_footer'] ) ? sanitize_text_field(wp_unslash($_POST['accodes_hide_footer']) ): ''; 528 529 //Update values of meta boxes 530 update_term_meta( $term_id, '_accodes_header_metabox', $accodes_header_metabox ); 531 update_term_meta( $term_id, '_accodes_footer_metabox', $accodes_footer_metabox ); 532 533 //Update values of check boxes 534 update_term_meta( $term_id, 'accodes_hide_header', $hide_header ); 535 update_term_meta( $term_id, 'accodes_hide_footer', $hide_footer ); 536 } 537 add_action('edited_term', 'accodes_save_taxonomy_meta_data'); 538 add_action('create_term', 'accodes_save_taxonomy_meta_data'); 539 540 541 337 542 ?> -
add-custom-codes/trunk/css/style43.css
r3255818 r3255819 4 4 border-radius: 0px; 5 5 padding: 5px 21px; 6 border-radius: 5px;7 background: # 0b7c8e;6 border-radius: 40px; 7 background: #1799cb; 8 8 } 9 9 .accodes_cols #submit:hover { 10 background: # 086d7d;10 background: #333; 11 11 } 12 12 .accodes_cols p, … … 39 39 width: 65%; 40 40 float: left; 41 background: #f afdff;41 background: #fff; 42 42 padding: 20px 30px; 43 43 box-sizing: border-box; 44 border: 1px solid # fff;44 border: 1px solid #d5edf1; 45 45 } 46 46 … … 100 100 /* Single page meta */ 101 101 #_accodes_metabox.postbox .inside { 102 background: #f afdff;102 background: #fff; 103 103 padding: 20px 30px; 104 104 box-sizing: border-box; … … 145 145 font-weight: 500; 146 146 } 147 148 .accodes-taxonomy-edit 149 { 150 background: #fff; 151 padding: 20px; 152 border: 1px solid #ccc; 153 } -
add-custom-codes/trunk/global-form.php
r2884088 r3255819 6 6 ?> 7 7 <?php if (isset($_GET['settings-updated'])) : ?> 8 <div class="notice notice-success is-dismissible"><p><?php _e('Changes saved! Please clear your cache if the changes are not reflected on the website.'); ?></p></div>9 <?php endif ;?>8 <div class="notice notice-success is-dismissible"><p><?php esc_html_e('Changes saved! Please clear your cache if the changes are not reflected on the website.', 'add-custom-codes'); ?></p></div> 9 <?php endif ?> 10 10 11 11 <div class="wrap"> 12 <h2><?php _e( 'Add Custom Codes by Mak', 'add-custom-codes' ) ?></h2>12 <h2><?php esc_html_e( 'Add Custom Codes by Mak', 'add-custom-codes' ) ?></h2> 13 13 <div class="full_row"> 14 14 <div class="accodes_cols"> 15 15 <form method="post" action="options.php"> 16 16 <?php settings_fields( 'accodes-settings-group' ); ?> 17 <?php wp_nonce_field('accodes_save_settings', 'accodes_nonce'); ?> 17 18 <?php do_settings_sections( 'accodes-settings-group' ); ?> 18 19 … … 21 22 $global_css = get_option('custom-css-codes-input'); 22 23 ?> 23 <p><label for="custom-css-codes-input" class="accodes-label green-label"><?php _e( 'Custom CSS (Global)', 'add-custom-codes' ) ?></label><br/>24 <p><label for="custom-css-codes-input" class="accodes-label green-label"><?php esc_html_e( 'Custom CSS (Global)', 'add-custom-codes' ) ?></label><br/> 24 25 You can add custom css (global) codes below. DO NOT INCLUDE <em><style></em> and <em></style></em> tags:</p> 25 26 <textarea class="codemirror-accodes-css" id="custom-css-codes-input" name="custom-css-codes-input"><?php echo esc_attr( $global_css ); ?></textarea> 26 27 27 28 <?php 28 $css_on_footer ='';29 $css_on_footer = esc_attr( get_option('accodes_global_css_on_footer'));29 // $css_on_footer =''; 30 $css_on_footer = get_option('accodes_global_css_on_footer', false); 30 31 ?> 31 32 <p> 32 33 <label for="accodes_global_css_on_footer" class="accodes-checkbox-label"> 33 <input type="checkbox" <?php echo checked( $css_on_footer, 'on', false )?>34 name="accodes_global_css_on_footer" id="accodes_global_css_on_footer" />35 <?php _e( "Insert Custom CSS before <em></body></em> of website.", 'add-custom-codes' ); ?>34 <input type="checkbox" <?php echo checked( $css_on_footer, 1, false ); ?> 35 name="accodes_global_css_on_footer" id="accodes_global_css_on_footer" value="1"/> 36 <?php esc_html_e( "Insert Custom CSS before <em></body></em> of website.", 'add-custom-codes' ); ?> 36 37 </label><br/> 37 <?php _e( "By default, Custom CSS will be added before <em></head></em> section of your website.", 'add-custom-codes' ); ?>38 <?php esc_html_e( "By default, Custom CSS will be added before <em></head></em> section of your website.", 'add-custom-codes' ); ?> 38 39 </p> 39 40 <?php submit_button(); ?> … … 43 44 44 45 <p><label for="custom-header-codes-input" class="accodes-label green-label"> 45 <?php _e( 'Global Header Codes', 'add-custom-codes' ) ?></label><br/>46 <?php esc_html_e( 'Global Header Codes', 'add-custom-codes' ) ?></label><br/> 46 47 Global Codes or scripts to add before <em></head></em> section of your website. Google Search Console Verification, Bing Verification and any other codes. Include <em><script></em> and <em></script></em> tags when necessary: </p> 47 48 <textarea class="codemirror" id="custom-verification-codes-input" name="custom-header-codes-input"><?php echo esc_attr(get_option('custom-header-codes-input') ); ?></textarea> … … 51 52 52 53 <p><label for="custom-footer-codes-input" class="accodes-label green-label"> 53 <?php _e( 'Global Footer Codes', 'add-custom-codes' ) ?></label><br/>54 <?php esc_html_e( 'Global Footer Codes', 'add-custom-codes' ) ?></label><br/> 54 55 Global Codes or scripts to add before <em></body></em> section of your website. You can add Google Anaylytics Tracking Code, Facebook Scripts, third party ad scripts etc here. Include <em><script></em> and <em></script></em> tags when necessary: </p> 55 56 <textarea class="codemirror" placeholder="" id="custom-analytics-codes-input" name="custom-footer-codes-input"><?php echo esc_attr( get_option('custom-footer-codes-input') ); ?></textarea> … … 68 69 </div> 69 70 </div> 70 71 <div class="clear"></div> 71 72 </div> -
add-custom-codes/trunk/readme.txt
r3019452 r3255819 2 2 Contributors: SaifuMak 3 3 Donate link: https://donate.stripe.com/9AQdRz5xJ87c9i0bIS 4 Tags: custom css, google analytics, header codes, footer codes, c ss, javascript, custom codes, wordpress custom css5 Requires at least: 6. 06 Tested up to: 6. 4.24 Tags: custom css, google analytics, header codes, footer codes, custom codes 5 Requires at least: 6.6.2 6 Tested up to: 6.7.2 7 7 Requires PHP: 7.4 8 Stable tag: 4. 68 Stable tag: 4.7 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 11 12 Add custom codes to your wordpress website. A completely free plugin to add Custom CSS, Javascript, Google Analytics, Search console verification orany other codes to your website.12 Add custom codes to your wordpress site. A completely free plugin to add Custom CSS, Javascript, Google Analytics, any other codes to your website. 13 13 14 14 == Description == … … 100 100 * Tested to work with latest Wordpress 101 101 102 = 4.7 = 103 * Bugfixes and improvements 104 * Tested to work with latest Wordpress 105 * Option to Add custom codes to taxonomy pages 106 102 107 == Upgrade Notice == 103 108 … … 131 136 = 4.6 = 132 137 Tested to work with latest Wordpress 138 139 = 4.7 = 140 Bug fixes & improvements. Option to add Custom Codes to taxonomy pages. -
add-custom-codes/trunk/single-meta.php
r2884088 r3255819 5 5 } 6 6 ?> 7 <?php 8 function accodes_is_gutenberg_active() { 9 // Check if we're on a post edit screen and Gutenberg is loaded 10 $current_screen = get_current_screen(); 11 return (function_exists('is_gutenberg_page') && is_gutenberg_page()) 12 || (isset($current_screen->is_block_editor) && $current_screen->is_block_editor) 13 || (defined('REST_REQUEST') && REST_REQUEST); 14 } 15 ?> 16 <div class="acc-ind-col-1 "> 17 <?php wp_nonce_field('accodes_save_meta', 'accodes_meta_nonce'); ?> 7 18 8 <div class="acc-ind-col-1 ">9 19 <fieldset class="accodes_ind_field"> 10 20 <div> … … 12 22 <label for="_accodes_header_metabox" class="first-label accodes-label green-label"> 13 23 <?php 14 // This runs the text through a translation and echoes it (for internationalization)15 _e( 'Header Codes', 'add-custom-codes' );24 // escape 25 esc_html_e( 'Header Codes', 'add-custom-codes' ); 16 26 ?> 17 27 </label> 18 <?php _e( "Codes & scripts to add before <em></head></em> section of this page. Use <em><script> </script></em>, <em><style> </style></em> tags when necessary.", 'add-custom-codes' ); ?>28 <?php esc_html_e( "Codes & scripts to add before <em></head></em> section of this page. Use <em><script> </script></em>, <em><style> </style></em> tags when necessary.", 'add-custom-codes' ); ?> 19 29 </p> 20 30 <textarea 21 31 type="text" 22 32 name="_accodes_header_metabox" 23 id="_accodes_header_metabox" class=" codemirror small-codemirror"24 ><?php echo esc_ attr( $header_script ); ?></textarea>33 id="_accodes_header_metabox" class="<?php if (!accodes_is_gutenberg_active()) { echo "codemirror small-codemirror";} ?>" 34 ><?php echo esc_textarea($header_script) ; ?></textarea> 25 35 </div> 26 36 <p> 27 <label for="accodes_hide_header" class="accodes-checkbox-label ">37 <label for="accodes_hide_header" class="accodes-checkbox-label "> 28 38 <input type="checkbox" <?php echo checked( $hide_header, 'on', false ) ?> 29 39 name="accodes_hide_header" id="accodes_hide_header"/> 30 <?php _e( "Hide Global Header Codes on this page", 'add-custom-codes' ); ?>40 <?php esc_html_e( "Hide Global Header Codes on this page", 'add-custom-codes' ); ?> 31 41 </label> 32 <?php _e( "Go to <em>Appearance -> Add Custom Codes</em> to see your Global Header Codes", 'add-custom-codes' ); ?>42 <?php esc_html_e( "Go to <em>Appearance -> Add Custom Codes</em> to see your Global Header Codes", 'add-custom-codes' ); ?> 33 43 </p> 34 44 </fieldset> … … 39 49 <label for="_accodes_footer_metabox" class="accodes-label green-label"> 40 50 <?php 41 _e( 'Footer Codes', 'add-custom-codes' );51 esc_html_e( 'Footer Codes', 'add-custom-codes' ); 42 52 ?> 43 53 </label> 44 <?php _e( "Codes & scripts to add before <em></body></em> section of this page. Use <em><script> </script></em>, <em><style> </style></em> tags when necessary.", 'add-custom-codes' ); ?>54 <?php esc_html_e( "Codes & scripts to add before <em></body></em> section of this page. Use <em><script> </script></em>, <em><style> </style></em> tags when necessary.", 'add-custom-codes' ); ?> 45 55 </p> 46 56 <textarea 47 57 type="text" 48 58 name="_accodes_footer_metabox" 49 id="_accodes_footer_metabox" class=" codemirror small-codemirror"50 ><?php echo esc_ attr( $footer_script ); ?></textarea>59 id="_accodes_footer_metabox" class="<?php if (!accodes_is_gutenberg_active()) { echo "codemirror small-codemirror";} ?>" 60 ><?php echo esc_textarea($footer_script) ; ?></textarea> 51 61 <p> 52 62 <label for="accodes_hide_footer" class="accodes-checkbox-label"> 53 63 <input type="checkbox" <?php echo checked( $hide_footer, 'on', false ) ?> 54 64 name="accodes_hide_footer" id="accodes_hide_footer"/> 55 <?php _e( "Hide Global Footer Codes on this page", 'add-custom-codes' ); ?>65 <?php esc_html_e( "Hide Global Footer Codes on this page", 'add-custom-codes' ); ?> 56 66 </label> 57 <?php _e( "Go to <em>Appearance -> Add Custom Codes</em> to see your Global Footer Codes", 'add-custom-codes' ); ?>67 <?php esc_html_e( "Go to <em>Appearance -> Add Custom Codes</em> to see your Global Footer Codes", 'add-custom-codes' ); ?> 58 68 </p> 59 69 </div>
Note: See TracChangeset
for help on using the changeset viewer.