Properties

$url_prefix

$url_prefix : string

URL prefix

If this property is empty, service name will be used. e.g. http://example.jp/facebook/

Type

string

$verbose_service_name

$verbose_service_name : string

Verbose service name

If not set, $this->service_name will be used;

Type

string

$umeta_id

$umeta_id : string

User meta key for amazon id

Type

string

$message_key_name

$message_key_name : string

Message post type

Type

string

$service_name

$service_name : string

Type

string

$enabled

$enabled : bool

Type

bool

$dir

$dir : string

Type

string

$url

$url : string

Type

string

$all_services

$all_services : array

Type

array

$nonce_key_name

$nonce_key_name : string

Type

string

$amazon_client_id

$amazon_client_id : string

Amazon's client ID

Type

string

$amazon_client_secret

$amazon_client_secret : string

Amazon'2 client secret

Type

string

$option_keys

$option_keys : array

Option key to retrieve

Type

array

$name

$name : string

Name

Used for option key, nonce, etc.

Type

string

$version

$version : string

Version number

Type

string

$domain

$domain : string

i18n Domain

Type

string

$instances

$instances : \Gianism\Singleton

Instance holder

Type

\Gianism\Singleton

$_all_services

$_all_services : array

All services

Type

array

Methods

is_connected()

is_connected(int $user_id) : bool

Detect if user is connected to this service

Parameters

int $user_id

Returns

bool

disconnect()

disconnect(int $user_id) : mixed

Disconnect user from this service

Parameters

int $user_id

Returns

mixed

set_option()

set_option() : void

Setup default option

is_pseudo_mail()

is_pseudo_mail(string $mail) : bool

This controller reutrn always false

Parameters

string $mail

Returns

bool

parse_request()

parse_request(string $action, \WP_Query $wp_query) : void

Called on redirect endpoint

Parameters

string $action
\WP_Query $wp_query

handle_login()

handle_login(\WP_Query $wp_query)

Make user login

Parameters

\WP_Query $wp_query

profile_connect()

profile_connect(\WP_User $user) : void

Show connect button on profile page

Parameters

\WP_User $user

connection_message()

connection_message(string $context) : string

Connection message

Overriding this function, you can customize connection message

Parameters

string $context

Returns

string

login_form()

login_form(boolean $is_register) : void

Display login buttons

Parameters

boolean $is_register

filter_link()

filter_link(string $markup, string $href, string $text, bool $is_register) : string

Resturns link to filter

Parameters

string $markup
string $href
string $text
bool $is_register

Returns

string

button()

button(string $text, string $href, bool $icon_name, array $class_names, array $attributes) : string

Create common button

Parameters

string $text
string $href
bool $icon_name
array $class_names
array $attributes

Returns

string

login_button()

login_button(string $redirect, bool $register) : string

Show login button

Parameters

string $redirect
bool $register

Returns

string

connect_button()

connect_button(string $redirect_to) : string

Get connect button

Parameters

string $redirect_to

If not set, profile page's URL

Returns

string

disconnect_button()

disconnect_button(string $redirect_to) : string

Get disconnect button

Parameters

string $redirect_to

If not set, profile page's URL

Returns

string

user_can_register()

user_can_register() : bool

Detect if user can register

Returns

bool

__get()

__get(string $name) : mixed

Getter

Parameters

string $name

Returns

mixed

get_instance()

get_instance(array $argument) : self

Get instance

Parameters

array $argument

Returns

self

_()

_(string $string) : string

Alias of __

Parameters

string $string

Returns

string

e()

e(string $string)

Alias of _e

Parameters

string $string

get()

get(string $key) : mixed

Return $_GET

Parameters

string $key

Returns

mixed

post()

post(string $key) : mixed

Return $_POST

Parameters

string $key

Returns

mixed

request()

request(string $key) : mixed

return $_REQUEST

Parameters

string $key

Returns

mixed

nonce_action()

nonce_action(string $action) : string

Return nonce name with prefix

Parameters

string $action

Returns

string

nonce_create()

nonce_create(string $action) : string

Parameters

string $action

Returns

string

nonce_field()

nonce_field(string $action, bool $referrer)

Alias of wp_nonce_field

Parameters

string $action
bool $referrer

Default false.

verify_nonce()

verify_nonce(string $action, string $referrer) : boolean

Check nonce

Parameters

string $action
string $referrer

Returns

boolean

is_ssl_required()

is_ssl_required() : boolean

Returns if login is forced to use SSL.

To override it, use filter gianism_force_ssl_login

Returns

boolean

is_enabled()

is_enabled(string $service) : bool

Determine if service is enabled.

Parameters

string $service

If not specified, one of the services are enabled, return true.

Returns

bool

get_meta_owner()

get_meta_owner(string $key, string $value) : int

Retrieve user meta's owner ID

Parameters

string $key
string $value

Returns

int —

User ID. If not exists, return 0

get_service_instance()

get_service_instance(string $service) : null|\Gianism\Service\Common\Mail

Get service instance

Parameters

string $service

Returns

null|\Gianism\Service\Common\Mail

handle_default()

handle_default(string $action) : void

Handle callback request

This function must exit at last.

Parameters

string $action

get_api_url()

get_api_url(string $action) : string|false

Return api URL to authenticate

If you need additional information (ex. token), use $this->session_write inside.

$this->session_write('token', $token); return $url;

Parameters

string $action

'connect', 'login'

Throws

\Exception

Returns

string|false —

URL to redirect

__construct()

__construct(array $argument)

Constructor

Parameters

array $argument

init_action()

init_action() : void

Initialize

If some stuff is required, override this.

handle_connect()

handle_connect(\WP_Query $wp_query)

Handle connect

Parameters

\WP_Query $wp_query

handle_disconnect()

handle_disconnect(\WP_Query $wp_query)

Handle disconnect

Parameters

\WP_Query $wp_query

get_redirect_to()

get_redirect_to(string $default, array $args) : string

Returns redirect to url if set.

Parameters

string $default
array $args

Returns

string

get_action()

get_action() : string

Returns current action name.

Returns

string

filter_redirect()

filter_redirect(string $url, string $context) : string

Filter redirect URL

Parameters

string $url
string $context

login, connect, disconnect

Returns

string

get_redirect_endpoint()

get_redirect_endpoint(string $action, string $nonce_key, array $args) : string

Get URL for immediate endpoint.

Parameters

string $action

'connect', 'disconnect', 'login' or else.

string $nonce_key

If empty, nonce won't be set.

array $args

Returns

string

is_smartphone()

is_smartphone() : boolean

Detect if current client is smartphone.

Returns

boolean

hook_connect()

hook_connect(int $user_id, mixed $data, bool $on_creation)

Fires connect hook

Parameters

int $user_id
mixed $data
bool $on_creation

hook_disconnect()

hook_disconnect(mixed $user_id)

Fires disconnect hook

Parameters

mixed $user_id

user_password_unknown()

user_password_unknown(int $user_id)

Use's password is automatically generated

Parameters

int $user_id

valid_username_from_mail()

valid_username_from_mail(string $email) : string

Create valid username from email address

Parameters

string $email

Throws

\Exception

Returns

string

api_error_string()

api_error_string() : string

Returns API error string

Returns

string

duplicate_account_string()

duplicate_account_string() : string

Message account duplication

Returns

string

welcome()

welcome(string $who)

Add welcome message

Parameters

string $who

auth_fail()

auth_fail(string $message)

Add error message

Parameters

string $message

mail_fail_string()

mail_fail_string() : string

Add error message

Returns

string

registration_error_string()

registration_error_string() : string

Registration error string

Returns

string

kill_wrong_access()

kill_wrong_access()

Kill wrong access

test_user_can_register()

test_user_can_register() : bool

Test if can register.

Throws

\Exception

Returns

bool

get_response()

get_response(string $endpoint, string|array $request, string $method, bool $json, array $additional_headers) : array|\stdClass|bool|null

Get Request

Parameters

string $endpoint
string|array $request
string $method

If x-www-form-urlencoded required, pass array or else, pass query string.

bool $json

if this request is JSON

array $additional_headers

Additional headers.

Returns

array|\stdClass|bool|null

add_message()

add_message(string $string, bool $error)

Add message to show

Parameters

string $string
bool $error

wp_die()

wp_die(string $message, int $status_code, bool $return)

Short hand for wp_die

Parameters

string $message
int $status_code
bool $return

session_write()

session_write(string $key, mixed $value)

Write session

Parameters

string $key
mixed $value

session_get()

session_get(string $key) : bool

Get session

After get, session key will be deleted.

Parameters

string $key

Returns

bool

session_delete()

session_delete(string $key)

Delete session

Parameters

string $key

get_user_profile()

get_user_profile(string $code, string $state, string $saved_state) : array

Get user profile

Parameters

string $code
string $state
string $saved_state

Throws

\Exception

Returns

array

get_access_token()

get_access_token(string $code, string $state, string $saved_state) : bool

Test token

Parameters

string $code
string $state
string $saved_state

Throws

\Exception

Returns

bool