Plugin Directory

Changeset 3446052


Ignore:
Timestamp:
01/24/2026 10:08:19 AM (2 months ago)
Author:
jamesdlow
Message:

1.5.4

  • Add syntax highlighting for CSS/JS
Location:
css-js-files
Files:
7 added
4 edited

Legend:

Unmodified
Added
Removed
  • css-js-files/trunk/css-js-files.php

    r3208104 r3446052  
    44Plugin URI: https://wordpress.org/plugins/css-js-files/
    55Description: Add CSS files and/or CSS custom rules to any single page or post or globally
    6 Version: 1.5.3
     6Version: 1.5.4
    77Author: James Low
    88Author URI: http://jameslow.com
     
    1313
    1414class CSS_JS_Files {
     15    public static $_version;
     16    public static function version() {
     17        if (!self::$_version) {
     18            $data = get_plugin_data(__FILE__);
     19            self::$_version = $data['Version'];
     20        }
     21        return self::$_version;
     22    }
     23
    1524    public static function add_hooks() {
    1625        /* Define the custom box */
     
    179188        $screen = get_current_screen();
    180189        if (strpos($_SERVER['REQUEST_URI'],'post.php') !== false || strpos($screen->base, 'css-js-files')  !== false || strpos($screen->base, 'css-js-files-editor') !== false) {
    181             wp_enqueue_style('css-js-files.css', plugins_url('css/css-js-files.css', __FILE__));
    182             wp_enqueue_script('css-js-files.js', plugins_url('js/css-js-files.js', __FILE__), array(), '1.0.0', true);
     190            wp_enqueue_style('css-js-files.css', plugins_url('css/css-js-files.css', __FILE__), array(), self::version());
     191            wp_enqueue_script('css-js-files.js', plugins_url('js/css-js-files.js', __FILE__), array(), self::version(), true);
     192            wp_enqueue_code_editor(['type' => 'text/css']);
     193            wp_enqueue_code_editor(['type' => 'text/javascript']);
     194            wp_enqueue_code_editor(['type' => 'text/html']);
     195            wp_enqueue_script('wp-theme-plugin-editor');
     196            wp_enqueue_style('wp-codemirror');
    183197        }
    184198    }
     
    275289        echo '<h2>'.strtoupper($type).'</h2>';
    276290        echo '<div class="row"><label>Select '.$upper.' files</label><br />'.self::get_file(explode(',', $files), $type).' <button type="button" id="css-js-files-'.$type.'-button" class="css-js-files-button button button-primary button-large">Add other file</button><hr /></div>';
     291        echo '<div class="row"><label for="css-js-files-'.$type.'-rules">Enter '.$upper.' links here (one URL per line)</label><br /><textarea class="css-js-files-text" id="css-js-files-'.$type.'-links" name="css_js_files_'.$type.'_links">'.htmlentities($links).'</textarea></div>';
    277292        echo '<div class="row"><label for="css-js-files-'.$type.'-rules">Write your custom '.$upper.'</label><br /><textarea class="css-js-files-text" id="css-js-files-'.$type.'-rules" name="css_js_files_'.$type.'_rules">'.htmlentities($rules).'</textarea></div>';
    278         echo '<div class="row"><label for="css-js-files-'.$type.'-rules">Enter '.$upper.' links here</label><br /><textarea class="css-js-files-text" id="css-js-files-'.$type.'-links" name="css_js_files_'.$type.'_links">'.htmlentities($links).'</textarea></div>';
    279293        if ($post == null) {
    280294            echo '<div class="row"><label for="css-js-files-'.$type.'-admin">Enter admin '.$upper.' here</label><br /><textarea class="css-js-files-text" id="css-js-files-'.$type.'-admin" name="css_js_files_'.$type.'_admin">'.htmlentities($admin).'</textarea></div>';
  • css-js-files/trunk/css/css-js-files.css

    r1557309 r3446052  
    11.css-js-files-text {
    2     width:100%;
    3     min-height: 250px;
    4     box-sizing: border-box;
     2    width:100%;
     3    min-height: 250px;
     4    box-sizing: border-box;
    55}
    66.css-js-files-text-full {
    77    min-height: 1024px;
    88}
     9body.wp-block-editor .CodeMirror-wrap pre,
     10body.block-editor-page .CodeMirror-wrap pre {
     11    margin-left: 16px;
     12}
  • css-js-files/trunk/js/css-js-files.js

    r2407090 r3446052  
    1717            }
    1818        });
     19    }
     20
     21    function initEditor(id, mode) {
     22        console.log(initEditor);
     23        if ( ! window.wp || ! wp.codeEditor ) {
     24            return;
     25        }
     26
     27        const textarea = document.getElementById( id );
     28        if ( ! textarea ) {
     29            return;
     30        }
     31
     32        const settings = _.clone( wp.codeEditor.defaultSettings );
     33        settings.codemirror = settings.codemirror || {};
     34        settings.codemirror.mode = mode;
     35        settings.codemirror.lineNumbers = false;
     36        settings.codemirror.autoCloseBrackets = true;
     37
     38        wp.codeEditor.initialize( textarea, settings );
    1939    }
    2040   
     
    5676    init('css');
    5777    init('js');
     78    document.addEventListener( 'DOMContentLoaded', function () {
     79        initEditor('css-js-files-css-rules', 'css');
     80        initEditor('css-js-files-css-admin', 'css');
     81        initEditor('css-js-files-js-rules', 'javascript');
     82        initEditor('css-js-files-js-admin', 'javascript');
     83        initEditor('css-js-files-head-rules', 'htmlmixed');
     84        initEditor('css-js-files-body-rules', 'htmlmixed');
     85        initEditor('css-js-files-footer-rules', 'htmlmixed');
     86    });
    5887}(jQuery));
  • css-js-files/trunk/readme.txt

    r3208104 r3446052  
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=PGV92BZCFTDL4&item_name=Donation%20to%20jameslow%2ecom&currency_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8
    44Tags: css, page, post, custom css, file css, js, javascript, file js, custom js, custom, global, cdn
    5 Requires at least: 3.0
     5Requires at least: 4.9.0
    66Tested up to: 6.5.5
    7 Stable tag: 1.5.3
     7Stable tag: trunk
    88License: MIT Licens
    99License URI: https://opensource.org/licenses/MIT
     
    2929
    3030== Changelog ==
     31
     32= 1.5.4 =
     33* Add syntax highlighting for CSS/JS
    3134
    3235= 1.5.3 =
Note: See TracChangeset for help on using the changeset viewer.