override_i18n($map); // Some SDK connect strings deliberately use the default SDK slug. Scope their // official override to our own admin pages, never other products or the site front. if(self::page())fs_override_i18n($map,'freemius'); },5); add_action('admin_menu',static function()use($sdk){ if(!current_user_can('manage_options'))return; global $_registered_pages;$hook=get_plugin_page_hookname('abece-booking-pricing','abece-booking'); if(!isset($_registered_pages[$hook]))add_submenu_page('abece-booking',__('Upgrade ABeCe Booking','abece-booking'),__('Upgrade ABeCe Booking','abece-booking'),'manage_options','abece-booking-pricing',static function()use($sdk){$sdk->_pricing_page_render();}); },PHP_INT_MAX); foreach(['templates/pricing.php','templates/checkout.php'] as $hook)$sdk->add_filter($hook,static fn($html)=>self::upgrade($sdk,$html)); add_action('admin_notices',static function()use($sdk){if(!self::page()||!current_user_can('manage_options')||!$sdk->is_premium()||$sdk->is_registered())return;echo '

'.esc_html__('Use a customer license key here. A developer secret key (sk_) is not a license key.','abece-booking').'

';}); } private static function page():bool {return isset($_GET['page'])&&is_string($_GET['page'])&&str_starts_with(sanitize_key(wp_unslash($_GET['page'])),'abece-booking');} /** Keys and printf placeholders verified against SDK 2.13.4 connect/account templates. */ private static function strings():array {return [ 'skip'=>__('Skip','abece-booking'), 'skipping-wait'=>__('Skipping, please wait','abece-booking'), 'activate-license'=>__('Activate License','abece-booking'), 'license-key'=>__('License key','abece-booking'), 'connect-header'=>__('Never miss an important update','abece-booking'), 'opt-in-connect'=>__('Allow & Continue','abece-booking'), 'contact-for-updates'=>__("Please let us know if you'd like us to contact you for security & feature updates, educational content, and occasional offers:",'abece-booking'), 'send-updates'=>__('send me security & feature updates, educational content and offers.','abece-booking'), /* translators: %1$s: opening emphasis markup; %2$s: closing emphasis markup. The SDK supplies these wrappers. */ 'do-not-send-updates'=>__('do %1$sNOT%2$s send me security & feature updates, educational content and offers.','abece-booking'), /* translators: %s: plugin or theme product type supplied by Freemius. */ 'connect-message'=>__('Optional sharing helps improve compatibility of the %s and sends update information and occasional offers. Lite bookings also work with Skip; no marketing permission is required. Review the permissions below.','abece-booking'), /* translators: %s: product name supplied by Freemius. */ 'thanks-for-purchasing'=>__('Welcome to %s! To get started, please enter your license key:','abece-booking'), ];} /** A successful HTTP envelope alone is insufficient: SDK pricing JS iterates pricing. */ public static function pricingReady(mixed $data):bool { if(!is_object($data)||isset($data->error)||!isset($data->plans)||!is_array($data->plans)||!$data->plans)return false; $paid=false;foreach($data->plans as $plan){if(!is_object($plan)||!isset($plan->pricing)||!is_array($plan->pricing))return false;if($plan->pricing)$paid=true;}return $paid; } public static function upgrade(\Freemius $sdk,string $html):string { if(!current_user_can('manage_options'))return '

'.esc_html__('You do not have permission to manage this site.','abece-booking').'

'; $available=false;$unpublished=false; try{$data=$sdk->get_api_plugin_scope()->get($sdk->add_show_pending('pricing.json?is_enriched=true'));$available=self::pricingReady($data);$unpublished=is_object($data)&&!is_wp_error($data)&&!isset($data->error)&&isset($data->plans)&&!$available;}catch(\Throwable){/* Never expose SDK objects, response bodies or keys. */} if(!$available)wp_dequeue_script('freemius-pricing'); $message=$available?__('Prices and checkout are provided by Freemius. If the pricing form does not load, try again later. Booking remains available.','abece-booking'):($unpublished?__('Paid editions of ABeCe Booking are not yet available to purchase.','abece-booking'):__('Paid editions could not be loaded. Please try again later. Booking remains available.','abece-booking')); $notice='

'.esc_html__('Upgrade ABeCe Booking','abece-booking').'

'.esc_html($message).'

'.esc_html__('Editions and features','abece-booking').'

'; return $notice.($available?$html:''); } }