| @@ -13,11 +13,11 @@ | ||
| 13 | 13 | * which will be applied to the navigation markup in the front-end. |
| 14 | 14 | * |
| 15 | 15 | * @since 5.9.0 |
| 16 | 16 | * |
| 17 | - * @param array $context Navigation block context. | |
| 18 | - * @param array $attributes Block attributes. | |
| 19 | - * @param bool $is_sub_menu Whether the link is part of a sub-menu. Default false. | |
| 17 | + * @param array $context Navigation block context. | |
| 18 | + * @param array $attributes Block attributes. | |
| 19 | + * @param bool $is_sub_menu Whether the link is part of a sub-menu. Default false. | |
| 20 | 20 | * @return array Colors CSS classes and inline styles. |
| 21 | 21 | */ |
| 22 | 22 | function gutenberg_block_core_navigation_link_build_css_colors( $context, $attributes, $is_sub_menu = false ) { |
| 23 | 23 | $colors = array( |
| @@ -80,8 +80,68 @@ | ||
| 80 | 80 | return $colors; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | + * Build an array with CSS classes and inline styles defining the font sizes | |
| 85 | + * which will be applied to the navigation markup in the front-end. | |
| 86 | + * | |
| 87 | + * This function is no longer used internally and is kept only for backward | |
| 88 | + * compatibility with third-party code that may call it directly. | |
| 89 | + * | |
| 90 | + * @since 5.9.0 | |
| 91 | + * @deprecated 7.0.0 | |
| 92 | + * | |
| 93 | + * @param array $context Navigation block context. | |
| 94 | + * @return array Font size CSS classes and inline styles. | |
| 95 | + */ | |
| 96 | +function gutenberg_block_core_navigation_link_build_css_font_sizes( $context ) { | |
| 97 | + _deprecated_function( __FUNCTION__, '7.0.0' ); | |
| 98 | + | |
| 99 | + // CSS classes. | |
| 100 | + $font_sizes = array( | |
| 101 | + 'css_classes' => array(), | |
| 102 | + 'inline_styles' => '', | |
| 103 | + ); | |
| 104 | + | |
| 105 | + $has_named_font_size = array_key_exists( 'fontSize', $context ); | |
| 106 | + $has_custom_font_size = isset( $context['style']['typography']['fontSize'] ); | |
| 107 | + | |
| 108 | + if ( $has_named_font_size ) { | |
| 109 | + // Add the font size class. | |
| 110 | + $font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] ); | |
| 111 | + } elseif ( $has_custom_font_size ) { | |
| 112 | + // Add the custom font size inline style. | |
| 113 | + $font_sizes['inline_styles'] = sprintf( | |
| 114 | + 'font-size: %s;', | |
| 115 | + gutenberg_get_typography_font_size_value( | |
| 116 | + array( | |
| 117 | + 'size' => $context['style']['typography']['fontSize'], | |
| 118 | + ) | |
| 119 | + ) | |
| 120 | + ); | |
| 121 | + } | |
| 122 | + | |
| 123 | + return $font_sizes; | |
| 124 | +} | |
| 125 | + | |
| 126 | +/** | |
| 127 | + * Returns the top-level submenu SVG chevron icon. | |
| 128 | + * | |
| 129 | + * @since 5.9.0 | |
| 130 | + * @deprecated 7.0.0 Use block_core_shared_navigation_render_submenu_icon() instead. | |
| 131 | + * | |
| 132 | + * @return string | |
| 133 | + */ | |
| 134 | +function gutenberg_block_core_navigation_link_render_submenu_icon() { | |
| 135 | + _deprecated_function( | |
| 136 | + __FUNCTION__, | |
| 137 | + '7.0.0', | |
| 138 | + 'block_core_shared_navigation_render_submenu_icon()' | |
| 139 | + ); | |
| 140 | + return block_core_shared_navigation_render_submenu_icon(); | |
| 141 | +} | |
| 142 | + | |
| 143 | +/** | |
| 84 | 144 | * Decodes a url if it's encoded, returning the same url if not. |
| 85 | 145 | * |
| 86 | 146 | * @since 6.2.0 |
| 87 | 147 | * |
| @@ -89,8 +149,12 @@ | ||
| 89 | 149 | * |
| 90 | 150 | * @return string $url Returns the decoded url. |
| 91 | 151 | */ |
| 92 | 152 | function gutenberg_block_core_navigation_link_maybe_urldecode( $url ) { |
| 153 | + if ( ! is_string( $url ) ) { | |
| 154 | + return ''; | |
| 155 | + } | |
| 156 | + | |
| 93 | 157 | $is_url_encoded = false; |
| 94 | 158 | $query = parse_url( $url, PHP_URL_QUERY ); |
| 95 | 159 | $query_params = wp_parse_args( $query ); |
| 96 | 160 | |
| @@ -126,12 +190,15 @@ | ||
| 126 | 190 | */ |
| 127 | 191 | function gutenberg_render_block_core_navigation_link( $attributes, $content, $block ) { |
| 128 | 192 | // Check if this navigation item should render based on post status. |
| 129 | 193 | if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) { |
| 130 | - if ( ! gutenberg_block_core_shared_navigation_item_should_render( $attributes, $block ) ) { | |
| 131 | - return ''; | |
| 132 | - } | |
| 194 | + $should_render = gutenberg_block_core_shared_navigation_item_should_render( $attributes, $block ); | |
| 195 | + } else { | |
| 196 | + $should_render = block_core_shared_navigation_item_should_render( $attributes, $block ); | |
| 133 | 197 | } |
| 198 | + if ( ! $should_render ) { | |
| 199 | + return ''; | |
| 200 | + } | |
| 134 | 201 | |
| 135 | 202 | // Don't render the block's subtree if it has no label. |
| 136 | 203 | if ( empty( $attributes['label'] ) ) { |
| 137 | 204 | return ''; |
| @@ -240,9 +307,9 @@ | ||
| 240 | 307 | * |
| 241 | 308 | * @since 5.9.0 |
| 242 | 309 | * |
| 243 | 310 | * @param WP_Taxonomy|WP_Post_Type $entity post type or taxonomy entity. |
| 244 | - * @param string $kind string of value 'taxonomy' or 'post-type'. | |
| 311 | + * @param string $kind string of value 'taxonomy' or 'post-type'. | |
| 245 | 312 | * |
| 246 | 313 | * @return array |
| 247 | 314 | */ |
| 248 | 315 | function gutenberg_build_variation_for_navigation_link( $entity, $kind ) { |