Current File : /home/bravrvjk/cepurhuye.rw/wp-content/plugins/bopea-function/inc/bbpress/templates//parts.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'jelly_bbp_render_private' ) ) {
function jelly_bbp_render_private( $output, $id ) {
if ( ! get_option( 'jelly_bbp_private' ) ) {
return $output;
}
$private_html = get_post_meta( $id, 'jelly_bbp_private_content', true );
if ( empty( $private_html ) ) {
return $output;
}
$content = '<div class="bbp-private-section">';
if ( ! current_user_can( 'moderate' ) && ! current_user_can( 'edit_reply', $id ) ) {
$content .= '<div class="content-blocked"><i class="jli-link" aria-hidden="true"></i><span>' . esc_html__( 'Private content area', 'jelly-bbp' ) . '</span></div>';
} else {
$content .= '<div class="content-unlocked">';
$content .= '<span class="h4"><i class="jli-link" aria-hidden="true"></i>' . esc_html__( 'Private content', 'jelly-bbp' ) . '</span>';
$content .= '<div class="private-content">' . $private_html . '</div>';
$content .= '</div>';
}
$content .= '</div>';
$output .= $content;
return $output;
}
}
if ( ! function_exists( 'jelly_bbp_sidebar' ) ) {
function jelly_bbp_sidebar( $name = '' ) {
if ( is_active_sidebar( $name ) ) : ?>
<div class="sidebar-wrap jelly-bbp-sidebar">
<div class="sidebar-inner clearfix"><?php dynamic_sidebar( $name ); ?></div>
</div>
<?php endif;
}
}
if ( ! function_exists( 'jelly_bbp_toggle_topic' ) ) {
function jelly_bbp_toggle_topic() {
if ( ! bbp_current_user_can_access_create_topic_form() ) {
return false;
}
$classes = 'bbp-toggle-topic';
if ( bbp_has_errors() ) {
$classes .= ' is-topic-error';
}
?>
<div class="<?php echo esc_attr( $classes ); ?>">
<div class="bbp-toggle-intro">
<?php if ( get_option( 'jelly_bbp_topic_image' ) ) : ?>
<img src="<?php echo esc_url( get_option( 'jelly_bbp_topic_image' ) ); ?>" alt="<?php esc_attr_e( 'create new topic', 'jelly-bbp' ); ?>" class="bbp-toggle-intro-image">
<?php endif; ?>
<div class="bbp-toggle-intro-content">
<?php if ( get_option( 'jelly_bbp_topic_title' ) ) : ?>
<span class="h2 bbp-toggle-intro-title"><?php echo esc_html( get_option( 'jelly_bbp_topic_title' ) ); ?></span>
<?php endif; ?>
<?php if ( get_option( 'jelly_bbp_topic_description' ) ) : ?>
<span class="bbp-toggle-intro-desc"><?php echo esc_html( get_option( 'jelly_bbp_topic_description' ) ); ?></span>
<?php endif; ?>
</div>
<a id="bbp-new-topic-toggle-btn" class="is-btn" href="#"><?php echo get_option( 'jelly_bbp_topic_button', 'Add a New Topic' ); ?></a>
</div>
<div id="bbp-new-topic-toggle" class="bbp-new-topic-form">
<?php bbp_get_template_part( 'form', 'topic' ); ?>
</div>
</div>
<?php
}
}
if ( ! function_exists( 'jelly_bbp_topic_status' ) ) {
function jelly_bbp_topic_status() {
$status = bbp_get_topic_status();
$frontend_status = get_post_meta( get_the_ID(), 'jelly_topic_status', true );
$status_data = jelly_bbp_status_config();
$class_name = 'meta-status meta-status-' . trim( $status );
$label = '';
switch ( $status ) {
case 'closed' :
$label = esc_html__( 'Closed', 'jelly-bbp' );
break;
case 'publish' :
$label = esc_html__( 'Open', 'jelly-bbp' );
break;
}
if ( ! empty( $frontend_status ) ) {
$class_name .= ' bbp-status-' . trim( $frontend_status );
if ( ! empty( $status_data[ $frontend_status ] ) ) {
$label = $status_data[ $frontend_status ];
}
}
echo '<span class="' . $class_name . '">' . $label . '</span>';
}
}
if ( ! function_exists( 'jelly_bbp_render_extra_fields' ) ) {
function jelly_bbp_render_extra_fields( $output, $id ) {
if ( 'topic' !== get_post_type( $id ) ) {
return $output;
}
$buffer = '';
$data = [
get_option( 'jelly_bbp_topic_custom_field_1', [] ),
get_option( 'jelly_bbp_topic_custom_field_2', [] ),
];
foreach ( $data as $index => $field ) :
$index ++;
if ( empty( $field['title'] ) ) {
continue;
}
$str = get_post_meta( $id, 'jelly_bbp_topic_custom_field_' . $index, true );
if ( empty( $str ) ) {
continue;
}
$buffer .= '<div class="bbp-extra-meta">';
$buffer .= '<div class="extra-meta-title">' . esc_html( $field['title'] ) . '</div>';
if ( ! empty( $field['private'] ) ) {
if ( ! current_user_can( 'moderate' ) && ! current_user_can( 'edit_reply', $id ) ) {
$buffer .= '<span class="extra-meta-content"><i class="jli-link" aria-hidden="true"></i>' . esc_html__( 'hidden', 'jelly-bbp' ) . '</span>';
} else {
$buffer .= '<span class="extra-meta-content">' . esc_html( $str ) . '</span>';
}
} else {
$buffer .= '<span class="extra-meta-content">' . esc_html( $str ) . '</span>';
}
$buffer .= '</div>';
endforeach;
if ( ! empty( $buffer ) ) {
$output .= '<div class="bbp-extra-meta-wrap">' . $buffer . '</div>';
}
return $output;
}
}
if ( ! function_exists( 'jelly_bbp_get_author_link' ) ) {
function jelly_bbp_get_author_link( $args = array() ) {
$post_id = is_numeric( $args ) ? (int) $args : 0;
$r = bbp_parse_args( $args, array(
'post_id' => $post_id,
'link_title' => '',
'type' => 'both',
'size' => 80,
'sep' => ''
), 'get_author_link' );
if ( bbp_is_topic( $r['post_id'] ) ) {
return jelly_bbp_get_topic_author_link( $r );
} elseif ( bbp_is_reply( $r['post_id'] ) ) {
return jelly_bbp_get_reply_author_link( $r );
}
$author_link = '';
if ( ! empty( $r['post_id'] ) ) {
$user_id = get_post_field( 'post_author', $r['post_id'] );
$author_url = bbp_get_user_profile_url( $user_id );
$anonymous = bbp_is_reply_anonymous( $r['post_id'] );
if ( empty( $r['link_title'] ) ) {
$author = get_the_author_meta( 'display_name', $user_id );
$title = empty( $anonymous )
? esc_attr__( "View %s's profile", 'jelly-bbp' )
: esc_attr__( "Visit %s's website", 'jelly-bbp' );
$r['link_title'] = sprintf( $title, $author );
}
$author_links = array();
$link_title = ! empty( $r['link_title'] )
? ' title="' . esc_attr( $r['link_title'] ) . '"'
: '';
if ( ( 'avatar' === $r['type'] ) || ( 'both' === $r['type'] ) ) {
$author_links['avatar'] = jelly_bbp_get_avatar( $user_id, $r['size'] );
}
if ( ( 'name' === $r['type'] ) || ( 'both' === $r['type'] ) ) {
$author_links['name'] = esc_html( get_the_author_meta( 'display_name', $user_id ) );
}
$links = array();
$sprint = '<span %1$s>%2$s</span>';
foreach ( $author_links as $link => $link_text ) {
$link_class = ' class="bbp-author-' . esc_attr( $link ) . '"';
$links[] = sprintf( $sprint, $link_class, $link_text );
}
$author_links = $links;
unset( $links );
$sections = apply_filters( 'bbp_get_author_links', $author_links, $r, $args );
$author_link = implode( $r['sep'], $sections );
if ( empty( $anonymous ) && bbp_user_has_profile( $user_id ) ) {
$author_link = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, ' class="bbp-author-link"', $author_link );
}
}
return apply_filters( 'bbp_get_author_link', $author_link, $r, $args );
}
}
if ( ! function_exists( 'jelly_bbp_get_topic_author_link' ) ) {
function jelly_bbp_get_topic_author_link( $args = array() ) {
$r = bbp_parse_args( $args, array(
'post_id' => 0,
'link_title' => '',
'type' => 'both',
'size' => 80,
'sep' => '',
'show_role' => false
), 'get_topic_author_link' );
$author_link = '';
$topic_id = is_numeric( $args )
? bbp_get_topic_id( $args )
: bbp_get_topic_id( $r['post_id'] );
if ( ! empty( $topic_id ) ) {
$author_url = bbp_get_topic_author_url( $topic_id );
$anonymous = bbp_is_topic_anonymous( $topic_id );
if ( empty( $r['link_title'] ) ) {
$author = bbp_get_topic_author_display_name( $topic_id );
$title = empty( $anonymous )
? esc_attr__( "View %s's profile", 'jelly-bbp' )
: esc_attr__( "Visit %s's website", 'jelly-bbp' );
$link_title = sprintf( $title, $author );
} else {
$link_title = $r['link_title'];
}
$author_links = array();
$link_title = ! empty( $link_title )
? ' title="' . esc_attr( $link_title ) . '"'
: '';
if ( ( 'avatar' === $r['type'] ) || ( 'both' === $r['type'] ) ) {
$author_links['avatar'] = jelly_bbp_get_topic_author_avatar( $topic_id, $r['size'] );
}
if ( ( 'name' === $r['type'] ) || ( 'both' === $r['type'] ) ) {
$author_links['name'] = esc_html( bbp_get_topic_author_display_name( $topic_id ) );
}
$links = array();
$sprint = '<span %1$s>%2$s</span>';
foreach ( $author_links as $link => $link_text ) {
$link_class = ' class="bbp-author-' . esc_attr( $link ) . '"';
$links[] = sprintf( $sprint, $link_class, $link_text );
}
$author_links = $links;
unset( $links );
$sections = apply_filters( 'bbp_get_topic_author_links', $author_links, $r, $args );
$author_link = implode( $r['sep'], $sections );
if ( empty( $anonymous ) && bbp_user_has_profile( bbp_get_topic_author_id( $topic_id ) ) ) {
$author_link = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, ' class="bbp-author-link"', $author_link );
}
if ( true === $r['show_role'] ) {
$author_link .= bbp_get_topic_author_role( array( 'topic_id' => $topic_id ) );
}
}
return apply_filters( 'bbp_get_topic_author_link', $author_link, $r, $args );
}
}
if ( ! function_exists( 'jelly_bbp_get_reply_author_link' ) ) {
function jelly_bbp_get_reply_author_link( $args = array() ) {
$r = bbp_parse_args( $args, array(
'post_id' => 0,
'link_title' => '',
'type' => 'both',
'size' => 80,
'sep' => '',
'show_role' => false
), 'get_reply_author_link' );
$author_link = '';
$reply_id = is_numeric( $args )
? bbp_get_reply_id( $args )
: bbp_get_reply_id( $r['post_id'] );
if ( ! empty( $reply_id ) ) {
$author_url = bbp_get_reply_author_url( $reply_id );
$anonymous = bbp_is_reply_anonymous( $reply_id );
if ( empty( $r['link_title'] ) ) {
$author = bbp_get_reply_author_display_name( $reply_id );
$title = empty( $anonymous )
? esc_attr__( "View %s's profile", 'jelly-bbp' )
: esc_attr__( "Visit %s's website", 'jelly-bbp' );
$link_title = sprintf( $title, $author );
} else {
$link_title = $r['link_title'];
}
$author_links = array();
$link_title = ! empty( $link_title )
? ' title="' . esc_attr( $link_title ) . '"'
: '';
if ( ( 'avatar' === $r['type'] ) || ( 'both' === $r['type'] ) ) {
$author_links['avatar'] = jelly_bbp_get_reply_author_avatar( $reply_id, $r['size'] );
}
if ( ( 'name' === $r['type'] ) || ( 'both' === $r['type'] ) ) {
$author_links['name'] = esc_html( bbp_get_reply_author_display_name( $reply_id ) );
}
$links = array();
$sprint = '<span %1$s>%2$s</span>';
foreach ( $author_links as $link => $link_text ) {
$link_class = ' class="bbp-author-' . esc_attr( $link ) . '"';
$links[] = sprintf( $sprint, $link_class, $link_text );
}
$author_links = $links;
unset( $links );
$sections = apply_filters( 'bbp_get_reply_author_links', $author_links, $r, $args );
$author_link = implode( $r['sep'], $sections );
if ( empty( $anonymous ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) {
$author_link = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, ' class="bbp-author-link"', $author_link );
}
if ( true === $r['show_role'] ) {
$author_link .= bbp_get_reply_author_role( array( 'reply_id' => $reply_id ) );
}
}
return apply_filters( 'bbp_get_reply_author_link', $author_link, $r, $args );
}
}
if ( ! function_exists( 'jelly_bbp_get_reply_author_avatar' ) ) {
function jelly_bbp_get_reply_author_avatar( $reply_id = 0, $size = 40 ) {
$reply_id = bbp_get_reply_id( $reply_id );
if ( empty( $reply_id ) ) {
return false;
}
if ( ! bbp_is_reply_anonymous( $reply_id ) ) {
$id_or_email = bbp_get_reply_author_id( $reply_id );
} else {
$id_or_email = get_post_meta( $reply_id, '_bbp_anonymous_email', true );
}
return jelly_bbp_get_avatar( $id_or_email, $size );
}
}
if ( ! function_exists( 'jelly_bbp_get_topic_author_avatar' ) ) {
function jelly_bbp_get_topic_author_avatar( $topic_id = 0, $size = 40 ) {
$topic_id = bbp_get_topic_id( $topic_id );
if ( empty( $topic_id ) ) {
return '';
}
if ( ! bbp_is_topic_anonymous( $topic_id ) ) {
$id_or_email = bbp_get_topic_author_id( $topic_id );
} else {
$id_or_email = get_post_meta( $topic_id, '_bbp_anonymous_email', true );
}
return jelly_bbp_get_avatar( $id_or_email, $size );
}
}
function jelly_bbp_get_avatar( $id_or_email, $size ) {
if ( ! get_option( 'jelly_bbp_avatar' ) ) {
return get_avatar( $id_or_email, $size );
}
if ( is_numeric( $id_or_email ) ) {
$user = get_user_by( 'id', absint( $id_or_email ) );
} else {
$user = get_user_by( 'email', absint( $id_or_email ) );
}
if ( empty( $user->ID ) ) {
return get_avatar( $id_or_email, $size );
}
$args = get_avatar_data( $id_or_email, [ 'default' => 404 ] );
$cache_ID = 'jelly_avatar_code_' . $user->ID;
$code = get_transient( $cache_ID );
if ( empty( $code ) ) {
$response = wp_remote_get( $args['url'] );
$code = wp_remote_retrieve_response_code( $response );
set_transient( $cache_ID, $code, 2592000 );
}
if ( '404' === (string) $code ) {
$letter = substr( trim( $user->display_name ), 0, 1 );
$output = '<div class="jelly-avatar jelly-letter-' . strtolower( $letter ) . '" data-letter="' . $letter . '">';
$output .= '<img class="avatar wp-user-avatar" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==">';
$output .= '</div>';
return $output;
}
return get_avatar( $id_or_email, $size );
}