Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(!function_exists('nabia_custom_bg')) {
- function nabia_custom_bg() {
- global $post;
- if( is_singular(array('post', 'page')) && get_post_meta( $post->ID, 'nabia_cmb_post_bimg', true) ) {
- $background = get_post_meta( $post->ID, 'nabia_cmb_post_bimg', true);
- } else {
- $background = get_background_image();
- }
- if( is_singular(array('post', 'page')) && get_post_meta( $post->ID, 'nabia_cmb_post_bg_color', true) ) {
- $color = get_post_meta($post->ID, 'nabia_cmb_post_bg_color', true);
- } else {
- $color = get_background_color();
- }
- if ( ! $background && ! $color )
- return;
- if( is_singular(array('post', 'page')) && get_post_meta( $post->ID, 'nabia_cmb_post_bg_color', true) ) {
- $style = $color ? "background-color: $color;" : '';
- } else {
- $style = $color ? "background-color: #$color;" : '';
- }
- if ( $background ) {
- $image = " background-image: url($background);";
- if( is_singular(array('post', 'page')) && get_post_meta( $post->ID, 'nabia_cmb_post_bg_repeat', true) && get_post_meta( $post->ID, 'nabia_cmb_post_bimg', true) ) {
- $repeat = get_post_meta( $post->ID, 'nabia_cmb_post_bg_repeat', true);
- } else {
- $repeat = nabia_theme_mod( 'background_repeat' );
- }
- if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) )
- $repeat = 'repeat';
- $repeat = " background-repeat: $repeat;";
- if( is_singular(array('post', 'page')) && get_post_meta( $post->ID, 'nabia_cmb_post_bg_position', true) && get_post_meta( $post->ID, 'nabia_cmb_post_bimg', true) ) {
- $position = get_post_meta( $post->ID, 'nabia_cmb_post_bg_position', true);
- } else {
- $position = nabia_theme_mod( 'background_position_x' );
- }
- if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) )
- $position = 'left';
- $position = " background-position: top $position;";
- if( is_singular(array('post', 'page')) && get_post_meta( $post->ID, 'nabia_cmb_post_bg_attachament', true) && get_post_meta( $post->ID, 'nabia_cmb_post_bimg', true) ) {
- $attachment = get_post_meta( $post->ID, 'nabia_cmb_post_bg_attachament', true);
- } else {
- $attachment = nabia_theme_mod( 'background_attachment' );
- }
- if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) )
- $attachment = 'scroll';
- $attachment = " background-attachment: $attachment;";
- $style .= $image . $repeat . $position . $attachment;
- }
- ?>
- <style type="text/css">
- body.custom-background { <?php echo esc_attr( $style ); ?> }
- </style>
- <?php
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement