rray containing * the css rules and the style handle. */ function bp_add_cover_image_inline_css( $return = false ) { $bp = buddypress(); // Find the component of the current item. if ( bp_is_user() ) { // User is not allowed to upload cover images // no need to carry on. if ( bp_disable_cover_image_uploads() ) { return; } $cover_image_object = array( 'component' => 'members', 'object' => $bp->displayed_user ); } elseif ( bp_is_group() ) { // Users are not allowed to upload cover images for their groups // no need to carry on. if ( bp_disable_group_cover_image_uploads() ) { return; } $cover_image_object = array( 'component' =>'groups', 'object' => $bp->groups->current_group ); } else { $cover_image_object = apply_filters( 'bp_current_cover_image_object_inline_css', array() ); } // Bail if no component were found. if ( empty( $cover_image_object['component'] ) || empty( $cover_image_object['object'] ) || ! bp_is_active( $cover_image_object['component'], 'cover_image' ) ) { return; } // Get the settings of the cover image feature for the current component. $params = bp_attachments_get_cover_image_settings( $cover_image_object['component'] ); // Bail if no params. if ( empty( $params ) ) { return; } // Try to call the callback. if ( is_callable( $params['callback'] ) ) { $object_dir = $cover_image_object['component']; if ( 'members' === $object_dir ) { $object_dir = 'members'; } $cover_image = bp_attachments_get_attachment( 'url', array( 'object_dir' => $object_dir, 'item_id' => $cover_image_object['object']->id, ) ); if ( empty( $cover_image ) ) { if ( ! empty( $params['default_cover'] ) ) { $cover_image = $params['default_cover']; } } $inline_css = call_user_func_array( $params['callback'], array( array( 'cover_image' => esc_url_raw( $cover_image ), 'component' => sanitize_key( $cover_image_object['component'] ), 'object_id' => (int) $cover_image_object['object']->id, 'width' => (int) $params['width'], 'height' => (int) $params['height'], ) ) ); // Finally add the inline css to the handle. if ( ! empty( $inline_css ) ) { // Used to get the css when Ajax setting the cover image. if ( true === $return ) { return array( 'css_rules' => '', 'handle' => $params['theme_handle'], ); } wp_add_inline_style( $params['theme_handle'], $inline_css ); } else { return false; } } } add_action( 'bp_enqueue_community_scripts', 'bp_add_cover_image_inline_css', 11 ); /** * Enqueues livestamp.js on BuddyPress pages. * * @since 2.7.0 */ function bp_core_add_livestamp() { if ( ! is_buddypress() ) { return; } bp_core_enqueue_livestamp(); } add_action( 'bp_enqueue_community_scripts', 'bp_core_add_livestamp' ); /** * Enqueue and localize livestamp.js script. * * @since 2.7.0 */ function bp_core_enqueue_livestamp() { // If bp-livestamp isn't enqueued, do it now. if ( wp_script_is( 'bp-livestamp' ) ) { return; } wp_add_inline_script( 'moment', sprintf( "moment.updateLocale( '%s', %s );", get_user_locale(), wp_json_encode( array( 'relativeTime' => array( /* Translators: %s is the relative time (eg: in a few seconds). */ 'future' => __( 'in %s', 'buddypress' ), /* translators: %s: the human time diff. */ 'past' => __( '%s ago', 'buddypress' ), 's' => __( 'a few seconds', 'buddypress' ), 'm' => __( 'a minute', 'buddypress' ), /* Translators: %d is the amount of minutes. */ 'mm' => __( '%d minutes', 'buddypress' ), 'h' => __( 'an hour', 'buddypress' ), /* Translators: %d is the amount of hours. */ 'hh' => __( '%d hours', 'buddypress' ), 'd' => __( 'a day', 'buddypress' ), /* Translators: %d is the amount of days. */ 'dd' => __( '%d days', 'buddypress' ), 'M' => __( 'a month', 'buddypress' ), /* Translators: %d is the amount of months. */ 'MM' => __( '%d months', 'buddypress' ), 'y' => __( 'a year', 'buddypress' ), /* Translators: %d is the amount of years. */ 'yy' => __( '%d years', 'buddypress' ), ), ) ) ) ); wp_enqueue_script( 'bp-livestamp' ); }