Plugin Directory

Changeset 2878471


Ignore:
Timestamp:
03/11/2023 03:38:23 PM (3 years ago)
Author:
pluginsclub
Message:

v1.0.1 added gutenberg block

Location:
diff-check
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • diff-check/trunk/README.txt

    r2878345 r2878471  
    55Tested up to: 6.1
    66Requires PHP: 5.4
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88Donate link: https://plugins.club/wordpress/diff-check/
    99License: GPLv2 or later
     
    1414DiffCheck allows you to display side-by-side comparisons of two text files.
    1515
    16 This plugin is ultra-lightweight (6KB) and uses WordPress's already built-in revision function.
     16This plugin is ultra-lightweight (7KB) and uses WordPress's already built-in revision function.
     17
     18*NEW!* The plugin now supports Gutenberg and you can use the "DiffCheck" block to comare two texts.
    1719
    1820= How to compare two files =
     
    3234== Changelog ==
    3335
     36= 1.1 =
     37* Added gutenberg block
     38
    3439= 1.0 =
    3540The first stable public version.
  • diff-check/trunk/diff_check.php

    r2878334 r2878471  
    44Plugin URI: https://plugins.club/wordpress/diff-check/
    55Description: Display a side-by-side comparison of two texts or files.
    6 Version: 1.0
     6Version: 1.1
    77Author: plugins.club
    88Author URI: https://plugins.club
     
    1212    wp_enqueue_script( 'diff_check', plugin_dir_url( __FILE__ ) . 'includes/js/diff_check.js', array(), '1.0.0', true );
    1313    wp_enqueue_style( 'diff_check', plugin_dir_url( __FILE__ ) . 'includes/css/diff_check.css', array(), '1.0.0' );
     14wp_enqueue_script( 'diff_check', plugin_dir_url( __FILE__ ) . 'includes/js/diff_check.js', array( 'wp-blocks', 'wp-editor', 'wp-element' ), '1.0.0', true );
     15wp_enqueue_script( 'diff_check_block', plugin_dir_url( __FILE__ ) . 'includes/js/diff_check_block.js', array( 'wp-blocks', 'wp-editor', 'wp-element' ), '1.0.0', true );
    1416}
    1517add_action( 'wp_enqueue_scripts', 'diff_check_scripts' );
    1618
    17 function diff_check_shortcode( $atts ) {
    18     $atts = shortcode_atts( array(
    19         'text1' => '',
    20         'text2' => '',
    21         'file1' => '',
    22         'file2' => '',
    23     ), $atts, 'diff_check' );
    24 
    25     if($atts['file1'] != ''){
    26         $text1 = file_get_contents($atts['file1']);
    27     }else{
    28         $text1 = $atts['text1'];
    29     }
    30 
    31     if($atts['file2'] != ''){
    32         $text2 = file_get_contents($atts['file2']);
    33     }else{
    34         $text2 = $atts['text2'];
    35     }
    36 
    37     $diff = wp_text_diff( $text1, $text2 );
    38     $differences_count = substr_count($diff,'<ins>') + substr_count($diff,'<del>');
    39 
    40     return '<div class="diff-check">' . $diff . '</div><p>Differences found: '.$differences_count.'</p>';
    41 }
    42 
    43 add_shortcode( 'diff_check', 'diff_check_shortcode' );
     19// Include Gutenberg block
     20require_once plugin_dir_path( __FILE__ ) . 'includes/gutenberg-block.php';
     21// Include Shortcodes
     22require_once plugin_dir_path( __FILE__ ) . 'includes/shortcodes.php';
Note: See TracChangeset for help on using the changeset viewer.