Plugin Directory

Changeset 2934071


Ignore:
Timestamp:
07/04/2023 06:36:54 PM (21 months ago)
Author:
firmcatalyst
Message:

version 1.5

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  
    2424        })
    2525        $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">&nbsp;&#8626;&nbsp;</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">&nbsp;&#8597;&nbsp;</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;
    2646    };
    2747
  • 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
    16= 1.4 =
    27
  • fcp-first-screen-css/trunk/first-screen.php

    r2933545 r2934071  
    33Plugin Name: FCP First Screen CSS
    44Description: 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.01
     5Version: 1.5
    66Requires at least: 5.8
    77Tested up to: 6.1
     
    248248});
    249249
    250 // style meta boxes
    251 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 admin
    255 
    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     <?php
    280 });
    281 
    282250// disable timymce to textarea
    283251add_filter( 'wp_editor_settings', function($settings, $editor_id) {
     
    303271    if ( !isset( $screen ) || !is_object( $screen ) || $screen->post_type !== FCPFSC_SLUG ) { return; }
    304272
     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
    305284    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 
    308285    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
    311288    wp_enqueue_script( 'codemirror-mode-css', plugin_dir_url(__FILE__) . 'assets/codemirror/mode/css/css.js', ['codemirror'], FCPFSC_CM_VER );
    312289    wp_enqueue_script( 'codemirror-addon-active-line', plugin_dir_url(__FILE__) . 'assets/codemirror/addon/selection/active-line.js', ['codemirror'], FCPFSC_CM_VER );
    313290    wp_enqueue_script( 'codemirror-addon-placeholder', plugin_dir_url(__FILE__) . 'assets/codemirror/addon/display/placeholder.js', ['codemirror'], FCPFSC_CM_VER );
    314291    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 );
    316299
    317300// save meta data
     
    319302
    320303    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; }
    322305    //if ( !current_user_can( 'edit_post', $postID ) ) { return; }
    323306    if ( !current_user_can( 'administrator' ) ) { return; }
     
    566549        placeholder="<?php echo isset( $a->placeholder ) ? esc_attr( $a->placeholder ) : '' ?>"
    567550        class="<?php echo isset( $a->className ) ? esc_attr( $a->className ) : '' ?>"
     551        style="<?php echo isset( $a->style ) ? esc_attr( $a->style ) : '' ?>"
    568552    ><?php
    569553        echo esc_textarea( isset( $a->value ) ? $a->value : '' )
     
    784768        'name' => 'rest-css',
    785769        'value' => get_post_meta( $post->ID, FCPFSC_PREF.'rest-css' )[0] ?? '',
     770        'style' => 'height:300px',
    786771    ]);
    787772
     
    837822
    838823// ++refactor - split in files
    839 // ++add the bigger height button and save it
     824// ++add the @bigger height@ button and save new height in local storage
    840825// ++switch selects to checkboxes or multiples
    841826// ++maybe limit the id-exclude to the fitting post types
  • fcp-first-screen-css/trunk/readme.txt

    r2933545 r2934071  
    55Tested up to: 6.2
    66Requires PHP: 7.4
    7 Stable tag: 1.4.01
     7Stable tag: 1.5
    88Author: Firmcatalyst, Vadim Volkov
    99Author URI: https://firmcatalyst.com
     
    5353== Upgrade Notice ==
    5454
     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
    5560= 1.4 =
    5661
Note: See TracChangeset for help on using the changeset viewer.