Plugin Directory

Changeset 2584954


Ignore:
Timestamp:
08/18/2021 03:18:30 PM (5 years ago)
Author:
rmanaf
Message:

2.4.9

Location:
code-injection/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code-injection/trunk/assets/css/code-editor.css

    r2576471 r2584954  
    99}
    1010
    11 .dcp-ci-toolbar > button{
     11.dcp-ci-toolbar>button {
    1212    color: white;
    1313}
    14 
    15 #titlediv #title {
    16     background: #1e1e1e;
    17     border-radius: 0;
    18     border: none;
    19     color: #d4d4d4;
    20     font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback";
    21 }
    22 
    2314
    2415.wp-core-ui .dcp-ci-editor .button, .wp-core-ui .dcp-ci-editor .button-secondary {
     
    2819    vertical-align: unset;
    2920    outline: none!important;
    30 
    3121    min-height: inherit!important;
    3222    margin: inherit;
    3323    padding: inherit!important;
    34 
    3524    -webkit-appearance: inherit!important;
    3625    border-radius: inherit!important;
     
    4332}
    4433
    45 textarea:focus,
    46 .wp-core-ui .dcp-ci-editor .button:focus{
     34textarea:focus, .wp-core-ui .dcp-ci-editor .button:focus {
    4735    outline: none!important;
    4836    box-shadow: none!important;
    4937}
    5038
    51 .monaco-aria-container{
     39.monaco-aria-container {
    5240    display: none;
    5341}
    5442
    55 
    5643.wp-core-ui .monaco-editor.hc-black .find-widget .button:not(.disabled):hover, .monaco-editor.vs-dark .find-widget .button:not(.disabled):hover {
    57     background-color: hsla(0,0%,100%,.1)!important;
     44    background-color: hsla(0, 0%, 100%, .1)!important;
    5845}
    5946
     
    6350}
    6451
    65 
    66 .ci-description
    67 {
     52.ci-description {
    6853    position: relative;
    6954    font-size: 13px;
     
    7459}
    7560
    76 .ci-description .dashicons{
     61.ci-description .dashicons {
    7762    position: absolute;
    7863    left: 0;
    7964}
    8065
    81 
    8266.ci-header {
    83 
    8467    display: flex;
    8568    align-items: center;
    8669    text-align: justify;
    8770    margin-top: 14px!important;
    88 
    8971}
    9072
     
    10284    padding-right: 7px;
    10385}
    104 
    10586
    10687#postdivrich.fullscreen {
     
    11697}
    11798
    118 input.apple-switch:focus{
    119     box-shadow:unset;
     99input.apple-switch:focus {
     100    box-shadow: unset;
    120101}
    121102
     
    143124}
    144125
     126#titlediv #title {
     127    border-radius: 0;
     128    border: none;
     129    color: #d4d4d4;
     130    font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback";
     131    z-index: 2;
     132    position: relative;
     133    font-size: 1.1rem;
     134    background: transparent;
     135}
     136
     137#title-prompt-text {
     138    display: none;
     139}
     140
     141#titlewrap {
     142    position: relative;
     143    overflow: hidden;
     144    background: #1e1e1e;
     145}
     146
     147#titlewrap.busy{
     148    background: transparent;
     149}
     150
     151#titlewrap.busy::before {
     152    content: '';
     153    display: block;
     154    position: absolute;
     155    left: -46px;
     156    right: 0;
     157    top: 0;
     158    bottom: 0;
     159    z-index: 1;
     160
     161    background: -webkit-repeating-linear-gradient( 145deg, #1e1e1e 1px, #272727 2px, #272727 11px, #1e1e1e 12px, #1e1e1e 20px);
     162    background: repeating-linear-gradient( -55deg, #1e1e1e 1px, #272727 2px, #272727 11px, #1e1e1e 12px, #1e1e1e 20px);
     163    -webkit-animation-name: MOVE-BG;
     164    -webkit-animation-duration: .6s;
     165    -webkit-animation-timing-function: linear;
     166    -webkit-animation-iteration-count: infinite;
     167    animation-name: MOVE-BG;
     168    animation-duration: .6s;
     169    animation-timing-function: linear;
     170    animation-iteration-count: infinite;
     171}
     172
    145173input.apple-switch {
    146174    position: relative;
    147     appearance: none; 
     175    appearance: none;
    148176    outline: none;
    149     width: 50px; 
     177    width: 50px;
    150178    height: 30px;
    151     background-color: #ffffff; 
     179    background-color: #ffffff;
    152180    border: 1px solid #D9DADC;
    153     border-radius: 50px;
    154 
     181    border-radius: 50px;
    155182    box-shadow: inset -20px 0 0 0 #ffffff;
    156 
    157183    transition: box-shadow 200ms linear;
    158184    -webkit-transition: box-shadow 200ms linear;
     
    160186    -ms-transition: box-shadow 200ms linear;
    161187    -o-transition: box-shadow 200ms linear;
    162    }
    163 
    164    input.apple-switch:after {
    165     content: ""; 
     188}
     189
     190input.apple-switch:after {
     191    content: "";
    166192    position: absolute;
    167     top: 1px; left: 1px;
    168     width: 26px; height: 26px;
     193    top: 1px;
     194    left: 1px;
     195    width: 26px;
     196    height: 26px;
    169197    background-color: transparent;
    170     border-radius: 50%;
    171 
    172     box-shadow: 2px 4px 6px rgba(0,0,0,0.2);
    173    
     198    border-radius: 50%;
     199    box-shadow: 2px 4px 6px rgba(0, 0, 0, 0.2);
    174200    transition: all 200ms linear;
    175201    -webkit-transition: all 200ms linear;
     
    177203    -ms-transition: all 200ms linear;
    178204    -o-transition: all 200ms linear;
    179 
    180    }
    181 
    182    input.apple-switch:checked {
     205}
     206
     207input.apple-switch:checked {
    183208    border-color: #4e9bd1;
    184209    box-shadow: inset 20px 0 0 0 #4e9bd1;
    185    }
    186 
    187    input.apple-switch:checked:after {
     210}
     211
     212input.apple-switch:checked:after {
    188213    left: 20px;
    189     box-shadow: -2px 4px 3px rgba(0,0,0,0.05);
    190    }
    191 
    192    input.apple-switch:checked:before {
    193        content:"";
    194    }
    195 
    196 
    197    @media screen and (max-width: 782px){
    198         #postdivrich.fullscreen {
    199             padding-top: 46px;
    200         }
    201         .quicktags-toolbar {
    202             min-height: 35px!important;
    203         }
    204     }
     214    box-shadow: -2px 4px 3px rgba(0, 0, 0, 0.05);
     215}
     216
     217input.apple-switch:checked:before {
     218    content: "";
     219}
     220
     221@media screen and (max-width: 782px) {
     222    #postdivrich.fullscreen {
     223        padding-top: 46px;
     224    }
     225    .quicktags-toolbar {
     226        min-height: 35px!important;
     227    }
     228}
     229
     230@-webkit-keyframes MOVE-BG {
     231    from {
     232        -webkit-transform: translateX(0);
     233    }
     234    to {
     235        -webkit-transform: translateX(46px);
     236    }
     237}
     238
     239@keyframes MOVE-BG {
     240    from {
     241        transform: translateX(0);
     242    }
     243    to {
     244        transform: translateX(46px);
     245    }
     246}
  • code-injection/trunk/assets/js/code-editor.js

    r2576471 r2584954  
    77
    88    // init i18n methods
    9     if(typeof wp !==  "undefined" && typeof wp.i18n !==  "undefined"){
     9    if (typeof wp !== "undefined" && typeof wp.i18n !== "undefined") {
    1010        var { __, _x, _n, sprintf } = wp.i18n;
    11     }else{
    12         function __(text , ctx){
     11    } else {
     12        function __(text, ctx) {
    1313            var dic = _ci.i18n[ctx] || {
    14                 "texts" : [],
    15                 "translates" : []
     14                "texts": [],
     15                "translates": []
    1616            };
    1717            var index = dic["texts"].indexOf(text);
     
    1919        }
    2020    }
    21  
     21
    2222    var parent, textarea, toolbar, fullscreen, code,
    2323        languages = [
     
    3030        ], langsList;
    3131
     32
     33    function updatePostTitle(){
     34        var $title =  $("#title");
     35        var $wrap = $("#titlewrap");
     36        if ($title .val().length == 0) {
     37            $wrap.addClass('busy');
     38            $.get(_ci.ajax_url, {
     39                "action": "code_generate_title",
     40                "_wpnonce": _ci.ajax_nonce
     41            }, function (result) {
     42                $wrap.removeClass('busy');
     43                if(result.success){
     44                    $title.val(result.data);
     45                }
     46            }).fail(function () {
     47                $wrap.removeClass('busy');
     48            });
     49        }
     50    }
     51
    3252    $(document).ready(() => {
    3353
     
    3656        $('#wp-content-editor-tools').hide();
    3757        $('#wp-content-wrap').hide();
     58
     59
     60        updatePostTitle();
     61
    3862
    3963        $('#post-status-info').remove();
     
    6589                });
    6690
    67             if(l == "html"){
     91            if (l == "html") {
    6892                item.addClass("active");
    6993            }
     
    79103        toolbar.append(langsList);
    80104
    81        
     105
    82106        container = $('<div>')
    83107            .addClass('dcp-ci-editor')
     
    129153
    130154
    131         $("[data-checkbox-activator]").each(function(index, element){
     155        $("[data-checkbox-activator]").each(function (index, element) {
    132156
    133157            var _this = $(this);
    134158
    135             function toggleTargets(obj , reverse = false){
    136 
    137                 if(reverse){
     159            function toggleTargets(obj, reverse = false) {
     160
     161                if (reverse) {
    138162
    139163                    var hidetargets = obj.attr("data-hide-targets") || "";
    140164
    141                     hidetargets.split(',').forEach(function(e,i){
     165                    hidetargets.split(',').forEach(function (e, i) {
    142166
    143167                        var elem = $(`#${e}`);
    144    
    145                         if(obj[0].checked){
     168
     169                        if (obj[0].checked) {
    146170                            elem.hide();
    147                         }else{
     171                        } else {
    148172                            elem.show();
    149173                        }
    150    
     174
    151175                    });
    152176
     
    156180                var showtargets = obj.attr("data-show-targets") || "";
    157181
    158                 showtargets.split(',').forEach(function(e,i){
     182                showtargets.split(',').forEach(function (e, i) {
    159183
    160184                    var elem = $(`#${e}`);
    161185
    162                     if(obj[0].checked){
     186                    if (obj[0].checked) {
    163187                        elem.show();
    164                     }else{
     188                    } else {
    165189                        elem.hide();
    166190                    }
     
    171195
    172196            toggleTargets(_this);
    173             toggleTargets(_this , true);
    174 
    175             _this.on("click" , function(event){
     197            toggleTargets(_this, true);
     198
     199            _this.on("click", function (event) {
    176200                var obj = $(event.target);
    177201                toggleTargets(obj);
    178                 toggleTargets(obj , true);
     202                toggleTargets(obj, true);
    179203            });
    180204
     
    189213
    190214
    191         $("#title").attr("disabled" , true);
     215        $("#title").attr("disabled", true);
    192216
    193217
     
    208232
    209233            if (filesize > 300000) {
    210                 var sizeConfirm = confirm(__("The File is too large. Do you want to proceed?" , "code-injection"));
     234                var sizeConfirm = confirm(__("The File is too large. Do you want to proceed?", "code-injection"));
    211235                if (!sizeConfirm) {
    212236                    return;
     
    215239
    216240            if (!isSuccess) {
    217                 alert(__("The selected file type is not supported."  , "code-injection") + " [ *." + fileTypes.join(", *.") + " ]");
     241                alert(__("The selected file type is not supported.", "code-injection") + " [ *." + fileTypes.join(", *.") + " ]");
    218242                return;
    219243            }
     
    229253
    230254                if (textarea.text() != "") {
    231                     var overrideConfirm = confirm(__("Are you sure? You are about to replace the current code with the selected file content." , "code-injection"));
     255                    var overrideConfirm = confirm(__("Are you sure? You are about to replace the current code with the selected file content.", "code-injection"));
    232256                    if (overrideConfirm) {
    233257                        //textarea.text(e.target.result);
  • code-injection/trunk/assets/js/essentials.js

    r2576471 r2584954  
    2727        $.get(_ci.ajax_url, {
    2828            action: "code_stats",
     29            _wpnonce : _ci.ajax_nonce,
    2930            id: id
    3031        }, function (result) {
    3132            target.parent().html(result);
    3233        }).fail(function () {
    33             console.error("Faild");
    3434        });
    3535    }
  • code-injection/trunk/code-injection.php

    r2576471 r2584954  
    55 * Plugin URI: https://github.com/Rmanaf/wp-code-injection
    66 * Description: This plugin allows you to inject code snippets into the pages.
    7  * Version: 2.4.8
     7 * Version: 2.4.9
    88 * Author: Rmanaf
    99 * Author URI: https://profiles.wordpress.org/rmanaf/
     
    3434        private static $role_version = '1.0.0';
    3535
    36         private static $version = '2.4.8';
     36        private static $version = '2.4.9';
    3737
    3838        function __construct()
  • code-injection/trunk/includes/asset-manager.php

    r2576471 r2584954  
    5454            wp_localize_script( 'ci-essentials', "_ci", [
    5555                'ajax_url' => admin_url( 'admin-ajax.php' ),
     56                "ajax_nonce" => wp_create_nonce("code-injection-ajax-nonce"),
    5657                "i18n" => [
    5758                    "code-injection" => [
  • code-injection/trunk/includes/code-type.php

    r2576471 r2584954  
    2424            self::$plugin = $plugin;
    2525
    26             add_action('init', 'WP_CI_Code_Type::create_posttype');
    27 
    28             add_action('admin_head', 'WP_CI_Code_Type::admin_head');
    29 
    30             add_action('admin_enqueue_scripts', 'WP_CI_Code_Type::print_scripts', 51);
    31 
    32             add_filter('title_save_pre', 'WP_CI_Code_Type::auto_generate_post_title');
    33 
    34             add_filter('user_can_richedit', 'WP_CI_Code_Type::disable_wysiwyg');
    35 
    36             add_filter('post_row_actions', 'WP_CI_Code_Type::custom_row_actions', 10, 2);
    37 
    38             add_filter('manage_code_posts_columns', 'WP_CI_Code_Type::manage_code_posts_columns');
    39 
    40             add_action('manage_code_posts_custom_column', 'WP_CI_Code_Type::manage_code_posts_custom_column', 10, 2);
    41 
    42             add_action('restrict_manage_posts',  'WP_CI_Code_Type::filter_codes_by_taxonomies', 10, 2);
    43 
    44             add_action('wp_ajax_code_stats' , 'WP_CI_Code_Type::get_code_stats');
     26            $clazz = get_called_class();
     27
     28            add_action('init', "$clazz::create_posttype");
     29
     30            add_action("admin_head", "$clazz::admin_head");
     31
     32            add_action("admin_enqueue_scripts", "$clazz::print_scripts", 51);
     33
     34            add_filter("title_save_pre", "$clazz::auto_generate_post_title");
     35
     36            add_filter("user_can_richedit", "$clazz::disable_wysiwyg");
     37
     38            add_filter("post_row_actions", "$clazz::custom_row_actions", 10, 2);
     39
     40            add_filter("manage_code_posts_columns", "$clazz::manage_code_posts_columns");
     41
     42            add_action("manage_code_posts_custom_column", "$clazz::manage_code_posts_custom_column", 10, 2);
     43
     44            add_action("restrict_manage_posts",  "$clazz::filter_codes_by_taxonomies", 10, 2);
     45
     46            add_action("wp_ajax_code_stats" , "$clazz::get_code_stats");
     47
     48            add_action("wp_ajax_code_generate_title" , "$clazz::ajax_generate_post_title");
    4549
    4650        }
     
    6872
    6973            global  $wpdb;
     74
     75            check_ajax_referer("code-injection-ajax-nonce");
    7076
    7177            if(!isset($_GET["id"])){
     
    309315        }
    310316
     317
     318        /**
     319         * @since 2.4.9
     320         */
     321        static function ajax_generate_post_title(){
     322
     323            check_ajax_referer("code-injection-ajax-nonce");
     324
     325            wp_send_json_success(WP_Code_Injection_Plugin::generate_id('code-'));
     326
     327        }
    311328
    312329        /**
  • code-injection/trunk/readme.txt

    r2576471 r2584954  
    44Requires at least: 4.5.0
    55Tested up to: 5.8.0
    6 Stable tag: 2.4.8
     6Stable tag: 2.4.9
    77License: MIT License
    88License URI: https://github.com/Rmanaf/wp-code-injection/blob/master/LICENSE
Note: See TracChangeset for help on using the changeset viewer.