esc_html__( 'Ads.txt saved', 'ads-txt' ),
'error_message' => esc_html__( 'Your Ads.txt contains the following issues:', 'ads-txt' ),
'unknown_error' => esc_html__( 'An unknown error occurred.', 'ads-txt' ),
);
wp_localize_script( 'adstxt', 'adstxt', $strings );
}
add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\admin_enqueue_scripts' );
/**
* Output some CSS directly in the head of the document.
*
* Should there ever be more than ~25 lines of CSS, this should become a separate file.
*
* @return void
*/
function admin_head_css() {
?>
post_content;
$errors = get_post_meta( $post->ID, 'adstxt_errors', true );
}
?>
';
// Errors were originally stored as an array
// This old style only needs to be accounted for here at runtime display
if ( isset( $error['message'] ) ) {
$message = sprintf(
/* translators: Error message output. 1: Line number, 2: Error message */
__( 'Line %1$s: %2$s', 'ads-txt' ),
$error['line'],
$error['message']
);
echo esc_html( $message );
} else {
/*
* Important: This is escaped piece-wise inside `format_error()`,
* as we cannot do absolute-end late escaping as normally recommended.
* This is because the placeholders in the translations can contain HTML,
* namely escaped data values wrapped in code tags.
* We don't have good JS translation tools yet and it's better to avoid duplication,
* so we use a single PHP function for both the JS template and in PHP.
*/
echo format_error( $error ); // WPCS: XSS ok.
}
echo '';
}
?>
' . esc_html( $error['value'] ) . '' );
$message = sprintf(
/* translators: Error message output. 1: Line number, 2: Error message */
__( 'Line %1$s: %2$s', 'ads-txt' ),
esc_html( $error['line'] ),
$message // This is escaped piece-wise above and may contain HTML (code tags) at this point
);
return $message;
}
/**
* Get all non-generic error messages, translated and with placeholders intact.
*
* @return array Associative array of error messages.
*/
function get_error_messages() {
$messages = array(
'invalid_variable' => __( 'Unrecognized variable' ),
'invalid_record' => __( 'Invalid record' ),
'invalid_account_type' => __( 'Third field should be RESELLER or DIRECT' ),
/* translators: %s: Subdomain */
'invalid_subdomain' => __( '%s does not appear to be a valid subdomain' ),
/* translators: %s: Exchange domain */
'invalid_exchange' => __( '%s does not appear to be a valid exchange domain' ),
/* translators: %s: Alphanumeric TAG-ID */
'invalid_tagid' => __( '%s does not appear to be a valid TAG-ID' ),
);
return $messages;
}