CCDzine
1/1/2017 - 5:57 PM

Add a message about your WordPress theme's content width to the Media Settings admin page.

Add a message about your WordPress theme's content width to the Media Settings admin page.

<?php
// Add to theme functions.php file
function ccd_content_width() {
  
  // Set content width
	if ( ! isset( $content_width ) ) {
		$content_width = 1280;
	}
  
  // Content width message
	global $pagenow;

	if ( 'options-media.php' == $pagenow ) {
		$class   = 'notice notice-info';
		$theme   = wp_get_theme();
		$url     = admin_url( 'themes.php' );
		$message = __( 'The content width of the <a href="', 'my-theme' ) . $url . '">' . $theme->get( 'Name' ) . __( '</a> theme is ', 'my-theme' ) . $content_width . __( ' pixels.', 'my-theme' );

	printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
	
	}
}
add_action( 'admin_notices', 'ccd_content_width' );

?>

Content Width Notice in Media Settings

WordPress Snippet