nonce_url_no_esc() public static method

public static nonce_url_no_esc ( $actionurl, $action, $name = '_wpnonce' )
 /**
  * Builds a URL to the Jetpack connection auth page
  *
  * @since 3.9.5
  *
  * @param bool $raw If true, URL will not be escaped.
  * @param bool|string $redirect If true, will redirect back to Jetpack wp-admin landing page after connection.
  *                              If string, will be a custom redirect.
  * @param bool|string $from If not false, adds 'from=$from' param to the connect URL.
  *
  * @return string Connect URL
  */
 function build_connect_url($raw = false, $redirect = false, $from = false)
 {
     if (!Jetpack_Options::get_option('blog_token') || !Jetpack_Options::get_option('id')) {
         $url = Jetpack::nonce_url_no_esc(Jetpack::admin_url('action=register'), 'jetpack-register');
         if (is_network_admin()) {
             $url = add_query_arg('is_multisite', network_admin_url('admin.php?page=jetpack-settings'), $url);
         }
     } else {
         require_once JETPACK__GLOTPRESS_LOCALES_PATH;
         $role = $this->translate_current_user_to_role();
         $signed_role = $this->sign_role($role);
         $user = wp_get_current_user();
         $redirect = $redirect ? esc_url_raw($redirect) : esc_url_raw(menu_page_url('jetpack', false));
         $gp_locale = GP_Locales::by_field('wp_locale', get_locale());
         if (isset($_REQUEST['is_multisite'])) {
             $redirect = Jetpack_Network::init()->get_url('network_admin_page');
         }
         $secrets = Jetpack::init()->generate_secrets('authorize');
         @(list($secret) = explode(':', $secrets));
         $site_icon = function_exists('has_site_icon') && has_site_icon() ? get_site_icon_url() : false;
         $args = urlencode_deep(array('response_type' => 'code', 'client_id' => Jetpack_Options::get_option('id'), 'redirect_uri' => add_query_arg(array('action' => 'authorize', '_wpnonce' => wp_create_nonce("jetpack-authorize_{$role}_{$redirect}"), 'redirect' => urlencode($redirect)), menu_page_url('jetpack', false)), 'state' => $user->ID, 'scope' => $signed_role, 'user_email' => $user->user_email, 'user_login' => $user->user_login, 'is_active' => Jetpack::is_active(), 'jp_version' => JETPACK__VERSION, 'auth_type' => 'calypso', 'secret' => $secret, 'locale' => isset($gp_locale->slug) ? $gp_locale->slug : '', 'blogname' => get_option('blogname'), 'site_url' => site_url(), 'home_url' => home_url(), 'site_icon' => $site_icon));
         $url = add_query_arg($args, Jetpack::api_url('authorize'));
     }
     if ($from) {
         $url = add_query_arg('from', $from, $url);
     }
     if (isset($_GET['calypso_env'])) {
         $url = add_query_arg('calypso_env', $_GET['calypso_env'], $url);
     }
     return $raw ? $url : esc_url($url);
 }
Esempio n. 2
0
 function build_connect_url($raw = false, $redirect = false)
 {
     if (!Jetpack_Options::get_option('blog_token')) {
         $url = Jetpack::nonce_url_no_esc(Jetpack::admin_url('action=register'), 'jetpack-register');
         if (is_network_admin()) {
             $url = add_query_arg('is_multisite', network_admin_url('admin.php?page=jetpack-settings'), $url);
         }
     } else {
         $role = $this->translate_current_user_to_role();
         $signed_role = $this->sign_role($role);
         $user = wp_get_current_user();
         $redirect = $redirect ? esc_url_raw($redirect) : '';
         if (isset($_REQUEST['is_multisite'])) {
             $redirect = Jetpack_Network::init()->get_url('network_admin_page');
         }
         $args = urlencode_deep(array('response_type' => 'code', 'client_id' => Jetpack_Options::get_option('id'), 'redirect_uri' => add_query_arg(array('action' => 'authorize', '_wpnonce' => wp_create_nonce("jetpack-authorize_{$role}_{$redirect}"), 'redirect' => $redirect ? urlencode($redirect) : false), menu_page_url('jetpack', false)), 'state' => $user->ID, 'scope' => $signed_role, 'user_email' => $user->user_email, 'user_login' => $user->user_login, 'is_active' => Jetpack::is_active(), 'jp_version' => JETPACK__VERSION));
         $url = add_query_arg($args, Jetpack::api_url('authorize'));
     }
     return $raw ? $url : esc_url($url);
 }
Esempio n. 3
0
 /**
  * Builds a URL to the Jetpack connection auth page
  *
  * @since 3.9.5
  *
  * @param bool $raw If true, URL will not be escaped.
  * @param bool|string $redirect If true, will redirect back to Jetpack wp-admin landing page after connection.
  *                              If string, will be a custom redirect.
  * @param bool|string $from If not false, adds 'from=$from' param to the connect URL.
  *
  * @return string Connect URL
  */
 function build_connect_url($raw = false, $redirect = false, $from = false)
 {
     if (!Jetpack_Options::get_option('blog_token') || !Jetpack_Options::get_option('id')) {
         $url = Jetpack::nonce_url_no_esc(Jetpack::admin_url('action=register'), 'jetpack-register');
         if (is_network_admin()) {
             $url = add_query_arg('is_multisite', network_admin_url('admin.php?page=jetpack-settings'), $url);
         }
     } else {
         if (defined('JETPACK__GLOTPRESS_LOCALES_PATH') && (include_once JETPACK__GLOTPRESS_LOCALES_PATH)) {
             $gp_locale = GP_Locales::by_field('wp_locale', get_locale());
         }
         $role = self::translate_current_user_to_role();
         $signed_role = self::sign_role($role);
         $user = wp_get_current_user();
         $jetpack_admin_page = esc_url_raw(admin_url('admin.php?page=jetpack'));
         $redirect = $redirect ? wp_validate_redirect(esc_url_raw($redirect), $jetpack_admin_page) : $jetpack_admin_page;
         if (isset($_REQUEST['is_multisite'])) {
             $redirect = Jetpack_Network::init()->get_url('network_admin_page');
         }
         $secrets = Jetpack::init()->generate_secrets('authorize');
         @(list($secret) = explode(':', $secrets));
         $site_icon = function_exists('has_site_icon') && has_site_icon() ? get_site_icon_url() : false;
         /**
          * Filter the type of authorization.
          * 'calypso' completes authorization on wordpress.com/jetpack/connect
          * while 'jetpack' ( or any other value ) completes the authorization at jetpack.wordpress.com.
          *
          * @since 4.3.3
          *
          * @param string $auth_type Defaults to 'calypso', can also be 'jetpack'.
          */
         $auth_type = apply_filters('jetpack_auth_type', 'calypso');
         $args = urlencode_deep(array('response_type' => 'code', 'client_id' => Jetpack_Options::get_option('id'), 'redirect_uri' => add_query_arg(array('action' => 'authorize', '_wpnonce' => wp_create_nonce("jetpack-authorize_{$role}_{$redirect}"), 'redirect' => urlencode($redirect)), esc_url(admin_url('admin.php?page=jetpack'))), 'state' => $user->ID, 'scope' => $signed_role, 'user_email' => $user->user_email, 'user_login' => $user->user_login, 'is_active' => Jetpack::is_active(), 'jp_version' => JETPACK__VERSION, 'auth_type' => $auth_type, 'secret' => $secret, 'locale' => isset($gp_locale) && isset($gp_locale->slug) ? $gp_locale->slug : '', 'blogname' => get_option('blogname'), 'site_url' => site_url(), 'home_url' => home_url(), 'site_icon' => $site_icon));
         $url = add_query_arg($args, Jetpack::api_url('authorize'));
     }
     if ($from) {
         $url = add_query_arg('from', $from, $url);
     }
     if (isset($_GET['calypso_env'])) {
         $url = add_query_arg('calypso_env', sanitize_key($_GET['calypso_env']), $url);
     }
     return $raw ? $url : esc_url($url);
 }