textarea id) and i18n.saved; Header & Footer Code adds lines. * @param string[] $deps Script dependencies. * @return void */ public static function enqueue( array $data, array $deps = array() ) { wp_enqueue_script( self::HANDLE, ADMINKEEP_URL . self::SCRIPT, $deps, Assets::version( self::SCRIPT ), true ); $data['nonce'] = wp_create_nonce( 'wp_rest' ); $data['notices'] = self::NOTICES_ID; $data['i18n'] = array_merge( array( 'failed' => __( 'Could not save. Check your connection and try again.', 'adminkeep' ), 'expired' => __( 'Could not save: your login has expired or this page is out of date. Your changes are still here. Copy them somewhere safe, reload the page, paste them back and save again.', 'adminkeep' ), ), isset( $data['i18n'] ) ? (array) $data['i18n'] : array() ); // Inline JSON rather than wp_localize_script(), as for the live CSS panel, and with tags // hex-escaped: a display name is free text and must not be able to end the script element. wp_add_inline_script( self::HANDLE, 'var adminkeepCodeScreen = ' . wp_json_encode( $data, JSON_HEX_TAG | JSON_HEX_AMP ) . ';', 'before' ); } /** * Print the notice area, holding the notice the page was loaded with, if any. * * The script replaces what is inside after a save, so the area is printed even when empty. It * is a live region, which is how screen readers hear the outcome of a save that no longer * reloads the page. * * @param string $kind 'success', 'error', or '' for an empty area. * @param string $message Notice text. * @return void */ public static function print_notices( $kind = '', $message = '' ) { printf( '
', esc_attr( self::NOTICES_ID ) ); if ( '' !== $kind ) { printf( '

%2$s

', esc_attr( $kind ), esc_html( $message ) ); } echo '
'; } }