Changeset 3452102 for sureforms/trunk/admin/admin.php
- Timestamp:
- 02/02/2026 01:04:42 PM (8 weeks ago)
- File:
-
- 1 edited
-
sureforms/trunk/admin/admin.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sureforms/trunk/admin/admin.php
r3443209 r3452102 69 69 70 70 add_action( 'current_screen', [ $this, 'enable_gutenberg_for_sureforms' ], 100 ); 71 // Register notices early for React pages (before admin_enqueue_scripts). 72 add_action( 'admin_init', [ $this, 'register_pro_compatibility_notices' ], 5 ); 73 // Display notices on traditional WordPress admin pages. 71 74 add_action( 'admin_notices', [ $this, 'srfm_pro_version_compatibility' ] ); 72 75 … … 919 922 wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/entries.js', $script_info['dependencies'], SRFM_VER, true ); 920 923 924 wp_localize_script( 925 SRFM_SLUG . $asset_handle, 926 SRFM_SLUG . '_admin', 927 apply_filters( 928 SRFM_SLUG . '_admin_filter', 929 $localization_data 930 ) 931 ); 921 932 $script_translations_handlers[] = SRFM_SLUG . $asset_handle; 922 933 } … … 938 949 SRFM_SLUG . $asset_handle, 939 950 SRFM_SLUG . '_admin', 940 $localization_data 951 apply_filters( 952 SRFM_SLUG . '_admin_filter', 953 $localization_data 954 ) 941 955 ); 942 956 wp_enqueue_style( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/forms.css', [], SRFM_VER, 'all' ); … … 1157 1171 1158 1172 return $status; 1173 } 1174 1175 /** 1176 * Register Pro compatibility notices early for React pages. 1177 * 1178 * This method runs on admin_init (priority 5) to ensure notices are 1179 * registered BEFORE admin_enqueue_scripts, so they're available when 1180 * wp_localize_script runs. 1181 * 1182 * Hooked - admin_init (priority 5) 1183 * 1184 * @return void 1185 * @since 2.5.0 1186 */ 1187 public function register_pro_compatibility_notices() { 1188 // Early exit if Pro is not active, user lacks permissions, or Notice_Manager is unavailable. 1189 if ( ! Helper::has_pro() || ! Helper::current_user_can() || ! class_exists( 'SRFM\Admin\Notice_Manager' ) ) { 1190 return; 1191 } 1192 1193 // Register version outdated notice for React pages. 1194 if ( ! version_compare( SRFM_PRO_VER, SRFM_PRO_RECOMMENDED_VER, '>=' ) ) { 1195 $pro_plugin_name = defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro'; 1196 $react_outdated_message = sprintf( 1197 // translators: %1$s: SureForms version, %2$s: SureForms Pro Plugin Name, %3$s: SureForms Pro Version. 1198 esc_html__( 'SureForms %1$s requires minimum %2$s %3$s to work properly. Please update to the latest version.', 'sureforms' ), 1199 esc_html( SRFM_VER ), 1200 esc_html( $pro_plugin_name ), 1201 esc_html( SRFM_PRO_RECOMMENDED_VER ) 1202 ); 1203 1204 \SRFM\Admin\Notice_Manager::register_notice( 1205 [ 1206 'id' => 'sureforms-pro-version-outdated', 1207 'variant' => 'warning', 1208 'message' => $react_outdated_message, 1209 'actions' => [ 1210 [ 1211 'label' => esc_html__( 'Update Now', 'sureforms' ), 1212 'url' => admin_url( 'update-core.php' ), 1213 'variant' => 'primary', 1214 ], 1215 ], 1216 'pages' => [ 'all' ], 1217 ] 1218 ); 1219 } 1159 1220 } 1160 1221
Note: See TracChangeset
for help on using the changeset viewer.