Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function and replace logic #5084

Merged
merged 4 commits into from
Apr 15, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion includes/Modules/AdSense.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ function( Google_Service_Adsense_Alert $alert ) {
protected function parse_data_response( Data_Request $data, $response ) {
switch ( "{$data->method}:{$data->datapoint}" ) {
case 'GET:accounts':
return array_map( array( self::class, 'filter_account_with_ids' ), $response->getAccounts() );
$accounts = array_filter( $response->getAccounts(), array( self::class, 'is_account_not_closed' ) );
return array_map( array( self::class, 'filter_account_with_ids' ), $accounts );
case 'GET:adunits':
return array_map( array( self::class, 'filter_adunit_with_ids' ), $response->getAdUnits() );
case 'GET:alerts':
Expand All @@ -421,6 +422,20 @@ protected function parse_data_response( Data_Request $data, $response ) {
return parent::parse_data_response( $data, $response );
}

/**
* Checks for the state of an Account, whether close or not.
*
* @since n.e.x.t
*
felixarntz marked this conversation as resolved.
Show resolved Hide resolved
* @param object $account The AdSense account object.
*
* @return bool Whether the account is not closed.
felixarntz marked this conversation as resolved.
Show resolved Hide resolved
*/
public static function is_account_not_closed($account){

return 'CLOSED' !== $account->getState();
felixarntz marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Gets the service URL for the current account or signup if none.
*
Expand Down