Plugin Directory

Changeset 1089546


Ignore:
Timestamp:
02/14/2015 01:03:29 AM (11 years ago)
Author:
louyx
Message:

Version 2.0

Location:
fp/trunk
Files:
43 added
7 deleted
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • fp/trunk/fp.php

    r482880 r1089546  
    44Description: All the tools you need to integrate your wordpress and facebook.
    55Author: Louy
    6 Version: 1.4
     6Version: 2.0
    77Author URI: http://l0uy.com/
    88Text Domain: fp
     
    1313 add your info and uncomment the following three lines:
    1414*/
     15
    1516//define('FACEBOOK_APP_ID', 'EnterYourAppIDHere');
    1617//define('FACEBOOK_APP_SECRET', 'EtnterYourSecretHere');
    1718//define('FACEBOOK_FANPAGE', 'EnterYourPageIDHere');
    18 
    1919//define('FACEBOOK_DISABLE_LOGIN', true);
    2020
     
    2222load_plugin_textdomain( 'fp', false, dirname( plugin_basename( __FILE__ ) ) . '/po/' );
    2323
    24 define('FP_VERSION', '1.4');
     24define( 'FP_VERSION', '2.0' );
     25define( 'FP_PHP_VERSION_REQUIRED', '5.4.0' );
    2526
    26 require_once dirname(__FILE__).'/wp-oauth.php';
    27 
    28 /**
    29  * FacePress Core:
    30  */
    3127function fp_activate(){
    32     oauth_activate();
    33    
    3428    // require PHP 5
    35     if (version_compare(PHP_VERSION, '5.0.0', '<')) {
     29    if( version_compare(PHP_VERSION, FP_PHP_VERSION_REQUIRED, '<')) {
    3630        deactivate_plugins(basename(__FILE__)); // Deactivate ourself
    37         wp_die(__("Sorry, FacePress requires PHP 5 or higher. Ask your host how to enable PHP 5 as the default on your servers.", 'fp'));
     31        wp_die( sprintf( __("Sorry, FacePress requires PHP %1$s or higher. Ask your host how to enable PHP %1$s as the default on your servers.", 'tp'), FP_PHP_VERSION_REQUIRED ) );
    3832    }
    3933}
    4034register_activation_hook(__FILE__, 'fp_activate');
    4135
    42 if( !isset( $_SERVER['HTTPS'] ) )
    43     $_SERVER['HTTPS'] = false;
    44 
    45 add_action('init','fp_init');
    46 function fp_init() {
    47 
    48     wp_enqueue_script('jquery');
    49 
    50     if (session_id() == '') {
    51         session_start();
    52     }
    53    
    54     isset($_SESSION['fb-connected']) or
    55         $_SESSION['fb-connected'] = false;
    56    
     36if( version_compare(PHP_VERSION, FP_PHP_VERSION_REQUIRED, '>=') ) {
     37    require_once dirname(__FILE__) . '/fp-social.php';
     38    global $fp;
     39    $fp = FP_Social::get_instance(__FILE__);
    5740}
    58 
    59 function fp_app_options_defined() {
    60     return defined('FACEBOOK_APP_ID') && defined('FACEBOOK_APP_SECRET');
    61 }
    62 
    63 function fp_options($k=false) {
    64     $options = get_option('fp_options');
    65 
    66     if( !is_array($options) ) {
    67         add_option('fp_options', $options = array(
    68             'allow_comment' => false,
    69             'comm_text' => '',
    70             'like_position' => '',
    71             'like_layout' => '',
    72             'like_send' => 'true',
    73             'like_action' => '',
    74             'like_css' => '',
    75         ));
    76     }
    77 
    78     $options = array_merge($options, fp_app_options());
    79     if( $k ) {
    80             $options = $options[$k];
    81     }
    82     return $options;
    83 }
    84 
    85 function fp_app_options() {
    86     $options = get_site_option('fp_app_options');
    87 
    88     if( !is_array($options) ) {
    89         add_site_option('fp_app_options', $options = array(
    90             'appId' => '',
    91             'secret' => '',
    92             'fanpage' => '',
    93             'disable_login' => false
    94         ));
    95     }
    96 
    97     if( fp_app_options_defined() ) {
    98         defined('FACEBOOK_FANPAGE') or
    99         define('FACEBOOK_FANPAGE', '');
    100        
    101         defined('FACEBOOK_DISABLE_LOGIN') or
    102         define('FACEBOOK_DISABLE_LOGIN', fales);
    103        
    104         $options['appId']         = FACEBOOK_APP_ID       ;
    105         $options['secret']        = FACEBOOK_APP_SECRET   ;
    106         $options['fanpage']       = FACEBOOK_FANPAGE      ;
    107         $options['disable_login'] = FACEBOOK_DISABLE_LOGIN;
    108     }
    109 
    110     return $options;
    111 }
    112 
    113 function fp_ready() {
    114     $o = fp_app_options();
    115     return isset($o['appId'])  && !empty($o['appId']) &&
    116            isset($o['secret']) && !empty($o['secret']);
    117 }
    118 
    119 function fb_access_token() {
    120     if( $_SESSION['fb-connected'] ) {
    121         return $_SESSION['fp_access_token'];
    122     }
    123     return false;
    124 }
    125 
    126 function fb_app_access_token() {
    127     if( fp_ready() ) {
    128         return fp_options('appId') . '|' . fp_options('secret');
    129     }
    130     return false;
    131 }
    132 
    133 function fb_me() {
    134     if( $_SESSION['fb-connected'] ) {
    135         return $_SESSION['fb-me'];
    136     }
    137     return false;
    138 }
    139 
    140 function fb_all_js() {
    141     /* translators: Facebook Locale */
    142     $locale = _x('en_US', 'FB Locale', 'fp');
    143 ?>
    144 <div id="fb-root"></div>
    145 <script>(function(d, s, id) {
    146   var js, fjs = d.getElementsByTagName(s)[0];
    147   if (d.getElementById(id)) {return;}
    148   js = d.createElement(s); js.id = id;
    149   js.src = "//connect.facebook.net/<?php echo $locale; ?>/all.js#xfbml=1&appId=<?php echo fp_options('appId'); ?>";
    150   fjs.parentNode.insertBefore(js, fjs);
    151 }(document, 'script', 'facebook-jssdk'));</script>
    152 <?php
    153 }
    154 
    155 // basic XFBML load into footer
    156 add_action('wp_footer','fb_all_js',20);
    157 
    158 // fix up the html tag to have the FBML extensions
    159 //add_filter('language_attributes','fp_lang_atts');
    160 function fp_lang_atts($lang) {
    161     return ' xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/" '.$lang;
    162 }
    163 
    164 function fp_get_connect_button($action='', $perms = '', $data = array(), $image ='login-with-fb.gif') {
    165     $image = apply_filters('fp_connect_button_image', $image, $action);
    166     $imgsrc = apply_filters('fp_connect_button_image_src', plugins_url() . '/fp/images/'.$image, $image, $action);
    167     $return = '<a href="' . oauth_link('facebook', array(
    168                 'action' => $action,
    169                 'location' => fp_get_current_url(),
    170                 'perms' => $perms
    171                 ) ) . '" title="'.__('Login with Facebook', 'fp').'"';
    172                
    173     foreach( $data as $k => $v ) {
    174         $return .= " $k=\"$v\"";
    175     }
    176    
    177     $return .= '>'.
    178             '<img src="'.$imgsrc.'" alt="'.__('Login with Facebook', 'fp').'" style="border:none;" />'.
    179         '</a>';
    180     return apply_filters('fp_get_connect_button', $return, $action, $perms, $image, $data);
    181 }
    182 
    183 function fp_get_current_url() {
    184     // build the URL in the address bar
    185     $requested_url  = ( !empty($_SERVER['HTTPS'] ) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
    186     $requested_url .= $_SERVER['HTTP_HOST'];
    187     $requested_url .= $_SERVER['REQUEST_URI'];
    188     return $requested_url;
    189 }
    190 
    191 // this adds the app id to allow you to use Facebook Insights on your domain, linked to your application.
    192 add_action('wp_head','fp_meta_head');
    193 function fp_meta_head() {
    194     $options = fp_options();
    195    
    196     if ($options['appId']) {
    197     ?>
    198 <meta property='fb:app_id' content='<?php echo $options['appId']; ?>' />
    199 <?php
    200     }
    201     ?>
    202 <meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
    203 <?php
    204     if ( is_singular() ) {
    205         global $wp_the_query;
    206         if ( $id = $wp_the_query->get_queried_object_id() ) {
    207             $link = get_permalink( $id );
    208             echo "<meta property='og:url' content='{$link}' />\n";
    209         }
    210     } else if (is_home()) {
    211         $link = get_bloginfo('url');
    212         echo "<meta property='og:url' content='{$link}' />\n";
    213     }
    214     do_action('og_meta');
    215 }
    216 
    217 require_once 'fp-oauth.php';
    218 
    219 require_once 'fp-login.php';
    220 
    221 require_once 'fp-admin.php';
    222 
    223 require_once 'fp-comment.php';
    224 
    225 require_once 'fp-like.php';
    226 
  • fp/trunk/la-social/wp-oauth.php

    r880404 r1089546  
    1717function oauth_init() {
    1818    global $wp, $oauth_activate;
    19    
     19
    2020    add_rewrite_rule('oauth/(.+)/?$', 'index.php?oauth=$matches[1]',1);
    2121    add_rewrite_rule('oauth/?', 'index.php?oauth=null',1);
    22    
     22
    2323    $wp->add_query_var('oauth');
    24    
    2524}
    2625
     
    3433        // Nothing happened!?
    3534        do_action('wp_oauth_unknown_site');
    36         die( __('OAuth site not recognized!') );
     35        wp_die( __('OAuth site not recognized!') );
    3736    }
    3837}
    3938
    4039function oauth_link($site,$args=array()){
     40    global $wp_rewrite;
     41
    4142    $link = get_bloginfo('url');
    42     $link .= '/oauth/' . $site;
     43    if( $wp_rewrite->using_permalinks() ) {
     44        $link .= '/oauth/' . $site;
     45    } else {
     46        $link = add_query_arg(array(
     47            'oauth' => $site
     48        ), $link);;
     49    }
    4350    $link = add_query_arg($args, $link);
     51
    4452    return $link;
    4553}
  • fp/trunk/readme.txt

    r880404 r1089546  
    11=== Plugin Name ===
    22Contributors: louyx
    3 Author URL: http://louyblog.wordpress.com/
    4 Tags: facebook, oauth, login, share, likebutton, comment, connect
    5 Requires at least: 3.0
    6 Tested up to: 3.7
     3Author URL: http://l0uy.com/
     4Tags: Facebook, oauth, login, share, likebutton, comment, connect
     5Requires at least: 3.3
     6Tested up to: 4.1
    77Stable tag: 1.4
    88
    9 All the tools you need to integrate your wordpress and facebook.
     9All the tools you need to integrate WordPress and Facebook.
    1010
    1111== Description ==
    1212
    13 FacePress, is a plugin that allows you to integrate facebook and your blog very easily, you just need to configure a few stuff and voila! you're done! Happy FaceBook-ing.
     13FacePress, is a plugin that allows you to integrate Facebook and your blog very easily, you just need to configure a few stuff and voila! you're done! Happy FaceBook-ing.
    1414
    1515= Key Features =
    1616
    17 * Allow your visitors to comment using their facebook ids
     17* Allow your visitors to comment using their Facebook ids
    1818* Adds a like button to your posts, so your visitors can share your content.
    19 * Allow your blog users to sign in with their facebook ids. one click signin!
     19* Allow your blog users to sign in with their Facebook ids. one click signin!
    2020
    2121== Changelog ==
     22
     23== Changelog ==
     24
     25= 2.0 =
     26* Rewritten from ground up. Cleaner code and more extensibility.
     27* Now using Facebook PHP SDK v4.
    2228
    2329= 1.4 =
     
    2531
    2632= 1.3 =
    27 * Fixing an issue with facebook and SSL on some servers
     33* Fixing an issue with Facebook and SSL on some servers
    2834* Using Facebook HTML5 support and graph API
    2935
    3036= 1.2 =
    31 * Adding an option to disable login with facebook in the app settings page
     37* Adding an option to disable login with Facebook in the app settings page
    3238
    3339= 1.1 =
Note: See TracChangeset for help on using the changeset viewer.