'
'
];
/**
* @inheritdoc
*/
protected $section_options = [
'wrapper' => ''
];
/**
* VK Options
*/
const OPTION_VK_TOGGLE = 'social_vkontakte_toggle_field';
const OPTION_VK_APP_ID = 'social_vkontakte_app_id_field';
const OPTION_VK_SECRET = 'social_vkontakte_app_secret_field';
/**
* Twitter options
*/
const OPTION_TWITTER_TOGGLE = 'social_twitter_toggle_field';
const OPTION_TWITTER_CONSUMER_KEY = 'social_twitter_consumer_key_field';
const OPTION_TWITTER_CONSUMER_SECRET = 'social_twitter_consumer_secret_field';
/**
* Facebook Options
*/
const OPTION_FACEBOOK_TOGGLE = 'social_facebook_toggle_field';
const OPTION_FACEBOOK_APP_ID = 'social_facebook_app_id_field';
const OPTION_FACEBOOK_APP_SECRET = 'social_facebook_app_secret_field';
/**
* Google Options
*/
const OPTION_GOOGLE_TOGGLE = 'social_google_toggle_field';
const OPTION_GOOGLE_CLIENT_ID = 'social_google_client_id_field';
const OPTION_GOOGLE_SECRET = 'social_google_secret_field';
/**
* Github Options
*/
const OPTION_GITHUB_TOGGLE = 'social_github_toggle_field';
const OPTION_GITHUB_CLIENT_ID = 'social_github_app_id_field';
const OPTION_GITHUB_SECRET = 'social_github_app_secret_field';
/**
* Odnoklassniki Options
*/
const OPTION_OK_TOGGLE = 'social_odnoklassniki_toggle_field';
const OPTION_OK_APP_ID = 'social_odnoklassniki_app_id_field';
const OPTION_OK_APP_KEY = 'social_odnoklassniki_app_key_field';
const OPTION_OK_APP_SECRET = 'social_odnoklassniki_app_secret_field';
/**
* Instagram
*/
const OPTION_INSTAGRAM_TOGGLE = 'social_instagram_toggle_field';
const OPTION_INSTAGRAM_CLIENT_ID = 'social_instagram_client_id_field';
const OPTION_INSTAGRAM_CLIENT_SECRET = 'social_instagram_client_secret_field';
/**
* Twitch
*/
const OPTION_TWITCH_TOGGLE = 'social_twitch_toggle_field';
const OPTION_TWITCH_CLIENT_ID = 'social_twitch_client_id_field';
const OPTION_TWITCH_CLIENT_SECRET = 'social_twitch_client_secret_field';
/**
* Dribbble
*/
const OPTION_DRIBBBLE_TOGGLE = 'social_dribbble_toggle_field';
const OPTION_DRIBBBLE_CLIENT_ID = 'social_dribbble_client_id_field';
const OPTION_DRIBBBLE_CLIENT_SECRET = 'social_dribbble_client_secret_field';
/**
* Steam
*/
const OPTION_STEAM_TOGGLE = 'social_steam_toggle_field';
const OPTION_STEAM_SECRET = 'social_steam_client_secret_field';
/**
* Yandex
*/
const OPTION_YANDEX_TOGGLE = 'social_yandex_toggle_field';
const OPTION_YANDEX_CLIENT_ID = 'social_yandex_client_id_field';
const OPTION_YANDEX_CLIENT_SECRET = 'social_yandex_client_secret_field';
/**
* Mailru
*/
const OPTION_MAILRU_TOGGLE = 'social_mailru_toggle_field';
const OPTION_MAILRU_CLIENT_ID = 'social_mailru_client_id_field';
const OPTION_MAILRU_CLIENT_SECRET = 'social_mailru_client_secret_field';
/**
* Yahoo
*/
const OPTION_YAHOO_TOGGLE = 'social_yahoo_toggle_field';
const OPTION_YAHOO_APP_ID = 'social_yahoo_app_id_field';
const OPTION_YAHOO_CLIENT_SECRET = 'social_yahoo_client_secret_field';
/**
* WordPress.
*/
const OPTION_WORDPRESS_NATIVE_TOGGLE = 'social_wordpress_toggle_field';
/**
* AC_SocialSettingPage constructor.
*
* @param bool $init If required to init the model.
*/
public function __construct( $init = true ) {
parent::__construct();
if ( $init ) {
$this->init_hooks();
}
}
/**
* Initiate hooks.
*/
private function init_hooks() {
add_action( 'admin_init', [ $this, 'init_settings' ] );
}
/**
* {@inheritdoc}
*/
public function init_settings() {
$this->form()
->add_section(
$this->section_builder()
->set_id( 'vkontakte' )
->set_title( __( 'Vkontakte', 'anycomment' ) )
->set_wrapper( '' )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_VK_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( esc_html( __( 'Allow VK authorization', "anycomment" ) ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_VK_APP_ID )
->set_title( __( 'Application ID', "anycomment" ) )
->set_description( sprintf( __( 'Enter app id. Can be found in apps page', "anycomment" ), 'https://vk.com/apps?act=manage' ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_VK_SECRET )
->set_title( __( 'Secure key', "anycomment" ) )
->set_description( sprintf( __( 'Enter secure key. Can be found in apps page', "anycomment" ), 'https://vk.com/apps?act=manage' ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_vk_callback();
return '';
} ),
] )
)
->add_section(
$this->section_builder()
->set_id( 'twitter' )
->set_title( __( 'Twitter', "anycomment" ) )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_TWITTER_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( __( 'Allow Twitter authorization', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_TWITTER_CONSUMER_KEY )
->set_title( __( 'Consumer Key', "anycomment" ) )
->set_description( sprintf( __( 'Enter consumer key. Can be found in the list of apps', "anycomment" ), 'https://apps.twitter.com/' ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_TWITTER_CONSUMER_SECRET )
->set_title( __( 'Consumer Secret', "anycomment" ) )
->set_description( sprintf( __( 'Enter consumer secret. Can be found in the list of apps', "anycomment" ), 'https://apps.twitter.com/' ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_twitter_callback();
return '';
} )
] )
)
->add_section(
$this->section_builder()
->set_id( 'facebook' )
->set_title( __( 'Facebook', "anycomment" ) )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_FACEBOOK_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( __( 'Allow Facebook authorization', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_FACEBOOK_APP_ID )
->set_title( __( 'App ID', "anycomment" ) )
->set_description( sprintf( __( 'Enter app id. Can be found in the list of apps', "anycomment" ), 'https://developers.facebook.com/apps/' ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_FACEBOOK_APP_SECRET )
->set_title( __( 'App Secret', "anycomment" ) )
->set_description( sprintf( __( 'Enter app secret. Can be found in the list of apps', "anycomment" ), 'https://developers.facebook.com/apps/' ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_facebook_callback();
return '';
} ),
] )
)
->add_section(
$this->section_builder()
->set_id( 'google' )
->set_title( __( 'Google', "anycomment" ) )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_GOOGLE_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( __( 'Allow Google authorization', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_GOOGLE_CLIENT_ID )
->set_title( __( 'Client ID', "anycomment" ) )
->set_description( sprintf( __( 'Enter client id. Can be found in the list of apps', "anycomment" ), 'https://console.developers.google.com/apis/credentials' ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_GOOGLE_SECRET )
->set_title( __( 'Client Secret', "anycomment" ) )
->set_description( sprintf( __( 'Enter client secret. Can be found in the list of apps', "anycomment" ), 'https://console.developers.google.com/apis/credentials' ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_google_callback();
return '';
} ),
] )
)
->add_section(
$this->section_builder()
->set_id( 'github' )
->set_title( __( 'GitHub', "anycomment" ) )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_GITHUB_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( __( 'Allow GitHub authorization', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_GITHUB_CLIENT_ID )
->set_title( __( 'Client ID', "anycomment" ) )
->set_description( sprintf( __( 'Enter client id. Can be found in the list of apps', "anycomment" ), 'https://github.com/settings/developers' ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_GITHUB_SECRET )
->set_title( __( 'Client Secret', "anycomment" ) )
->set_description( sprintf( __( 'Enter client secret. Can be found in the list of apps', "anycomment" ), 'https://github.com/settings/developers' ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_github_callback();
return '';
} ),
] )
)
->add_section(
$this->section_builder()
->set_id( 'odnoklassniki' )
->set_title( __( 'Odnoklassniki', "anycomment" ) )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_OK_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( __( 'Allow Odnoklassniki authorization', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_OK_APP_ID )
->set_title( __( 'App ID', "anycomment" ) )
->set_description( __( 'Enter app id. Can be found in the email sent to you by Odnoklassniki', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_OK_APP_KEY )
->set_title( __( 'App Key', "anycomment" ) )
->set_description( __( 'Enter app key. Can be found in the email sent to you by Odnoklassniki', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_OK_APP_SECRET )
->set_title( __( 'App Secret', "anycomment" ) )
->set_description( __( 'Enter client secret. Can be found in the email sent to you by Odnoklassniki', "anycomment" ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_ok_callback();
return '';
} ),
] )
)
->add_section(
$this->section_builder()
->set_id( 'instagram' )
->set_title( __( 'Instagram', "anycomment" ) )
->set_callback( function () {
return '';
} )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_INSTAGRAM_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( __( 'Allow Instagram authorization', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_INSTAGRAM_CLIENT_ID )
->set_title( __( 'Client ID', "anycomment" ) )
->set_description( sprintf( __( 'Enter client id. Can be found in Manage Clients', "anycomment" ), 'https://www.instagram.com/developer/clients/manage/' ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_INSTAGRAM_CLIENT_SECRET )
->set_title( __( 'Client Secret', "anycomment" ) )
->set_description( sprintf( __( 'Enter client secret. Can be found in Manage Clients', "anycomment" ), 'https://www.instagram.com/developer/clients/manage/' ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_instagram_callback();
return '';
} ),
] )
)
->add_section(
$this->section_builder()
->set_id( 'twitch' )
->set_title( __( 'Twitch', "anycomment" ) )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_TWITCH_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( __( 'Allow Twitch authorization', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_TWITCH_CLIENT_ID )
->set_title( __( 'Client ID', "anycomment" ) )
->set_description( sprintf( __( 'Enter client id. It can be found in the apps', "anycomment" ), 'https://glass.twitch.tv/console/apps' ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_TWITCH_CLIENT_SECRET )
->set_title( __( 'Client Secret', "anycomment" ) )
->set_description( sprintf( __( 'Enter client secret. It can be found in the apps', "anycomment" ), 'https://glass.twitch.tv/console/apps' ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_twitch_callback();
return '';
} ),
] )
)
->add_section(
$this->section_builder()
->set_id( 'steam' )
->set_title( __( 'Steam', "anycomment" ) )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_STEAM_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( __( 'Allow Steam authorization', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_STEAM_SECRET )
->set_title( __( 'Key', "anycomment" ) )
->set_description( sprintf( __( 'Enter key. It can be found in the Register Steam Web API Key', "anycomment" ), 'https://steamcommunity.com/dev/registerkey' ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_steam_callback();
return '';
} ),
] )
)
->add_section(
$this->section_builder()
->set_id( 'yandex' )
->set_title( __( 'Yandex', "anycomment" ) )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_YANDEX_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( __( 'Allow Yandex authorization', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_YANDEX_CLIENT_ID )
->set_title( __( 'ID', "anycomment" ) )
->set_description( sprintf( __( 'Enter id. It can be found after you register your web-application', "anycomment" ), 'https://oauth.yandex.ru/client/new' ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_YANDEX_CLIENT_SECRET )
->set_title( __( 'Client Secret', "anycomment" ) )
->set_description( sprintf( __( 'Enter password (NOT your email password). It can be found after you register your web-application', "anycomment" ), 'https://oauth.yandex.ru/client/new' ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_yandex_callback();
return '';
} ),
] )
)
->add_section(
$this->section_builder()
->set_id( 'mailru' )
->set_title( __( 'Mail.Ru', "anycomment" ) )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_MAILRU_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( __( 'Allow Mail.Ru authorization', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_MAILRU_CLIENT_ID )
->set_title( __( 'ID', "anycomment" ) )
->set_description( sprintf( __( 'Enter id. It can be found after you register your web-application', "anycomment" ), 'http://api.mail.ru/sites/my/add' ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_MAILRU_CLIENT_SECRET )
->set_title( __( 'Client Secret', "anycomment" ) )
->set_description( sprintf( __( 'Enter client secret. It can be found after you register your web-application', "anycomment" ), 'https://api.mail.ru/sites/my/add' ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_mailru_callback();
return '';
} ),
] )
)
->add_section(
$this->section_builder()
->set_id( 'dribbble' )
->set_title( __( 'Dribbble', "anycomment" ) )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_DRIBBBLE_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( __( 'Allow Dribbble authorization', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_DRIBBBLE_CLIENT_ID )
->set_title( __( 'Client ID', "anycomment" ) )
->set_description( sprintf( __( 'Enter client id. It can be found in the your applications', "anycomment" ), 'https://dribbble.com/account/applications' ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_DRIBBBLE_CLIENT_SECRET )
->set_title( __( 'Client Secret', "anycomment" ) )
->set_description( sprintf( __( 'Enter client secret. It can be found in the your applications', "anycomment" ), 'https://dribbble.com/account/applications' ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_dribbble_callback();
return '';
} ),
] )
)
->add_section(
$this->section_builder()
->set_id( 'yahoo' )
->set_title( __( 'Yahoo', "anycomment" ) )
->set_visible( false )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_YAHOO_TOGGLE )
->set_title( __( 'Enable', "anycomment" ) )
->set_description( __( 'Allow Yahoo authorization', "anycomment" ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_YAHOO_APP_ID )
->set_title( __( 'App ID', "anycomment" ) )
->set_description( sprintf( __( 'Enter app id. It can be found in the my apps', "anycomment" ), 'https://developer.yahoo.com/apps/' ) ),
$this->field_builder()
->text()
->set_id( self::OPTION_YAHOO_CLIENT_SECRET )
->set_title( __( 'Client Secret', "anycomment" ) )
->set_description( sprintf( __( 'Enter client secret. It can be found in the my apps', "anycomment" ), 'https://developer.yahoo.com/apps/' ) )
->set_after( function () {
$callback_label = __( 'Callback URL', 'anycomment' );
$callback_url = AnyCommentSocialAuth::get_yahoo_callback();
return '';
} ),
] )
)
->add_section(
$this->section_builder()
->set_id( 'wordpress' )
->set_title( __( 'WordPress', "anycomment" ) )
->set_fields( [
$this->field_builder()
->checkbox()
->set_id( self::OPTION_WORDPRESS_NATIVE_TOGGLE )
->set_title( __( 'Enable Native', "anycomment" ) )
->set_description( __( 'Allow WordPress native authorization', "anycomment" ) ),
] )
);
}
/**
* {@inheritdoc}
*/
public function run() {
$sections_html = '';
$tabs = $this->do_tab_menu();
$html = <<