public static function init() { if (is_null(self::$instance)) { self::$instance = new BP_Profile_Cover_Settings(); } return self::$instance; }
function bp_group_profile_cover() { global $bp; $group_id = $bp->groups->current_group->id; $cover_url = groups_get_groupmeta($group_id, 'cover'); $position_x = intval(groups_get_groupmeta($group_id, 'position_x')); $position_y = intval(groups_get_groupmeta($group_id, 'position_y')); $repeat = groups_get_groupmeta($group_id, 'repeat'); if (!isset($position_x)) { $position_x = '50'; } if (!isset($position_y)) { $position_y = '50'; } if (empty($repeat)) { $repeat = 'no-repeat'; } if (empty($cover_url)) { $default = BP_Profile_Cover_Settings::get(); 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> #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>'; }