require_once LFAPPS__PLUGIN_PATH . "/libs/php/LFAPPS_JWT.php"; $network_name = get_option('livefyre_apps-livefyre_domain_name', 'livefyre.com'); $delegate_auth_url = 'http://admin.' . $network_name; $site_id = get_option('livefyre_apps-livefyre_site_id'); $article_id = get_the_ID(); $site_key = get_option('livefyre_apps-livefyre_site_key'); $collection_meta = array('title' => apply_filters('livefyre_collection_title', get_the_title(get_the_ID())), 'url' => apply_filters('livefyre_collection_url', get_permalink(get_the_ID())), 'articleId' => apply_filters('livefyre_article_id', get_the_ID()), 'type' => 'sidenotes'); $jwtString = LFAPPS_JWT::encode($collection_meta, $site_key); $conv_config = array('siteId' => $site_id, 'articleId' => $article_id, 'collectionMeta' => $jwtString, 'network' => $network_name, 'selectors' => get_option('livefyre_apps-livefyre_sidenotes_selectors')); $strings = apply_filters('livefyre_custom_sidenotes_strings', null); $conv_config_str = json_encode($conv_config); ?> <script type="text/javascript"> Livefyre.require(['<?php echo Livefyre_Apps::get_package_reference('sidenotes'); ?> '], function (Sidenotes) { load_livefyre_auth(); var convConfigSidenotes = <?php echo $conv_config_str; ?> ; convConfigSidenotes['network'] = "<?php echo esc_js($network_name); ?> "; <?php echo isset($strings) ? "convConfigSidenotes['strings'] = " . json_encode($strings) . ';' : ''; ?> if(typeof(livefyreSidenotesConfig) !== 'undefined') {
/** * Get the Livefyre.require package reference name and version * @return string */ public static function get_package_reference() { $option_version = get_option('livefyre_apps-livefyre_chat_version'); $available_versions = Livefyre_Apps::get_available_package_versions('fyre.conv'); if (empty($available_versions)) { $available_versions = array(LFAPPS_Chat::$default_package_version); } $required_version = Livefyre_Apps::get_package_reference(); if (is_null($required_version)) { if ($option_version == 'latest') { //get latest version $latest_version = array_pop($available_versions); if (strpos($latest_version, '.') !== false) { $required_version = substr($latest_version, 0, strpos($latest_version, '.')); } else { $required_version = $latest_version; } } else { $required_version = $option_version; } } return 'fyre.conv#' . $required_version; }
echo esc_js($collectionMetaToken); ?> ", checksum: "<?php echo esc_js($checksum); ?> " }; if(typeof(liveChatConfig) !== 'undefined') { convConfigChat<?php echo esc_js($articleId); ?> = lf_extend(liveChatConfig, convConfigChat<?php echo esc_js($articleId); ?> ); } Livefyre.require(['<?php echo Livefyre_Apps::get_package_reference('fyre.conv'); ?> '], function(ConvChat) { load_livefyre_auth(); new ConvChat(networkConfigChat, [convConfigChat<?php echo esc_js($articleId); ?> ], function(chatWidget) { }()); }); </script>