$partner_attribution = $c->get('api.helper.partner-attribution'); assert($partner_attribution instanceof PartnerAttribution); wp_localize_script('ppcp-paylater-configurator', 'PcpPayLaterConfigurator', array('ajax' => array('save_config' => array('endpoint' => \WC_AJAX::get_endpoint(SaveConfig::ENDPOINT), 'nonce' => wp_create_nonce(SaveConfig::nonce())), 'get_config' => array('endpoint' => \WC_AJAX::get_endpoint(GetConfig::ENDPOINT), 'nonce' => wp_create_nonce(GetConfig::nonce()))), 'config' => $config_factory->from_settings($settings), 'merchantClientId' => $settings->get('client_id'), 'partnerClientId' => $c->get('api.partner_merchant_id'), 'bnCode' => $partner_attribution->get_bn_code(), 'publishButtonClassName' => 'ppcp-paylater-configurator-publishButton', 'headerClassName' => 'ppcp-paylater-configurator-header', 'subheaderClassName' => 'ppcp-paylater-configurator-subheader')); }); return \true; } /** * Conditionally registers a new admin notice to highlight the new Pay-Later UI. * * The notice appears on any PayPal-Settings page, except for the Pay-Later settings page, * when no Pay-Later messaging is used yet. * * @param array $message_locations PayLater messaging locations. * @param bool $is_settings_page Whether the current page is a WC settings page. * @param string $current_page_id ID of current settings page tab. * * @return void */ private static function add_paylater_update_notice(array $message_locations, bool $is_settings_page, string $current_page_id): void { // The message must be registered on any WC-Settings page, except for the Pay Later page. if (!$is_settings_page || Settings::PAY_LATER_TAB_ID === $current_page_id) { return; } // Don't display the notice when Pay-Later messaging is already used. if (count($message_locations)) { return; } add_filter( Repository::NOTICES_FILTER, /** * Notify the user about the new Pay-Later UI. * * @param array $notices The notices. * @return array * * @psalm-suppress MissingClosureParamType */ static function ($notices): array { $settings_url = admin_url('admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-tab=ppcp-pay-later'); $message = sprintf( // translators: %1$s and %2$s are the opening and closing of HTML tag directing to the Pay-Later settings page. __('NEW: Check out the recently revamped %1$sPayPal Pay Later messaging experience here%2$s. Get paid in full at checkout while giving your customers the flexibility to pay in installments over time.', 'woocommerce-paypal-payments'), '', '' ); $notices[] = new PersistentMessage('pay-later-messaging', $message, 'info', 'ppcp-notice-wrapper'); return $notices; } ); } }