[The Hub Client] Hub Client – add field for custom JS/CSS

0

Nice easy one. 2 fields in the Hub Client admin for custom js / css.

An example use case: Live chat. You support a couple of different live chat providers, but not the one we use (Zoho Sales IQ). Having a js field would allow us to add our own live chat and provide better support to our customers

  • Patrick Freitas
    • FLS

    Hi Chris Ryu (Dorset Tech)

    I hope you are doing well.

    We actually have two hooks that you can use for it, but then it requires some custom coding:

    <?php
    	/**
    	 * Fires before </head> close tag on HTML of Hub Client front page
    	 *
    	 * @since 1.0.0
    	 */
    	do_action( 'wpmudev_hub_template_head' );

    For example:

    add_action('wpmudev_hub_template_footer, function(){ ?>
    
    <style> .. CSS .. </style>
    
    }, 20 );

    And

    <?php
    /**
     * Fires before </body> close tag on HTML of Hub Client front page
     *
     * @since 1.0.0
     */
    do_action( 'wpmudev_hub_template_footer' );

    Just remember that HUB Client fetches the content from API, for example, if you need to trigger a JS it is a good idea to add a set timeout.

    I wouldn’t suggest allowing JS directly in the database as it is not safe, instead, a better approach is to create the integration on the plugin side and the script is generated on the fly, but maybe CSS could work well.

    I also escalated this request to our developers and designers.

    Best Regards
    Patrick Freitas