public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/admin/functions.php
/**
 * Change Course Unit Counts in the Table Filter View.
 *
 * @since 1.0.0
 */
Change Course Unit Counts in the Table Filter View.
Change Course Unit Counts in the Table Filter View .
function WPCW_course_unit_permissions_list_table_views_filter( $view ) {
	global $wpdb;
	$current_user = wp_get_current_user();
	$post_type    = 'course_unit';
	$all = $wpdb->get_var( "SELECT COUNT(*) 
		 FROM $wpdb->posts 
		 WHERE ( post_status = 'publish' OR post_status = 'draft' ) 
		 AND ( post_author = '$current_user->ID' AND post_type = '$post_type' )"
	);
	if ( isset( $view['mine'] ) ) {
		$mine = $wpdb->get_var( "SELECT COUNT(*) 
			 FROM $wpdb->posts 
			 WHERE post_status = 'publish' 
			 AND post_author = '$current_user->ID' 
			 AND post_type = '$post_type'"
		);
	}
	$publish = $wpdb->get_var( "SELECT COUNT(*) 
		 FROM $wpdb->posts 
		 WHERE post_status = 'publish' 
		 AND post_author = '$current_user->ID' 
		 AND post_type = '$post_type' "
	);
	if ( isset( $view['draft'] ) ) {
		$draft = $wpdb->get_var( "SELECT COUNT(*) 
			 FROM $wpdb->posts 
			 WHERE post_status = 'draft' 
			 AND post_author = '$current_user->ID' 
			 AND post_type = '$post_type'"
		);
	}
	if ( isset( $view['all'] ) ) {
		$view['all'] = preg_replace( '/\(.+\)/U', '(' . $all . ')', $view['all'] );
	}
	if ( isset( $view['mine'] ) ) {
		$view['mine'] = preg_replace( '/\(.+\)/U', '(' . $mine . ')', $view['mine'] );
	}
	if ( isset( $view['publish'] ) ) {
		$view['publish'] = preg_replace( '/\(.+\)/U', '(' . $publish . ')', $view['publish'] );
	}
	if ( isset( $view['draft'] ) ) {
		$view['draft'] = preg_replace( '/\(.+\)/U', '(' . $draft . ')', $view['draft'] );
	}
	return $view;
}
function WPCW_course_unit_permissions_list_table_views_filter ( $ view ) { global $ wpdb ; $ current_user = wp_get_current_user ( ) ; $ post_type = 'course_unit' ; $ all = $ wpdb -> get_var ( " SELECT COUNT(*) 
		 FROM  $ wpdb -> posts  
		 WHERE ( post_status = 'publish' OR post_status = 'draft' ) 
		 AND ( post_author = ' $ current_user -> ID ' AND post_type = ' $ post_type ' ) " ) ; if ( isset ( $ view [ 'mine' ] ) ) { $ mine = $ wpdb -> get_var ( " SELECT COUNT(*) 
			 FROM  $ wpdb -> posts  
			 WHERE post_status = 'publish' 
			 AND post_author = ' $ current_user -> ID ' 
			 AND post_type = ' $ post_type ' " ) ; } $ publish = $ wpdb -> get_var ( " SELECT COUNT(*) 
		 FROM  $ wpdb -> posts  
		 WHERE post_status = 'publish' 
		 AND post_author = ' $ current_user -> ID ' 
		 AND post_type = ' $ post_type '  " ) ; if ( isset ( $ view [ 'draft' ] ) ) { $ draft = $ wpdb -> get_var ( " SELECT COUNT(*) 
			 FROM  $ wpdb -> posts  
			 WHERE post_status = 'draft' 
			 AND post_author = ' $ current_user -> ID ' 
			 AND post_type = ' $ post_type ' " ) ; } if ( isset ( $ view [ 'all' ] ) ) { $ view [ 'all' ] = preg_replace ( '/\(.+\)/U' , '(' . $ all . ')' , $ view [ 'all' ] ) ; } if ( isset ( $ view [ 'mine' ] ) ) { $ view [ 'mine' ] = preg_replace ( '/\(.+\)/U' , '(' . $ mine . ')' , $ view [ 'mine' ] ) ; } if ( isset ( $ view [ 'publish' ] ) ) { $ view [ 'publish' ] = preg_replace ( '/\(.+\)/U' , '(' . $ publish . ')' , $ view [ 'publish' ] ) ; } if ( isset ( $ view [ 'draft' ] ) ) { $ view [ 'draft' ] = preg_replace ( '/\(.+\)/U' , '(' . $ draft . ')' , $ view [ 'draft' ] ) ; } return $ view ; }
Change Course Unit Counts in the Table Filter View.
Change Course Unit Counts in the Table Filter View .
// Global // Get Current User /*
     * Change the counts
	 *
	 * [all] => <a href="edit.php?post_type=course_unit&#038;all_posts=1" class="current">All <span class="count">(6)</span></a>
     * [mine] => <a href="edit.php?post_type=course_unit&#038;author=2">Mine <span class="count">(1)</span></a>
     * [publish] => <a href="edit.php?post_status=publish&#038;post_type=course_unit">Published <span class="count">(5)</span></a>
     * [draft] => <a href="edit.php?post_status=draft&#038;post_type=course_unit">Draft <span class="count">(1)</span></a>
     */ // All // Mine // Publish // Draft