Plugin Directory

Changeset 3255819


Ignore:
Timestamp:
03/14/2025 10:46:57 AM (10 months ago)
Author:
SaifuMak
Message:

version 4.7 release

Location:
add-custom-codes/trunk
Files:
1 added
4 edited
2 moved

Legend:

Unmodified
Added
Removed
  • add-custom-codes/trunk/add-custom-codes.php

    r3019452 r3255819  
    33 * Plugin Name: Add Custom Codes - Insert Header, Footer, Custom Code Snippets
    44 * 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.6
     5 * Version: 4.7
    66 * Author: Saifudheen Mak
    77 * Author URI: https://maktalseo.com
     
    2323plugin links 'Plugins' page
    2424------------------*/
    25 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'add_action_links_accodes' );
     25add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'accodes_action_links' );
    2626 
    27 function add_action_links_accodes ( $actions ) {
     27function accodes_action_links ( $actions ) {
    2828   $mylinks = array(
    2929      '<a href="' . admin_url( 'themes.php?page=add-custom-codes' ) . '">Settings</a>',
     
    3333}
    3434
    35 add_filter( 'plugin_row_meta', 'plugin_row_meta_accodes', 10, 2 );
    36 
    37 function plugin_row_meta_accodes( $links, $file ) {   
     35add_filter( 'plugin_row_meta', 'accodes_row_meta', 10, 2 );
     36
     37function accodes_row_meta( $links, $file ) {   
    3838    if ( plugin_basename( __FILE__ ) == $file ) {
    3939        $row_meta = array(     
    4040          '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>'               
    4442        );
    45 
    4643        return array_merge( $links, $row_meta );
    4744    }
     
    5350-----------------------------------------*/
    5451
    55 add_action('admin_enqueue_scripts', 'codemirror_enqueue_scripts');
     52add_action('admin_enqueue_scripts', 'accodes_codemirror_scripts');
    5653 
    57 function codemirror_enqueue_scripts($hook) {
     54function accodes_codemirror_scripts($hook) {
    5855    $cm_settings['codeEditor'] = wp_enqueue_code_editor(array('type' => 'htmlmixed'));
    5956    wp_localize_script('jquery', 'cm_settings', $cm_settings);
     
    6158    wp_enqueue_style('wp-codemirror');
    6259   
    63     wp_register_style( 'accodes-css', plugins_url( 'add-custom-codes/css/style41.css' ), '', '4.192' );
     60    wp_register_style( 'accodes-css', plugins_url( 'add-custom-codes/css/style43.css' ), '', '4.193' );
    6461        wp_enqueue_style( 'accodes-css' );
    6562   
    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' );
    6865   
    6966}
     
    7269add menu link for plugin settings page
    7370------------------------*/
    74 add_action('admin_menu', 'accodes_menu');
    75 
    76 function accodes_menu() {
     71add_action('admin_menu', 'accodes_show_menu');
     72
     73function accodes_show_menu() {
    7774    add_theme_page('Add Custom Codes', 'Add Custom Codes', 'administrator', 'add-custom-codes', 'accodes_settings_page');
    7875}
    7976
    8077function 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');
    8283}
    8384
     
    8586define items in settings page
    8687-------------------------------*/
    87 add_action( 'admin_init', 'accodes_settings' );
     88
     89function 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
     96add_action('admin_init', 'accodes_settings');
    8897
    8998function 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    );
    94142}
    95143
     
    118166}
    119167
     168function 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
    120178/*---------------------------------
    121179output Global CSS
     
    126184        $options  = get_option( 'custom-css-codes-input' );
    127185        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;
    135188        }
    136189    return $accodes_global_css;
     
    141194function accodes_css_output_header() {
    142195    //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);
    144197    //put css in footer not ticked
    145     if($css_on_footer != 'on')
     198    if(!$css_on_footer)
    146199    {
    147200        $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 -->';
    149203    }
    150204}
     
    153207function accodes_css_output_footer() {
    154208    //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);
    156210    //put css in footer ticked
    157     if($css_on_footer == 'on')
     211    if($css_on_footer)
    158212    {
    159213        $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 -->';
    161216    }
    162217}
     
    169224    $hide_global_header = '';
    170225    $current_page_id = get_current_page_id();
     226    $current_taxonomy_id =  get_current_taxonomy_id();
    171227    $global_header_codes ='';
     228    $get_single_header_codes = '';
    172229    $single_header_codes = '';
     230    $get_taxonomy_header_codes = '';
     231    $taxonomy_header_codes = '';
    173232    $output = '';
    174233   
     234    //check if single page
    175235    if ( $current_page_id ) {
    176236        //value is 'on' if checked
     
    186246    }
    187247   
     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   
    188262    //get global header - if not set to hide
    189263    if($hide_global_header != 'on')
     
    193267        if($get_global_header_codes!='')
    194268        {
    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 --> ';
    196270            $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 --> ';
    198272        } 
    199273    }
    200274    $output .= $global_header_codes;
    201275    $output .= $single_header_codes;
     276    $output .= $taxonomy_header_codes;
    202277   
    203278    if($output !='')
    204279    {
     280        //escape
    205281        echo $output;
    206282    }
     
    218294    $hide_global_footer = '';
    219295    $current_page_id = get_current_page_id();
     296    $current_taxonomy_id = get_current_taxonomy_id();
    220297    $global_footer_codes ='';
    221298    $single_footer_codes = '';
     299    $taxonomy_footer_codes = '';
    222300    $output = '';
    223301   
     
    235313    }
    236314   
     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   
    237329    //get global footer - if not set to hide
    238330    if($hide_global_footer != 'on')
     
    249341    $output .= $global_footer_codes;
    250342    $output .= $single_footer_codes;
     343    $output .= $taxonomy_footer_codes;
    251344   
    252345    if($output !='')
    253346    {
     347        //escape
    254348        echo $output;
    255349    }
     
    263357 * -----------------------*/
    264358
    265 /**
     359/**-----------------------------
    266360 * Create the meta boxes for Single post, page, product any other custom post type
    267  */
     361 ------------------------------------*/
    268362function _accodes_create_metabox_single() {
    269363   
     
    272366
    273367    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                    );
    276376    }
    277377
     
    294394    $hide_footer  = get_post_meta( $post->ID, 'accodes_hide_footer', true );
    295395   
    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');
    300397   
    301398}
     
    307404function _accodes_save_metabox_single( $post_id, $post ) {
    308405
    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   
    314412    // Verify user has permission to edit post
    315413    if ( !current_user_can( 'edit_post', $post->ID )) {
    316414        return $post->ID;
    317415    }
    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    : '';
    322449   
    323450    // 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']) ): '';
    326453   
    327454    //Update values of meta boxes
     
    335462}
    336463add_action( 'save_post', '_accodes_save_metabox_single', 1, 2 );
     464
     465
     466/*
     467 * single meta end
     468 * -----------------------------------------------*/
     469
     470function 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
     478function 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}
     492add_action('admin_init', 'accodes_render_taxonomy_meta_box');
     493
     494// Save meta box data of taxonomies
     495function 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}
     537add_action('edited_term', 'accodes_save_taxonomy_meta_data');
     538add_action('create_term', 'accodes_save_taxonomy_meta_data');
     539
     540
     541
    337542?>
  • add-custom-codes/trunk/css/style43.css

    r3255818 r3255819  
    44    border-radius: 0px;
    55    padding: 5px 21px;
    6     border-radius: 5px;
    7     background: #0b7c8e;
     6    border-radius: 40px;
     7    background: #1799cb;
    88}
    99.accodes_cols #submit:hover {
    10     background: #086d7d;
     10    background: #333;
    1111}
    1212.accodes_cols p,
     
    3939    width: 65%;
    4040    float: left;
    41     background: #fafdff;
     41    background: #fff;
    4242    padding: 20px 30px;
    4343    box-sizing: border-box;
    44     border: 1px solid #fff;
     44    border: 1px solid #d5edf1;
    4545}
    4646
     
    100100/* Single page meta */
    101101#_accodes_metabox.postbox .inside {
    102     background: #fafdff;
     102    background: #fff;
    103103    padding: 20px 30px;
    104104    box-sizing: border-box;
     
    145145    font-weight: 500;
    146146}
     147
     148.accodes-taxonomy-edit
     149{
     150background: #fff;
     151  padding: 20px;
     152  border: 1px solid #ccc;
     153}
  • add-custom-codes/trunk/global-form.php

    r2884088 r3255819  
    66?>
    77<?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 ?>
    1010
    1111<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>
    1313<div class="full_row">
    1414    <div class="accodes_cols">
    1515        <form method="post" action="options.php">
    1616            <?php settings_fields( 'accodes-settings-group' ); ?>
     17            <?php wp_nonce_field('accodes_save_settings', 'accodes_nonce'); ?>
    1718            <?php do_settings_sections( 'accodes-settings-group' ); ?>
    1819           
     
    2122            $global_css = get_option('custom-css-codes-input');
    2223            ?>
    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/>
    2425You can add custom css (global) codes below. DO NOT INCLUDE <em>&lt;style&gt;</em> and <em>&lt;/style&gt;</em> tags:</p>   
    2526                <textarea class="codemirror-accodes-css" id="custom-css-codes-input" name="custom-css-codes-input"><?php echo esc_attr( $global_css ); ?></textarea>
    2627           
    2728            <?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);
    3031            ?>
    3132            <p>
    3233                <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>&lt;/body&gt;</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>&lt;/body&gt;</em> of website.", 'add-custom-codes' ); ?>
    3637                </label><br/>
    37                 <?php _e( "By default, Custom CSS will be added before <em>&lt;/head&gt;</em> section of your website.", 'add-custom-codes' ); ?>
     38                <?php esc_html_e( "By default, Custom CSS will be added before <em>&lt;/head&gt;</em> section of your website.", 'add-custom-codes' ); ?>
    3839            </p>
    3940            <?php submit_button(); ?>
     
    4344           
    4445                <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/>
    4647Global Codes or scripts to add before <em>&lt;/head&gt;</em> section of your website. Google Search Console Verification, Bing Verification and any other codes. Include <em>&lt;script&gt;</em> and <em>&lt;/script&gt;</em> tags when necessary: </p>
    4748                 <textarea class="codemirror" id="custom-verification-codes-input" name="custom-header-codes-input"><?php echo esc_attr(get_option('custom-header-codes-input') ); ?></textarea>   
     
    5152           
    5253            <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/>
    5455Global Codes or scripts to add before <em>&lt;/body&gt;</em> section of your website. You can add Google Anaylytics Tracking Code, Facebook Scripts, third party ad scripts etc here. Include <em>&lt;script&gt;</em> and <em>&lt;/script&gt;</em> tags when necessary: </p>
    5556                <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>   
     
    6869        </div>
    6970    </div>
    70 
     71<div class="clear"></div>
    7172</div>
  • add-custom-codes/trunk/readme.txt

    r3019452 r3255819  
    22Contributors: SaifuMak
    33Donate link: https://donate.stripe.com/9AQdRz5xJ87c9i0bIS
    4 Tags: custom css, google analytics, header codes, footer codes, css, javascript, custom codes, wordpress custom css
    5 Requires at least: 6.0
    6 Tested up to: 6.4.2
     4Tags: custom css, google analytics, header codes, footer codes, custom codes
     5Requires at least: 6.6.2
     6Tested up to: 6.7.2
    77Requires PHP: 7.4
    8 Stable tag: 4.6
     8Stable tag: 4.7
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1111
    12 Add custom codes to your wordpress website. A completely free plugin to add Custom CSS, Javascript, Google Analytics, Search console verification or any other codes to your website.
     12Add custom codes to your wordpress site. A completely free plugin to add Custom CSS, Javascript, Google Analytics, any other codes to your website.
    1313
    1414== Description ==
     
    100100* Tested to work with latest Wordpress
    101101
     102= 4.7 =
     103* Bugfixes and improvements
     104* Tested to work with latest Wordpress
     105* Option to Add custom codes to taxonomy pages
     106
    102107== Upgrade Notice ==
    103108
     
    131136= 4.6 =
    132137Tested to work with latest Wordpress
     138
     139= 4.7 =
     140Bug fixes & improvements. Option to add Custom Codes to taxonomy pages.
  • add-custom-codes/trunk/single-meta.php

    r2884088 r3255819  
    55}
    66?>
     7<?php
     8function 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'); ?>
    718
    8 <div class="acc-ind-col-1 ">
    919        <fieldset class="accodes_ind_field">
    1020            <div>
     
    1222                <label for="_accodes_header_metabox" class="first-label accodes-label green-label">
    1323                    <?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' );
    1626                    ?>
    1727                </label>
    18                     <?php _e( "Codes & scripts to add before <em>&lt;/head&gt;</em> section of this page. Use  <em>&lt;script&gt; &lt;/script&gt;</em>, <em>&lt;style&gt; &lt;/style&gt;</em> tags when necessary.", 'add-custom-codes' ); ?>
     28                    <?php esc_html_e( "Codes & scripts to add before <em>&lt;/head&gt;</em> section of this page. Use  <em>&lt;script&gt; &lt;/script&gt;</em>, <em>&lt;style&gt; &lt;/style&gt;</em> tags when necessary.", 'add-custom-codes' ); ?>
    1929    </p>
    2030                <textarea
    2131                    type="text"
    2232                    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>
    2535            </div>
    2636            <p>
    27                 <label for="accodes_hide_header" class="accodes-checkbox-label">
     37                <label for="accodes_hide_header" class="accodes-checkbox-label ">
    2838                            <input type="checkbox" <?php echo checked( $hide_header, 'on', false ) ?>
    2939                                   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' ); ?>
    3141                </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' ); ?>
    3343            </p>
    3444        </fieldset>
     
    3949                <label for="_accodes_footer_metabox" class="accodes-label green-label">
    4050                    <?php
    41                         _e( 'Footer Codes', 'add-custom-codes' );
     51                        esc_html_e( 'Footer Codes', 'add-custom-codes' );
    4252                    ?>
    4353                </label>
    44                     <?php _e( "Codes & scripts to add before <em>&lt;/body&gt;</em> section of this page. Use <em>&lt;script&gt; &lt;/script&gt;</em>, <em>&lt;style&gt; &lt;/style&gt;</em> tags when necessary.", 'add-custom-codes' ); ?>
     54                    <?php esc_html_e( "Codes & scripts to add before <em>&lt;/body&gt;</em> section of this page. Use <em>&lt;script&gt; &lt;/script&gt;</em>, <em>&lt;style&gt; &lt;/style&gt;</em> tags when necessary.", 'add-custom-codes' ); ?>
    4555    </p>
    4656                <textarea
    4757                    type="text"
    4858                    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>
    5161                <p>
    5262                <label for="accodes_hide_footer" class="accodes-checkbox-label">
    5363                            <input type="checkbox" <?php echo checked( $hide_footer, 'on', false ) ?>
    5464                                   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' ); ?>
    5666                        </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' ); ?>
    5868                </p>
    5969            </div>
Note: See TracChangeset for help on using the changeset viewer.