ductions ) { // Bail when there are no introductions to show. return; } // Update user meta to have "seen" these introductions. $this->update_user_introductions( $user_id, $introductions ); $this->admin_asset_manager->enqueue_script( self::SCRIPT_HANDLE ); $this->admin_asset_manager->localize_script( self::SCRIPT_HANDLE, 'wpseoIntroductions', [ 'introductions' => $introductions, 'isPremium' => $this->product_helper->is_premium(), 'isRtl' => \is_rtl(), 'linkParams' => $this->short_link_helper->get_query_params(), 'pluginUrl' => \plugins_url( '', \WPSEO_FILE ), 'wistiaEmbedPermission' => $this->wistia_embed_permission_repository->get_value_for_user( $user_id ), 'isWooEnabled' => $this->woocommerce_conditional->is_met(), ], ); $this->admin_asset_manager->enqueue_style( 'introductions' ); } /** * Updates the user metadata to have "seen" the introductions. * * @param int $user_id The user ID. * @param array $introductions The introductions. * * @return void */ private function update_user_introductions( $user_id, $introductions ) { $metadata = $this->user_helper->get_meta( $user_id, Introductions_Seen_Repository::USER_META_KEY, true ); if ( ! \is_array( $metadata ) ) { $metadata = []; } if ( empty( $introductions ) || ! \is_array( $introductions ) ) { return; } // Find the introduction with the highest priority, because JS will only show that one. $highest_priority_intro = \array_reduce( $introductions, static function ( $carry, $item ) { return ( $carry === null || $item['priority'] < $carry['priority'] ) ? $item : $carry; }, null, ); if ( $highest_priority_intro === null ) { return; } // Mark the introduction with the highest priority as seen. $metadata[ $highest_priority_intro['id'] ]['is_seen'] = true; $metadata[ $highest_priority_intro['id'] ]['seen_on'] = \time(); $this->user_helper->update_meta( $user_id, Introductions_Seen_Repository::USER_META_KEY, $metadata ); } /** * Updates the introductions metadata format for the user * This is needed because we're introducing timestamps for introductions that have been seen, thus changing the format. * * @param int $user_id The user ID. * * @return void */ private function update_metadata_for( int $user_id ) { $metadata = $this->introductions_collector->get_metadata( $user_id ); foreach ( $metadata as $introduction_name => $introduction_data ) { if ( \is_bool( $introduction_data ) ) { $metadata[ $introduction_name ] = [ 'is_seen' => $introduction_data, 'seen_on' => ( $introduction_data === true ) ? \time() : 0, ]; } } $this->user_helper->update_meta( $user_id, Introductions_Seen_Repository::USER_META_KEY, $metadata ); } } bmw X1 plug-in hybrid - Auto-moto portál, magazín

Štítek: bmw X1 plug-in hybrid

Oblíbená cestovatelská videa

Vítejte zpět!

Níže se přihlaste do vašeho účtu

Načtěte vaše heslo

Vložte prosím vaše uživatelské jméno nebo email pro reset hesla

Previous Next
Close
Test Caption
Test Description goes like this