Public Ticket #3222702

edit-product

Closed
Comments
1 Ticket 1
Moz started the conversation 4 years ago on February 2, 2023 at 5:49pm

I'm writing a plugin to extend functionality of product page according to the site requirements. I have copied the page edit-product.php in the child theme directory. The theme used is Flatsome.
In the plugin I need to enqueue script and css.

I have read in precedent ticket to use the hook

add_action('marketking_dashboard_head', array($this, 'frontend_enqueue'));

public function frontend_enqueue(){

add_action('wp_print_scripts', function () { 

wp_enqueue_script('frontend_pagejs', PluginUtils::$PLUGIN_URL . '/js/frontend-page.js', array('jquery'), '1.0'); });

}

An then I have done as I read:

"...MarketKing completely disconnects the dashboard from default styles and scripts - we did this because we want to preserve the specific design of the dashboard, regardless of theme and other plugins, and prevent conflict.

Copy the marketking-dashboard-login.php file (from marketking core / public / dashboard) to your child theme, and edit it there.

In that file you will find lines of code that start with:

$wp_styles->queue =

$wp_scripts->queue =

"

For me doesn't work. I work just if I modify marketking-dashboard-login.php in your plugin directory.


To Sum up, I just want to know how to properly load custom js and css in the edit-product.php using wp_enqueue_script and wp_enqueue_style.

Thank you!





2,762
KingsPlugins replied 4 years ago on February 2, 2023 at 6:25pm

Hi there,

Thank you for purchasing our plugin!

I understand that you are working on a modified edit-product.php in your child theme. If you want to enqueue custom scripts / style there, you can just add this CODE at the top of the edit-product.php page:

add_action('wp_print_styles', function(){
    wp_enqueue_style ( 'b2bking_global_admin_style', plugins_url('assets/css/adminglobal.css', __FILE__));
});
add_action('wp_print_scripts', function(){
    
    wp_enqueue_script('chartist', plugins_url('assets/dashboard/chartist/chartist.min.js', __FILE__), $deps = array(), $ver = false, $in_footer =true);
});

Any styles go in the top part, any scripts in the bottom part. The 2 lines there (b2bking / chartist) are just examples and should be removed.


Regarding where exactly to add that, you can add it before "Integrations" around line 90:

4719659575.png



Please let me know if that works for you,


Kind regards,

Stefan

1 Ticket 1
Moz replied 4 years ago on February 3, 2023 at 11:48am

Thank you Stefan for you fast reply!

I have tried to copy marketking-dashboard-login.php in the child them directory, but it seems as if this file is not being considered. instead if I add my code in the original file of your plugin it works. So there is no way to make this change without changing the original marketing plugin file?

1 Ticket 1
Moz replied 4 years ago on February 3, 2023 at 8:58pm

Hi! 

After marketing core update (I was using 1.3.0) and coping edit-product.php and marketking-dashboard-login.php under flatsome-child/marketking 

IT WORKS!!!

Thank you so much for your help!

1

Sign In