Created
March 27, 2019 15:34
-
-
Save KaineLabs/35ae10fd240256c525a8e3f4d20197cd to your computer and use it in GitHub Desktop.
Total Reviews Shortcode [yz_total_reviews user_id=""]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get User Reviews Count. | |
*/ | |
function yzc_get_total_reviews_shortcode( $args = null ) { | |
global $bp, $wpdb, $Yz_reviews_table; | |
// Get Shortcode Args. | |
$args = wp_parse_args( $args, array( | |
'user_id' => false, | |
) | |
); | |
// Get Global Request | |
$request = "SELECT COUNT(*) FROM {$Yz_reviews_table}"; | |
if ( ! empty( $args['user_id'] ) ) { | |
$request .= " WHERE reviewed = {$args['user_id']}"; | |
} | |
return $wpdb->get_var( $request ); | |
} | |
add_shortcode( 'yz_total_reviews', 'yzc_get_total_reviews_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment