• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Akismet_Admin::get_jetpack_user() –

Description

Usage

Akismet_Admin::get_jetpack_user();

Parameters

Returns

void

Source

File name: akismet/class.akismet-admin.php
Lines:

1 to 41 of 41
  private static function get_jetpack_user() {
    if ( !class_exists('Jetpack') )
      return false;

    if ( defined( 'JETPACK__VERSION' ) && version_compare( JETPACK__VERSION, '7.7', '<' )  ) {
      // For version of Jetpack prior to 7.7.
      Jetpack::load_xml_rpc_client();
    }

    $xml = new Jetpack_IXR_ClientMulticall( array( 'user_id' => get_current_user_id() ) );

    $xml->addCall( 'wpcom.getUserID' );
    $xml->addCall( 'akismet.getAPIKey' );
    $xml->query();

    Akismet::log( compact( 'xml' ) );

    if ( !$xml->isError() ) {
      $responses = $xml->getResponse();
      if ( count( $responses ) > 1 ) {
        // Due to a quirk in how Jetpack does multi-calls, the response order
        // can't be trusted to match the call order. It's a good thing our
        // return values can be mostly differentiated from each other.
        $first_response_value = array_shift( $responses[0] );
        $second_response_value = array_shift( $responses[1] );
        
        // If WPCOM ever reaches 100 billion users, this will fail. :-)
        if ( preg_match( '/^[a-f0-9]{12}$/i', $first_response_value ) ) {
          $api_key = $first_response_value;
          $user_id = (int) $second_response_value;
        }
        else {
          $api_key = $second_response_value;
          $user_id = (int) $first_response_value;
        }
        
        return compact( 'api_key', 'user_id' );
      }
    }
    return false;
  }
 

 View on GitHub View on Trac

Called by

    Invoked by

      Calls

      1 to 1 of 1
      • Akismet::log() – Log debugging info to the error log.

      Call hooks

      Function name: Akismet_Admin::get_jetpack_user
      Class ref: Akismet_Admin
      Plugin ref: Akismet
      Version: 4.1.9
      Sourcefile: class.akismet-admin.php
      File ref: class.akismet-admin.php
      Deprecated?: No
      API Letters: A,G,J,U

      Published: 19th December 2019 | Last updated: 19th December 2019

      Primary Sidebar

      Information

      Function name: Akismet_Admin::get_jetpack_user
      Class ref: Akismet_Admin
      Plugin ref: Akismet
      Version: 4.1.9
      Sourcefile: class.akismet-admin.php
      File ref: class.akismet-admin.php
      Deprecated?: No
      API Letters: A,G,J,U

      Footer

      WordPress a2z
      WordPress a2z
      WordPress Dynamic API Reference
      WordPress 5.7. PHP: 7.3.27
      WordPress a2z
      WordPress core a2z
      Genesis Theme Framework a2z
      Jetpack a2z
      WordPress develop tests
      Easy Digital Downloads a2z
      WooCommerce a2z
      Yoast SEO a2z
      WordPress Blocks

      Site:  wp-a2z.org
      © Copyright WordPress a2z 2014-2021. All rights reserved.


      Website designed and developed by Herb Miller
      Proudly powered by WordPress and oik plugins

      • Home
      • Blog
      • Sitemap
      • Sites