init_hooks();
}
}
/**
* Initiate hooks.
*/
private function init_hooks() {
add_action( 'admin_init', [ $this, 'init_settings' ] );
}
/**
* {@inheritdoc}
*/
public function init_settings() {
// Vkontakte
$this->render_fields(
[
'id' => 'section_vkontakte',
'name' => __( 'VK', "anycomment" ),
],
[
[
'id' => self::OPTION_VK_TOGGLE,
'title' => __( 'Enable', "anycomment" ),
'type' => 'checkbox',
'description' => esc_html( __( 'Allow VK authorization', "anycomment" ) ),
],
[
'id' => self::OPTION_VK_APP_ID,
'title' => __( 'Application ID', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter app id. Can be found in apps page', "anycomment" ), 'https://vk.com/apps?act=manage' )
],
[
'id' => self::OPTION_VK_SECRET,
'title' => __( 'Secure key', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter secure key. Can be found in apps page', "anycomment" ), 'https://vk.com/apps?act=manage' ),
'after' => function () {
?>
render_fields(
[
'id' => 'section_twitter',
'name' => __( 'Twitter', "anycomment" ),
],
[
[
'id' => self::OPTION_TWITTER_TOGGLE,
'title' => __( 'Enable', "anycomment" ),
'type' => 'checkbox',
'description' => __( 'Allow Twitter authorization', "anycomment" )
],
[
'id' => self::OPTION_TWITTER_CONSUMER_KEY,
'title' => __( 'Consumer Key', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter consumer key. Can be found in the list of apps', "anycomment" ), 'https://apps.twitter.com/' )
],
[
'id' => self::OPTION_TWITTER_CONSUMER_SECRET,
'title' => __( 'Consumer Secret', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter consumer secret. Can be found in the list of apps', "anycomment" ), 'https://apps.twitter.com/' ),
'after' => function () {
?>
render_fields(
[
'id' => 'section_facebook',
'name' => __( 'Facebook', "anycomment" ),
],
[
[
'id' => self::OPTION_FACEBOOK_TOGGLE,
'title' => __( 'Enable', "anycomment" ),
'type' => 'checkbox',
'description' => __( 'Allow Facebook authorization', "anycomment" )
],
[
'id' => self::OPTION_FACEBOOK_APP_ID,
'title' => __( 'App ID', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter app id. Can be found in the list of apps', "anycomment" ), 'https://developers.facebook.com/apps/' )
],
[
'id' => self::OPTION_FACEBOOK_APP_SECRET,
'title' => __( 'App Secret', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter app secret. Can be found in the list of apps', "anycomment" ), 'https://developers.facebook.com/apps/' ),
'after' => function () {
?>
render_fields(
[
'id' => 'section_google',
'name' => __( 'Google', "anycomment" ),
],
[
[
'id' => self::OPTION_GOOGLE_TOGGLE,
'title' => __( 'Enable', "anycomment" ),
'type' => 'checkbox',
'description' => __( 'Allow Google authorization', "anycomment" )
],
[
'id' => self::OPTION_GOOGLE_CLIENT_ID,
'title' => __( 'Client ID', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter client id. Can be found in the list of apps', "anycomment" ), 'https://console.developers.google.com/apis/credentials' )
],
[
'id' => self::OPTION_GOOGLE_SECRET,
'title' => __( 'Client Secret', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter client secret. Can be found in the list of apps', "anycomment" ), 'https://console.developers.google.com/apis/credentials' ),
'after' => function () {
?>
render_fields(
[
'id' => 'section_github',
'name' => __( 'GitHub', "anycomment" ),
],
[
[
'id' => self::OPTION_GITHUB_TOGGLE,
'title' => __( 'Enable', "anycomment" ),
'type' => 'checkbox',
'description' => __( 'Allow GitHub authorization', "anycomment" )
],
[
'id' => self::OPTION_GITHUB_CLIENT_ID,
'title' => __( 'Client ID', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter client id. Can be found in the list of apps', "anycomment" ), 'https://github.com/settings/developers' )
],
[
'id' => self::OPTION_GITHUB_SECRET,
'title' => __( 'Client Secret', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter client secret. Can be found in the list of apps', "anycomment" ), 'https://github.com/settings/developers' ),
'after' => function () {
?>
render_fields(
[
'id' => 'section_odnoklassniki',
'name' => __( 'Odnoklassniki', "anycomment" ),
],
[
[
'id' => self::OPTION_OK_TOGGLE,
'title' => __( 'Enable', "anycomment" ),
'type' => 'checkbox',
'description' => __( 'Allow Odnoklassniki authorization', "anycomment" )
],
[
'id' => self::OPTION_OK_APP_ID,
'title' => __( 'App ID', "anycomment" ),
'type' => 'text',
'description' => __( 'Enter app id. Can be found in the email sent to you by Odnoklassniki', "anycomment" ),
],
[
'id' => self::OPTION_OK_APP_KEY,
'title' => __( 'App Key', "anycomment" ),
'type' => 'text',
'description' => __( 'Enter app key. Can be found in the email sent to you by Odnoklassniki', "anycomment" ),
],
[
'id' => self::OPTION_OK_APP_SECRET,
'title' => __( 'App Secret', "anycomment" ),
'type' => 'text',
'description' => __( 'Enter client secret. Can be found in the email sent to you by Odnoklassniki', "anycomment" ),
'after' => function () {
?>
render_fields(
[
'id' => 'section_instagram',
'name' => __( 'Instagram', "anycomment" ),
'callback' => function () {
return '';
}
],
[
[
'id' => self::OPTION_INSTAGRAM_TOGGLE,
'title' => __( 'Enable', "anycomment" ),
'type' => 'checkbox',
'description' => __( 'Allow Instagram authorization', "anycomment" )
],
[
'id' => self::OPTION_INSTAGRAM_CLIENT_ID,
'title' => __( 'Client ID', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter client id. Can be found in Manage Clients', "anycomment" ), 'https://www.instagram.com/developer/clients/manage/' )
],
[
'id' => self::OPTION_INSTAGRAM_CLIENT_SECRET,
'title' => __( 'Client Secret', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter client secret. Can be found in Manage Clients', "anycomment" ), 'https://www.instagram.com/developer/clients/manage/' ),
'after' => function () {
?>
render_fields(
[
'id' => 'section_twitch',
'name' => __( 'Twitch', "anycomment" ),
],
[
[
'id' => self::OPTION_TWITCH_TOGGLE,
'title' => __( 'Enable', "anycomment" ),
'type' => 'checkbox',
'description' => __( 'Allow Twitch authorization', "anycomment" )
],
[
'id' => self::OPTION_TWITCH_CLIENT_ID,
'title' => __( 'Client ID', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter client id. It can be found in the apps', "anycomment" ), 'https://glass.twitch.tv/console/apps' )
],
[
'id' => self::OPTION_TWITCH_CLIENT_SECRET,
'title' => __( 'Client Secret', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter client secret. It can be found in the apps', "anycomment" ), 'https://glass.twitch.tv/console/apps' ),
'after' => function () {
?>
render_fields(
[
'id' => 'section_dribbble',
'name' => __( 'Dribbble', "anycomment" ),
],
[
[
'id' => self::OPTION_DRIBBBLE_TOGGLE,
'title' => __( 'Enable', "anycomment" ),
'type' => 'checkbox',
'description' => __( 'Allow Dribbble authorization', "anycomment" )
],
[
'id' => self::OPTION_DRIBBBLE_CLIENT_ID,
'title' => __( 'Client ID', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter client id. It can be found in the your applications', "anycomment" ), 'https://dribbble.com/account/applications' )
],
[
'id' => self::OPTION_DRIBBBLE_CLIENT_SECRET,
'title' => __( 'Client Secret', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter client secret. It can be found in the your applications', "anycomment" ), 'https://dribbble.com/account/applications' ),
'after' => function () {
?>
render_fields(
[
'id' => 'section_yahoo',
'name' => __( 'Yahoo', "anycomment" ),
],
[
[
'id' => self::OPTION_YAHOO_TOGGLE,
'title' => __( 'Enable', "anycomment" ),
'type' => 'checkbox',
'description' => __( 'Allow Yahoo authorization', "anycomment" )
],
[
'id' => self::OPTION_YAHOO_APP_ID,
'title' => __( 'App ID', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter app id. It can be found in the my apps', "anycomment" ), 'https://developer.yahoo.com/apps/' )
],
[
'id' => self::OPTION_YAHOO_CLIENT_SECRET,
'title' => __( 'Client Secret', "anycomment" ),
'type' => 'text',
'description' => sprintf( __( 'Enter client secret. It can be found in the my apps', "anycomment" ), 'https://developer.yahoo.com/apps/' ),
'after' => function () {
?>
render_fields(
[
'id' => 'section_wordpress',
'name' => __( 'WordPress', "anycomment" ),
],
[
[
'id' => self::OPTION_WORDPRESS_NATIVE_TOGGLE,
'title' => __( 'Enable Native', "anycomment" ),
'type' => 'checkbox',
'description' => __( 'Allow WordPress native authorization', "anycomment" )
],
]
);
}
/**
* top level menu:
* callback functions
*
* @param bool $wrapper Whether to wrap for with header or not.
*/
public function page_html( $wrapper = true ) {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
if ( isset( $_GET['settings-updated'] ) ) {
add_settings_error( $this->alert_key, 'anycomment_message', __( 'Settings Saved', 'anycomment' ), 'updated' );
}
settings_errors( $this->alert_key );
?>
';
$i = 0;
foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
$liClasses = ( $i == 0 ? 'current' : '' );
$liClasses .= ' ' . ( static::is_enabled( str_replace( 'section_', '', $section['id'] ) ) ? 'toggled' : '' );
$path = sprintf( AnyComment()->plugin_url() . '/assets/img/icons/auth/%s.svg', str_replace( 'section_', 'social-', $section['id'] ) );
echo '
' . $section['title'] . '
';
$i ++;
}
echo '';
?>
{$section['title']}";
}
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) {
continue;
}
echo '