wp_enqueue_script called incorrectly

UGH. I solved this. I’m an idiot. I had a file in my theme named admin.php that was setting up wp-admin handlers and the like for a portion of my application. I was including this via include_once( ‘admin.php’ ) from its parent file, and apparently that was calling the main wp-core admin.php file. So yeah. … Read more

wp enqueue script- jQuery not loading

It appears that “mdbootstrap” is built in such a way that it does not support jQuery in No Conflict mode, which is how WordPress runs it. According to this forum thread they were going to add support 2 years ago, but apparently they never did. If you must use this library, then I think the … Read more

Load JS Script only for custom post types

To enqueue scripts on the front-end, the hook should be wp_enqueue_scripts, not login_enqueue_scripts. Also, a better way to see if you’re on a single custom post type is to use is_singular() and pass the post type you want to check: if ( is_singular( ‘events’ ) ) { } get_post_type() relies on the global $post object, … Read more

Enqueuing javascript files

Example for themes I would recommend using wp_enqueue_script with get_theme_file_uri this allows child themes to overwrite this file. get_theme_file_uri() function Searches in the stylesheet directory before the template directory so themes which inherit from a parent theme can just override one file. wp_enqueue_script( ‘example-script’, get_theme_file_uri( ‘/js/example-script.js’ ), array(‘jquery’), null, true ); Example for plugins wp_enqueue_script( … Read more

enqueue admin styling and scripts only on plugin page

You can use $screen = get_current_screen(); functions to get the current screen and add warp your enqueue method with the if conditions to check the screen. https://codex.wordpress.org/Function_Reference/get_current_screen public function enqueue_scripts() { $screen = get_current_screen(); // Check screen base and page if ( ‘options-general’ === $screen->base && $_GET[‘page’] ===’uwc’ ) { wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) … Read more

My scripts-bundle.js file is getting sent to the browser as a stylesheet css file. Help!

Ok, I managed to solve this issue because I was using the wrong WP functions to point my child themes directory and thus my bundled javascript script. I cleared out my functions.php file and added the below and it all works now: function load_js_files() { wp_enqueue_script( ‘script’, get_stylesheet_directory_uri() . ‘/js/scripts-bundled.js’, array ( ‘jquery’ ), 1.1, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)