PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.2.7
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.2.7
2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 All 28 releases
← All changes | admin/includes/class.snippets.table.php +14 -46 2.4.22.2.7 View file →
@@ -85,9 +85,9 @@
85 85 * @param bool $modal
86 86 */
87 87 function __construct( $modal = false ) {
88 88 global $status, $page;
89 - add_thickbox();
89 +
90 90 $this->modal = $modal;
91 91 $this->common = true;
92 92
93 93 // Set parent defaults
@@ -130,9 +130,8 @@
130 130 case 'desc':
131 131 $desc = strlen( $item[ $column_name ] ) > 500 ? substr( $item[ $column_name ], 0, 500 ) : $item[ $column_name ];
132 132
133 133 return '<div class="wbcr-inp-snippet-description" title="' . esc_attr( $desc ) . '">' . esc_html( $desc ) . '</div>';
134 - case 'preview':
135 134 case 'datetime':
136 135 case 'insert':
137 136 case 'delete':
138 137 return $item[ $column_name ];
@@ -199,21 +198,17 @@
199 198 * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
200 199 **************************************************************************@see WP_List_Table::::single_row_columns()
201 200 */
202 201 public function get_columns() {
203 - $columns = [// 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
202 + $columns = [
203 + // 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
204 + 'type' => __( 'Type', 'insert-php' ),
205 + 'title' => __( 'Title', 'insert-php' ),
206 + 'desc' => __( 'Description', 'insert-php' ),
207 + 'datetime' => __( 'Date', 'insert-php' ),
208 + 'insert' => __( 'Insert', 'insert-php' ),
204 209 ];
205 - $columns['type'] = __( 'Type', 'insert-php' );
206 - $columns['title'] = __( 'Title', 'insert-php' );
207 210
208 - if ( ! $this->modal && $this->common ) {
209 - $columns['preview'] = __( 'Preview', 'insert-php' );
210 - }
211 -
212 - $columns['desc'] = __( 'Description', 'insert-php' );
213 - $columns['datetime'] = __( 'Date', 'insert-php' );
214 - $columns['insert'] = __( 'Insert', 'insert-php' );
215 -
216 211 if ( ! $this->modal && ! $this->common ) {
217 212 $columns['delete'] = __( 'Delete', 'insert-php' );
218 213 }
219 214
@@ -280,22 +275,8 @@
280 275 }*/
281 276 }
282 277
283 278 /**
284 - * Возвращает id youtube видео
285 - *
286 - * @param $video_link - ссылка на видео
287 - *
288 - * @return bool|string - если id сниппета не найден, то вернёт false
289 - */
290 - private function get_video_id( $video_link ) {
291 - // youtube regex
292 - preg_match( "#([\/|\?|&]vi?[\/|=]|youtu\.be\/|embed\/)([a-zA-Z0-9_-]+)#", $video_link, $matches );
293 -
294 - return ! empty( $matches ) ? end( $matches ) : false;
295 - }
296 -
297 - /**
298 279 * Get snippets data
299 280 *
300 281 * @return array
301 282 */
@@ -304,9 +285,9 @@
304 285 $saved_data = [];
305 286
306 287 $orderby = WINP_Plugin::app()->request->request( 'orderby', 'datetime', true );
307 288 $order = WINP_Plugin::app()->request->request( 'order', 'desc', true );
308 - $paged = WINP_Plugin::app()->request->request( 'paged', 1, 'intval' );
289 + $paged = WINP_Plugin::app()->request->request( 'paged', 1 );
309 290
310 291 $order_tags = [
311 292 'title' => 'title',
312 293 'type' => 'type_id',
@@ -322,37 +303,24 @@
322 303 $snippets = WINP_Plugin::app()->get_api_object()->get_all_snippets( $this->common, $args );
323 304
324 305 if ( ! empty( $snippets ) ) {
325 306 foreach ( (array) $snippets as $snippet ) {
326 - $_data = [
327 - 'ID' => (int) $snippet->id,
307 + $data[] = [
308 + 'ID' => $snippet->id,
328 309 'title' => esc_html( $snippet->title ),
329 310 'desc' => esc_html( $snippet->description ),
330 311 'type' => $snippet->type->title,
331 312 'datetime' => date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $snippet->updated_at ),
332 - 'insert' => '<a class="wbcr-inp-enable-snippet-button button" data-snippet="' . esc_attr( $snippet->id ) . '" data-common="' . ( $this->common ? 1 : 0 ) . '" href="javascript: void(0)"><span class="dashicons dashicons-plus"></span></a>',
333 - 'delete' => '<a class="wbcr-inp-delete-snippet-button button" data-snippet="' . esc_attr( $snippet->id ) . '" href="javascript: void(0)"><span class="dashicons dashicons-no"></span></a>',
313 + 'insert' => '<a class="wbcr-inp-enable-snippet-button button" data-snippet="' . $snippet->id . '" data-common="' . ( $this->common ? 1 : 0 ) . '" href="javascript: void(0)"><span class="dashicons dashicons-plus"></span></a>',
314 + 'delete' => '<a class="wbcr-inp-delete-snippet-button button" data-snippet="' . $snippet->id . '" href="javascript: void(0)"><span class="dashicons dashicons-no"></span></a>',
334 315 ];
335 316
336 - if ( $this->common ) {
337 - $_data['preview'] = '';
338 - }
339 -
340 - $video_id = $this->get_video_id( $snippet->video_link );
341 -
342 - if ( $video_id ) {
343 - $_data['preview'] = '<a class="thickbox" href="https://www.youtube.com/embed/' . esc_attr( $video_id ) . '?autoplay=1&rel=0&TB_iframe=true">' . '<img src="' . WINP_PLUGIN_URL . '/admin/assets/img/video.png" class="winp-library-image-preview" data-videoid="' . esc_attr( $video_id ) . '" alt="' . __( 'View the video', 'insert-php' ) . '">' . '</a>';
344 - }
345 -
346 - $data[] = $_data;
347 -
348 317 $saved_data[ $snippet->id ] = [
349 318 'title' => esc_html( $snippet->title ),
350 319 'desc' => esc_html( $snippet->description ),
351 320 'type' => $snippet->type->slug,
352 321 'content' => $snippet->content,
353 - 'type_id' => (int) $snippet->type_id,
354 - 'scope' => $snippet->execute_everywhere ? 'evrywhere' : 'shortcode',
322 + 'type_id' => $snippet->type_id,
355 323 ];
356 324 }
357 325
358 326 update_user_meta( get_current_user_id(), WINP_Plugin::app()->getPrefix() . 'current_snippets', $saved_data );