| 1 |
<?php |
| 2 |
// Courses |
| 3 |
add_filter('manage_edit-course_columns', 'wpc_course_columns', 9, 1); |
| 4 |
|
| 5 |
function wpc_course_columns($columns) |
| 6 |
{ |
| 7 |
$columns['title'] = esc_html__('Course', 'wp-courses'); |
| 8 |
$columns = wpc_array_insert_after('title', $columns, 'lessons', esc_html__('Connected Lessons / Quizzes', 'wp-courses')); |
| 9 |
$columns = wpc_array_insert_after('lessons', $columns, 'teacher', esc_html__('Connected Teachers', 'wp-courses')); |
| 10 |
$columns = wpc_array_insert_after('teacher', $columns, 'woo', esc_html__('Connected WooCommerce Products', 'wp-courses')); |
| 11 |
unset($columns['date']); |
| 12 |
|
| 13 |
return $columns; |
| 14 |
} |
| 15 |
|
| 16 |
add_action('manage_course_posts_custom_column', 'wpc_manage_course_columns', 10, 2); |
| 17 |
|
| 18 |
function wpc_manage_course_columns($column, $post_id) |
| 19 |
{ |
| 20 |
switch ($column) { |
| 21 |
case 'lessons': |
| 22 |
$lessons = wpc_get_connected_lessons($post_id); |
| 23 |
$list = wpc_lesson_collection($lessons); |
| 24 |
|
| 25 |
echo $list; |
| 26 |
break; |
| 27 |
|
| 28 |
case 'teacher': |
| 29 |
$args = array( |
| 30 |
'post_from' => $post_id, |
| 31 |
'connection_type' => array('course-to-teacher'), |
| 32 |
'order_by' => 'post_title', |
| 33 |
'order' => 'asc', |
| 34 |
'order_posts_table' => true, |
| 35 |
'join' => true, |
| 36 |
'join_on' => "post_to" |
| 37 |
); |
| 38 |
|
| 39 |
$teachers = wpc_get_connected($args); |
| 40 |
|
| 41 |
$list = wpc_teacher_collection($teachers); |
| 42 |
|
| 43 |
echo $list; |
| 44 |
break; |
| 45 |
|
| 46 |
case 'woo': |
| 47 |
if (is_plugin_active('wp-courses-premium/wp-courses-premium.php') == false) { |
| 48 |
$wooCell = 'Sell your courses via WooCommerce with our: <a target="_blank" href="https://wpcoursesplugin.com/cart/?add-to-cart=829" class="wpc-btn wpc-btn-solid wpc-premium-upgrade-small wpc-premium-upgrade-all"><i class="fa fa-shopping-cart"></i> Premium Plugin</a>'; |
| 49 |
} else if (function_exists('wpc_get_connected_product_id') && class_exists('WooCommerce')) { |
| 50 |
$product_id = wpc_get_connected_product_id($post_id); |
| 51 |
|
| 52 |
$_product = wc_get_product($product_id); |
| 53 |
|
| 54 |
if ($_product) { |
| 55 |
$wooCell = esc_html($_product->get_name()); |
| 56 |
} else { |
| 57 |
$wooCell = '—'; |
| 58 |
} |
| 59 |
} else { |
| 60 |
$wooCell = '—'; |
| 61 |
} |
| 62 |
|
| 63 |
echo $wooCell; |
| 64 |
break; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
// Lessons |
| 69 |
add_filter('manage_edit-lesson_columns', 'wpc_lesson_columns', 9, 1); |
| 70 |
|
| 71 |
function wpc_lesson_columns($columns) |
| 72 |
{ |
| 73 |
$columns = array( |
| 74 |
'cb' => '<input type="checkbox" />', |
| 75 |
'title' => esc_html__('Lesson', 'wp-courses'), |
| 76 |
'course' => esc_html__('Connected Courses', 'wp-courses'), |
| 77 |
'restriction' => esc_html__('Restriction', 'wp-courses') |
| 78 |
); |
| 79 |
|
| 80 |
if (is_plugin_active('wp-courses-premium/wp-courses-premium.php') == false) { |
| 81 |
$columns = wpc_array_insert_after('restriction', $columns, 'woo_pmp', esc_html__('WooCommerce / Paid Memberships Pro', 'wp-courses')); |
| 82 |
} |
| 83 |
|
| 84 |
return $columns; |
| 85 |
} |
| 86 |
|
| 87 |
add_action('manage_lesson_posts_custom_column', 'wpc_manage_lesson_columns', 10, 2); |
| 88 |
|
| 89 |
function wpc_manage_lesson_columns($column, $post_id) |
| 90 |
{ |
| 91 |
switch ($column) { |
| 92 |
case 'course': |
| 93 |
if (is_plugin_active('wp-courses-woocommerce/wp-courses-woocommerce.php')) { |
| 94 |
echo "<div class='wpc-warning'>You cannot connect lessons to courses until you update to WP Courses Premium 3.0 or later. <a href='https://wpcoursesplugin.com/lesson/upgrading-wp-courses-woocommerce-integration-for-3-0/?course_id=958'>More information can be found here</a>.<div>"; |
| 95 |
} else { |
| 96 |
$course_ids = wpc_get_connected_course_ids($post_id); |
| 97 |
wpc_course_multiselect($course_ids, "course-selection[]", 'wpc-course-multiselect wpc-lesson-type-lesson'); |
| 98 |
} |
| 99 |
|
| 100 |
break; |
| 101 |
|
| 102 |
case 'restriction': |
| 103 |
$radio_name = 'radio-' . $post_id; |
| 104 |
echo wpc_lesson_restriction_radio_buttons($post_id, $radio_name); |
| 105 |
|
| 106 |
break; |
| 107 |
|
| 108 |
case 'woo_pmp': |
| 109 |
echo '<b>Sell your lessons</b> via WooCommerce / Paid Memberships Pro<br>NEW: Setup <b>DRIP CONTENT!</b><br><a target="_blank" href="https://wpcoursesplugin.com/cart/?add-to-cart=829" class="wpc-btn wpc-btn-solid wpc-premium-upgrade-small wpc-premium-upgrade-all"><i class="fa fa-shopping-cart"></i> Premium Plugin</a>'; |
| 110 |
break; |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
// Quizzes |
| 115 |
add_filter('manage_edit-wpc-quiz_columns', 'wpc_quiz_columns', 9, 1); |
| 116 |
|
| 117 |
function wpc_quiz_columns($columns) |
| 118 |
{ |
| 119 |
$columns = array( |
| 120 |
'cb' => '<input type="checkbox" />', |
| 121 |
'title' => esc_html__('Quiz', 'wp-courses'), |
| 122 |
'course' => esc_html__('Connected Courses', 'wp-courses'), |
| 123 |
'restriction' => esc_html__('Restriction', 'wp-courses') |
| 124 |
); |
| 125 |
return $columns; |
| 126 |
} |
| 127 |
|
| 128 |
add_action('manage_wpc-quiz_posts_custom_column', 'wpc_manage_quiz_columns', 10, 2); |
| 129 |
|
| 130 |
function wpc_manage_quiz_columns($column, $post_id) |
| 131 |
{ |
| 132 |
global $post; |
| 133 |
switch ($column) { |
| 134 |
case 'course': |
| 135 |
if (is_plugin_active('wp-courses-woocommerce/wp-courses-woocommerce.php')) { |
| 136 |
echo "<div class='wpc-warning'>You cannot connect quizzes to courses until you update to WP Courses Premium 3.0 or later. <a href='https://wpcoursesplugin.com/lesson/upgrading-wp-courses-woocommerce-integration-for-3-0/?course_id=958'>More information can be found here</a>.<div>"; |
| 137 |
} else { |
| 138 |
$course_ids = wpc_get_connected_course_ids($post_id, 'quiz-to-course'); |
| 139 |
wpc_course_multiselect($course_ids, "course-selection[]", 'wpc-course-multiselect wpc-lesson-type-quiz'); |
| 140 |
} |
| 141 |
|
| 142 |
break; |
| 143 |
|
| 144 |
case 'restriction': |
| 145 |
$radio_name = 'radio-' . $post_id; |
| 146 |
echo wpc_lesson_restriction_radio_buttons($post_id, $radio_name); |
| 147 |
|
| 148 |
break; |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
// Teachers |
| 153 |
add_filter('manage_edit-teacher_columns', 'teacher_columns', 9, 1); |
| 154 |
|
| 155 |
function teacher_columns($columns) |
| 156 |
{ |
| 157 |
$columns['title'] = esc_html__('Teachers', 'wp-courses'); |
| 158 |
$columns = wpc_array_insert_after('title', $columns, 'courses', esc_html__('Connected Courses', 'wp-courses')); |
| 159 |
unset($columns['date']); |
| 160 |
|
| 161 |
return $columns; |
| 162 |
} |
| 163 |
|
| 164 |
add_action('manage_teacher_posts_custom_column', 'wpc_manage_teacher_columns', 10, 2); |
| 165 |
|
| 166 |
function wpc_manage_teacher_columns($column, $post_id) |
| 167 |
{ |
| 168 |
global $post; |
| 169 |
switch ($column) { |
| 170 |
case 'courses': |
| 171 |
$args = array( |
| 172 |
'post_to' => $post_id, |
| 173 |
'connection_type' => array('course-to-teacher'), |
| 174 |
'order_by' => 'post_title', |
| 175 |
'order' => 'asc', |
| 176 |
'order_posts_table' => true, |
| 177 |
'join' => true, |
| 178 |
'join_on' => "post_from" |
| 179 |
); |
| 180 |
|
| 181 |
$teachers = wpc_get_connected($args); |
| 182 |
|
| 183 |
$list = wpc_course_collection($teachers); |
| 184 |
|
| 185 |
echo $list; |
| 186 |
break; |
| 187 |
} |
| 188 |
} |