function lf_init_script() { /* Reset the query data because theme code might have moved the $post gloabl to point at different post rather than the current one, which causes our JS not to load properly. We do this in the footer because the wp_footer() should be the last thing called on the page. We don't do it earlier, because it might interfere with what the theme code is trying to accomplish. */ wp_reset_query(); global $post, $current_user, $wp_query; $network = $this->ext->get_network_option('livefyre_domain_name', LF_DEFAULT_PROFILE_DOMAIN); if (comments_open() && $this->livefyre_show_comments()) { // is this a post page? if ($parent_id = wp_is_post_revision($wp_query->post->ID)) { $original_id = $parent_id; } else { $original_id = $wp_query->post->ID; } $post_obj = get_post($wp_query->post->ID); $tags = array(); $posttags = get_the_tags($wp_query->post->ID); if ($posttags) { foreach ($posttags as $tag) { array_push($tags, $tag->name); } } $domain = $this->lf_core->lf_domain_object; $site = $this->lf_core->site; if (empty($tags)) { $article = $site->article($original_id, get_permalink($original_id), get_the_title($original_id)); } else { $article = $site->article($original_id, get_permalink($original_id), get_the_title($original_id), $tags = $tags); } $conv = $article->conversation(); $initcfg = array(); if ($network != LF_DEFAULT_PROFILE_DOMAIN) { if (function_exists('livefyre_onload_handler')) { $initcfg['onload'] = livefyre_onload_handler(); } if (function_exists('livefyre_delegate_name')) { $initcfg['delegate'] = livefyre_delegate_name(); } if (get_option('livefyre_auth_delegate_name', '') != '') { $initcfg['delegate'] = get_option('livefyre_auth_delegate_name', ''); } if (function_exists('livefyre_strings_chooser')) { $filename = livefyre_strings_chooser(); $initcfg['strings'] = $this->load_strings($filename); } else { $language = get_option('livefyre_language', 'English'); $initcfg['strings'] = $this->load_strings($language); } } else { $language = get_option('livefyre_language', 'English'); $initcfg['strings'] = $this->load_strings($language); } // Do we need to add in some things for Enterprise? echo $conv->to_initjs_v3('livefyre-comments', $initcfg); } if (!is_single()) { echo '<script type="text/javascript" data-lf-domain="' . $network . '" id="ncomments_js" src="' . $this->lf_core->assets_url . '/wjs/v1.0/javascripts/CommentCount.js"></script>'; } }
function lf_init_script() { global $post, $current_user, $wp_query; $network = $this->ext->get_option('livefyre_domain_name', LF_DEFAULT_PROFILE_DOMAIN); try { if ($this->livefyre_show_comments() && comments_open()) { // is this a post page? // It is possible that the ID of the queried object is for a revision. Be sure to get it back to the originating post. if ($parent_id = wp_is_post_revision($wp_query->get_queried_object_id())) { $original_id = $parent_id; } else { $original_id = $wp_query->get_queried_object_id(); } $post_obj = get_post($wp_query->get_queried_object_id()); $domain = $this->lf_core->lf_domain_object; $site = $this->lf_core->site; $article = $site->article($original_id, get_permalink($original_id), get_the_title($original_id)); $conv = $article->conversation(); $initcfg = array(); $initcfg['betaBanner'] = false; if (function_exists('livefyre_onload_handler')) { $initcfg['onload'] = livefyre_onload_handler(); } if (function_exists('livefyre_delegate_name')) { $initcfg['delegate'] = livefyre_delegate_name(); } echo $conv->to_initjs_v3('comments', $initcfg); } else { if (!is_single()) { echo '<script type="text/javascript" data-lf-domain="' . esc_attr($network) . '" id="ncomments_js" src="' . esc_url($this->lf_core->assets_url) . '/wjs/v1.0/javascripts/CommentCount.js"></script>'; } } } catch (Exception $error) { // do nothing but silence the jsonEncode utf-8 error see http://99deploys.wordpress.com/2014/05/27/these-fatal-errors-have-been/ // http://99deploys.wordpress.com/2014/05/21/i-got-99-fatals-and/ return false; } }