Changeset 1477367
- Timestamp:
- 08/17/2016 11:27:45 PM (10 years ago)
- Location:
- video-capture/trunk
- Files:
-
- 3 added
- 1 edited
-
js/video_rating.js (added)
-
lib/css/star-rating.min.css (added)
-
lib/js/star-rating.min.js (added)
-
wp-video-capture.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
video-capture/trunk/wp-video-capture.php
r1460514 r1477367 64 64 add_action( 'wp_ajax_nopriv_store_video_file', array( &$this, 'store_video_file' ) ); 65 65 add_action( 'wp_ajax_validate_video_download_link', array( &$this, 'validate_video_download_link' ) ); 66 add_action( 'wp_ajax_set_rating_video', array( &$this, 'set_rating_video' ) ); 66 67 67 68 // On plugin init. … … 266 267 'cb' => $columns['cb'], 267 268 'title' => __( 'Filename' ), 269 'vidrack_video_rating' => __( 'Rating' ), 268 270 'vidrack_video_configurable_options' => __( 'Configurable Options' ), 269 271 'vidrack_video_ip' => __( 'IP' ), … … 283 285 } elseif ( 'vidrack_video_external_id' === $column ) { 284 286 echo esc_html( get_post_meta( get_the_ID(), '_vidrack_external_id', true ) ); 287 } elseif ( 'vidrack_video_rating' === $column ) { 288 echo esc_html( get_post_meta( get_the_ID(), '_vidrack_video_rating', true ) ); 285 289 } elseif ( 'vidrack_video_configurable_options' === $column ) { 286 290 $configure_options_array = array( ); … … 546 550 } 547 551 } 552 553 /** 554 * Set video rating on video list page. 555 */ 556 public function set_rating_video() { 557 558 if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['nonce'] ), 'vidrack_nonce_secret' ) ) { // Input var "nonce" is set? 559 echo wp_json_encode( array( 'status' => 'error' ) ); 560 die; 561 } 562 563 if ( isset( $_POST['rating_value'] ) && isset( $_POST['post_id'] ) ) { // Input var "rating_value" and "post_id" set? 564 $rating_value = esc_html( wp_unslash( $_POST['rating_value'] ) ); 565 $post_id = esc_html( wp_unslash( $_POST['post_id'] ) ); 566 $result = update_post_meta($post_id, '_vidrack_video_rating', $rating_value); 567 echo wp_json_encode( array( 'result' => $result ) ); 568 die; 569 } else { 570 echo wp_json_encode( array( 'result' => false ) ); 571 die; 572 } 573 } 548 574 } 549 575 } … … 637 663 wp_enqueue_script( 'spinner_runner' ); 638 664 665 wp_register_script( 666 'star-rating', 667 plugin_dir_url( __FILE__ ) . 'lib/js/star-rating.min.js', 668 array(), '1.1.0' 669 ); 670 671 wp_register_script( 672 'video_rating', 673 plugin_dir_url( __FILE__ ) . 'js/video_rating.js', array( 'jquery', 'star-rating' ) 674 ); 675 676 wp_enqueue_style( 'star-rating', plugin_dir_url( __FILE__ ) . 'lib/css/star-rating.min.css' ); 677 678 wp_enqueue_script( 'video_rating' ); 679 680 wp_localize_script( 681 'video_rating', 682 'VideoRating', 683 array( 684 'ajaxurl' => admin_url( 'admin-ajax.php' ), 685 'nonce' => wp_create_nonce( 'vidrack_nonce_secret' ), 686 ) 687 ); 639 688 } 640 689 if ( isset( $_GET['post_type'] ) && 'vidrack_video' === $_GET['post_type'] ) { // Input var "post_type" is set.
Note: See TracChangeset
for help on using the changeset viewer.