I wrote the following code in a standalone plugin, but it doesn't work
Please guide me how to modify the code, so the JS file is loaded.
<?php
/*
Plugin Name: Copy post
*/
class CopyPostApi{
public function __construct(){
// Add assets
add_action( 'wp_enqueue_scripts', array($this, 'load_assets'));
}
public function load_assets()
{
wp_enqueue_script(
'main_js',
plugin_dir_url(__FILE__) . 'assets/main.js',
array(),
1,
true
);
}
}
new CopyPostApi;
Note: I searched and used the suggested codes, but it didn't work
<script>
tag is being output?