Plugin Directory

Changeset 1400942


Ignore:
Timestamp:
04/21/2016 05:32:21 AM (10 years ago)
Author:
parth.kumar
Message:

Added new version which allows to record comments and recording for pages too.

Location:
wp-voice-recorder/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • wp-voice-recorder/trunk/js/jRecorder.js

    r1355188 r1400942  
    5353            element = $("body");
    5454        }
    55            
     55            if ( typeof wpvr_variables == 'undefined' && typeof wpvr_cmt_variables !='undefined'  ) {
     56                var plugins_url = wpvr_cmt_variables.plugins_url;
     57                var host_url = wpvr_cmt_variables.ajaxurl + '/filename=comment_file' + wpvr_cmt_variables.comment_id + '?action=wpvr_upload_cmt_file';
     58            }
     59            else {
     60                var plugins_url = wpvr_variables.plugins_url;
     61                var host_url = wpvr_variables.ajaxurl + '/filename=recorded_file' + wpvr_variables.post_id + '?action=wpvr_upload_file';
     62            }
    5663        //default settings
    5764                        var settings = {
     
    6572                        'wmode' : 'transparent',
    6673                        'bgcolor': '#ff0000',
    67                         'swf_path': wpvr_variables.plugins_url + '/wp-voice-recorder/js/jRecorder.swf',
    68                         'host' :  wpvr_variables.ajaxurl + '/filename=recorded_file' + wpvr_variables.post_id + '?action=wpvr_upload_file',
     74                        'swf_path': plugins_url + '/wp-voice-recorder/js/jRecorder.swf',
     75                        'host' :  host_url,
    6976                        'callback_started_recording' : function(){},
    7077                        'callback_finished_recording' : function(){},
  • wp-voice-recorder/trunk/js/wpvr-audio-recorder.js

    r1358133 r1400942  
    11var $ = jQuery.noConflict();
    22$(document).ready(function(){
    3     var host_url = wpvr_audio.ajaxurl + '/filename=recorded_file' + wpvr_audio.post_id + '?action=wpvr_upload_file';
     3    if ( typeof wpvr_audio == 'undefined' && typeof wpvr_cmt_audio !='undefined'  ) {
     4        var host_url = wpvr_cmt_audio.ajaxurl + '/filename=comment_file' + wpvr_cmt_audio.comment_id + '?action=wpvr_upload_cmt_file';
     5        var plugin_url = wpvr_cmt_audio.plugins_url;
     6    }
     7    else {
     8        var host_url = wpvr_audio.ajaxurl + '/filename=recorded_file' + wpvr_audio.post_id + '?action=wpvr_upload_file';
     9        var plugin_url = wpvr_audio.plugins_url;
     10    }
    411  $.jRecorder(
    512     {
     
    1017        callback_activityTime:          function(time){callback_activityTime(time); },
    1118        callback_finished_sending:      function(time){ callback_finished_sending(); },
    12         swf_path : wpvr_audio.plugins_url + '/wp-voice-recorder/js/jRecorder.swf',
     19        swf_path : plugin_url + '/wp-voice-recorder/js/jRecorder.swf',
    1320     }
    1421   );
  • wp-voice-recorder/trunk/lib/wpvr-voice-meta.php

    r1355188 r1400942  
    1010*@return none
    1111*/
    12 function add_audio_recorder() {
     12function add_audio_recorder_for_posts( $post ) {
    1313    add_meta_box(                                                 
    1414            'wpvr_post_recorder',
     
    1818    );
    1919}
    20 add_action( 'add_meta_boxes', 'add_audio_recorder' );
     20add_action( 'add_meta_boxes_post', 'add_audio_recorder_for_posts' );
     21
     22/*add a meta box to record the voice post
     23*@param  none
     24*@return none
     25*/
     26function add_audio_recorder_for_page( $post ) {
     27    add_meta_box(                                                 
     28            'wpvr_post_recorder',
     29            __( 'WP Post Recorder', 'myplugin_textdomain' ),
     30            'wpvr_record_box',
     31            'page','side'
     32    );
     33}
     34add_action( 'add_meta_boxes_page', 'add_audio_recorder_for_page' );
    2135/* Function to add metabox for the recorder
    2236*   @param none
  • wp-voice-recorder/trunk/readme.txt

    r1355188 r1400942  
    11=== WP Voice Recorder ===
    22Contributors: Kumar Parth   
    3 Tags: WordPress,Voice Recorder, posts record
     3Tags: WordPress,Voice Recorder, posts record, comment record, audio recording for pages
    44Requires at least: 3.1
    55Tested up to: 4.1
     
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
    10 WP Voice Recorder can help us to record the posts and play them in the front end.
     10WP Voice Recorder can help us to record the posts and pages and play them in the front end and also record comments too.
    1111
    1212== Description ==
    1313
    14 WP Voice Recorder can help us to record the posts and play them in the front end. It allows us to save the recorded audios into your uploads folder in wordpress install.
     14WP Voice Recorder can help us to record the posts, pages and play them in the front end. It also let us record comments too. It allows us to save the recorded audios into your uploads folder in wordpress install.
    1515
    1616
     
    19191. Download and extract `wp-voice-recorder.zip` to `wp-content/plugins/`
    20202. Activate the plugin through the 'Plugins' menu in WordPress.
    21 3. It will create a recorder in each posts editor and there you can record your voice and publish or update your posts.
     213. It will create a recorder in each posts editor and there you can record your voice and publish or update your posts as well as pages. And a recorder appears for the comments too.
    2222
    2323Special Thanks to
     
    3535== Changelog ==
    3636# 1.1 - Removed the dropbox account feature.
     37# 1.2 - Added comment recording and audio recording in pages too.
    3738
    3839
    3940= Version 1.1 =
    4041
    41 * Initial public release.
     42* New version updated.
    4243
    4344
    4445== Upgrade Notice ==
     46- Upgrade to new version to record comments and pages too.
    4547
    4648== Screenshots ==
    47492. screenshot-1.png
    48503. screenshot-2.png
     514. screenshot-3.png
     525. screenshot-4.png
  • wp-voice-recorder/trunk/wpvr-recorder.php

    r1355188 r1400942  
    5050*/
    5151function wpvr_admin_scripts( $hook_suffix ) {       
    52     if ( 'post.php' == $hook_suffix || 'post-new.php' == $hook_suffix ) {
     52    //if ( 'post.php' == $hook_suffix || 'post-new.php' == $hook_suffix || is_single() || is_page() ) {
    5353        wp_enqueue_script( 'jrecorder', plugins_url( 'js/jRecorder.js' , __FILE__ ), array('jquery') );   
    5454        wp_enqueue_script( 'audiorec', plugins_url( 'js/wpvr-audio-recorder.js' , __FILE__ ), array( 'jrecorder' ) );
     
    6060        wp_localize_script( 'audiorec', 'wpvr_audio', $site_parameters ); 
    6161        wp_localize_script( 'jrecorder', 'wpvr_variables', $site_parameters );
    62     }
     62    //}
    6363}
    6464add_action( 'admin_enqueue_scripts', 'wpvr_admin_scripts' );
     
    7575    $url_filename = $split_url[1];
    7676    $filename = rtrim( $url_filename, '?action=wpvr_upload_file' );
     77    $fp          = fopen( $upload_path.'/'.$filename.'.wav', 'wb' );
     78    fwrite( $fp, file_get_contents( 'php://input' ) );
     79    fclose( $fp );
     80}
     81
     82add_action( 'wp_ajax_wpvr_upload_cmt_file', 'wpvr_upload_cmt_file' );
     83add_action( 'wp_ajax_nopriv_wpvr_upload_cmt_file', 'wpvr_upload_cmt_file' );
     84function wpvr_upload_cmt_file() {
     85    $upload_dir = wp_upload_dir();     
     86    //save the path in the uploads folder
     87    $upload_path = $upload_dir['basedir'] . '/recorded_files';
     88    $url = wp_get_referer();
     89    $host = parse_url($url, PHP_URL_QUERY);
     90    $split_url = explode( 'filename=',$host );
     91    $url_filename = $split_url[1];
     92    $filename = rtrim( $url_filename, '?action=wpvr_upload_cmt_file' );
    7793    $fp          = fopen( $upload_path.'/'.$filename.'.wav', 'wb' );
    7894    fwrite( $fp, file_get_contents( 'php://input' ) );
     
    95111    else
    96112        $file_url = '';
    97     if ( ! empty ( $file_url ) && is_single() )
     113    if ( ! empty ( $file_url ) && (is_single() || is_page()) )
    98114        require( 'lib/wpvr-jplayer-interface.php' );       
    99115    return $content;
     
    114130add_action( 'wp_footer' , 'wpvr_run_script' );
    115131
     132add_action( 'comment_form_logged_in_after', 'additional_fields' );
     133add_action( 'comment_form_after_fields', 'additional_fields' );
    116134
     135function additional_fields () {
     136  //  global $post;
     137    // Add an nonce field so we can check for it later.
     138    wp_nonce_field( 'save_audio', 'save_audio_nonce' );
     139    wp_enqueue_script( 'jrecorder', plugins_url( 'js/jRecorder.js' , __FILE__ ), array('jquery') );   
     140    wp_enqueue_script( 'audiorec', plugins_url( 'js/wpvr-audio-recorder.js' , __FILE__ ), array( 'jrecorder' ) );
     141    $site_parameters = array(
     142            'plugins_url' => plugins_url(),
     143            'comment_id' => get_comment_ID() + 1,
     144            'ajaxurl' => admin_url( 'admin-ajax.php' ),
     145        );
     146    wp_localize_script( 'audiorec', 'wpvr_cmt_audio', $site_parameters ); 
     147    wp_localize_script( 'jrecorder', 'wpvr_cmt_variables', $site_parameters );
     148    $html = '<div style="background-color: #eeeeee;border:1px solid #cccccc">
     149            Time: <span id="time">00:00</span>
     150            </div>';
     151    $html .= '<label for="record">';
     152    $html .= _e( 'record your voice', 'myplugin_textdomain' );
     153    $html .= '</label> ';
     154    $html .= '<div>
     155             Level: <span id="level"></span>
     156            </div> ';
     157    $html .= '<div id="levelbase" style="width:200px;height:20px;background-color:#ffff00">
     158              <div id="levelbar" style="height:19px; width:2px;background-color:red"></div>
     159              </div>';
     160    $html .= '<div> Status: <span id="status"></span></div>';
     161    $html .= '<input type="button" id="record" name="record" value="record" />';
     162    $html .= '<input type="button" id="stop" name="stop" value="Save/Stop"/>';
     163    $html .= '<input type="hidden" name="record_file" id="record_file" value="recorded_file'.get_comment_ID().'"/>';
     164    echo $html;
     165}
     166
     167add_action( 'comment_post', 'save_comment_meta_data' );
     168function save_comment_meta_data( $comment_id ) {
     169    $rec_upload_file = wp_upload_dir();
     170    $rec_path        = $rec_upload_file['baseurl'];
     171    $record_file     = 'comment_file'.$comment_id;
     172    add_comment_meta( $comment_id,'record_file', $rec_path . '/recorded_files/'. $record_file . '.wav' );
     173}
     174
     175add_filter( 'comment_text', 'modify_comment', 0, 3 );
     176function modify_comment( $comment_text, $comment, $args ){
     177    wp_enqueue_script( 'cmt-player', plugins_url( 'js/cmt-player.js',__FILE__ ), array( 'jquery' ), '', true );
     178    $comment_id = absint( $comment->comment_ID );
     179    error_log("Comment ID in this func" . $comment_id);
     180    $file_url = get_comment_meta( $comment_id, 'record_file', true );
     181    $site_parameters = array(
     182        'plugin_url'      => plugins_url(),
     183    );
     184    wp_localize_script( 'cmt-player', 'wpvr_cmtvar', $site_parameters );
     185    require( 'lib/cmtplayer-interface.php' );
     186    echo '<br/>';
     187    echo $comment_text;
     188}
Note: See TracChangeset for help on using the changeset viewer.