0 */ private function combine_rules_selectors() { // Build an array of selectors along with the JSON-ified styles to make comparisons easier. $selectors_json = array(); foreach ( $this->css_rules as $rule ) { $declarations = $rule->get_declarations()->get_declarations(); ksort( $declarations ); $selectors_json[ $rule->get_selector() ] = wp_json_encode( $declarations ); } // Combine selectors that have the same styles. foreach ( $selectors_json as $selector => $json ) { // Get selectors that use the same styles. $duplicates = array_keys( $selectors_json, $json, true ); // Skip if there are no duplicates. if ( 1 >= count( $duplicates ) ) { continue; } $declarations = $this->css_rules[ $selector ]->get_declarations(); foreach ( $duplicates as $key ) { // Unset the duplicates from the $selectors_json array to avoid looping through them as well. unset( $selectors_json[ $key ] ); // Remove the rules from the rules collection. unset( $this->css_rules[ $key ] ); } // Create a new rule with the combined selectors. $duplicate_selectors = implode( ',', $duplicates ); $this->css_rules[ $duplicate_selectors ] = new WP_Style_Engine_CSS_Rule( $duplicate_selectors, $declarations ); } } } aign data to an array. * * @param GoogleAdsRow $row Data row returned from a query request. * * @return array */ protected function convert_campaign( GoogleAdsRow $row ): array { $campaign = $row->getCampaign(); $data = [ 'id' => $campaign->getId(), 'name' => $campaign->getName(), 'status' => CampaignStatus::label( $campaign->getStatus() ), 'type' => CampaignType::label( $campaign->getAdvertisingChannelType() ), 'targeted_locations' => [], ]; $budget = $row->getCampaignBudget(); if ( $budget ) { $data += [ 'amount' => $this->from_micro( $budget->getAmountMicros() ), ]; } $shopping = $campaign->getShoppingSetting(); if ( $shopping ) { $data += [ 'country' => $shopping->getFeedLabel(), ]; } return $data; } /** * Combine converted campaigns data with campaign criterion results data * * @param array $campaigns Campaigns data returned from a query request and converted by convert_campaign function. * * @return array */ protected function combine_campaigns_and_campaign_criterion_results( array $campaigns ): array { if ( empty( $campaigns ) ) { return []; } $campaign_criterion_results = ( new AdsCampaignCriterionQuery() )->set_client( $this->client, $this->options->get_ads_id() ) ->where( 'campaign.id', array_keys( $campaigns ), 'IN' ) // negative: Whether to target (false) or exclude (true) the criterion. ->where( 'campaign_criterion.negative', 'false', '=' ) ->where( 'campaign_criterion.status', 'REMOVED', '!=' ) ->where( 'campaign_criterion.location.geo_target_constant', '', 'IS NOT NULL' ) ->get_results(); /** @var GoogleAdsRow $row */ foreach ( $campaign_criterion_results->iterateAllElements() as $row ) { $campaign = $row->getCampaign(); $campaign_id = $campaign->getId(); if ( ! isset( $campaigns[ $campaign_id ] ) ) { continue; } $campaign_criterion = $row->getCampaignCriterion(); $location = $campaign_criterion->getLocation(); $geo_target_constant = $location->getGeoTargetConstant(); $location_id = $this->parse_geo_target_location_id( $geo_target_constant ); $country_code = $this->google_helper->find_country_code_by_id( $location_id ); if ( $country_code ) { $campaigns[ $campaign_id ]['targeted_locations'][] = $country_code; } } return $campaigns; } /** * Send a batch of operations to mutate a campaign. * * @param MutateOperation[] $operations * * @return int Campaign ID from the MutateOperationResponse. * @throws ApiException If any of the operations fail. */ protected function mutate( array $operations ): int { $request = new MutateGoogleAdsRequest(); $request->setCustomerId( $this->options->get_ads_id() ); $request->setMutateOperations( $operations ); $responses = $this->client->getGoogleAdsServiceClient()->mutate( $request ); foreach ( $responses->getMutateOperationResponses() as $response ) { if ( 'campaign_result' === $response->getResponse() ) { $campaign_result = $response->getCampaignResult(); return $this->parse_campaign_id( $campaign_result->getResourceName() ); } } // When editing only the budget there is no campaign mutate result. return 0; } /** * Convert ID from a resource name to an int. * * @param string $name Resource name containing ID number. * * @return int * @throws Exception When unable to parse resource ID. */ protected function parse_campaign_id( string $name ): int { try { $parts = CampaignServiceClient::parseName( $name ); return absint( $parts['campaign_id'] ); } catch ( ValidationException $e ) { throw new Exception( __( 'Invalid campaign ID', 'google-listings-and-ads' ) ); } } /** * Convert location ID from a geo target constant resource name to an int. * * @param string $geo_target_constant Resource name containing ID number. * * @return int * @throws Exception When unable to parse resource ID. */ protected function parse_geo_target_location_id( string $geo_target_constant ): int { if ( 1 === preg_match( '#geoTargetConstants/(?\d+)#', $geo_target_constant, $parts ) ) { return absint( $parts['id'] ); } else { throw new Exception( __( 'Invalid geo target location ID', 'google-listings-and-ads' ) ); } } } Pagina niet gevonden – Revelatio
Revelatio
page not found
Sorry, blijkbaar is er een pagina niet in orde ...

Get special offers from us


Fatal error: Uncaught Error: Class 'WP_Style_Engine_Processor' not found in /home/revelati/public_html/wp-includes/style-engine/class-wp-style-engine.php:740 Stack trace: #0 /home/revelati/public_html/wp-includes/style-engine.php(192): WP_Style_Engine::compile_stylesheet_from_css_rules(Array, '') #1 /home/revelati/public_html/wp-includes/script-loader.php(3237): wp_style_engine_get_stylesheet_from_context('block-supports', '') #2 /home/revelati/public_html/wp-includes/class-wp-hook.php(324): wp_enqueue_stored_styles('') #3 /home/revelati/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #4 /home/revelati/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #5 /home/revelati/public_html/wp-includes/general-template.php(3208): do_action('wp_footer') #6 /home/revelati/public_html/wp-content/themes/erica/footer.php(20): wp_footer() #7 /home/revelati/public_html/wp-includes/template.php(810): require_once('/home/revelati/...') #8 /home/revelati/public_html/wp-includes/template.ph in /home/revelati/public_html/wp-includes/style-engine/class-wp-style-engine.php on line 740