diff --git a/plugins/hwp-previews/src/Hooks/Preview_Hooks.php b/plugins/hwp-previews/src/Hooks/Preview_Hooks.php index fe6c2d49..e9889bea 100644 --- a/plugins/hwp-previews/src/Hooks/Preview_Hooks.php +++ b/plugins/hwp-previews/src/Hooks/Preview_Hooks.php @@ -77,8 +77,8 @@ public static function add_hook_actions(): void { // iframe preview functionality. add_filter( 'template_include', [ self::class, 'add_iframe_preview_template' ], 10, 1 ); - // Preview link functionality. - add_filter( 'preview_post_link', [ self::class, 'update_preview_post_link' ], 10, 2 ); + // Preview link functionality. Extra priority to ensure it runs after the Faust preview link filter. + add_filter( 'preview_post_link', [ self::class, 'update_preview_post_link' ], 1001, 2 ); /** diff --git a/plugins/hwp-previews/src/Integration/Faust_Integration.php b/plugins/hwp-previews/src/Integration/Faust_Integration.php new file mode 100644 index 00000000..07d3f550 --- /dev/null +++ b/plugins/hwp-previews/src/Integration/Faust_Integration.php @@ -0,0 +1,185 @@ +get_cached_settings(); + + if ( ! empty( $plugin_settings ) ) { + return; + } + + $setting_preview_key = $settings_group->get_settings_key_preview_url(); + $setting_enabled_key = $settings_group->get_settings_key_enabled(); + + $default_settings = []; + + foreach ( $types_config->get_public_post_types() as $key => $label ) { + $default_settings[ $key ] = [ + $setting_enabled_key => true, + $setting_preview_key => self::get_faust_preview_url(), + ]; + } + + update_option( HWP_PREVIEWS_SETTINGS_KEY, $default_settings ); + } + + /** + * Dismiss the Faust admin notice. + */ + public static function dismiss_faust_admin_notice(): void { + update_user_meta( get_current_user_id(), self::FAUST_NOTICE_KEY, 1 ); + } + + /** + * Register admin notice to inform users about Faust integration. + */ + public static function register_faust_admin_notice(): void { + add_action( 'admin_notices', static function (): void { + $screen = get_current_screen(); + + // Exit if not this plugin's settings page. + if ( ! is_object( $screen ) || 'settings_page_hwp-previews' !== $screen->id ) { + return; + } + + $ajax_nonce = wp_create_nonce( self::FAUST_NOTICE_KEY ); + ?> + +