Exclude external uri for css and js version

Declaring functions inside functions can lead to problems as explained here: https://stackoverflow.com/a/1631579/1228379 To solve the issue of remote files, you can use an additional parameter to indicate it is remote (or local) and call get_theme_file_uri/path accordingly. Alternatively, you can just call wp_enqueue_script/style directly and use standard version numbers, or simply save the files locally. In … Read more

Adding external stylesheet after ALL other styles

It’s not elegant but it works. Add these lines to functions.php: ob_start(); add_action(‘shutdown’, function() { $final=””; $levels = ob_get_level(); for ($i = 0; $i < $levels; $i++) { $final .= ob_get_clean(); } // append styles just before </head> $final = str_replace( “</head>”, ‘<link rel=”stylesheet” src=”https://wordpress.stackexchange.com/questions/271293/mycss.css”></head>’, $final ); echo $final; }, 0); Alternatively you can move … Read more

Enqueueing scripts and styles multiple CPTS

There is a built-in function that you can use, instead of globals. The get_current_screen() function allows you to get the information associated with the current page. One of its return values is post_type. So you can check against an array of post types to see if anyone matches. function fhaac_admin_enqueue_scripts(){ $screen = get_current_screen(); if ( … Read more

How to dequeue theme’s RTL stylesheet?

RTL stylesheet is not loaded with wp_enqueue_style() so it wouldn’t appear in global $wp_styles variable. WordPress loads it with get_locale_stylesheet() function. You can remove loading locale scripts completely: function abort_loading_rtl_stylesheet() { remove_action( ‘wp_head’, ‘locale_stylesheet’ ); } add_action( ‘init’, ‘abort_loading_rtl_stylesheet’ ); or filter its output to load your custom rtl stylesheet: function override_default_rtl_styles(){ return ‘path/to/custom/rtl.css’; } … Read more

Theme in wp-content but my index.php search theme files in root

I assume you are adding your stylesheets like this in your header: <link rel=”stylesheet” type=”text/css” href=”https://wordpress.stackexchange.com/questions/285785/css/style.css”> Which won’t work. To construct the path dynamically, you need to use the PHP functions offered for this. Make sure your header has <?php wp_head(); ?> in it, and then enqueue your style in your theme’s functions.php file as … Read more

How to insert html/css/javascript code to wordpress plugin

Like mmm said, user_register() is not for displaying additional content, but for hooking into the internal user creation flow. What you will need to do is to hook into user_register() to store a short-lived transient marking that the user has registered. Then, add your modal code to the wp_footer() output, wrapped in a test for … Read more

Gutenberg blocks not getting styled on back end

FWIW, there was an error in the wp_enqueue_style function I received. This one works fine: // Enqueue optional editor only styles wp_enqueue_style( ‘pbdsblocks-blocks-editor-css’, plugins_url( $editorStylePath, __FILE__), [ ], filemtime( plugin_dir_path( __FILE__ ) . $editorStylePath ) ); Note the third argument has changed to [ ] from [‘wp-blocks’]