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.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / classes / Taxonomies.php
tutor / classes Last commit date
Addons.php 6 years ago Admin.php 6 years ago Ajax.php 6 years ago Assets.php 6 years ago Course.php 6 years ago Course_Settings_Tabs.php 6 years ago Course_Widget.php 6 years ago Dashboard.php 6 years ago Email.php 6 years ago FormHandler.php 6 years ago Frontend.php 6 years ago Gutenberg.php 6 years ago Instructor.php 6 years ago Instructors_List.php 6 years ago Lesson.php 6 years ago Options.php 6 years ago Post_types.php 6 years ago Q_and_A.php 6 years ago Question_Answers_List.php 6 years ago Quiz.php 6 years ago Quiz_Attempts_List.php 6 years ago RestAPI.php 6 years ago Rewrite_Rules.php 6 years ago Shortcode.php 6 years ago Student.php 6 years ago Students_List.php 6 years ago Taxonomies.php 6 years ago Template.php 6 years ago Theme_Compatibility.php 6 years ago Tools.php 6 years ago Tutor.php 6 years ago TutorEDD.php 6 years ago Tutor_Base.php 6 years ago Tutor_List_Table.php 6 years ago Tutor_Setup.php 6 years ago Upgrader.php 6 years ago User.php 6 years ago Utils.php 6 years ago Video_Stream.php 6 years ago Withdraw.php 6 years ago Withdraw_Requests_List.php 6 years ago WooCommerce.php 6 years ago
Taxonomies.php
222 lines
1 <?php
2 namespace TUTOR;
3
4 if ( ! defined( 'ABSPATH' ) )
5 exit;
6
7 class Taxonomies{
8
9 public function __construct() {
10
11 add_action( 'course-category_add_form_fields', array( $this, 'add_category_fields' ) );
12 add_action( 'course-category_edit_form_fields', array( $this, 'edit_category_fields' ) );
13
14 add_action( 'created_term', array( $this, 'save_category_fields' ), 10, 3 );
15 add_action( 'edit_term', array( $this, 'save_category_fields' ), 10, 3 );
16
17 add_filter( 'manage_edit-course-category_columns', array( $this, 'course_category_columns' ) );
18 add_filter( 'manage_course-category_custom_column', array( $this, 'course_category_column' ), 10, 3 );
19
20 }
21
22 public function add_category_fields(){
23 ?>
24 <div class="form-field term-thumbnail-wrap">
25 <label><?php esc_html_e( 'Thumbnail', 'tutor' ); ?></label>
26 <div id="course-category_thumbnail" style="float: left; margin-right: 10px;"><img src="<?php echo esc_url( tutor_placeholder_img_src() ); ?>" width="60px" height="60px" /></div>
27 <div style="line-height: 60px;">
28 <input type="hidden" id="course-category_thumbnail_id" name="course_category_thumbnail_id" />
29 <button type="button" class="upload_image_button button"><?php esc_html_e( 'Upload/Add image', 'tutor' ); ?></button>
30 <button type="button" class="remove_image_button button"><?php esc_html_e( 'Remove image', 'tutor' ); ?></button>
31 </div>
32 <script type="text/javascript">
33
34 // Only show the "remove image" button when needed
35 if ( ! jQuery( '#course-category_thumbnail_id' ).val() ) {
36 jQuery( '.remove_image_button' ).hide();
37 }
38
39 // Uploading files
40 var file_frame;
41
42 jQuery( document ).on( 'click', '.upload_image_button', function( event ) {
43
44 event.preventDefault();
45
46 // If the media frame already exists, reopen it.
47 if ( file_frame ) {
48 file_frame.open();
49 return;
50 }
51
52 // Create the media frame.
53 file_frame = wp.media.frames.downloadable_file = wp.media({
54 title: '<?php esc_html_e( 'Choose an image', 'tutor' ); ?>',
55 button: {
56 text: '<?php esc_html_e( 'Use image', 'tutor' ); ?>'
57 },
58 multiple: false
59 });
60
61 // When an image is selected, run a callback.
62 file_frame.on( 'select', function() {
63 var attachment = file_frame.state().get( 'selection' ).first().toJSON();
64 var attachment_thumbnail = attachment.sizes.thumbnail || attachment.sizes.full;
65
66 jQuery( '#course-category_thumbnail_id' ).val( attachment.id );
67 jQuery( '#course-category_thumbnail' ).find( 'img' ).attr( 'src', attachment_thumbnail.url );
68 jQuery( '.remove_image_button' ).show();
69 });
70
71 // Finally, open the modal.
72 file_frame.open();
73 });
74
75 jQuery( document ).on( 'click', '.remove_image_button', function() {
76 jQuery( '#course-category_thumbnail' ).find( 'img' ).attr( 'src', '<?php echo esc_js( tutor_placeholder_img_src() ); ?>' );
77 jQuery( '#course-category_thumbnail_id' ).val( '' );
78 jQuery( '.remove_image_button' ).hide();
79 return false;
80 });
81
82 </script>
83 <div class="clear"></div>
84 </div>
85 <?php
86 }
87
88
89 public function edit_category_fields($term){
90
91 $thumbnail_id = absint( get_term_meta( $term->term_id, 'thumbnail_id', true ) );
92
93 if ( $thumbnail_id ) {
94 $image = wp_get_attachment_thumb_url( $thumbnail_id );
95 } else {
96 $image = tutor_placeholder_img_src();
97 }
98 ?>
99
100 <tr class="form-field term-thumbnail-wrap">
101 <th scope="row" valign="top"><label><?php esc_html_e( 'Thumbnail', 'woocommerce' ); ?></label></th>
102 <td>
103
104 <div class="form-field term-thumbnail-wrap">
105 <div id="course-category_thumbnail" style="float: left; margin-right: 10px;"><img src="<?php echo esc_url( $image ); ?>" width="60px" height="60px" /></div>
106 <div style="line-height: 60px;">
107 <input type="hidden" id="course-category_thumbnail_id" name="course_category_thumbnail_id" value="<?php echo esc_attr( $thumbnail_id ); ?>" />
108 <button type="button" class="upload_image_button button"><?php esc_html_e( 'Upload/Add image', 'tutor' ); ?></button>
109 <button type="button" class="remove_image_button button"><?php esc_html_e( 'Remove image', 'tutor' ); ?></button>
110 </div>
111 <script type="text/javascript">
112
113 // Only show the "remove image" button when needed
114 if ( ! jQuery( '#course-category_thumbnail_id' ).val() ) {
115 jQuery( '.remove_image_button' ).hide();
116 }
117
118 // Uploading files
119 var file_frame;
120
121 jQuery( document ).on( 'click', '.upload_image_button', function( event ) {
122
123 event.preventDefault();
124
125 // If the media frame already exists, reopen it.
126 if ( file_frame ) {
127 file_frame.open();
128 return;
129 }
130
131 // Create the media frame.
132 file_frame = wp.media.frames.downloadable_file = wp.media({
133 title: '<?php esc_html_e( 'Choose an image', 'tutor' ); ?>',
134 button: {
135 text: '<?php esc_html_e( 'Use image', 'tutor' ); ?>'
136 },
137 multiple: false
138 });
139
140 // When an image is selected, run a callback.
141 file_frame.on( 'select', function() {
142 var attachment = file_frame.state().get( 'selection' ).first().toJSON();
143 var attachment_thumbnail = attachment.sizes.thumbnail || attachment.sizes.full;
144
145 jQuery( '#course-category_thumbnail_id' ).val( attachment.id );
146 jQuery( '#course-category_thumbnail' ).find( 'img' ).attr( 'src', attachment_thumbnail.url );
147 jQuery( '.remove_image_button' ).show();
148 });
149
150 // Finally, open the modal.
151 file_frame.open();
152 });
153
154 jQuery( document ).on( 'click', '.remove_image_button', function() {
155 jQuery( '#course-category_thumbnail' ).find( 'img' ).attr( 'src', '<?php echo esc_js( tutor_placeholder_img_src() ); ?>' );
156 jQuery( '#course-category_thumbnail_id' ).val( '' );
157 jQuery( '.remove_image_button' ).hide();
158 return false;
159 });
160
161 </script>
162 <div class="clear"></div>
163 </div>
164
165 </td>
166 </tr>
167 <?php
168 }
169
170 /**
171 * @param $term_id
172 * @param string $tt_id
173 * @param string $taxonomy
174 *
175 * Save Course Category Thumbnail
176 */
177
178 public function save_category_fields( $term_id, $tt_id = '', $taxonomy = '' ) {
179 if ( isset( $_POST['course_category_thumbnail_id'] ) && 'course-category' === $taxonomy ) {
180 update_term_meta( $term_id, 'thumbnail_id', absint( $_POST['course_category_thumbnail_id'] ) );
181 }
182 }
183
184
185 public function course_category_columns($columns){
186 $new_columns = array();
187
188 if ( isset( $columns['cb'] ) ) {
189 $new_columns['cb'] = $columns['cb'];
190 unset( $columns['cb'] );
191 }
192
193 $new_columns['thumb'] = __( 'Image', 'tutor' );
194
195 $columns = array_merge( $new_columns, $columns );
196 $columns['handle'] = '';
197
198 return $columns;
199 }
200
201 public function course_category_column( $columns, $column, $id ) {
202 if ( 'thumb' === $column ) {
203 $thumbnail_id = get_term_meta( $id, 'thumbnail_id', true );
204
205 if ( $thumbnail_id ) {
206 $image = wp_get_attachment_thumb_url( $thumbnail_id );
207 } else {
208 $image = tutor_placeholder_img_src();
209 }
210
211 // Prevent esc_url from breaking spaces in urls for image embeds. Ref: https://core.trac.wordpress.org/ticket/23605 .
212 $image = str_replace( ' ', '%20', $image );
213 $columns .= '<img src="' . esc_url( $image ) . '" alt="' . esc_attr__( 'Thumbnail', 'tutor' ) . '" class="wp-post-image" height="48" width="48" />';
214 }
215 if ( 'handle' === $column ) {
216 $columns .= '<input type="hidden" name="term_id" value="' . esc_attr( $id ) . '" />';
217 }
218 return $columns;
219 }
220
221
222 }