/**
  * Initialise Livefyre auth
  */
 public static function init_auth()
 {
     if (self::$auth_initiated) {
         return false;
     }
     self::$auth_initiated = true;
     LFAPPS_View::render_partial('script_auth');
 }
 /**
  * Run Livefyre Apps General page
  */
 public static function menu_general()
 {
     $conflicting_plugins = Livefyre_Apps::get_conflict_plugins();
     if (count($conflicting_plugins) > 0) {
         self::menu_plugin_conflict();
         return;
     }
     //process data returned from livefyre.com community sign up
     if (self::verified_blog()) {
         update_option('livefyre_apps-livefyre_domain_name', 'livefyre.com');
         update_option('livefyre_apps-livefyre_site_id', sanitize_text_field($_GET["site_id"]));
         update_option('livefyre_apps-livefyre_site_key', sanitize_text_field($_GET["secretkey"]));
     }
     LFAPPS_View::render('general');
 }
 /**
  * Check if comments are active and there are no issues stopping them from loading
  * @return boolean
  */
 public static function comments_active()
 {
     return Livefyre_Apps::active();
 }
 /**
  * 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;
 }
 /**
  * Check if comments are active and there are no issues stopping them from loading
  * @return boolean
  */
 public static function blog_active()
 {
     return Livefyre_Apps::active();
 }
Ejemplo n.º 6
0
                                        <p><a target="_blank" href="http://web.livefyre.com/streamhub/#liveBlog">Click here</a> for more information.</p>
                                    </div>
                                </div>
                                <div class='lfapps-appmgt-box enterprise-only'>
                                    <label for='lfapps_chat_enable'>
                                        <?php 
$icon_src = Livefyre_Apps::is_app_enabled('chat') ? 'lf-chat-icon.png' : 'lf-chat-icon-grey.png';
?>
                                        <img id="lfapps_chat_icon" src="<?php 
echo esc_url(LFAPPS__PLUGIN_URL . 'assets/img/' . $icon_src);
?>
"/>
                                    </label>
                                    <div class="lfapps-appmgt-controls">
                                        <input id="lfapps_chat_enable" name="livefyre_apps-apps[]" type="checkbox" value="chat" <?php 
echo Livefyre_Apps::is_app_enabled('chat') ? 'checked' : '';
?>
>
                                        <label for='lfapps_chat_enable'>
                                            <span><?php 
esc_html_e('Chat™', 'lfapps');
?>
</span>
                                        </label>
                                        <p><a target="_blank" href="http://web.livefyre.com/streamhub/#liveChat">Click here</a> for more information.</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="major-publishing-actions">
                            <div id="publishing-action">
    </script>    
    
    <div class='postbox-large'>
        <div class="postbox-container">
            <div id="normal-sortables" class="meta-box-sortables ui-sortable">                
                <div id="referrers" class="postbox">
                    <div class="handlediv" title="Click to toggle"><br></div>
                    <h3 class="hndle"><span><?php 
esc_html_e('Livefyre Plugin Conflict', 'lfapps');
?>
</span></h3>
                    <div class="inside">
                        <p>The following plugins cannot run at the same time as Livefyre Apps. Please de-activate these plugins before you can use Livefyre Apps.</p>
                        <ul>
                            <?php 
foreach (Livefyre_Apps::get_conflict_plugins() as $plugin) {
    ?>
                            <li><?php 
    echo esc_html('- ' . $plugin);
    ?>
</li>
                            <?php 
}
?>
                        </ul>
                        <p>Check your plugin settings to make sure that Livefyre Comments and Livefyre Sidenotes are deactivated.</p>
                    </div>
                </div>
            </div>
        </div>        
    </div>
Ejemplo n.º 8
0
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 list of post types where LiveChat is enabled
  * @return array
  */
 public static function get_chat_display_post_types()
 {
     $used_types = array();
     if (Livefyre_Apps::is_app_enabled('chat')) {
         $excludes = array('_builtin' => false);
         $post_types = get_post_types($excludes);
         $post_types = array_merge(array('post' => 'post', 'page' => 'page'), $post_types);
         foreach ($post_types as $post_type) {
             $post_type_name = 'livefyre_chat_display_' . $post_type;
             if (get_option('livefyre_apps-' . $post_type_name) === true || get_option('livefyre_apps-' . $post_type_name) === 'true') {
                 $used_types[$post_type_name] = $post_type_name;
             }
         }
     }
     return $used_types;
 }
 /**
  * Run shortcode [livecomments]
  * @param array $atts array of attributes passed to shortcode
  */
 public static function init_shortcode($atts = array())
 {
     if (isset($atts['article_id'])) {
         $articleId = $atts['article_id'];
         $title = isset($pagename) ? $pagename : 'Comments (ID: ' . $atts['article_id'];
         global $wp;
         $url = add_query_arg($_SERVER['QUERY_STRING'], '', home_url($wp->request));
         $tags = array();
     } else {
         global $post;
         if (get_the_ID() !== false) {
             $articleId = apply_filters('livefyre_article_id', get_the_ID());
             $title = apply_filters('livefyre_collection_title', get_the_title(get_the_ID()));
             $url = apply_filters('livefyre_collection_url', get_permalink(get_the_ID()));
             $tags = array();
             $posttags = get_the_tags($post->ID);
             if ($posttags) {
                 foreach ($posttags as $tag) {
                     array_push($tags, $tag->name);
                 }
             }
         } else {
             return;
         }
     }
     Livefyre_Apps::init_auth();
     $network = get_option('livefyre_apps-livefyre_domain_name', 'livefyre.com');
     $network = $network == '' ? 'livefyre.com' : $network;
     $siteId = get_option('livefyre_apps-livefyre_site_id');
     $siteKey = get_option('livefyre_apps-livefyre_site_key');
     $network_key = get_option('livefyre_apps-livefyre_domain_key', '');
     $network = Livefyre::getNetwork($network, strlen($network_key) > 0 ? $network_key : null);
     $site = $network->getSite($siteId, $siteKey);
     $collectionMetaToken = $site->buildCollectionMetaToken($title, $articleId, $url, array("tags" => $tags, "type" => "livecomments"));
     $checksum = $site->buildChecksum($title, $url, $tags, 'livecomments');
     $strings = apply_filters('livefyre_custom_comments_strings', null);
     $livefyre_element = 'livefyre-comments-' . $articleId;
     $display_template = true;
     return LFAPPS_View::render_partial('script', compact('siteId', 'siteKey', 'network', 'articleId', 'collectionMetaToken', 'checksum', 'strings', 'livefyre_element', 'display_template'), 'comments', true);
 }
Ejemplo n.º 11
0
"><?php 
    echo esc_html_e($post_type, 'lfapps-chat');
    echo $disabled ? ' <small><em>(Comments enabled.)</em></small>' : '';
    ?>
</label><br/>
                                        <?php 
}
?>
                                </td>
                            </tr>
                            <tr>                               
                                <?php 
esc_html_e('(Select the types of posts on which you wish to enable Chat. Note: Only Chat or Comments may be enabled for each of these options.)', 'lfapps-chat');
?>
                                <?php 
$available_versions = Livefyre_Apps::get_available_package_versions('fyre.conv');
if (empty($available_versions)) {
    $available_versions = array(LFAPPS_Chat::$default_package_version);
}
$available_versions['latest'] = 'latest';
$available_versions = array_reverse($available_versions);
?>
                                <th align="left" scope="row">
                                    <?php 
esc_html_e('Package version', 'lfapps-chat');
?>
<br/>
                                    <span class="info"><?php 
esc_html_e('(If necessary you can revert back to an older version if available)', 'lfapps-chat');
?>
</span>
                            window.location = href;
                        },
                        editProfile: function() {
                            href = "<?php 
    echo admin_url('profile.php');
    ?>
";
                            window.location = href;
                        }
                    });

            <?php 
    if (is_user_logged_in()) {
        ?>
                        auth.authenticate({livefyre: "<?php 
        echo esc_js(Livefyre_Apps::generate_wp_user_token());
        ?>
"});
            <?php 
    }
    ?>
                    window.authDelegate = auth.delegate;
                });
            }
            livefyre_auth_loaded = true;
        };
    </script>
<?php 
} elseif (get_option('livefyre_apps-auth_type') === 'auth_delegate') {
    ?>
    <script type="text/javascript">
 /**
  * Check if comments are active and there are no issues stopping them from loading
  * @return boolean
  */
 public static function sidenotes_active()
 {
     return Livefyre_Apps::active();
 }
Ejemplo n.º 14
0
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>
Ejemplo n.º 15
0
    esc_html_e('(The selectors option is used to specify which content can be Sidenoted. More information can be found ', 'lfapps-sidenotes');
    ?>
 <a href="http://answers.livefyre.com/developers/app-integrations/sidenotes/#Selectors" target="_blank">here</a>)</span>
                                </th>
                            </tr>
                            <tr>
                                <td align="left" valign="top">
                                    <textarea id='livefyre_apps-livefyre_sidenotes_selectors' name='livefyre_apps-livefyre_sidenotes_selectors' cols='60' rows='6'><?php 
    echo esc_html(get_option('livefyre_apps-livefyre_sidenotes_selectors'));
    ?>
</textarea>
                                </td>
                            </tr>
                            <tr>                               
                                <?php 
    $available_versions = Livefyre_Apps::get_available_package_versions('sidenotes');
    if (empty($available_versions)) {
        $available_versions = array(LFAPPS_Chat::$default_package_version);
    }
    $available_versions['latest'] = 'latest';
    $available_versions = array_reverse($available_versions);
    ?>
                                <th align="left" scope="row">
                                    <?php 
    esc_html_e('Package version', 'lfapps-chat');
    ?>
<br/>
                                    <span class="info"><?php 
    esc_html_e('(If necessary you can revert back to an older version if available)', 'lfapps-chat');
    ?>
</span>
Ejemplo n.º 16
0
 public static function show_blog()
 {
     global $post;
     /* Is this a post and is the settings checkbox on? */
     $display_posts = is_single() && get_option('livefyre_apps-livefyre_blog_display_post');
     /* Is this a page and is the settings checkbox on? */
     $display_pages = is_page() && get_option('livefyre_apps-livefyre_blog_display_page');
     /* Are comments open on this post/page? */
     $comments_open = $post->comment_status == 'open';
     $display = $display_posts || $display_pages;
     $post_type = get_post_type();
     if ($post_type != 'post' && $post_type != 'page') {
         $post_type_name = 'livefyre_blog_display_' . $post_type;
         $display = get_option('livefyre_apps-' . $post_type_name, 'true') == 'true';
         if ($post_type === false) {
             $display = true;
         }
     }
     return $display && Livefyre_Apps::is_app_enabled('blog') && !is_preview();
 }