Skip to content

Commit

Permalink
Update disable-shortcode-pasting.php
Browse files Browse the repository at this point in the history
  • Loading branch information
schlotterer authored Aug 25, 2024
1 parent dc5c406 commit dbee612
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions disable-shortcode-pasting.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
<?php
/**
* Plugin Name: Disable Shortcode Pasting in Plain Text Blocks
* Plugin Name: Disable Shortcode Block Creation when Pasting in Plain Text Blocks
* Description: Prevents new shortcode blocks from being inserted when pasting shortcodes into plain text blocks like paragraphs or headings.
* Version: 1.0
* Author: Joel Schlotterer
* Author URI: https://yourwebsite.com
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Requires at least: 6.5
* Tested up to: 6.6.1
* Requires PHP: 8.0
* Tags: shortcode, paste, block editor, gutenberg, content
* Text Domain: disable-shortcode-pasting
* Domain Path: /languages
*/

namespace Flexline\DisableShortcodePasting;

// Enqueue the block editor script
function enqueue_block_editor_assets() {
// Dependencies explained:
// - 'wp-blocks': Provides essential functions for registering and working with blocks.
// - 'wp-dom-ready': Ensures that the script is executed when the DOM is fully loaded.
// - 'wp-edit-post': Provides editor-level functionalities and controls used for block management.

wp_enqueue_script(
'dsp-shortcode-paste-handler',
plugin_dir_url(__FILE__) . 'shortcode-paste-handler.js',
array('wp-blocks', 'wp-dom-ready', 'wp-edit-post'),
filemtime(plugin_dir_path(__FILE__) . 'shortcode-paste-handler.js'),
true
array('wp-blocks', 'wp-dom-ready', 'wp-edit-post'), // Specify dependencies
filemtime(plugin_dir_path(__FILE__) . 'shortcode-paste-handler.js'), // Cache busting based on file modification time
true // Load in the footer for better performance
);
}

Expand Down

0 comments on commit dbee612

Please sign in to comment.