' . esc_html__( 'Stayrail', 'stayrail' ) . '

' . esc_html__( 'Loading…', 'stayrail' ) . '

'; } /** * Assets for the settings page. * * @param string $hook Current admin page hook. */ public static function enqueue( $hook ) { if ( $hook !== self::$hook ) { return; } wp_enqueue_style( 'wp-components' ); wp_enqueue_style( 'stayrail-admin', STAYRAIL_URL . 'assets/css/admin.css', array( 'wp-components' ), STAYRAIL_VERSION ); wp_enqueue_script( 'stayrail-admin', STAYRAIL_URL . 'assets/js/admin.js', array( 'wp-element', 'wp-components', 'wp-api-fetch', 'wp-i18n', 'wp-hooks' ), STAYRAIL_VERSION, true ); wp_set_script_translations( 'stayrail-admin', 'stayrail' ); $data = array( 'version' => STAYRAIL_VERSION, 'settings' => Settings::get(), 'defaults' => Settings::defaults(), 'legacy' => Importer::detect(), /** * Options owned by add-ons, edited and saved on this screen via /wp/v2/settings. * The add-on must register each option with show_in_rest. * * @param array $options Option name => current value. */ 'extraOptions' => (object) apply_filters( 'stayrail_admin_extra_options', array() ), /** * Whether Stayrail Pro (or another add-on) is active. Hides the Pro card. * * @param bool $active Default false. */ 'proActive' => (bool) apply_filters( 'stayrail_pro_active', false ), 'links' => array( 'widgets' => admin_url( 'widgets.php' ), 'plugins' => admin_url( 'plugins.php' ), 'support' => 'https://wordpress.org/support/plugin/stayrail/', 'pro' => 'https://stayrailwp.com/#pricing', ), ); wp_add_inline_script( 'stayrail-admin', 'window.StayrailAdmin = ' . wp_json_encode( $data ) . ';', 'before' ); /** * Enqueue add-on assets for the settings screen. Depend on "stayrail-admin". */ do_action( 'stayrail_admin_enqueue' ); } /** * "Settings" link on the Plugins screen. * * @param array $links Existing links. * * @return array */ public static function action_links( $links ) { array_unshift( $links, sprintf( '%s', esc_url( self::page_url() ), esc_html__( 'Settings', 'stayrail' ) ) ); return $links; } /** * Tell users switching from Fixed Widget that their setup can be imported. */ public static function import_notice() { $screen = get_current_screen(); if ( ! $screen || ! in_array( $screen->id, array( 'plugins', 'dashboard' ), true ) || ! current_user_can( 'manage_options' ) ) { return; } if ( get_option( Importer::DISMISSED_FLAG ) ) { return; } $legacy = Importer::detect(); if ( ! $legacy || $legacy['imported'] ) { return; } $dismiss = wp_nonce_url( admin_url( 'admin-post.php?action=stayrail_dismiss_import' ), 'stayrail_dismiss_import' ); printf( '

%1$s %2$s

%4$s %6$s

', esc_html__( 'Stayrail:', 'stayrail' ), esc_html__( 'We found settings from Fixed Widget. Import them in one click and keep your sticky widgets working.', 'stayrail' ), esc_url( self::page_url() ), esc_html__( 'Review and import', 'stayrail' ), esc_url( $dismiss ), esc_html__( 'Dismiss', 'stayrail' ) ); } /** * Hide the import notice for good. */ public static function dismiss_notice() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You are not allowed to do this.', 'stayrail' ) ); } check_admin_referer( 'stayrail_dismiss_import' ); update_option( Importer::DISMISSED_FLAG, 1, false ); wp_safe_redirect( wp_get_referer() ? wp_get_referer() : admin_url( 'plugins.php' ) ); exit; } /** * URL of the settings page. * * @return string */ public static function page_url() { return admin_url( 'options-general.php?page=' . self::PAGE ); } }