Plugin Directory

Changeset 1477367


Ignore:
Timestamp:
08/17/2016 11:27:45 PM (10 years ago)
Author:
Vincent Stark
Message:

Merge remote-tracking branch 'remotes/origin/VID-17(stars_system)'

Location:
video-capture/trunk
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • video-capture/trunk/wp-video-capture.php

    r1460514 r1477367  
    6464            add_action( 'wp_ajax_nopriv_store_video_file', array( &$this, 'store_video_file' ) );
    6565            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' ) );
    6667
    6768            // On plugin init.
     
    266267                'cb' => $columns['cb'],
    267268                'title' => __( 'Filename' ),
     269                'vidrack_video_rating' => __( 'Rating' ),
    268270                'vidrack_video_configurable_options' => __( 'Configurable Options' ),
    269271                'vidrack_video_ip' => __( 'IP' ),
     
    283285            } elseif ( 'vidrack_video_external_id' === $column ) {
    284286                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 ) );
    285289            } elseif ( 'vidrack_video_configurable_options' === $column ) {
    286290                $configure_options_array = array( );
     
    546550            }
    547551        }
     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        }
    548574    }
    549575}
     
    637663                wp_enqueue_script( 'spinner_runner' );
    638664
     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                );
    639688            }
    640689            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.