Beispiel #1
0
 /**
  * For users upgrading Reach who are on WordPress 4.5, migrate core's Custom Logo.
  *
  * @return  void
  * @access  public
  * @since   1.0.3
  */
 public function maybe_convert_to_custom_logo()
 {
     /* Return if update has already been run */
     if (-1 != get_theme_mod('custom_logo', -1)) {
         return;
     }
     /* Make sure we're on WP 4.5 */
     if (!function_exists('the_custom_logo')) {
         return;
     }
     $custom_logo = false;
     $current_logo = reach_get_customizer_image_data('logo');
     if ($current_logo) {
         /* Bail early if we don't have a valid logo anyway. */
         if (!isset($current_logo['image'])) {
             set_theme_mod('custom_logo', $custom_logo);
             return;
         }
         /* Swap the retina image for the standard. */
         if (isset($current_logo['id'])) {
             $logo = intval($current_logo['id']);
         } else {
             $logo = attachment_url_to_postid($current_logo['image']);
         }
         if (is_int($logo)) {
             $custom_logo = $logo;
         }
         remove_theme_mod('logo');
     }
     set_theme_mod('custom_logo', $custom_logo);
 }
 /**
  * Prints a block of background image CSS for the given image.
  *
  * @param   string  $key
  * @param   string  $element
  * @param   string  $repeat
  * @return  string
  * @access  private
  * @since   1.0.0
  */
 private function get_background_image_css($key, $element, $repeat = 'repeat')
 {
     $image = reach_get_customizer_image_data($key);
     if (!$image) {
         return;
     }
     $output = sprintf('%s { background-image: url("%s"); background-repeat: %s; }', $element, esc_url($image['image']), esc_attr($repeat));
     if (isset($image['retina_image'])) {
         $output .= '@media only screen and (-Webkit-min-device-pixel-ratio: 1.5), only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (min-device-pixel-ratio: 1.5) {';
         $output .= sprintf('%s { background-image: url("%s"); background-size: %spx %spx; }', $element, esc_url($image['retina_image']), esc_attr($image['width']), esc_attr($image['height']));
         $output .= '}';
     }
     return $output;
 }