Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../block-su...
File: typography.php
$view_port_width_offset = round( $minimum_viewport_width['value'] / 100, 3 ) . $font_size_unit;
[500] Fix | Delete
$linear_factor = 100 * ( ( $maximum_font_size['value'] - $minimum_font_size['value'] ) / ( $linear_factor_denominator ) );
[501] Fix | Delete
$linear_factor_scaled = round( $linear_factor * $scale_factor, 3 );
[502] Fix | Delete
$linear_factor_scaled = empty( $linear_factor_scaled ) ? 1 : $linear_factor_scaled;
[503] Fix | Delete
$fluid_target_font_size = implode( '', $minimum_font_size_rem ) . " + ((1vw - $view_port_width_offset) * $linear_factor_scaled)";
[504] Fix | Delete
[505] Fix | Delete
return "clamp($minimum_font_size_raw, $fluid_target_font_size, $maximum_font_size_raw)";
[506] Fix | Delete
}
[507] Fix | Delete
[508] Fix | Delete
/**
[509] Fix | Delete
* Returns a font-size value based on a given font-size preset.
[510] Fix | Delete
* Takes into account fluid typography parameters and attempts to return a CSS
[511] Fix | Delete
* formula depending on available, valid values.
[512] Fix | Delete
*
[513] Fix | Delete
* @since 6.1.0
[514] Fix | Delete
* @since 6.1.1 Adjusted rules for min and max font sizes.
[515] Fix | Delete
* @since 6.2.0 Added 'settings.typography.fluid.minFontSize' support.
[516] Fix | Delete
* @since 6.3.0 Using layout.wideSize as max viewport width, and logarithmic scale factor to calculate minimum font scale.
[517] Fix | Delete
* @since 6.4.0 Added configurable min and max viewport width values to the typography.fluid theme.json schema.
[518] Fix | Delete
* @since 6.6.0 Deprecated bool argument $should_use_fluid_typography.
[519] Fix | Delete
*
[520] Fix | Delete
* @param array $preset {
[521] Fix | Delete
* Required. fontSizes preset value as seen in theme.json.
[522] Fix | Delete
*
[523] Fix | Delete
* @type string $name Name of the font size preset.
[524] Fix | Delete
* @type string $slug Kebab-case, unique identifier for the font size preset.
[525] Fix | Delete
* @type string|int|float $size CSS font-size value, including units if applicable.
[526] Fix | Delete
* }
[527] Fix | Delete
* @param bool|array $settings Optional Theme JSON settings array that overrides any global theme settings.
[528] Fix | Delete
* Default is false.
[529] Fix | Delete
* @return string|null Font-size value or null if a size is not passed in $preset.
[530] Fix | Delete
*/
[531] Fix | Delete
[532] Fix | Delete
[533] Fix | Delete
function wp_get_typography_font_size_value( $preset, $settings = array() ) {
[534] Fix | Delete
if ( ! isset( $preset['size'] ) ) {
[535] Fix | Delete
return null;
[536] Fix | Delete
}
[537] Fix | Delete
[538] Fix | Delete
/*
[539] Fix | Delete
* Catches empty values and 0/'0'.
[540] Fix | Delete
* Fluid calculations cannot be performed on 0.
[541] Fix | Delete
*/
[542] Fix | Delete
if ( empty( $preset['size'] ) ) {
[543] Fix | Delete
return $preset['size'];
[544] Fix | Delete
}
[545] Fix | Delete
[546] Fix | Delete
/*
[547] Fix | Delete
* As a boolean (deprecated since 6.6), $settings acts as an override to switch fluid typography "on" (`true`) or "off" (`false`).
[548] Fix | Delete
*/
[549] Fix | Delete
if ( is_bool( $settings ) ) {
[550] Fix | Delete
_deprecated_argument( __FUNCTION__, '6.6.0', __( '`boolean` type for second argument `$settings` is deprecated. Use `array()` instead.' ) );
[551] Fix | Delete
$settings = array(
[552] Fix | Delete
'typography' => array(
[553] Fix | Delete
'fluid' => $settings,
[554] Fix | Delete
),
[555] Fix | Delete
);
[556] Fix | Delete
}
[557] Fix | Delete
[558] Fix | Delete
// Fallback to global settings as default.
[559] Fix | Delete
$global_settings = wp_get_global_settings();
[560] Fix | Delete
$settings = wp_parse_args(
[561] Fix | Delete
$settings,
[562] Fix | Delete
$global_settings
[563] Fix | Delete
);
[564] Fix | Delete
[565] Fix | Delete
$typography_settings = isset( $settings['typography'] ) ? $settings['typography'] : array();
[566] Fix | Delete
$should_use_fluid_typography = ! empty( $typography_settings['fluid'] );
[567] Fix | Delete
[568] Fix | Delete
if ( ! $should_use_fluid_typography ) {
[569] Fix | Delete
return $preset['size'];
[570] Fix | Delete
}
[571] Fix | Delete
[572] Fix | Delete
// $typography_settings['fluid'] can be a bool or an array. Normalize to array.
[573] Fix | Delete
$fluid_settings = is_array( $typography_settings['fluid'] ) ? $typography_settings['fluid'] : array();
[574] Fix | Delete
$layout_settings = isset( $settings['layout'] ) ? $settings['layout'] : array();
[575] Fix | Delete
[576] Fix | Delete
// Defaults.
[577] Fix | Delete
$default_maximum_viewport_width = '1600px';
[578] Fix | Delete
$default_minimum_viewport_width = '320px';
[579] Fix | Delete
$default_minimum_font_size_factor_max = 0.75;
[580] Fix | Delete
$default_minimum_font_size_factor_min = 0.25;
[581] Fix | Delete
$default_scale_factor = 1;
[582] Fix | Delete
$default_minimum_font_size_limit = '14px';
[583] Fix | Delete
[584] Fix | Delete
// Defaults overrides.
[585] Fix | Delete
$minimum_viewport_width = isset( $fluid_settings['minViewportWidth'] ) ? $fluid_settings['minViewportWidth'] : $default_minimum_viewport_width;
[586] Fix | Delete
$maximum_viewport_width = isset( $layout_settings['wideSize'] ) && ! empty( wp_get_typography_value_and_unit( $layout_settings['wideSize'] ) ) ? $layout_settings['wideSize'] : $default_maximum_viewport_width;
[587] Fix | Delete
if ( isset( $fluid_settings['maxViewportWidth'] ) ) {
[588] Fix | Delete
$maximum_viewport_width = $fluid_settings['maxViewportWidth'];
[589] Fix | Delete
}
[590] Fix | Delete
$has_min_font_size = isset( $fluid_settings['minFontSize'] ) && ! empty( wp_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) );
[591] Fix | Delete
$minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : $default_minimum_font_size_limit;
[592] Fix | Delete
[593] Fix | Delete
// Font sizes.
[594] Fix | Delete
$fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null;
[595] Fix | Delete
[596] Fix | Delete
// A font size has explicitly bypassed fluid calculations.
[597] Fix | Delete
if ( false === $fluid_font_size_settings ) {
[598] Fix | Delete
return $preset['size'];
[599] Fix | Delete
}
[600] Fix | Delete
[601] Fix | Delete
// Try to grab explicit min and max fluid font sizes.
[602] Fix | Delete
$minimum_font_size_raw = isset( $fluid_font_size_settings['min'] ) ? $fluid_font_size_settings['min'] : null;
[603] Fix | Delete
$maximum_font_size_raw = isset( $fluid_font_size_settings['max'] ) ? $fluid_font_size_settings['max'] : null;
[604] Fix | Delete
[605] Fix | Delete
// Font sizes.
[606] Fix | Delete
$preferred_size = wp_get_typography_value_and_unit( $preset['size'] );
[607] Fix | Delete
[608] Fix | Delete
// Protects against unsupported units.
[609] Fix | Delete
if ( empty( $preferred_size['unit'] ) ) {
[610] Fix | Delete
return $preset['size'];
[611] Fix | Delete
}
[612] Fix | Delete
[613] Fix | Delete
/*
[614] Fix | Delete
* Normalizes the minimum font size limit according to the incoming unit,
[615] Fix | Delete
* in order to perform comparative checks.
[616] Fix | Delete
*/
[617] Fix | Delete
$minimum_font_size_limit = wp_get_typography_value_and_unit(
[618] Fix | Delete
$minimum_font_size_limit,
[619] Fix | Delete
array(
[620] Fix | Delete
'coerce_to' => $preferred_size['unit'],
[621] Fix | Delete
)
[622] Fix | Delete
);
[623] Fix | Delete
[624] Fix | Delete
// Don't enforce minimum font size if a font size has explicitly set a min and max value.
[625] Fix | Delete
if ( ! empty( $minimum_font_size_limit ) && ( ! $minimum_font_size_raw && ! $maximum_font_size_raw ) ) {
[626] Fix | Delete
/*
[627] Fix | Delete
* If a minimum size was not passed to this function
[628] Fix | Delete
* and the user-defined font size is lower than $minimum_font_size_limit,
[629] Fix | Delete
* do not calculate a fluid value.
[630] Fix | Delete
*/
[631] Fix | Delete
if ( $preferred_size['value'] <= $minimum_font_size_limit['value'] ) {
[632] Fix | Delete
return $preset['size'];
[633] Fix | Delete
}
[634] Fix | Delete
}
[635] Fix | Delete
[636] Fix | Delete
// If no fluid max font size is available use the incoming value.
[637] Fix | Delete
if ( ! $maximum_font_size_raw ) {
[638] Fix | Delete
$maximum_font_size_raw = $preferred_size['value'] . $preferred_size['unit'];
[639] Fix | Delete
}
[640] Fix | Delete
[641] Fix | Delete
/*
[642] Fix | Delete
* If no minimumFontSize is provided, create one using
[643] Fix | Delete
* the given font size multiplied by the min font size scale factor.
[644] Fix | Delete
*/
[645] Fix | Delete
if ( ! $minimum_font_size_raw ) {
[646] Fix | Delete
$preferred_font_size_in_px = 'px' === $preferred_size['unit'] ? $preferred_size['value'] : $preferred_size['value'] * 16;
[647] Fix | Delete
[648] Fix | Delete
/*
[649] Fix | Delete
* The scale factor is a multiplier that affects how quickly the curve will move towards the minimum,
[650] Fix | Delete
* that is, how quickly the size factor reaches 0 given increasing font size values.
[651] Fix | Delete
* For a - b * log2(), lower values of b will make the curve move towards the minimum faster.
[652] Fix | Delete
* The scale factor is constrained between min and max values.
[653] Fix | Delete
*/
[654] Fix | Delete
$minimum_font_size_factor = min( max( 1 - 0.075 * log( $preferred_font_size_in_px, 2 ), $default_minimum_font_size_factor_min ), $default_minimum_font_size_factor_max );
[655] Fix | Delete
$calculated_minimum_font_size = round( $preferred_size['value'] * $minimum_font_size_factor, 3 );
[656] Fix | Delete
[657] Fix | Delete
// Only use calculated min font size if it's > $minimum_font_size_limit value.
[658] Fix | Delete
if ( ! empty( $minimum_font_size_limit ) && $calculated_minimum_font_size <= $minimum_font_size_limit['value'] ) {
[659] Fix | Delete
$minimum_font_size_raw = $minimum_font_size_limit['value'] . $minimum_font_size_limit['unit'];
[660] Fix | Delete
} else {
[661] Fix | Delete
$minimum_font_size_raw = $calculated_minimum_font_size . $preferred_size['unit'];
[662] Fix | Delete
}
[663] Fix | Delete
}
[664] Fix | Delete
[665] Fix | Delete
$fluid_font_size_value = wp_get_computed_fluid_typography_value(
[666] Fix | Delete
array(
[667] Fix | Delete
'minimum_viewport_width' => $minimum_viewport_width,
[668] Fix | Delete
'maximum_viewport_width' => $maximum_viewport_width,
[669] Fix | Delete
'minimum_font_size' => $minimum_font_size_raw,
[670] Fix | Delete
'maximum_font_size' => $maximum_font_size_raw,
[671] Fix | Delete
'scale_factor' => $default_scale_factor,
[672] Fix | Delete
)
[673] Fix | Delete
);
[674] Fix | Delete
[675] Fix | Delete
if ( ! empty( $fluid_font_size_value ) ) {
[676] Fix | Delete
return $fluid_font_size_value;
[677] Fix | Delete
}
[678] Fix | Delete
[679] Fix | Delete
return $preset['size'];
[680] Fix | Delete
}
[681] Fix | Delete
[682] Fix | Delete
// Register the block support.
[683] Fix | Delete
WP_Block_Supports::get_instance()->register(
[684] Fix | Delete
'typography',
[685] Fix | Delete
array(
[686] Fix | Delete
'register_attribute' => 'wp_register_typography_support',
[687] Fix | Delete
'apply' => 'wp_apply_typography_support',
[688] Fix | Delete
)
[689] Fix | Delete
);
[690] Fix | Delete
[691] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function