Ejemplo n.º 1
0
function jwplayer_login_logout()
{
    if (!current_user_can('manage_options')) {
        jwplayer_login_print_error('You do not have sufficient privileges to access this page.');
        return;
    }
    if (!isset($_POST['logout'])) {
        //input var okay
        jwplayer_login_logout_form();
        return;
    }
    // Check the nonce (counter XSRF)
    if (isset($_POST['_wpnonce'])) {
        $nonce = sanitize_text_field($_POST['_wpnonce']);
        //input var okay
        if (!wp_verify_nonce($nonce, 'jwplayer-logout-nonce')) {
            jwplayer_login_print_error('Could not verify the form data.');
            jwplayer_login_logout_form();
            return;
        }
    }
    // Perform the logout.
    update_option('jwplayer_login', null);
    update_option('jwplayer_api_key', '');
    update_option('jwplayer_api_secret', '');
    echo '<h2>Deauthorized</h2><p>Deauthorization successful. Returning you to the <a href="' . esc_url('options-media.php') . '">media settings</a> page...</p>';
    // Perform a manual JavaScript redirect
    echo '<script type="application/x-javascript">document.location.href = "options-media.php"</script>';
}
Ejemplo n.º 2
0
function jwplayer_login_logout()
{
    if (!current_user_can('manage_options')) {
        jwplayer_login_print_error('You do not have sufficient privileges to access this page.');
        return;
    }
    if (!isset($_POST['logout'])) {
        // Input var okay
        jwplayer_login_logout_form();
        return;
    }
    // Check the nonce (counter XSRF)
    if (!isset($_POST['_wpnonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_wpnonce'])), 'jwplayer-logout-nonce')) {
        // Input var okay
        jwplayer_login_print_error('Could not verify the form data.');
        jwplayer_login_logout_form();
        return;
    }
    // Perform the logout.
    update_option('jwplayer_login', null);
    update_option('jwplayer_api_key', '');
    update_option('jwplayer_api_secret', '');
    $login_url = get_admin_url(null, 'admin.php?page=jwplayer_login_page');
    $plugins_url = get_admin_url(null, 'plugins.php');
    ?>
	<h2>Deauthorization successful.</h2>
	<p>
		You can <a href="<?php 
    echo esc_url($login_url);
    ?>
">authorized the plugin with different credentials</a> or
		disable the JW Player plugin on <a href="<?php 
    echo esc_url($plugins_url);
    ?>
">the plugins page</a>.
	</p>
	<?php 
}