Changeset 2584954
- Timestamp:
- 08/18/2021 03:18:30 PM (5 years ago)
- Location:
- code-injection/trunk
- Files:
-
- 7 edited
-
assets/css/code-editor.css (modified) (10 diffs)
-
assets/js/code-editor.js (modified) (13 diffs)
-
assets/js/essentials.js (modified) (1 diff)
-
code-injection.php (modified) (2 diffs)
-
includes/asset-manager.php (modified) (1 diff)
-
includes/code-type.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
code-injection/trunk/assets/css/code-editor.css
r2576471 r2584954 9 9 } 10 10 11 .dcp-ci-toolbar > button{11 .dcp-ci-toolbar>button { 12 12 color: white; 13 13 } 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 23 14 24 15 .wp-core-ui .dcp-ci-editor .button, .wp-core-ui .dcp-ci-editor .button-secondary { … … 28 19 vertical-align: unset; 29 20 outline: none!important; 30 31 21 min-height: inherit!important; 32 22 margin: inherit; 33 23 padding: inherit!important; 34 35 24 -webkit-appearance: inherit!important; 36 25 border-radius: inherit!important; … … 43 32 } 44 33 45 textarea:focus, 46 .wp-core-ui .dcp-ci-editor .button:focus{ 34 textarea:focus, .wp-core-ui .dcp-ci-editor .button:focus { 47 35 outline: none!important; 48 36 box-shadow: none!important; 49 37 } 50 38 51 .monaco-aria-container {39 .monaco-aria-container { 52 40 display: none; 53 41 } 54 42 55 56 43 .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; 58 45 } 59 46 … … 63 50 } 64 51 65 66 .ci-description 67 { 52 .ci-description { 68 53 position: relative; 69 54 font-size: 13px; … … 74 59 } 75 60 76 .ci-description .dashicons {61 .ci-description .dashicons { 77 62 position: absolute; 78 63 left: 0; 79 64 } 80 65 81 82 66 .ci-header { 83 84 67 display: flex; 85 68 align-items: center; 86 69 text-align: justify; 87 70 margin-top: 14px!important; 88 89 71 } 90 72 … … 102 84 padding-right: 7px; 103 85 } 104 105 86 106 87 #postdivrich.fullscreen { … … 116 97 } 117 98 118 input.apple-switch:focus {119 box-shadow: unset;99 input.apple-switch:focus { 100 box-shadow: unset; 120 101 } 121 102 … … 143 124 } 144 125 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 145 173 input.apple-switch { 146 174 position: relative; 147 appearance: none; 175 appearance: none; 148 176 outline: none; 149 width: 50px; 177 width: 50px; 150 178 height: 30px; 151 background-color: #ffffff; 179 background-color: #ffffff; 152 180 border: 1px solid #D9DADC; 153 border-radius: 50px; 154 181 border-radius: 50px; 155 182 box-shadow: inset -20px 0 0 0 #ffffff; 156 157 183 transition: box-shadow 200ms linear; 158 184 -webkit-transition: box-shadow 200ms linear; … … 160 186 -ms-transition: box-shadow 200ms linear; 161 187 -o-transition: box-shadow 200ms linear; 162 }163 164 input.apple-switch:after {165 content: ""; 188 } 189 190 input.apple-switch:after { 191 content: ""; 166 192 position: absolute; 167 top: 1px; left: 1px; 168 width: 26px; height: 26px; 193 top: 1px; 194 left: 1px; 195 width: 26px; 196 height: 26px; 169 197 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); 174 200 transition: all 200ms linear; 175 201 -webkit-transition: all 200ms linear; … … 177 203 -ms-transition: all 200ms linear; 178 204 -o-transition: all 200ms linear; 179 180 } 181 182 input.apple-switch:checked { 205 } 206 207 input.apple-switch:checked { 183 208 border-color: #4e9bd1; 184 209 box-shadow: inset 20px 0 0 0 #4e9bd1; 185 }186 187 input.apple-switch:checked:after {210 } 211 212 input.apple-switch:checked:after { 188 213 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 217 input.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 7 7 8 8 // init i18n methods 9 if (typeof wp !== "undefined" && typeof wp.i18n !== "undefined"){9 if (typeof wp !== "undefined" && typeof wp.i18n !== "undefined") { 10 10 var { __, _x, _n, sprintf } = wp.i18n; 11 } else{12 function __(text , ctx){11 } else { 12 function __(text, ctx) { 13 13 var dic = _ci.i18n[ctx] || { 14 "texts" : [],15 "translates" : []14 "texts": [], 15 "translates": [] 16 16 }; 17 17 var index = dic["texts"].indexOf(text); … … 19 19 } 20 20 } 21 21 22 22 var parent, textarea, toolbar, fullscreen, code, 23 23 languages = [ … … 30 30 ], langsList; 31 31 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 32 52 $(document).ready(() => { 33 53 … … 36 56 $('#wp-content-editor-tools').hide(); 37 57 $('#wp-content-wrap').hide(); 58 59 60 updatePostTitle(); 61 38 62 39 63 $('#post-status-info').remove(); … … 65 89 }); 66 90 67 if (l == "html"){91 if (l == "html") { 68 92 item.addClass("active"); 69 93 } … … 79 103 toolbar.append(langsList); 80 104 81 105 82 106 container = $('<div>') 83 107 .addClass('dcp-ci-editor') … … 129 153 130 154 131 $("[data-checkbox-activator]").each(function (index, element){155 $("[data-checkbox-activator]").each(function (index, element) { 132 156 133 157 var _this = $(this); 134 158 135 function toggleTargets(obj , reverse = false){136 137 if (reverse){159 function toggleTargets(obj, reverse = false) { 160 161 if (reverse) { 138 162 139 163 var hidetargets = obj.attr("data-hide-targets") || ""; 140 164 141 hidetargets.split(',').forEach(function (e,i){165 hidetargets.split(',').forEach(function (e, i) { 142 166 143 167 var elem = $(`#${e}`); 144 145 if (obj[0].checked){168 169 if (obj[0].checked) { 146 170 elem.hide(); 147 } else{171 } else { 148 172 elem.show(); 149 173 } 150 174 151 175 }); 152 176 … … 156 180 var showtargets = obj.attr("data-show-targets") || ""; 157 181 158 showtargets.split(',').forEach(function (e,i){182 showtargets.split(',').forEach(function (e, i) { 159 183 160 184 var elem = $(`#${e}`); 161 185 162 if (obj[0].checked){186 if (obj[0].checked) { 163 187 elem.show(); 164 } else{188 } else { 165 189 elem.hide(); 166 190 } … … 171 195 172 196 toggleTargets(_this); 173 toggleTargets(_this , true);174 175 _this.on("click" , function(event){197 toggleTargets(_this, true); 198 199 _this.on("click", function (event) { 176 200 var obj = $(event.target); 177 201 toggleTargets(obj); 178 toggleTargets(obj , true);202 toggleTargets(obj, true); 179 203 }); 180 204 … … 189 213 190 214 191 $("#title").attr("disabled" , true);215 $("#title").attr("disabled", true); 192 216 193 217 … … 208 232 209 233 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")); 211 235 if (!sizeConfirm) { 212 236 return; … … 215 239 216 240 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(", *.") + " ]"); 218 242 return; 219 243 } … … 229 253 230 254 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")); 232 256 if (overrideConfirm) { 233 257 //textarea.text(e.target.result); -
code-injection/trunk/assets/js/essentials.js
r2576471 r2584954 27 27 $.get(_ci.ajax_url, { 28 28 action: "code_stats", 29 _wpnonce : _ci.ajax_nonce, 29 30 id: id 30 31 }, function (result) { 31 32 target.parent().html(result); 32 33 }).fail(function () { 33 console.error("Faild");34 34 }); 35 35 } -
code-injection/trunk/code-injection.php
r2576471 r2584954 5 5 * Plugin URI: https://github.com/Rmanaf/wp-code-injection 6 6 * Description: This plugin allows you to inject code snippets into the pages. 7 * Version: 2.4. 87 * Version: 2.4.9 8 8 * Author: Rmanaf 9 9 * Author URI: https://profiles.wordpress.org/rmanaf/ … … 34 34 private static $role_version = '1.0.0'; 35 35 36 private static $version = '2.4. 8';36 private static $version = '2.4.9'; 37 37 38 38 function __construct() -
code-injection/trunk/includes/asset-manager.php
r2576471 r2584954 54 54 wp_localize_script( 'ci-essentials', "_ci", [ 55 55 'ajax_url' => admin_url( 'admin-ajax.php' ), 56 "ajax_nonce" => wp_create_nonce("code-injection-ajax-nonce"), 56 57 "i18n" => [ 57 58 "code-injection" => [ -
code-injection/trunk/includes/code-type.php
r2576471 r2584954 24 24 self::$plugin = $plugin; 25 25 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"); 45 49 46 50 } … … 68 72 69 73 global $wpdb; 74 75 check_ajax_referer("code-injection-ajax-nonce"); 70 76 71 77 if(!isset($_GET["id"])){ … … 309 315 } 310 316 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 } 311 328 312 329 /** -
code-injection/trunk/readme.txt
r2576471 r2584954 4 4 Requires at least: 4.5.0 5 5 Tested up to: 5.8.0 6 Stable tag: 2.4. 86 Stable tag: 2.4.9 7 7 License: MIT License 8 8 License URI: https://github.com/Rmanaf/wp-code-injection/blob/master/LICENSE
Note: See TracChangeset
for help on using the changeset viewer.