Skip to content

Commit

Permalink
Show networks when listing bots.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbohacek committed Mar 7, 2023
1 parent 12853a6 commit 5f3ecba
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
8 changes: 3 additions & 5 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,11 +769,9 @@ function get_site_info( $url ){
);
}

// if (!function_exists('get_network_name')){
// function get_network_name( $network_term_slug ){
// return get_term_by( 'slug', $network_term_slug, 'network' )->name;
// }
// }
function get_network_name( $network ){
return $network->name;
}

function bw_register_import_endpoint(/* $_REQUEST */) {
register_rest_route('bw', 'import-bots', array(
Expand Down
21 changes: 20 additions & 1 deletion loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,26 @@
<div class="card-footer">
<p class="text-muted mt-n2"><a href="<?php echo get_author_posts_url( $author_id, get_the_author_meta( 'user_nicename', $author_id ) ); ?>"><img width="22" height="22" loading="lazy" class="lazy-load u-photo rounded-circle mr-2" src="<?php echo $profile_img_url; ?>" data-src="<?php echo $profile_img_url; ?>" alt="$<?php echo $author_nickname; ?>"><?php echo $author_nickname; ?></a> | <span title="<?php echo $post_date; ?>"><?php echo $post_date_ago; ?></span></p>
<?php } ?>
</p>
<?php if ( $post_type === 'bot' ){

$networks = get_the_terms( $post_id, 'network' );
$network_names = [];

if ( $networks ){
$network_names = array_map( 'get_network_name', $networks );
}

$network_links = array();
if ( $networks ){
foreach ( $networks as $network ) {
$network_links[] = '<li class="list-inline-item"><span class="badge badge-secondary p-2 mb-2">' . $network->name . '</span></li>';
}
}
?>
</div>
<div class="card-footer">
<p class="text-muted mt-n2"><ul class="list-unstyled list-inline"><?php echo join( '', $network_links );?></ul></p>
<?php } ?>
</div>
</div>
</div>
Expand Down
4 changes: 0 additions & 4 deletions single.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@
<?php

$networks = get_the_terms( $post_id, 'network' );
function get_network_name( $network ){
return $network->name;
}

$network_names = [];

if ( $networks ){
Expand Down
4 changes: 0 additions & 4 deletions template-submit-your-bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
$dominant_color_css = str_replace( '[', 'background-color:rgb( ', $dominant_color );
$dominant_color_css = str_replace( ']', ' )', $dominant_color_css );

function get_network_name( $network_term_slug ){
return get_term_by( 'slug', $network_term_slug, 'network' )->name;
}

if ( !empty( $_POST ) ){
// error_log( print_r( $_POST, true ) );

Expand Down

0 comments on commit 5f3ecba

Please sign in to comment.