Make WordPress Core

Ticket #57506: 57506.functions2.patch

File 57506.functions2.patch, 2.2 KB (added by sabernhardt, 3 years ago)

another functions.php option that rearranges properties so the filter only adjusts the border width (on all sides)

  • src/wp-content/themes/twentytwentythree/functions.php

     
     1<?php
     2/**
     3 * Twenty Twenty-Three functions and definitions
     4 *
     5 * @link https://developer.wordpress.org/themes/basics/theme-functions/
     6 *
     7 * @package WordPress
     8 * @subpackage Twenty_Twenty_Three
     9 * @since Twenty Twenty-Three 1.2
     10 */
     11
     12
     13/**
     14 * Modifies the theme JSON data.
     15 *
     16 * @since Twenty Twenty-Three 1.2 Reverse Quote block border in right-to-left languages.
     17 *
     18 * @param object $theme_json The original theme JSON data.
     19 * @return object The modified theme JSON data.
     20 */
     21function twentytwentythree_modify_theme_json( $theme_json ) {
     22        if ( is_rtl() ) {
     23                $new_data = array(
     24                        'version' => 2,
     25                        'styles'  => array(
     26                                'blocks' => array(
     27                                        'core/quote' => array(
     28                                                'border' => array(
     29                                                        'width' => '0 1px 0 0'
     30                                                )
     31                                        )
     32                                )
     33                        )
     34                );
     35
     36                // Returns the modified theme JSON data.
     37                return $theme_json->update_with( $new_data );
     38        }
     39
     40        // Returns the original theme JSON data.
     41        return $theme_json;
     42}
     43
     44// Runs the filter after theme setup.
     45function twentytwentythree_apply_theme_json_theme_filters() {
     46        add_filter( 'wp_theme_json_data_theme', 'twentytwentythree_modify_theme_json' );
     47}
     48add_action( 'after_setup_theme', 'twentytwentythree_apply_theme_json_theme_filters' );
     49
  • src/wp-content/themes/twentytwentythree/theme.json

    Property changes on: src/wp-content/themes/twentytwentythree/functions.php
    ___________________________________________________________________
    Added: svn:eol-style
    ## -0,0 +1 ##
    +native
    \ No newline at end of property
     
    539539                        },
    540540                        "core/quote": {
    541541                                "border": {
    542                                         "width": "1px"
     542                                        "color": "currentColor",
     543                                        "style": "solid",
     544                                        "width": "0 0 0 1px"
    543545                                },
    544546                                "elements": {
    545547                                        "cite": {