PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.4.0
Forumax – AI Powered Advanced Community Forum Plugin v1.4.0
2.5.1 2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 All 31 releases
bbp-core / includes / features / bbp_voting / agree-disagree / init.php

init.php in Forumax – AI Powered Advanced Community Forum Plugin 1.4.0, at includes/features/bbp_voting/agree-disagree/init.php

78 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Add Agree/Disagree buttons counters
3 function bbpc_get_reply_count(){
4 ob_start();
5 bbp_topic_reply_count(get_the_ID());
6 return ob_get_clean();
7 }
8
9 // add a menu inside bbpress profile
10 add_action('bbp_template_after_user_details_menu_items', function() {
11 ?>
12 <ul>
13 <li class="bbp-user-votings-wrap">
14 <span>
15 <a href="<?php echo esc_url( bbp_user_profile_url() . '?bbpc-voting=true' ); ?>"
16 title="<?php
17
18 echo esc_attr(
19 sprintf( /* translators: %s: Display name of the user */
20 __( "%s's Votings", 'bbp-core' ),
21 bbp_get_displayed_user_field( 'display_name' )
22 )
23 );
24 ?>">
25 <?php esc_html_e( 'Reactions', 'bbp-core' ); ?>
26 </a>
27 </span>
28 </li>
29 </ul>
30 <?php
31 });
32
33 // Display the voting content
34 function bbpc_geo_voting_content(){
35 ob_start();
36 echo do_shortcode("[bbpc_geo_votings type='liked']") . do_shortcode("[bbpc_geo_votings type='disliked']");
37 return ob_get_clean();
38 }
39
40 // Display the voting content in profile content section
41 add_action( 'bbp_template_before_user_wrapper', function(){
42 $bbpc_voting = $_GET['bbpc-voting'] ?? '';
43 if ( $bbpc_voting == true ) {
44 if ( get_current_user_id() != bbp_get_displayed_user_field( 'ID' ) ) {
45 wp_enqueue_style( 'bbpc' );
46 ?>
47 <script>
48 ;(function($){
49 $(document).ready(function(){
50 $('#bbp-user-navigation ul li').removeClass('current');
51 $('.bbp-user-votings-wrap').addClass('current');
52 $('#bbp-user-body').html("<div class='bbpc-no-voting-wrap'> You must logged in to view your votes! </div>");
53 $('.bbpc-no-voting-wrap:not(:last-child)').remove();
54 });
55 })(jQuery);
56 </script>
57 <?php
58 } else {
59 $voting_content = bbpc_geo_voting_content();
60 $voting_content = wp_json_encode($voting_content);
61 wp_enqueue_style( 'bbpc' );
62 ?>
63 <script>
64 ;(function($){
65 $(document).ready(function(){
66 $('#bbp-user-navigation ul li').removeClass('current');
67 $('.bbp-user-votings-wrap').addClass('current');
68 $('#bbp-user-body').html(
69 <?php echo wp_json_encode( $voting_content ); ?>
70 );
71 $('.bbpc-no-voting-wrap:not(:last-child)').remove();
72 });
73 })(jQuery);
74 </script>
75 <?php
76 }
77 }
78 } );