Skip to content

Commit

Permalink
Add in album add the time and count and genre
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerl92 committed Sep 12, 2024
1 parent 3ad0da4 commit 7647f4a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

McPlayer is a full-width HTML5/CSS/PHP/JS/AJAX audio Player with Playlist, Plugin for WordPress.</br>

<img style="max-width: 100%;" src="https://i.ibb.co/Jvf7gDN/mcplayer486486.png" alt="MCPlayer" />
<img style="max-width: 100%;" src="https://i.ibb.co/rZ0tpCh/mcplayer4846157.png" alt="MCPlayer" />

## Description
With McPlayer you can get your music from all around the world, from public Wi-Fi or your cellular network.</br>
Expand Down
54 changes: 52 additions & 2 deletions includes/McPlayer-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,13 +604,63 @@ function save_unsave_for_later_album($post) {
}
}


if ( ! empty( $matches ) ) {
$argv = array(
'posts_per_page' => -1,
'post_type' => 'music',
'post__in' => $matches,
'order' => 'DESC',
'orderby' => 'post__in',
);
} else {
$argv = null;
}

$posts = get_posts($argv);

$i = 0;
foreach($posts as $post){
$songs_length_calc_[$i++] = seconds_from_time(get_post_meta($post->ID, 'meta-box-track-length', true));
}

$x = 0;
foreach($posts as $the_query_post){
foreach ( get_the_terms( $the_query_post->ID, 'genre' ) as $tax ) {
$taxname[$x] = $tax->name;
$taxid[$x] = $tax->term_id;
$x++;
}
}

$taxname_count = array_count_values($taxname);
$taxid_count = array_count_values($taxid);

arsort($taxname_count);
arsort($taxid_count);

if ( ! empty( $matches ) ) {
for ($x = 0; $x <= 12; $x++) {
$value = get_term_link( key($taxid_count), 'genre' );
if(!is_wp_error( $value )){
$arraykey .= '<a href="'.get_term_link( intval(key($taxid_count)), 'genre' ).'">'.key($taxname_count).'</a>'.' ';
next($taxname_count);
next($taxid_count);
}
}
} else {
$arraykey = '<li style="text-align: center; padding:15px 0; list-style-type:none;">Nothing in the playlist</li>';
}

$return = array(
'status' => user_if_login(),
'update' => $saved_album,
'postid' => $html,
'postid_album' => $object_id,
'count' => esc_attr( $count ),
'count_album' => esc_attr( $count_album ),
'count' => $count,
'count_album' => $count_album,
'length' => time_from_seconds(array_sum($songs_length_calc_)),
'genres' => $arraykey
);

return wp_send_json ( $return );
Expand Down
6 changes: 6 additions & 0 deletions includes/js/rs-save-for-later-album-public.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ function rs_save_for_later_album($) {
$(this).removeClass('saved');
}
});
$('.genre_widget').html(data.genres);
$('.playlist_matches_count').html(data.count);
$('.playlist_matches_length').html(data.length);
$this.attr('data-title', 'Add to Playlist');
$this.attr('data-original-title', 'Add to Playlist');
ajax_playlist_remove_album($, data);
Expand All @@ -40,6 +43,9 @@ function rs_save_for_later_album($) {
$(this).addClass("saved");
}
});
$('.genre_widget').html(data.genres);
$('.playlist_matches_count').html(data.count);
$('.playlist_matches_length').html(data.length);
$this.attr('data-title', 'Remove');
$this.attr('data-original-title', 'Remove');
ajax_playlist_add_album($, data);
Expand Down

0 comments on commit 7647f4a

Please sign in to comment.