/
return apply_filters( "get_the_generator_{$type}", $gen, $type );
}
/**
* Outputs the HTML checked attribute.
*
* Compares the first two arguments and if identical marks as checked.
*
* @since 1.0.0
*
* @param mixed $checked One of the values to compare.
* @param mixed $current Optional. The other value to compare if not just true.
* Default true.
* @param bool $display Optional. Whether to echo or just return the string.
* Default true.
* @return string HTML attribute or empty string.
*/
function checked( $checked, $current = true, $display = true ) {
return __checked_selected_helper( $checked, $current, $display, 'checked' );
}
/**
* Outputs the HTML selected attribute.
*
* Compares the first two arguments and if identical marks as selected.
*
* @since 1.0.0
*
* @param mixed $selected One of the values to compare.
* @param mixed $current Optional. The other value to compare if not just true.
* Default true.
* @param bool $display Optional. Whether to echo or just return the string.
* Default true.
* @return string HTML attribute or empty string.
*/
function selected( $selected, $current = true, $display = true ) {
return __checked_selected_helper( $selected, $current, $display, 'selected' );
}
/**
* Outputs the HTML disabled attribute.
*
* Compares the first two arguments and if identical marks as disabled.
*
* @since 3.0.0
*
* @param mixed $disabled One of the values to compare.
* @param mixed $current Optional. The other value to compare if not just true.
* Default true.
* @param bool $display Optional. Whether to echo or just return the string.
* Default true.
* @return string HTML attribute or empty string.
*/
function disabled( $disabled, $current = true, $display = true ) {
return __checked_selected_helper( $disabled, $current, $display, 'disabled' );
}
/**
* Outputs the HTML readonly attribute.
*
* Compares the first two arguments and if identical marks as readonly.
*
* @since 5.9.0
*
* @param mixed $readonly_value One of the values to compare.
* @param mixed $current Optional. The other value to compare if not just true.
* Default true.
* @param bool $display Optional. Whether to echo or just return the string.
* Default true.
* @return string HTML attribute or empty string.
*/
function wp_readonly( $readonly_value, $current = true, $display = true ) {
return __checked_selected_helper( $readonly_value, $current, $display, 'readonly' );
}
/*
* Include a compat `readonly()` function on PHP < 8.1. Since PHP 8.1,
* `readonly` is a reserved keyword and cannot be used as a function name.
* In order to avoid PHP parser errors, this function was extracted
* to a separate file and is only included conditionally on PHP < 8.1.
*/
if ( PHP_VERSION_ID < 80100 ) {
require_once __DIR__ . '/php-compat/readonly.php';
}
/**
* Private helper function for checked, selected, disabled and readonly.
*
* Compares the first two arguments and if identical marks as `$type`.
*
* @since 2.8.0
* @access private
*
* @param mixed $helper One of the values to compare.
* @param mixed $current The other value to compare if not just true.
* @param bool $display Whether to echo or just return the string.
* @param string $type The type of checked|selected|disabled|readonly we are doing.
* @return string HTML attribute or empty string.
*/
function __checked_selected_helper( $helper, $current, $display, $type ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
if ( (string) $helper === (string) $current ) {
$result = " $type='$type'";
} else {
$result = '';
}
if ( $display ) {
echo $result;
}
return $result;
}
/**
* Assigns a visual indicator for required form fields.
*
* @since 6.1.0
*
* @return string Indicator glyph wrapped in a `span` tag.
*/
function wp_required_field_indicator() {
/* translators: Character to identify required form fields. */
$glyph = __( '*' );
$indicator = '' . esc_html( $glyph ) . '';
/**
* Filters the markup for a visual indicator of required form fields.
*
* @since 6.1.0
*
* @param string $indicator Markup for the indicator element.
*/
return apply_filters( 'wp_required_field_indicator', $indicator );
}
/**
* Creates a message to explain required form fields.
*
* @since 6.1.0
*
* @return string Message text and glyph wrapped in a `span` tag.
*/
function wp_required_field_message() {
$message = sprintf(
'%s',
/* translators: %s: Asterisk symbol (*). */
sprintf( __( 'Required fields are marked %s' ), wp_required_field_indicator() )
);
/**
* Filters the message to explain required form fields.
*
* @since 6.1.0
*
* @param string $message Message text and glyph wrapped in a `span` tag.
*/
return apply_filters( 'wp_required_field_message', $message );
}
/**
* Default settings for heartbeat.
*
* Outputs the nonce used in the heartbeat XHR.
*
* @since 3.6.0
*
* @param array $settings
* @return array Heartbeat settings.
*/
function wp_heartbeat_settings( $settings ) {
if ( ! is_admin() ) {
$settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
}
if ( is_user_logged_in() ) {
$settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' );
}
return $settings;
}