_x( 'Type de badge', 'taxonomy general name' ), 'singular_name' => _x( 'Type de badge', 'taxonomy singular name' ), 'search_items' => __( 'Chercher un type de badge' ), 'all_items' => __( 'Tous les types de badge' ), 'parent_item' => __( 'Parent' ), 'parent_item_colon' => __( 'Parent :' ), 'edit_item' => __( 'Modifier le type de badge' ), 'update_item' => __( 'Sauvegarder le type de badge' ), 'add_new_item' => __( 'Ajouter un nouveau type de badge' ), 'new_item_name' => __( 'Nom du nouveau type' ), 'menu_name' => __( 'Type de badge' ), ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'badge-type' ), ); register_taxonomy( 'badge_type', array( 'mycred_badge' ), $args ); } /** * Count all Registered Users. */ function count_all_my_users() { global $wpdb; $user_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users" ); echo "{$user_count}"; } /** * Check if user has earned the Badge. */ function check_badge_status() { // check if page visitor is logged_in or not if ( is_user_logged_in() ) { $user_id = get_current_user_id(); // get user_id of logged in visitor $id = get_the_ID(); // get post_id $value = get_metadata( 'user', $user_id, 'mycred_badge'.$id, true ); // check if the field has a value if( ! empty( $value ) ) { echo '
'; // earned add this } else { echo '
'; // not earned add this } } else { echo '
'; // if visitor ins't logged_in add this } } /** * List all Badges based on their badge_type. */ function get_list_types_badges( $type ) { global $post; $args = array( 'order' => 'ASC', // ascending order, 1,2,3 (oldest post first) 'post_type' => 'mycred_badge', // search in the post type "mycred_badge" 'badge_type' => $type, // only list the badges assigned to the badge type entered 'post_status' => 'publish' // only list those who are publish, no drafts ); $myposts = get_posts( $args ); echo '
    '; foreach ( $myposts as $post ) : setup_postdata( $post ); echo '
  • '; echo check_badge_status(); $img_url = get_post_meta( get_the_ID(), 'main_image', true ); echo '

    '.get_the_title().'

    '; // check if the custom field has a value if( ! empty( $img_url ) ) { echo ''.get_the_title().''; } echo '
'; echo '(' .mycred_count_users_with_badge( get_the_ID() ); echo '/'; echo count_all_my_users(). ' MKXFans)'; echo ''; endforeach; echo ''; wp_reset_postdata(); } /** * myCRED Shortcode: mycred_list_badges * @since 1.5.3 * @version 1.5.3 */ // [mycred_list_badges type="posting"] function mycred_list_badges( $atts ){ extract( shortcode_atts( array( 'type' => 'general', ), $atts ) ); ob_start(); get_list_types_badges($type); $output = ob_get_contents(); ob_end_clean(); return $output; } add_shortcode( 'mycred_list_badges', 'mycred_list_badges' ); — Forum Mortal Kombat X IOs/Android Skip to content
#1266