\

Namespaces

Gianism

Constants

GIANISM_VERSION

GIANISM_VERSION

Plugin version

GIANISM_DOMAIN

GIANISM_DOMAIN

Domain for i18n

GIANISM_DOC_UPDATED

GIANISM_DOC_UPDATED

Documented date

Functions

gianism_message()

gianism_message(int $user_id, string $body, int $from, string $subject) : bool

Save message to specified user

If user's email is pseudo one(e.g. example@pseudo.twitter.com), WordPress's mail function wp_mail fails. This function is originally used for wp_mail fallback. But you can use this function to send message which will be displayed on admin screen.

Parameters

int $user_id
string $body
int $from
string $subject

Returns

bool

get_facebook_id()

get_facebook_id(int $user_id) : string

Returns Facebook ID

Parameters

int $user_id

Returns

string

get_facebook_publish_permission_link()

get_facebook_publish_permission_link(string $redirect_url, string $action, array $args) : string

Returns url to get Publish stream permission

This function itself has no effect without action hook. See example below:

// In some template, display button.
get_facebook_publish_permission_link(get_permalink(), 'my_favorite_action', array('post_id' => get_the_ID()));

// Then, hook action in functions.php in your theme.
add_action('my_favorite_action', 'my_publish_action');

function my_publish_action($facebook, $args){
     $post = get_post($args['post_id']);
     try{
         $facebook->api("/me/feed", "POST", array(
         "message" => "I read this article!",
         "link" => get_permalink($post->ID),
         "name" => get_the_title($post->ID),
         "description" => strip_tags($post->post_content),
         "action" => json_encode(array(
             "name" => get_bloginfo('name'),
             "link" => home_url('/')))
         ));
     }catch(FacebookApiException $e){
         // Error
         wp_die($e->getMessage());
      }
}

Parameters

string $redirect_url

URL where user will be redirect afeter authentication

string $action

Action name which will be fired after authenticaction

array $args

Array which will be passed to action hook

Returns

string

gianism_fb_admin()

gianism_fb_admin() : \Facebook|\WP_Error

Get facebook API client for admin

$fb = gianism_fb_admin();
if( !is_wp_error($fb) ){
    // Get feed.
    $feeds = $fb->api('/me/feed');
    // Post feed.
    $fb->api('/me/feed', 'POST', array(
        'message' => 'Hola!',
    ));
}

Returns

\Facebook|\WP_Error

gianism_fb_admin_id()

gianism_fb_admin_id() : int|string

Get admin facebook id

This will be user id or facebook page id.

// Example
$fb = gianism_fb_admin();
if( !is_wp_error($fb) ){
    $feed = $fb->api(gianism_fb_admin_id().'/feed');
    foreach( $feed['data'] as $status ){
        // Do stuff.
    }
}

Returns

int|string

is_user_connected_with()

is_user_connected_with(string $service, int $user_id) : boolean

Returns if user is connected with particular web service.

Parameters

string $service

One of facebook, mixi, yahoo, twitter or google.

int $user_id

If not specified, current user id will be used.

Returns

boolean

get_user_by_service()

get_user_by_service(string $service, mixed $credential) : \WP_User

Get user object by credencial

Only facebook is supported.

Parameters

string $service
mixed $credential

Returns

\WP_User

is_user_like_fangate()

is_user_like_fangate() : boolean

Returns if current user liked or not.

You can use this function only on Facebook fan page tab.

Returns

boolean

is_guest_on_fangate()

is_guest_on_fangate() : boolean

Returns if current user is guest.

Valid only on facebook fan gate.

Returns

boolean

is_user_registered_with()

is_user_registered_with(string $service) : boolean

Returns if current user has wordpress account.

You can this function only on Facebook fan page tab.

Parameters

string $service

Returns

boolean

get_user_id_on_fangate()

get_user_id_on_fangate() : string|boolean

Returns facebook id on fan gate.

Returns

string|boolean

get_twitter_screen_name()

get_twitter_screen_name(int $user_id) : string|false

Get Twitter Screen Name

Parameters

int $user_id

Returns

string|false

update_twitter_status()

update_twitter_status(string $string)

Update Twitter timeline

Parameters

string $string

twitter_reply_to()

twitter_reply_to(int $user_id, string $string) : boolean

Reply to specified user by Owner Account

Parameters

int $user_id
string $string

Returns

boolean

twitter_get_timeline()

twitter_get_timeline(string $screen_name, array $additional_data) : object

Get twitter time line in JSON format object

Caching is recommended.

$timeline = get_transient('twitter_timeline');
if( false === $timeline){
    $timeline = twitter_get_timeline('my_screen_name');
    set_transient('twitter_timeline', $timeline, 3600);
}
foreach($timeline as $status){
    // Echo status
}

Parameters

string $screen_name

If not specified, admin user's screen name will be used.

array $additional_data

Returns

object —

JSON format object.

gianism_login()

gianism_login(string $before, string $after)

Show Login buttons

Show login buttons where you want.

Parameters

string $before
string $after

is_geek()

is_geek(int $user_id) : bool

Detect if user is geek

Geek means user is connected with Github.

Parameters

int $user_id

Returns

bool

is_current_user_geek()

is_current_user_geek() : bool

Detect if current user is geek

Returns

bool