wp/wp-admin/includes/class-custom-background.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    88 				'title'   => __( 'Overview' ),
    88 				'title'   => __( 'Overview' ),
    89 				'content' =>
    89 				'content' =>
    90 					'<p>' . __( 'You can customize the look of your site without touching any of your theme&#8217;s code by using a custom background. Your background can be an image or a color.' ) . '</p>' .
    90 					'<p>' . __( 'You can customize the look of your site without touching any of your theme&#8217;s code by using a custom background. Your background can be an image or a color.' ) . '</p>' .
    91 					'<p>' . __( 'To use a background image, simply upload it or choose an image that has already been uploaded to your Media Library by clicking the &#8220;Choose Image&#8221; button. You can display a single instance of your image, or tile it to fill the screen. You can have your background fixed in place, so your site content moves on top of it, or you can have it scroll with your site.' ) . '</p>' .
    91 					'<p>' . __( 'To use a background image, simply upload it or choose an image that has already been uploaded to your Media Library by clicking the &#8220;Choose Image&#8221; button. You can display a single instance of your image, or tile it to fill the screen. You can have your background fixed in place, so your site content moves on top of it, or you can have it scroll with your site.' ) . '</p>' .
    92 					'<p>' . __( 'You can also choose a background color by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. &#8220;#ff0000&#8221; for red, or by choosing a color using the color picker.' ) . '</p>' .
    92 					'<p>' . __( 'You can also choose a background color by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. &#8220;#ff0000&#8221; for red, or by choosing a color using the color picker.' ) . '</p>' .
    93 					'<p>' . __( 'Don&#8217;t forget to click on the Save Changes button when you are finished.' ) . '</p>',
    93 					'<p>' . __( 'Do not forget to click on the Save Changes button when you are finished.' ) . '</p>',
    94 			)
    94 			)
    95 		);
    95 		);
    96 
    96 
    97 		get_current_screen()->set_help_sidebar(
    97 		get_current_screen()->set_help_sidebar(
    98 			'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    98 			'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   508 		$url      = $file['url'];
   508 		$url      = $file['url'];
   509 		$type     = $file['type'];
   509 		$type     = $file['type'];
   510 		$file     = $file['file'];
   510 		$file     = $file['file'];
   511 		$filename = wp_basename( $file );
   511 		$filename = wp_basename( $file );
   512 
   512 
   513 		// Construct the object array.
   513 		// Construct the attachment array.
   514 		$object = array(
   514 		$attachment = array(
   515 			'post_title'     => $filename,
   515 			'post_title'     => $filename,
   516 			'post_content'   => $url,
   516 			'post_content'   => $url,
   517 			'post_mime_type' => $type,
   517 			'post_mime_type' => $type,
   518 			'guid'           => $url,
   518 			'guid'           => $url,
   519 			'context'        => 'custom-background',
   519 			'context'        => 'custom-background',
   520 		);
   520 		);
   521 
   521 
   522 		// Save the data.
   522 		// Save the data.
   523 		$id = wp_insert_attachment( $object, $file );
   523 		$id = wp_insert_attachment( $attachment, $file );
   524 
   524 
   525 		// Add the metadata.
   525 		// Add the metadata.
   526 		wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
   526 		wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
   527 		update_post_meta( $id, '_wp_attachment_is_custom_background', get_option( 'stylesheet' ) );
   527 		update_post_meta( $id, '_wp_attachment_is_custom_background', get_option( 'stylesheet' ) );
   528 
   528