Esempio n. 1
0
/**
 * Register plugin settings and redirect to plugin page if this is the first activation
 * 
 */
function rublon2factor_register_settings()
{
    RublonHelper::checkIfUserPermitted();
    // register additional settings
    register_setting('rublon2factor_additional_settings_group', RublonHelper::RUBLON_ADDITIONAL_SETTINGS_KEY);
    // Below settings works only when plugin works as Business Edition
    if (RublonFeature::isBusinessEdition()) {
        add_settings_section('rublon2factor-additional-settings', __('Protection', 'rublon'), 'rublon2factor_render_additional_settings', 'rublon');
        add_settings_field('rublon2factor_protection_types', __('Role protection level', 'rublon'), 'rublon2factor_render_protection_types', 'rublon', 'rublon2factor-additional-settings');
    }
    add_settings_section('rublon2factor-other-settings', __('Other settings', 'rublon'), 'rublon2factor_render_other_settings', 'rublon');
    add_settings_field('rublon2factor_disable_xmlrpc', __('XML-RPC', 'rublon'), 'rublon2factor_render_disable_xmlrpc', 'rublon', 'rublon2factor-other-settings');
    // Enable/disable Adam on login page
    add_settings_field('rublon2factor_enable_adam', __('Show Adam on the login page', 'rublon'), 'rublon2factor_render_enable_adam', 'rublon', 'rublon2factor-other-settings');
    // Below settings works only when plugin works as Business Edition
    if (RublonFeature::isBusinessEdition()) {
        // Remote logout available since WordPress version 3.6.0
        if (version_compare(get_bloginfo('version'), '3.6', 'ge')) {
            add_settings_field('rublon2factor_rl_activelistener', __('Real-Time Remote Logout', 'rublon'), 'rublon2factor_render_rl_activelistener', 'rublon', 'rublon2factor-other-settings');
        }
    }
    if (RublonFeature::checkFeature(RublonAPIGetAvailableFeatures::FEATURE_IDENTITY_PROVIDING)) {
        add_settings_field('rublon2factor_access_control', __('Account Sharing Widget', 'rublon'), 'rublon2factor_render_access_control', 'rublon', 'rublon2factor-other-settings');
    }
    if (RublonFeature::checkFeature(RublonAPIGetAvailableFeatures::FEATURE_BUFFERED_CONFIRMATION)) {
        add_settings_field('rublon2factor_buffered_confirmation_time', __('Buffered confirmation time', 'rublon'), 'rublon2factor_render_buffered_confirmation_time', 'rublon', 'rublon2factor-other-settings');
    }
    register_setting('rublon2factor_confirmations_settings_group', RublonHelper::RUBLON_CONFIRMATIONS_SETTINGS_KEY);
    add_settings_section('rublon2factor-confirmations-settings', __('Confirmations', 'rublon'), 'rublon2factor_render_confirmations_settings', 'rublon_confirmations');
    add_settings_field('rublon2factor_confirmations', __('Confirmations', 'rublon'), 'rublon2factor_render_confirmations', 'rublon_confirmations', 'rublon2factor-confirmations-settings');
    if (RublonHelper::canPluginAttemptRegistration() || RublonHelper::isSiteRegistered()) {
        if (RublonHelper::isTrackingAllowed() === null) {
            require_once dirname(__FILE__) . '/classes/class-rublon-pointers.php';
            add_action('admin_enqueue_scripts', array('Rublon_Pointers', 'getInstance'));
        } elseif (!RublonHelper::isSiteRegistered()) {
            require_once dirname(__FILE__) . '/classes/class-rublon-pointers.php';
            add_action('admin_enqueue_scripts', array('Rublon_Pointers', 'getInstance'));
        }
    }
    do_action('rublon_admin_init');
}