'. wp_kses_post( __( 'Author - List plugin is activated successfully. You can view the author list from Add New Page by adding the shortcode [author-list role=administrator post_type=post,page number=1 orderby=email order=ASC] from backend.', 'author_list' ) ) . '

'; delete_option( 'author_list_activate_msg' ); } } /** * Class to show author list. */ class authorList { /** * Call default construtor. */ function __construct() { /** * Action to call author shortcode. */ add_action('init', array( $this, 'authorlist_shortcodes_init' ) ); } /** * Add author list shortcode. */ public function authorlist_shortcodes_init() { add_shortcode('author-list', array( $this, 'list_author_shortcode' ) ); } /** * List all user as per their role. * * @param array $atts * @return string */ public function list_author_shortcode( $atts ) { $atts = shortcode_atts( array( 'role' => 'Administrator', 'number' => 5, 'post_type' => 'post', 'orderby' => 'post_count', 'order' => 'DESC', ), $atts, 'list_author_shortcode' ); $current_page = max( 1, get_query_var('paged') ); $offset = ($current_page - 1) * $atts[ 'number' ]; if ( false !== strpos($atts[ 'post_type' ], ',') ) { $atts[ 'post_type' ] = explode(',', $atts[ 'post_type' ] ); } // get users list. $args = array( 'has_published_posts' => $atts[ 'post_type' ], 'role' => $atts[ 'role' ], 'orderby' => $atts[ 'orderby' ], 'order' => $atts[ 'order' ], 'number' => $atts[ 'number' ], 'offset' => $offset, ); // The Query $user_query = new WP_User_Query( $args ); $user_count = $user_query->total_users; global $author_list_user, $total_pages; // count the number of users found in the query $total_users = $user_count ? $user_count : 1; $total_pages = 1; $total_pages = ceil( $total_users / $atts[ 'number' ]); // User Loop if ( ! empty( $user_query->results ) ) { foreach ( $user_query->results as $author_list_user ) { // Call author template. author_list_get_template_part( 'author-bio' ); } // Call to pagination tempalte. author_list_get_template_part( 'pagination' ); } else { echo __( 'No users found.', 'author_list' ); } } } /** * Get template part. * * * @access public * @param string $name (default: '') */ function author_list_get_template_part( $name = '' ) { $template = ''; // If template file doesn't exist, look in yourtheme/author-bio.php if ( $name ) { $template = locate_template( array( "{$name}.php", "author-list/{$name}.php" ) ); } // Get default name.php if ( ! $template && $name && file_exists( plugin_dir_path( __FILE__ ) . "author-list/{$name}.php" ) ) { $template = plugin_dir_path( __FILE__ ) . "author-list/{$name}.php"; } // Allow 3rd party plugins to filter template file from their plugin. $template = apply_filters( 'author_list_get_template_part', $template, $name ); if ( $template ) { load_template( $template, false ); } } $authorList = new authorList(); // go