Scripts not loading through function Method in WordPress Theme

There are several fundamental problems with what you’re trying to do that prevent you reaching your goal The Problems Naming You register 2 scripts, but you name them both ‘custom’. How is WordPress supposed to know which script you meant when you later tell it to display ‘custom’? /* Register scripts. */ wp_register_script( ‘custom’, JS … Read more

disable tags on wordpress text editor

WordPress already disallows the use of JavaScript in the editor for users without the unfiltered_html capability. By default, only the Administrator and Editor roles have this capability. If necessary, you could remove this capability from Editor users as well. (It doesn’t make sense to remove it from Administrators, because they will still have the ability … Read more

Correctly enqueue scripts of type=text/paperscript (PaperJs Library)

I’m not sure if this will solve your problem, but you can use the script_loader_tag filter to change the type text/javascript to text/paperscript add_filter( ‘script_loader_tag’, function( $tag, $handle, $src ) { if( ‘your-script-handle’ === $handle ) { $tag = str_replace( ‘text/javascript’, ‘text/paperscript ‘, $tag ); } return $tag; }, 10, 3 );

Add custom classes for blocks in editor based on custom attributes

You can do this with the editor.BlockListBlock filter. More info here. This allows you to do something like the following: const withCustomAttributeClass = createHigherOrderComponent( ( BlockListBlock ) => { return ( props ) => { const { attributes } = props; const { yourCustomAttribute } = attributes; const class = yourCustomAttribute ? ‘my_custom_class’ : ”; … Read more

wp_enqueue_script not loading my custom js file

You need to reference your WordPress template directory when you register the script. Change this: wp_enqueue_script(‘my_javascript_file’, ‘/javascripts/app.js’, array(‘jquery’)); …to this: wp_enqueue_script(‘my_javascript_file’, get_template_directory_uri() . ‘/javascripts/app.js’, array(‘jquery’)); Codex reference: get_template_directory_uri()

Adjusting jquery for WordPress

By default, jQuery runs in no conflict mode in WordPress. You have an anonymous function that passes the jQuery object so you can use it. Your code will error on line two because it doesn’t know what $ is. Move the first three lines into the anonymous function to resolve this. (function($){ var array = … Read more