/** * Generates content for a single row of the table in the user management * screen. * * @since 1.7.0 * * @param object $item The current item * * @return void */ protected function get_row_data($item) { global $wp_version, $woothemes_sensei; switch ($this->view) { case 'learners': // in this case the item passed in is actually the users activity on course of lesson $user_activity = $item; $post_id = false; if ($this->lesson_id) { $post_id = intval($this->lesson_id); $object_type = __('lesson', 'woothemes-sensei'); $post_type = 'lesson'; } elseif ($this->course_id) { $post_id = intval($this->course_id); $object_type = __('course', 'woothemes-sensei'); $post_type = 'course'; } if ('complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved) { $status_html = '<span class="graded">' . apply_filters('sensei_completed_text', __('Completed', 'woothemes-sensei')) . '</span>'; } else { $status_html = '<span class="in-progress">' . apply_filters('sensei_in_progress_text', __('In Progress', 'woothemes-sensei')) . '</span>'; } $title = $woothemes_sensei->learners->get_learner_full_name($user_activity->user_id); $a_title = sprintf(__('Edit “%s”'), $title); // get the learners order for this course if the course was purchased $course_order_id_attribute = ''; if (is_woocommerce_active()) { $course_product_order_id = Sensei_WC::get_learner_course_active_order_id($user_activity->user_id, $post_id); if ($course_product_order_id) { $course_order_id_attribute = ' data-order_id="' . $course_product_order_id . '" '; } } /** * sensei_learners_main_column_data filter * * This filter runs on the learner management screen for a specific course. * It provides the learner row column details. * * @param array $columns{ * type string $title * type string $date_started * type string $course_status (completed, started etc) * type html $action_buttons * } */ $column_data = apply_filters('sensei_learners_main_column_data', array('title' => '<strong><a class="row-title" href="' . admin_url('user-edit.php?user_id=' . $user_activity->user_id) . '" title="' . esc_attr($a_title) . '">' . $title . '</a></strong>', 'date_started' => get_comment_meta($user_activity->comment_ID, 'start', true), 'user_status' => $status_html, 'actions' => '<a class="remove-learner button" data-user_id="' . $user_activity->user_id . '" data-post_id="' . $post_id . '" data-post_type="' . $post_type . '" ' . $course_order_id_attribute . '">' . sprintf(__('Remove from %1$s', 'woothemes-sensei'), $object_type) . '</a>'), $item, $post_id, $post_type); break; case 'lessons': $lesson_learners = WooThemes_Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_learners_lesson_learners', array('post_id' => $item->ID, 'type' => 'sensei_lesson_status', 'status' => 'any'))); $title = get_the_title($item); $a_title = sprintf(__('Edit “%s”'), $title); $grading_action = ''; if (get_post_meta($item->ID, '_quiz_has_questions', true)) { $grading_action = ' <a class="button" href="' . esc_url(add_query_arg(array('page' => 'sensei_grading', 'lesson_id' => $item->ID, 'course_id' => $this->course_id), admin_url('admin.php'))) . '">' . __('Grading', 'woothemes-sensei') . '</a>'; } $column_data = apply_filters('sensei_learners_main_column_data', array('title' => '<strong><a class="row-title" href="' . admin_url('post.php?action=edit&post=' . $item->ID) . '" title="' . esc_attr($a_title) . '">' . $title . '</a></strong>', 'num_learners' => $lesson_learners, 'updated' => $item->post_modified, 'actions' => '<a class="button" href="' . esc_url(add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID, 'course_id' => $this->course_id, 'view' => 'learners'), admin_url('admin.php'))) . '">' . __('Manage learners', 'woothemes-sensei') . '</a> ' . $grading_action), $item, $this->course_id); break; case 'courses': default: $course_learners = WooThemes_Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_learners_course_learners', array('post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any'))); $title = get_the_title($item); $a_title = sprintf(__('Edit “%s”'), $title); $grading_action = ''; if (version_compare($wp_version, '4.1', '>=')) { $grading_action = ' <a class="button" href="' . esc_url(add_query_arg(array('page' => 'sensei_grading', 'course_id' => $item->ID), admin_url('admin.php'))) . '">' . __('Grading', 'woothemes-sensei') . '</a>'; } $column_data = apply_filters('sensei_learners_main_column_data', array('title' => '<strong><a class="row-title" href="' . admin_url('post.php?action=edit&post=' . $item->ID) . '" title="' . esc_attr($a_title) . '">' . $title . '</a></strong>', 'num_learners' => $course_learners, 'updated' => $item->post_modified, 'actions' => '<a class="button" href="' . esc_url(add_query_arg(array('page' => $this->page_slug, 'course_id' => $item->ID, 'view' => 'learners'), admin_url('admin.php'))) . '">' . __('Manage learners', 'woothemes-sensei') . '</a> ' . $grading_action), $item); break; } // switch return $column_data; }