includes/class-freemius.php
private function fetch_user_marketing_flag_status_by_plugins( $user_email, $license_key, $plugin_ids ) {
            $request = array(
                'method'  => 'POST',
                'body'    => array(),
                'timeout' => WP_FS__DEBUG_SDK ? 60 : 30,
            );

            if ( is_string( $user_email ) ) {
                $request['body']['email'] = $user_email;
            } else {
                $request['body']['license_key'] = $license_key;
            }

            $result = array();

            $url              = WP_FS__ADDRESS . '/action/service/user_plugin/';
            $total_plugin_ids = count( $plugin_ids );

            $plugin_ids_count_per_request = 10;
            for ( $i = 1; $i <= $total_plugin_ids; $i += $plugin_ids_count_per_request ) {
                $plugin_ids_set = array_slice( $plugin_ids, $i - 1, $plugin_ids_count_per_request );

                $request['body']['plugin_ids'] = $plugin_ids_set;

                $response = self::safe_remote_post(
                    $url,
                    $request,
                    WP_FS__TIME_24_HOURS_IN_SEC,
                    WP_FS__TIME_12_HOURS_IN_SEC
                );

                if ( ! is_wp_error( $response ) ) {
                    $decoded = is_string( $response['body'] ) ?
                        json_decode( $response['body'] ) :
                        null;

                    if (
                        !is_object($decoded) ||
                        !isset($decoded->success) ||
                        true !== $decoded->success ||
                        !isset( $decoded->data ) ||
                        !is_array( $decoded->data )
                    ) {
                        return false;
                    }

                    $result = array_merge( $result, $decoded->data );
                }
            }

            return $result;
        }
private function fetch_user_marketing_flag_status_by_plugins( $user_email, $license_key, $plugin_ids ) {
            $request = array(
                'method'  => 'POST',
                'body'    => array(),
                'timeout' => WP_FS__DEBUG_SDK ? 60 : 30,
            );

            if ( is_string( $user_email ) ) {
                $request['body']['email'] = $user_email;
            } else {
                $request['body']['license_key'] = $license_key;
            }

            $result = array();

            $url              = WP_FS__ADDRESS . '/action/service/user_plugin/';
            $total_plugin_ids = count( $plugin_ids );

            $plugin_ids_count_per_request = 10;
            for ( $i = 1; $i <= $total_plugin_ids; $i += $plugin_ids_count_per_request ) {
                $plugin_ids_set = array_slice( $plugin_ids, $i - 1, $plugin_ids_count_per_request );

                $request['body']['plugin_ids'] = $plugin_ids_set;

                $response = self::safe_remote_post(
                    $url,
                    $request,
                    WP_FS__TIME_24_HOURS_IN_SEC,
                    WP_FS__TIME_12_HOURS_IN_SEC
                );

                if ( ! is_wp_error( $response ) ) {
                    $decoded = is_string( $response['body'] ) ?
                        json_decode( $response['body'] ) :
                        null;

                    if (
                        !is_object($decoded) ||
                        !isset($decoded->success) ||
                        true !== $decoded->success ||
                        !isset( $decoded->data ) ||
                        !is_array( $decoded->data )
                    ) {
                        return false;
                    }

                    $result = array_merge( $result, $decoded->data );
                }
            }

            return $result;
        }
private function fetch_user_marketing_flag_status_by_plugins ( $ user_email , $ license_key , $ plugin_ids ) { $ request = array ( 'method' => 'POST' , 'body' => array ( ) , 'timeout' => WP_FS__DEBUG_SDK ? 60 : 30 , ) ; if ( is_string ( $ user_email ) ) { $ request [ 'body' ] [ 'email' ] = $ user_email ; } else { $ request [ 'body' ] [ 'license_key' ] = $ license_key ; } $ result = array ( ) ; $ url = WP_FS__ADDRESS . '/action/service/user_plugin/' ; $ total_plugin_ids = count ( $ plugin_ids ) ; $ plugin_ids_count_per_request = 10 ; for ( $ i = 1 ; $ i <= $ total_plugin_ids ; $ i += $ plugin_ids_count_per_request ) { $ plugin_ids_set = array_slice ( $ plugin_ids , $ i - 1 , $ plugin_ids_count_per_request ) ; $ request [ 'body' ] [ 'plugin_ids' ] = $ plugin_ids_set ; $ response = self :: safe_remote_post ( $ url , $ request , WP_FS__TIME_24_HOURS_IN_SEC , WP_FS__TIME_12_HOURS_IN_SEC ) ; if ( ! is_wp_error ( $ response ) ) { $ decoded = is_string ( $ response [ 'body' ] ) ? json_decode ( $ response [ 'body' ] ) : null ; if ( ! is_object ( $ decoded ) || ! isset ( $ decoded -> success ) || true !== $ decoded -> success || ! isset ( $ decoded -> data ) || ! is_array ( $ decoded -> data ) ) { return false ; } $ result = array_merge ( $ result , $ decoded -> data ) ; } } return $ result ; }
This method is called for opted-in users to fetch the is_marketing_allowed flag of the user for all the
plugins and themes they've opted in to.

@author Leo Fajardo (@leorw)
@since 2.1.0

@param string      $user_email
@param string      $license_key
@param array       $plugin_ids
@param string|null $license_key

@return array|false
This method is called for opted - in users to fetch the is_marketing_allowed flag of the user for all the plugins and themes they ve opted in to .