GRADEBOOK
ID )) {
// specify desired image size in place of 'full'
$page_bgimg = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
$page_bgimg_url = $page_bgimg[0]; // this returns just the URL of the image
}
}
// get background image for a category
if ( is_archive() && $options['bgimg_category'] && function_exists('category_image_src') ) {
if ( category_image_src() != '' ) {
$page_bgimg_url = category_image_src();
}
}
}
// write out css
echo '
';
}
add_action('wp_head' , 'custom_background_image' , 9999);
// add theme support for custom-background
function add_cb_support(){
if ( !current_theme_supports( 'custom-background' ) ) {
add_theme_support( 'custom-background' );
}
}
add_action( 'after_setup_theme', 'add_cb_support' );
// Settings
function bgimg_add_admin_menu( ) {
add_submenu_page( 'themes.php', 'Background Images', 'Background Images', 'manage_options', 'background_images', 'background_images_options_page' );
}
function bgimg_settings_exist( ) {
if( false == get_option( 'background_images_settings' ) ) {
add_option( 'background_images_settings' );
}
}
function bgimg_settings_init( ) {
register_setting( 'pluginPage', 'bgimg_settings' );
add_settings_section(
'bgimg_pluginPage_section',
'',
'bgimg_settings_section_callback',
'pluginPage'
);
add_settings_field(
'bgimg_homepage',
__( 'Display background on home page only', 'bgimg' ),
'bgimg_homepage_render',
'pluginPage',
'bgimg_pluginPage_section'
);
add_settings_field(
'bgimg_fullscreen',
__( 'Make images fullscreen', 'bgimg' ),
'bgimg_fullscreen_render',
'pluginPage',
'bgimg_pluginPage_section'
);
add_settings_field(
'bgimg_single',
__( 'Use featured image on posts', 'bgimg' ),
'bgimg_single_render',
'pluginPage',
'bgimg_pluginPage_section'
);
add_settings_field(
'bgimg_category',
__( 'Use featured image on categories (requires WPCustom Category Image plugin)' , 'bgimg' ),
'bgimg_category_render',
'pluginPage',
'bgimg_pluginPage_section'
);
}
function bgimg_homepage_render( ) {
$options = get_option( 'bgimg_settings' );
?>
value='1'>
value='1'>
This theme does not support featured images. This setting has been disabled.';
echo ' ';
} else {
echo ' ';
}
}
function bgimg_category_render( ) {
$options = get_option( 'bgimg_settings' );
if ( !is_plugin_active('wpcustom-category-image/load.php') ) {
echo 'The WPCustom Category Images plugin is not active. This setting has been disabled.
';
echo ' ';
} else {
echo ' ';
}
}
function bgimg_settings_section_callback( ) {
echo __( 'Set your preferences for background images.
The global background image set in Background will be used on all pages unless overriden.', 'bgimg' );
}
function background_images_options_page( ) {
?>