Last active
November 6, 2023 08:11
-
-
Save humayunahmed8/f90fdca4271e92983d058f0ab27a7e88 to your computer and use it in GitHub Desktop.
Allowed html tags and class in codestar metabox feild
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
<?php | |
function lcorp_section_pricing_metabox( $metaboxes ) { | |
$section_id = 0; | |
if ( isset( $_REQUEST['post'] ) || isset( $_REQUEST['post_ID'] ) ) { | |
$section_id = empty( $_REQUEST['post_ID'] ) ? $_REQUEST['post'] : $_REQUEST['post_ID']; | |
} | |
if ( 'section' != get_post_type( $section_id ) ) { | |
return $metaboxes; | |
} | |
$section_meta = get_post_meta( $section_id, 'lcorp-section-type', true ); | |
if ( ! $section_meta ) { | |
return $metaboxes; | |
} else if ( 'pricing' != $section_meta['section-type'] ) { | |
return $metaboxes; | |
} | |
$metaboxes[] = array( | |
'id' => 'lcorp-pricing-section', | |
'title' => __( 'Pricing Section Settings', 'lcorp' ), | |
'post_type' => 'section', | |
'context' => 'normal', | |
'priority' => 'default', | |
'sections' => array( | |
array( | |
'name' => 'lcorp-pricing', | |
'icon' => 'fa fa-image', | |
'fields' => array( | |
array( | |
'id' => 'section_heading', | |
'type' => 'text', | |
'title' => __( 'Section Heading', 'lcorp' ), | |
'default' => __( 'Pricing made', 'lcorp' ), | |
'sanitize'=> false, | |
), | |
) | |
) | |
) | |
); | |
return $metaboxes; | |
} | |
add_filter( 'cs_metabox_options', 'lcorp_section_pricing_metabox' ); |
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
<h2 class="display-3 mb-4"> | |
<?php | |
if (!empty($lcorp_section_meta['section_heading'])) { | |
$content = $lcorp_section_meta['section_heading']; | |
// Use a regular expression to add the class to the span tag | |
$content_with_class = preg_replace('/<span([^>]*)>/', '<span$1 class="text-underline-warning">', $content); | |
echo $content_with_class; | |
} | |
?> | |
</h2> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Metabox