Forked from humayunahmed8/1-logo-setting-metabox-option.php
Created
September 20, 2022 06:30
-
-
Save milapdave/a7f651ca1f03a618e013c1d77e8650db to your computer and use it in GitHub Desktop.
Logo setting option using codestar framwork
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 | |
function stock_humayunbd_page_metabox($options){ | |
$options = array(); // remove old options | |
// Logo Setting | |
$options[] = array( | |
'name' => 'stock_humayunbd_logo_settings', | |
'title' => esc_html__('Logo Settings','stock-humayunbd'), | |
'icon' => 'fa fa-heart', | |
'fields' => array( | |
array( | |
'id' => 'enable_image_logo', | |
'type' => 'switcher', | |
'title' => esc_html__('Enable image logo','stock-humayunbd'), | |
'default' => false, | |
), | |
array( | |
'id' => 'image_logo', | |
'type' => 'image', | |
'title' => esc_html__('Upload logo','stock-humayunbd'), | |
'dependency' => array( 'enable_image_logo', '==', 'true' ), | |
), | |
array( | |
'id' => 'image_logo_max_width', | |
'type' => 'text', | |
'default' => esc_attr('200','stock-humayunbd'), | |
'title' => esc_html__('Logo max width','stock-humayunbd'), | |
'desc' => esc_html__('Type logo max width as numeric value','stock-humayunbd'), | |
'dependency' => array( 'enable_image_logo', '==', 'true' ), | |
), | |
array( | |
'id' => 'text_logo', | |
'type' => 'text', | |
'title' => esc_html__('Logo text','stock-humayunbd'), | |
'default' => esc_html__('Stock','stock-humayunbd'), | |
'dependency' => array( 'enable_image_logo', '==', 'false' ), | |
), | |
) | |
); | |
return $options; | |
} | |
add_filter( 'cs_metabox_options', 'stock_humayunbd_page_metabox' ); |
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 | |
/** | |
* Query logo setting option from database | |
* | |
*/ | |
// Store framework data | |
$enable_image_logo = cs_get_option('enable_image_logo'); | |
$image_logo = cs_get_option('image_logo'); | |
$image_logo_max_width = cs_get_option('image_logo_max_width'); | |
$text_logo = cs_get_option('text_logo'); | |
?> | |
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"> | |
<?php if($enable_image_logo == true && !empty($image_logo)) : | |
$image_logo_src = wp_get_attachment_image_src( $image_logo, 'large', false ); | |
?> | |
<img style="max-width:<?php echo esc_attr($image_logo_max_width); ?>px" src="<?php echo esc_url($image_logo_src[0]); ?>" alt="<?php echo esc_html(bloginfo( 'name' )); ?>"> | |
<?php else : ?> | |
<?php if(!empty($text_logo)) {echo esc_html($text_logo);} else{ echo esc_html(bloginfo( 'name' ));} ?> | |
<?php endif; ?> | |
</a> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment