|
<?php |
|
function my_theme_enqueue_styles() { |
|
$parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme. |
|
|
|
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); |
|
wp_enqueue_style( 'child-style', |
|
get_stylesheet_directory_uri() . '/style.css', |
|
array( $parent_style ), |
|
wp_get_theme()->get('Version') |
|
); |
|
} |
|
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); |
|
|
|
// Code below from: https://gist.github.com/thewheat/887c6009c8058e8140a0f8c086e3b841 |
|
// If you wish to manually install Intercom without any plugin: https://gist.github.com/JackGJenkins/039bdfce9c82cdc2eeb09df42d5079f3 |
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////// |
|
// Customise functionality of the default Intercom Wordpress plugin |
|
// https://github.com/intercom/intercom-wordpress |
|
//////////////////////////////////////////////////////////////////////////////////////////////////// |
|
// This code can be added to a plugin or a theme |
|
// Simplest install would be in your theme's function.php file |
|
//////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
// customise the current Intercom script |
|
// - add custom attributes https://docs.intercom.io/configuring-intercom/send-custom-user-attributes-to-intercom |
|
// - add custom activator https://docs.intercom.io/configuring-Intercom/in-app-messenger#custom-style |
|
function customise_intercom(){ |
|
// $current_user = wp_get_current_user(); // get current Wordpress user if needed |
|
echo "\n".'<script>'; |
|
// ensure this is defined, i.e. don't break if Intercom plugin not installed |
|
echo "\n".'window.intercomSettings = window.intercomSettings || {};'; |
|
|
|
// specify custom attributes |
|
// echo "\n".'window.intercomSettings["test_string"] = "123";'; |
|
// widget activator old messenger |
|
// echo "\n".'window.intercomSettings.widget = {"activator":"#idOfActivatorElement"};'; |
|
/////////////////////////////////////////////////////////////////////////////////////////// |
|
// new messenger customizations |
|
// https://docs.intercom.com/configure-intercom-for-your-product-or-site/customize-the-intercom-messenger/customize-the-intercom-messenger-technical |
|
/////////////////////////////////////////////////////////////////////////////////////////// |
|
// use a customer element as a launcher |
|
// echo "\n".'window.intercomSettings["custom_launcher_selector"] = "#idOfActivatorElement";'; |
|
// hide the messenger |
|
echo "\n".'window.intercomSettings["hide_default_launcher"] = false;'; |
|
echo "\n".'</script>'."\n"; |
|
} |
|
// priority 20 ensures it loads after Intercom plugin which users the default value of 10 |
|
// https://developer.wordpress.org/reference/functions/add_action/ |
|
// https://github.com/intercom/intercom-wordpress/blob/master/bootstrap.php |
|
add_action('wp_footer', 'customise_intercom',20); |
|
//////////////////////////////////////////////////////////////////////////////////////////////////// |
|
// add Intercom to admin dashboard i.e. /wp-admin/ interface - 1 |
|
add_action('admin_footer', 'add_intercom_snippet'); |
|
add_action('admin_footer', 'customise_intercom'); |
|
// add Intercom to admin dashboard i.e. /wp-admin/ interface - 0 |
|
//////////////////////////////////////////////////////////////////////////////////////////////////// |