-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
button and caption can inherit theme styles
- Loading branch information
prconcepcion
committed
Feb 12, 2024
1 parent
52f7bab
commit 608541a
Showing
8 changed files
with
107 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
// Exit if accessed directly. | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
var_dump(get_option( 'stackable_inherit_styles_from_theme' )); | ||
|
||
if ( get_option( 'stackable_inherit_styles_from_theme' ) === '1' ) { | ||
|
||
if ( ! function_exists( 'stackable_add_inherit_button_theme_class' ) ) { | ||
function stackable_add_inherit_button_theme_class( $block_content, $block ) { | ||
if ( ! class_exists( 'WP_HTML_Tag_Processor' ) ) { | ||
return $block_content; | ||
} | ||
|
||
$html_tag = new WP_HTML_Tag_Processor( $block_content ); | ||
|
||
while ( $html_tag->next_tag( 'a' ) ) { | ||
$img_classname = $html_tag->get_attribute( 'class' ); | ||
|
||
if ( strpos( $img_classname, 'stk-button') !== false ) { | ||
$html_tag->add_class( 'wp-element-button' ); | ||
} | ||
} | ||
|
||
return $html_tag->get_updated_html(); | ||
} | ||
|
||
} | ||
|
||
add_filter( 'render_block_stackable/button', 'stackable_add_inherit_button_theme_class', 1, 2 ); | ||
} | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
// Exit if accessed directly. | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
if ( get_option( 'stackable_inherit_styles_from_theme' ) === '1' ) { | ||
|
||
if ( ! function_exists( 'stackable_add_inherit_figcaption_theme_class' ) ) { | ||
function stackable_add_inherit_figcaption_theme_class( $block_content, $block ) { | ||
if ( ! class_exists( 'WP_HTML_Tag_Processor' ) ) { | ||
return $block_content; | ||
} | ||
|
||
$html_tag = new WP_HTML_Tag_Processor( $block_content ); | ||
|
||
while ( $html_tag->next_tag( 'figcaption' ) ) { | ||
$img_classname = $html_tag->get_attribute( 'class' ); | ||
|
||
if ( strpos( $img_classname, 'stk-img-figcaption') !== false ) { | ||
$html_tag->add_class( 'wp-element-caption' ); | ||
} | ||
} | ||
|
||
return $html_tag->get_updated_html(); | ||
} | ||
|
||
} | ||
|
||
add_filter( 'render_block_stackable/image', 'stackable_add_inherit_figcaption_theme_class', 1, 2 ); | ||
} |
This file contains 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
This file contains 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
This file contains 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