Changeset 2934071
- Timestamp:
- 07/04/2023 06:36:54 PM (21 months ago)
- Location:
- fcp-first-screen-css/trunk
- Files:
-
- 1 added
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
fcp-first-screen-css/trunk/assets/codemirror/init.js
r2933537 r2934071 24 24 }) 25 25 $editor.after( $format_button ); 26 27 const $linewrap_button = $( '<button name="linewrap" class="button button-small" type="button" title="Visually Break / Unbreak the long lines in the editor"> ↲ </button>' ); 28 $linewrap_button.click( () => { 29 const lineWrapping = editor.getOption( 'lineWrapping' ); 30 editor.setOption( 'lineWrapping', !lineWrapping ); 31 }) 32 $editor.after( $linewrap_button ); 33 34 const $infinity_button = $( '<button name="infinity" class="button button-small" type="button" title="Fit the editor to the content height"> ↕ </button>' ); 35 const editor_height = editor.getOption( 'viewportMargin' ); // 10 36 const textarea_height = $editor.css( 'height' ); // 300px 37 $infinity_button.click( () => { 38 const viewportMargin = editor.getOption( 'viewportMargin' ); 39 const infinity_on = viewportMargin === Infinity; 40 editor.setOption( 'viewportMargin', infinity_on ? editor_height : Infinity ); 41 editor.display.wrapper.style.height = infinity_on ? textarea_height : 'auto'; 42 }) 43 $editor.after( $infinity_button ); 44 45 return editor; 26 46 }; 27 47 -
fcp-first-screen-css/trunk/changelog.txt
r2933528 r2934071 1 = 1.5 = 2 3 * Added the Wrap button to softly break / unbreak long lines 4 * Added the Infinity button to fit the editor's height to the content 5 1 6 = 1.4 = 2 7 -
fcp-first-screen-css/trunk/first-screen.php
r2933545 r2934071 3 3 Plugin Name: FCP First Screen CSS 4 4 Description: Insert inline CSS to the head of the website, so the first screen renders with no jumps, which might improve the CLS web vital. Or for any other reason. 5 Version: 1. 4.015 Version: 1.5 6 6 Requires at least: 5.8 7 7 Tested up to: 6.1 … … 248 248 }); 249 249 250 // style meta boxes251 add_action( 'admin_footer', function() {252 253 $screen = get_current_screen();254 if ( !isset( $screen ) || !is_object( $screen ) || !in_array( $screen->base, [ 'post' ] ) ) { return; } // ++to inline css & include ++if can admin255 256 ?>257 <style type="text/css">258 [id^=first-screen-css] select {259 width:100%;260 box-sizing:border-box;261 }262 [id^=first-screen-css] fieldset label {263 display:inline-block;264 min-width:90px;265 margin-right:16px;266 white-space:nowrap;267 }268 [id^=first-screen-css] input[type=text],269 [id^=first-screen-css] textarea {270 width:100%;271 }272 [id^=first-screen-css] p {273 margin:30px 0 10px;274 }275 [id^=first-screen-css] p + p {276 margin-top:10px;277 }278 </style>279 <?php280 });281 282 250 // disable timymce to textarea 283 251 add_filter( 'wp_editor_settings', function($settings, $editor_id) { … … 303 271 if ( !isset( $screen ) || !is_object( $screen ) || $screen->post_type !== FCPFSC_SLUG ) { return; } 304 272 273 // remove wp-native codemirror 274 wp_deregister_script( 'code-editor' ); 275 wp_deregister_style( 'wp-codemirror' ); 276 277 global $wp_scripts; // remove cm_settings // priority 11 is for this part mostly - default is fine for the rest 278 $jquery_extra_core_data = $wp_scripts->get_data( 'jquery-core', 'data' ); 279 $jquery_extra_core_data = preg_replace( '/var cm_settings(?:.*?);/', '', $jquery_extra_core_data ); 280 $wp_scripts->add_data( 'jquery-core', 'data', $jquery_extra_core_data ); 281 //echo '***'; print_r( $wp_scripts ); exit; 282 283 // codemirror core 305 284 wp_enqueue_script( 'codemirror', plugin_dir_url(__FILE__) . 'assets/codemirror/codemirror.js', ['jquery'], FCPFSC_CM_VER ); 306 wp_enqueue_script( 'codemirror-init', plugin_dir_url(__FILE__) . '/assets/codemirror/init.js', ['jquery'], FCPFSC_VER );307 308 285 wp_enqueue_style( 'codemirror', plugin_dir_url(__FILE__) . 'assets/codemirror/codemirror.css', [], FCPFSC_CM_VER ); 309 wp_enqueue_style( 'codemirror-style', plugin_dir_url(__FILE__) . 'assets/codemirror/style.css', ['codemirror'], FCPFSC_VER ); 310 286 287 // codemirror addons 311 288 wp_enqueue_script( 'codemirror-mode-css', plugin_dir_url(__FILE__) . 'assets/codemirror/mode/css/css.js', ['codemirror'], FCPFSC_CM_VER ); 312 289 wp_enqueue_script( 'codemirror-addon-active-line', plugin_dir_url(__FILE__) . 'assets/codemirror/addon/selection/active-line.js', ['codemirror'], FCPFSC_CM_VER ); 313 290 wp_enqueue_script( 'codemirror-addon-placeholder', plugin_dir_url(__FILE__) . 'assets/codemirror/addon/display/placeholder.js', ['codemirror'], FCPFSC_CM_VER ); 314 291 wp_enqueue_script( 'codemirror-formatting', plugin_dir_url(__FILE__) . 'assets/codemirror/util/formatting.js', ['codemirror'], '2.38+' ); 315 }); 292 293 // codemirror init 294 wp_enqueue_script( 'codemirror-init', plugin_dir_url(__FILE__) . '/assets/codemirror/init.js', ['codemirror'], FCPFSC_VER ); 295 296 // overall styling 297 wp_enqueue_style( 'codemirror-style', plugin_dir_url(__FILE__) . 'assets/style.css', ['codemirror'], FCPFSC_VER ); 298 }, 11 ); 316 299 317 300 // save meta data … … 319 302 320 303 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } 321 if ( !wp_verify_nonce( $_POST[ FCPFSC_PREF.'nounce-name' ], FCPFSC_PREF.'nounce-action' ) ) { return; }304 if ( empty( $_POST[ FCPPBK_PREF.'nounce-name' ] ) || !wp_verify_nonce( $_POST[ FCPFSC_PREF.'nounce-name' ], FCPFSC_PREF.'nounce-action' ) ) { return; } 322 305 //if ( !current_user_can( 'edit_post', $postID ) ) { return; } 323 306 if ( !current_user_can( 'administrator' ) ) { return; } … … 566 549 placeholder="<?php echo isset( $a->placeholder ) ? esc_attr( $a->placeholder ) : '' ?>" 567 550 class="<?php echo isset( $a->className ) ? esc_attr( $a->className ) : '' ?>" 551 style="<?php echo isset( $a->style ) ? esc_attr( $a->style ) : '' ?>" 568 552 ><?php 569 553 echo esc_textarea( isset( $a->value ) ? $a->value : '' ) … … 784 768 'name' => 'rest-css', 785 769 'value' => get_post_meta( $post->ID, FCPFSC_PREF.'rest-css' )[0] ?? '', 770 'style' => 'height:300px', 786 771 ]); 787 772 … … 837 822 838 823 // ++refactor - split in files 839 // ++add the bigger height button and save it824 // ++add the @bigger height@ button and save new height in local storage 840 825 // ++switch selects to checkboxes or multiples 841 826 // ++maybe limit the id-exclude to the fitting post types -
fcp-first-screen-css/trunk/readme.txt
r2933545 r2934071 5 5 Tested up to: 6.2 6 6 Requires PHP: 7.4 7 Stable tag: 1. 4.017 Stable tag: 1.5 8 8 Author: Firmcatalyst, Vadim Volkov 9 9 Author URI: https://firmcatalyst.com … … 53 53 == Upgrade Notice == 54 54 55 = 1.5 = 56 57 * Added the Wrap button to softly break / unbreak long lines 58 * Added the Infinity button to fit the editor's height to the content 59 55 60 = 1.4 = 56 61
Note: See TracChangeset
for help on using the changeset viewer.