<commit_before><?php

function shoestrap_background_css( ) {
  $background_color = '#' . str_replace( '#', '', shoestrap_getVariable( 'color_body_bg' ) );
  // $background is the saved custom image, or the default image.
  if ( shoestrap_getVariable( 'background_image_toggle' ) == 1 ) {
    if ( shoestrap_getVariable( 'background_custom_image' ) != "" )
      $background = set_url_scheme( shoestrap_getVariable( 'background_custom_image' ) );
    else
      $background = set_url_scheme( shoestrap_getVariable( 'background_image' ) );

  } else if ( shoestrap_getVariable( 'background_pattern_toggle' ) == 1 && shoestrap_getVariable( 'background_pattern' ) != "" ) {
    $background = shoestrap_getVariable( 'background_pattern' );
  }
  // $color is the saved custom color.
  // A default has to be specified in style.css. It will not be printed here.
  $color = shoestrap_getVariable( 'color_body_bg' );

  if ( ! $background && ! $color )
    return;


  $style = $color ? "background-color: #$color;" : '';

  if ( shoestrap_getVariable( 'background_fixed_toggle' ) == 1 ) {
    $style .= "background-attachment: fixed;";
  }


  if ( $background ) {
    $image = " background-image: url( '$background' );";
    if ( shoestrap_getVariable( 'background_image_position_toggle' ) == 0 ) {
      if ( shoestrap_getVariable( 'background_fixed_toggle' ) == 0 )
        $style .= "background-position: 50% 0%;";
      else
        $style .= "background-position: 50% 50%; background-size: cover;";

      $style .= "background-repeat: no-repeat;";

    } else if ( shoestrap_getVariable( 'background_image_toggle' ) == 1 ) {

      $repeat = shoestrap_getVariable( 'background_repeat' );
      if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) )
        $repeat = 'repeat';

      $repeat = " background-repeat: $repeat;";

      $position = shoestrap_getVariable( 'background_position_x', 'left' );
      if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) )
        $position = 'left';

      $position = " background-position: top $position;";
    } else { // Pattern!

      $style .= "background-position: top left;";
    }
    $style .= $image . $repeat . $position;
  }
  echo '<style>body{' . trim( $style ) . ';}.wrap.main-section{background:' . $background_color . ';}</style>';
}
if ( shoestrap_getVariable( 'background_image_toggle' ) == 1 || shoestrap_getVariable( 'background_pattern_toggle' ) == 1 )
  add_action( 'wp_head', 'shoestrap_background_css' );<commit_msg>Final background and patterns fix. Complete redo.<commit_after><?php

function shoestrap_background_css( ) {
  // $background is the saved custom image, or the default image.
  if ( shoestrap_getVariable( 'background_image_toggle' ) == 1 ) {
    if ( shoestrap_getVariable( 'background_custom_image' ) != "" )
      $background = set_url_scheme( shoestrap_getVariable( 'background_custom_image' ) );
    else if ( shoestrap_getVariable( 'background_image' ) != "" )
      $background = set_url_scheme( shoestrap_getVariable( 'background_image' ) );
  } else if ( shoestrap_getVariable( 'background_pattern_toggle' ) == 1 && shoestrap_getVariable( 'background_pattern' ) != "" ) {
    $background = shoestrap_getVariable( 'background_pattern' );
  }

  if (shoestrap_getVariable( 'color_body_bg' ) != "") {
    $color = '#' . str_replace( '#', '', shoestrap_getVariable( 'color_body_bg' ) );
  }

  if ( ! $background && ! $color )
    return;

  $style = $color ? "background-color: $color;" : '';

  if ( shoestrap_getVariable( 'background_fixed_toggle' ) == 1 ) {
    $style .= "background-attachment: fixed;";
  }

  if ( $background ) {
    $image .= "background-image: url( '$background' );";
  }

  if ( shoestrap_getVariable( 'background_image_toggle' ) == 1 && ( shoestrap_getVariable( 'background_custom_image' ) != "" || shoestrap_getVariable( 'background_image' ) != "" ) ) {
    if ( shoestrap_getVariable( 'background_image_position_toggle' ) == 0 ) {
      if ( shoestrap_getVariable( 'background_fixed_toggle' ) == 1 ) {
        $style .= "background-position: 50% 50%;";
        $style .= "background-size: cover;";
      } else {
        $style .= "background-position: 50% 0%;";
        $style .= "background-size: contain;";
        $style .= "background-repeat: no-repeat;";
      }
    } else { // Not fixed position, custom
      $repeat = shoestrap_getVariable( 'background_repeat' );
      if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) ) {
        $repeat = 'repeat';
      }
      if ($repeat == "no-repeat") {
        $style .= "background-size: auto;";
      }
      $repeat = " background-repeat: $repeat;";
      $position = shoestrap_getVariable( 'background_position_x', 'left' );
      if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) ) {
        $position = 'left';
      }
      $position = " background-position: top $position;";
    }
  } 

  $style .= $image . $repeat . $position;
  
  echo '<style type="text/css" id="background">';
  echo 'body {' . trim( $style ) . '}';
  echo $color ? ".wrap.main-section{background: $color;}" : '';
  echo '</style>';
}
if ( shoestrap_getVariable( 'background_image_toggle' ) == 1 || shoestrap_getVariable( 'background_pattern_toggle' ) == 1 )
  add_action( 'wp_head', 'shoestrap_background_css' );
{'fraction_non_alphanumeric': 0.16451914098972922, 'fraction_numerical': 0.0056022408963585435, 'mean_word_length': 3.5974248927038626, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5987299', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1709, 'n_words': 356}