How to import the css in the plugin admin area?

Just hook your callback into admin_print_styles, i.e.: add_action( ‘admin_print_styles’, ‘mytheme_add_init’ ); Alternately, you could add an is_admin() conditional wrapper inside your callback, and hook into wp_enqueue_scripts: function mytheme_add_init() { if ( is_admin() ) { $file_dir=get_bloginfo(‘template_directory’); wp_enqueue_style(“functions”, $file_dir.”/scripts/custom.css”, false, “1.0”, “all”); wp_enqueue_script(“rm_script”, $file_dir.”/scripts/custom.js”, false, “1.0”); } } add_action( ‘wp_enqueue_scripts’, ‘mytheme_add_init’ ); But the absolute best approach … Read more

WordPress plugin enqueue scripts working for js, but not css files

The function wp_enqueue_style last argument is the $media and you set it to true so its mean you are doing <link rel=”stylesheet” … media=”1″ /> $media (string) (Optional) The media for which this stylesheet has been defined. Accepts media types like ‘all’, ‘print’ and ‘screen’, or media queries like ‘(orientation: portrait)’ and ‘(max-width: 640px)’. Default … Read more

Why is the ‘Gutenberg’ Plugin generating an ‘Inconsistent File Permissions’ error when other Plugins, with the same permissions, do not?

If you originally installed via FTP/Cpanel/CLI the directory and files may have a different “owner” belonging to “different group” than those installed via WordPress. One possible solution: If you have server access try deactivating Guttenberg and rename its plugin directory to something else. Then reinstall the plugin through WordPress – if this works your Dashboard … Read more

How to include jQuery into my plugin so I can use it on plugin page?

JQuery is a part of WordPress core, so it is automatically there for you to use (i.e. you do not need to register it). However, you still need to enqueue it. This can be done as follows: function my_script() { wp_enqueue_script(‘jquery’); } add_action(‘wp_enqueue_scripts’, ‘my_script’); This loads jQuery from WordPress core, the jQuery files can be … Read more

Extend Woocommerce Widget Class – WC_Widget_Product_Categories

When calling parent::__construct() from WC_Widget_Product_Departments the constructor of WC_Widget_Product_Categories immediately overwrites the class properties (especially the widget_id), see here at GitHub. So you have to extend WC_Widget to create a new widget and then you can copy anything what you need in your widget from WC_Widget_Product_Categories to WC_Widget_Product_Departments.

Remove an action by extending class and replacing it

Problem lies in this line: remove_action(‘woocommerce_before_my_account’, array( $this, ‘my_packages’)); This won’t remove action registered by parent class, because $this is a different object in this case, so you won’t remove any action at all. So how to remove such action? Since you can’t access the same $this value in your class, you’ll have to iterate … Read more