Last active
September 8, 2024 14:53
-
-
Save adam-laita/01c088b986dac578ec0839d52bdbb8a5 to your computer and use it in GitHub Desktop.
Adds support for Czech typography plugins for Bricks builder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Bricks Typography | |
* Description: Adds support for Czech typography plugins for Bricks builder. | |
* Plugin URI: https://gist.github.com/adam-laita/01c088b986dac578ec0839d52bdbb8a5 | |
* Author: Adam Laita | |
* Author URI: https://www.laita.cz | |
* License: GNU General Public License v3 or later | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
// Exit if accessed directly. | |
if ( !defined( 'ABSPATH' ) ) exit; | |
$bt_theme = wp_get_theme(); | |
if ( $bt_theme->name == 'Bricks' || $bt_theme->parent_theme == 'Bricks' ) { | |
// Filters Bricks text elements and applies plugins filters/functions. | |
add_filter( 'bricks/element/settings', function ( $settings, $element ) { | |
if ( $element->name === 'text-basic' || $element->name === 'text' || $element->name === 'post-title' || | |
$element->name === 'heading' || $element->name === "button" || $element->name === "text-link" ) { | |
$settings = replace_czech_hard_spaces( $settings, "text" ); | |
} | |
if ( $element->name === 'counter' ) { | |
$settings = replace_czech_hard_spaces( $settings, "prefix" ); | |
$settings = replace_czech_hard_spaces( $settings, "suffix" ); | |
} | |
if ( $element->name === "list" ) { | |
foreach ( $settings['items'] as &$item ) { | |
$item = replace_czech_hard_spaces( $item, "title" ); | |
$item = replace_czech_hard_spaces( $item, "meta" ); | |
$item = replace_czech_hard_spaces( $item, "description" ); | |
} | |
unset( $item ); | |
} | |
if ( $element->name === "accordion" ) { | |
foreach ( $settings['accordions'] as &$item ) { | |
$item = replace_czech_hard_spaces( $item, "title" ); | |
$item = replace_czech_hard_spaces( $item, "subtitle" ); | |
$item = replace_czech_hard_spaces( $item, "content" ); | |
} | |
unset($item); | |
} | |
if ( $element->name === "tabs" ) { | |
foreach ( $settings['tabs'] as &$item ) { | |
$item = replace_czech_hard_spaces( $item, "title" ); | |
$item = replace_czech_hard_spaces( $item, "content" ); | |
} | |
unset( $item ); | |
} | |
if ( $element->name === "progress-bar" ) { | |
foreach ( $settings['bars'] as &$item ) { | |
$item = replace_czech_hard_spaces( $item, "title" ); | |
} | |
unset( $item ); | |
} | |
if ( $element->name === "icon-box" ) { | |
$settings = replace_czech_hard_spaces( $settings, "content" ); | |
} | |
return $settings; | |
}, 10, 2 ); | |
} | |
function replace_czech_hard_spaces( $settings, $element_name ) { | |
// https://wordpress.org/plugins/cestina-zalomeni-radku/ plugin application | |
if ( class_exists( 'Bozimediazalomeni_Public' ) && isset( $settings[$element_name] ) ) { | |
$settings[$element_name] = Bozimediazalomeni_Public::add_hard_spaces( $settings[$element_name] ); | |
} | |
// https://wordpress.org/plugins/zalomeni/ plugin application | |
if ( class_exists( 'Zalomeni' ) && isset( $settings[$element_name] ) ) { | |
$settings[$element_name] = Zalomeni::texturize( $settings[$element_name] ); | |
} | |
return $settings; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment