function display_cover() { $user_id = bp_displayed_user_id(); $cover_url = get_user_meta($user_id, 'cover', true); $position_x = intval(get_user_meta($user_id, 'position_x', true)); $position_y = intval(get_user_meta($user_id, 'position_y', true)); $repeat = get_user_meta($user_id, 'repeat', true); if (!isset($position_x)) { $position_x = '50'; } if (!isset($position_y)) { $position_y = '50'; } if (empty($repeat)) { $repeat = 'no-repeat'; } $default = BP_Profile_Cover_Settings::init()->get(); if (empty($cover_url)) { if (empty($default) || empty($default['default_image'])) { $cover_url = apply_filters('bp_profile_cover_default', plugin_dir_url(__FILE__) . 'default_cover.jpeg'); } else { $attachment = wp_get_attachment_image_src($default['default_image'], 'full'); if (empty($attachment) || empty($attachment[0])) { $cover_url = apply_filters('bp_profile_cover_default', plugin_dir_url(__FILE__) . 'default_cover.jpeg'); } else { $cover_url = $attachment[0]; } } } echo '<style>.bp-user #buddypress #item-header{ padding:20px; background:url("' . $cover_url . '") ' . $position_x . '% ' . $position_y . '% ' . $repeat . ' ' . (empty($default['background_attachment']) ? 'fixed' : $default['background_attachment']) . ' !important; -webkit-background-size: ' . (empty($default['background_size']) ? 'cover' : $default['background_size']) . ' !important; background-size: ' . (empty($default['background_size']) ? 'cover' : $default['background_size']) . ' !important; }</style>'; }
function init_bp_profile_cover_settings_settings() { BP_Profile_Cover_Settings::init(); }