示例#1
0
 public function get_markup()
 {
     $element_size = $this->_get_property('element_size');
     $url = $this->_get_property('facebook_url');
     $global_settings = Upfront_SocialMedia_Setting::get_globals();
     if ($url == '' && $global_settings) {
         $services = $global_settings['services'];
         $url = false;
         foreach ($services as $s) {
             if ($s->id == 'facebook') {
                 $url = $s->url;
             }
         }
         if (!$url) {
             return $this->wrap(self::_get_l10n('url_nag'));
         }
     }
     if ($url) {
         $parts = parse_url($url);
         $fbname = end(explode('/', trim($parts['path'], '/')));
         $wide = intval($element_size['width']) - 22;
         if ($wide % 53 > 0) {
             $wide = intval($wide / 53) * 53 + 22;
         } else {
             $wide = $element_size['width'];
         }
         return $this->wrap("<iframe src='//www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2F{$fbname}&amp;width={$wide}&amp;height={$element_size['height']}&amp;show_faces=true&amp;colorscheme=light&amp;stream=false&amp;show_border=true&amp;header=false' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:{$wide}px; height:{$element_size['height']}px;' allowTransparency='true'></iframe>");
     } else {
         return $this->wrap(self::_get_l10n('url_nag'));
     }
 }
示例#2
0
function upfront_social_media_initialize()
{
    // Include the backend support stuff
    require_once dirname(__FILE__) . '/lib/upfront-social-media.php';
    // Expose our JavaScript definitions to the Upfront API
    upfront_add_layout_editor_entity('upfront-social_media', upfront_relative_element_url('js/upfront-social-media', __FILE__));
    // Add the public stylesheet
    add_action('wp_enqueue_scripts', array('Upfront_SocialMediaView', 'add_public_style'));
    add_action('upfront_data', array('Upfront_SocialMediaView', 'add_upfront_data'));
    add_filter('upfront_l10n', array('Upfront_SocialMediaView', 'add_l10n_strings'));
    //Add social to the posts
    Upfront_SocialMedia_Setting::add_post_filters();
}
 public static function add_upfront_data($data)
 {
     $globals = get_option('upfront_social_media_global_settings', false);
     // if by any chance the global data in the database is corrupt, then reset
     $globals_array = Upfront_SocialMedia_Setting::properties_to_array(json_decode($globals));
     if (!isset($globals_array['services']) || sizeof($globals_array['services']) < 1) {
         delete_option('upfront_social_media_global_settings');
         $globals = false;
     }
     $data['usocial'] = array('defaults' => self::default_properties(), 'global_defaults' => array('services' => array('facebook' => array('name' => 'Facebook', 'id' => 'facebook', 'url' => '', 'active' => false, 'meta' => array()), 'twitter' => array('name' => 'Twitter', 'id' => 'twitter', 'url' => '', 'active' => false, 'meta' => array(array('id' => 'consumer_key', 'name' => self::_get_l10n('consumer_key'), 'value' => ''), array('id' => 'consumer_secret', 'name' => self::_get_l10n('consumer_secret'), 'value' => ''))), 'google' => array('name' => 'Google +', 'id' => 'google', 'url' => '', 'active' => false, 'meta' => array())), 'inpost' => array('yes'), 'after_title' => array('yes'), 'after_title_align' => 'left', 'after_content' => array(), 'after_content_align' => 'left', 'counter_style' => 'horizontal'));
     if ($globals) {
         $data['usocial']['globals'] = Upfront_SocialMedia_Setting::properties_to_array(json_decode($globals));
     }
     return $data;
 }