Plugin Directory

Changeset 1355188


Ignore:
Timestamp:
02/21/2016 01:36:11 PM (10 years ago)
Author:
parth.kumar
Message:

Fixed the dropbox and file not present issue...Sorry for the delay..

Location:
wp-voice-recorder
Files:
3 deleted
8 edited

Legend:

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

    r1035822 r1355188  
    6161                        'rec_left': '0px',
    6262                        'recorderlayout_id' : 'flashrecarea',
    63                         'recorder_id' : 'audiorecorder',
    64                         'recorder_name': 'audiorecorder',
     63                        'recorder_id' : 'record',
     64                        'recorder_name': 'record',
    6565                        'wmode' : 'transparent',
    6666                        'bgcolor': '#ff0000',
    67                         'swf_path': wpvr_variables.plugins_url + '/wpvr-recorder/js/jRecorder.swf',
     67                        'swf_path': wpvr_variables.plugins_url + '/wp-voice-recorder/js/jRecorder.swf',
    6868                        'host' :  wpvr_variables.ajaxurl + '/filename=recorded_file' + wpvr_variables.post_id + '?action=wpvr_upload_file',
    6969                        'callback_started_recording' : function(){},
     
    132132    $.jRecorder.record = function(max_time){
    133133                                //change z-index to make it top
    134                                 $(  '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', 1000);
     134                                $(  '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', 10000);
    135135                                var recorder = getFlashMovie(jRecorderSettings['recorder_name']);
     136                               
    136137                                getFlashMovie(jRecorderSettings['recorder_name']).jStartRecording(max_time);
    137138                               
  • wp-voice-recorder/trunk/js/mfsjplayer.js

    r1035822 r1355188  
    1 jQuery(document).ready(function(){
    2     for ( var i = 0; i <= wpvr_var.post_id.length - 1; i++ ) { 
    3         var file_url = wpvr_var.file_url[i];
    4         var post_id = wpvr_var.post_id[i];
    5         jplayer(post_id, file_url);
    6     }   
    7     function jplayer( post_id, file_url ) {
    8         jQuery("#jquery_jplayer_" + post_id).jPlayer({
    9             ready: function () {
    10               jQuery(this).jPlayer("setMedia", {
    11                 wav: file_url
    12               });
    13             },
    14             swfPath: wpvr_var.plugin_url+'/wpvr-recorder/js/',
    15             supplied: "wav",
    16             cssSelectorAncestor: "#jp_container_" + post_id,
    17             wmode: "window"
    18         });
    19     }
     1jQuery(document).ready(function(){ 
     2    var file_url = wpvr_var.file_url;
     3    var post_id = wpvr_var.post_id;
     4    jQuery("#jquery_jplayer_" + post_id).jPlayer({
     5        ready: function () {
     6          jQuery(this).jPlayer("setMedia", {
     7            wav: file_url
     8          });
     9        },
     10        swfPath: wpvr_var.plugin_url+'/wpvr-recorder/js/',
     11        supplied: "wav",
     12        cssSelectorAncestor: "#jp_container_" + post_id,
     13        wmode: "window"
     14    });
    2015});
  • wp-voice-recorder/trunk/js/wpvr-audio-recorder.js

    r1035822 r1355188  
    1010        callback_activityTime:          function(time){callback_activityTime(time); },
    1111        callback_finished_sending:      function(time){ callback_finished_sending(); },
    12         swf_path : wpvr_audio.plugins_url + '/wpvr-recorder/js/jRecorder.swf',
     12        swf_path : wpvr_audio.plugins_url + '/wp-voice-recorder/js/jRecorder.swf',
    1313     }
    1414   );
  • wp-voice-recorder/trunk/lib/wpvr-voice-meta.php

    r1035822 r1355188  
    1111*/
    1212function add_audio_recorder() {
    13     $get_api_token = get_option( 'dropbox_api_token' );
    14     if ( isset( $get_api_token ) && ! empty( $get_api_token ) ) {
    15         add_meta_box(                                                 
    16                 'wpvr_post_recorder',
    17                 __( 'WP Post Recorder', 'myplugin_textdomain' ),
    18                 'wpvr_record_box',
    19                 'post','side'
    20         );
    21     }
     13    add_meta_box(                                                 
     14            'wpvr_post_recorder',
     15            __( 'WP Post Recorder', 'myplugin_textdomain' ),
     16            'wpvr_record_box',
     17            'post','side'
     18    );
    2219}
    2320add_action( 'add_meta_boxes', 'add_audio_recorder' );
     
    2825function wpvr_record_box() {
    2926    global $post;
    30     $get_api_token = get_option( 'dropbox_api_token' );
    31     if ( isset( $get_api_token ) && ! empty( $get_api_token ) ) {
    32         // Add an nonce field so we can check for it later.
    33         wp_nonce_field( 'save_audio', 'save_audio_nonce' );
    34         $html = '<div style="background-color: #eeeeee;border:1px solid #cccccc">
    35                 Time: <span id="time">00:00</span>
    36                 </div>';
    37         $html .= '<label for="record">';
    38         $html .= _e( 'record your voice', 'myplugin_textdomain' );
    39         $html .= '</label> ';
    40         $html .= '<div>
    41                  Level: <span id="level"></span>
    42                 </div> ';
    43         $html .= '<div id="levelbase" style="width:200px;height:20px;background-color:#ffff00">
    44                   <div id="levelbar" style="height:19px; width:2px;background-color:red"></div>
    45                   </div>';
    46         $html .= '<div> Status: <span id="status"></span></div>';
    47         $html .= '<input type="button" id="record" name="record" value="record" />';
    48         $html .= '<input type="button" id="stop" name="stop" value="Save/Stop"/>';
    49         $html .= '<input type="hidden" name="record_file" id="record_file" value="recorded_file'.get_the_ID().'"/>';
    50         echo $html;
    51     }
     27    // Add an nonce field so we can check for it later.
     28    wp_nonce_field( 'save_audio', 'save_audio_nonce' );
     29    $html = '<div style="background-color: #eeeeee;border:1px solid #cccccc">
     30            Time: <span id="time">00:00</span>
     31            </div>';
     32    $html .= '<label for="record">';
     33    $html .= _e( 'record your voice', 'myplugin_textdomain' );
     34    $html .= '</label> ';
     35    $html .= '<div>
     36             Level: <span id="level"></span>
     37            </div> ';
     38    $html .= '<div id="levelbase" style="width:200px;height:20px;background-color:#ffff00">
     39              <div id="levelbar" style="height:19px; width:2px;background-color:red"></div>
     40              </div>';
     41    $html .= '<div> Status: <span id="status"></span></div>';
     42    $html .= '<input type="button" id="record" name="record" value="record" />';
     43    $html .= '<input type="button" id="stop" name="stop" value="Save/Stop"/>';
     44    $html .= '<input type="hidden" name="record_file" id="record_file" value="recorded_file'.get_the_ID().'"/>';
     45    echo $html;
    5246}
    5347/* Function to save the meta data
     
    5650*/
    5751function wpvr_save_audio( $post_id ) {
    58     $get_api_token = get_option( 'dropbox_api_token' );
    59     if ( isset( $get_api_token ) && ! empty( $get_api_token ) ) {
    60         $rec_upload_file = wp_upload_dir();
    61         $rec_path        = $rec_upload_file['baseurl'];
    62         $record_file     = 'recorded_file'.$post_id;
    63         update_post_meta( $post_id,'record_file', $rec_path . '/recorded_files/'. $record_file . '.wav' );
    64     }
     52    $rec_upload_file = wp_upload_dir();
     53    $rec_path        = $rec_upload_file['baseurl'];
     54    $record_file     = 'recorded_file'.$post_id;
     55    update_post_meta( $post_id,'record_file', $rec_path . '/recorded_files/'. $record_file . '.wav' );
    6556}
    6657add_action( 'save_post', 'wpvr_save_audio' );
  • wp-voice-recorder/trunk/readme.txt

    r1036601 r1355188  
    33Tags: WordPress,Voice Recorder, posts record
    44Requires at least: 3.1
    5 Tested up to: 4.0
    6 Stable tag: 1.0
     5Tested up to: 4.1
     6Stable tag: 1.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    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 a dropbox account instead of saving it to the server files as it eats up memory.
    15 It adds a settings page to "Dashboard"->"Settings"->"WP Voice Recorder Settings" where you can add your Dropbox account access token.
    16 If the field "Enter the Dropbox API token" was not set or invalid, it will not save the recorded files into your dropbox account.
     14WP 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.
     15
    1716
    1817= Usage =
     
    20191. Download and extract `wp-voice-recorder.zip` to `wp-content/plugins/`
    21202. Activate the plugin through the 'Plugins' menu in WordPress.
    22 3. "Dashboard"->"Settings"->"WP Voice Recorder Settings" to set your Dropbox Access Token.(Make sure that the dropbox API token is set and valid)
    23 4. 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.
    2422
    2523Special Thanks to
     
    33311. Download and extract `wp-voice-recorder.zip` to `wp-content/plugins/`
    34322. Activate the plugin through the 'Plugins' menu in WordPress.
    35 3. "Dashboard"->"Settings"->"WP Voice Recorder Settings"
    36 4.  It will create a recorder in each posts editor and there you can record your voice and publish or update your posts.
     333. It will create a recorder in each posts editor and there you can record your voice and publish or update your posts.
    3734
    3835== Changelog ==
     36# 1.1 - Removed the dropbox account feature.
    3937
    40 = Version 1.0 =
     38
     39= Version 1.1 =
    4140
    4241* Initial public release.
     
    4645
    4746== Screenshots ==
    48 1. screenshot-1.png
    49 2. screenshot-2.png
    50 3. screenshot-3.png
     472. screenshot-1.png
     483. screenshot-2.png
  • wp-voice-recorder/trunk/wpvr-recorder.php

    r1035822 r1355188  
    99*/
    1010include( 'lib/wpvr-voice-meta.php' );
    11 # Include the Dropbox SDK libraries
    12 include( 'dropbox-sdk/Dropbox/autoload.php' );
    13 use \Dropbox as dbx;
    14 global $file_urls;
    15 global $post_ids;
    16 $file_urls = array();
    17 $post_ids  = array();
     11
    1812
    1913/* function to enqueue scripts for the plugin
     
    3630}
    3731add_action( 'wp_enqueue_style', 'wpvr_add_style' );
     32
    3833/*  Function for adding subdirectory for post recorded files into the uploads folder on plugin activation
    3934* @param none
     
    5550*/
    5651function wpvr_admin_scripts( $hook_suffix ) {       
    57     $get_api_token = get_option( 'dropbox_api_token' );
    5852    if ( 'post.php' == $hook_suffix || 'post-new.php' == $hook_suffix ) {
    59         if ( isset( $get_api_token ) && ! empty( $get_api_token ) ) {
    60             wp_enqueue_script( 'jrecorder', plugins_url( 'js/jRecorder.js' , __FILE__ ), array('jquery') );   
    61             wp_enqueue_script( 'audiorec', plugins_url( 'js/wpvr-audio-recorder.js' , __FILE__ ), array( 'jrecorder' ) );
    62             $site_parameters = array(
    63                 'plugins_url' => plugins_url(),
    64                 'post_id' => get_the_ID(),
    65                 'ajaxurl' => admin_url( 'admin-ajax.php' ),
    66             );
    67             wp_localize_script( 'audiorec', 'wpvr_audio', $site_parameters ); 
    68             wp_localize_script( 'jrecorder', 'wpvr_variables', $site_parameters );
    69         }
    70         else {
    71             echo '<div id="message" class="error">Please Update Dropbox API access token in order to use WP Voice Recorder!!</div>';
    72         }
     53        wp_enqueue_script( 'jrecorder', plugins_url( 'js/jRecorder.js' , __FILE__ ), array('jquery') );   
     54        wp_enqueue_script( 'audiorec', plugins_url( 'js/wpvr-audio-recorder.js' , __FILE__ ), array( 'jrecorder' ) );
     55        $site_parameters = array(
     56            'plugins_url' => plugins_url(),
     57            'post_id' => get_the_ID(),
     58            'ajaxurl' => admin_url( 'admin-ajax.php' ),
     59        );
     60        wp_localize_script( 'audiorec', 'wpvr_audio', $site_parameters ); 
     61        wp_localize_script( 'jrecorder', 'wpvr_variables', $site_parameters );
    7362    }
    7463}
     
    7867add_action( 'wp_ajax_nopriv_wpvr_upload_file', 'wpvr_upload_file' );
    7968function wpvr_upload_file() {
    80         $upload_dir = wp_upload_dir();     
    81         //save the path in the uploads folder
    82         $upload_path = $upload_dir['basedir'] . '/recorded_files';
    83         $url = wp_get_referer();
    84         $host = parse_url($url, PHP_URL_QUERY);
    85         $split_url = explode( 'filename=',$host );
    86         $url_filename = $split_url[1];
    87         $filename = rtrim( $url_filename, '?action=wpvr_upload_file' );
    88         $fp          = fopen( $upload_path.'/'.$filename.'.wav', 'wb' );
    89         fwrite( $fp, file_get_contents( 'php://input' ) );
    90         fclose( $fp );
    91         # Include the Dropbox SDK libraries
    92         $accessToken        = get_option( 'dropbox_api_token' );
    93         $dbxClient          = new dbx\Client( $accessToken, 'PHP-Example/1.0' );
    94         $search_old_record  = $dbxClient->searchFileNames( '/', $filename.'.wav', null, false );
    95         if ( ! empty ( $search_old_record ) )
    96             $delete_old_record  = $dbxClient->delete( '/'.$filename.'.wav' );
    97         $f      = fopen( $upload_path.'/'.$filename.'.wav', 'rb' );
    98         $result = $dbxClient->uploadFile( '/'.$filename.'.wav', dbx\WriteMode::add(), $f );
    99         fclose( $f );
    100         unlink( $upload_path.'/'.$filename.'.wav' );
     69    $upload_dir = wp_upload_dir();     
     70    //save the path in the uploads folder
     71    $upload_path = $upload_dir['basedir'] . '/recorded_files';
     72    $url = wp_get_referer();
     73    $host = parse_url($url, PHP_URL_QUERY);
     74    $split_url = explode( 'filename=',$host );
     75    $url_filename = $split_url[1];
     76    $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 );
    10180}
    10281
     
    10786 */
    10887function wpvr_content_filter( $content ) {
    109     global $file_urls;
    110     global $post_ids;
    11188    $post_id        = $GLOBALS['post']->ID;
    112     $accessToken    = get_option( 'dropbox_api_token' );
    113     $dbxClient      = new dbx\Client( $accessToken, 'PHP-Example/1.0' );
    114     $file_url_array = $dbxClient->createTemporaryDirectLink( '/recorded_file'.$post_id.'.wav' );
    115     $file_url       = isset( $file_url_array ) ? $file_url_array[0] : '';
    116     if ( ! empty( $file_url ) ) {
    117         $post_ids[]     = $post_id;
    118         $file_urls[]    = $file_url;
     89    $upload_dir = wp_upload_dir();     
     90    //save the path in the uploads folder
     91    $upload_path = $upload_dir['basedir'] . '/recorded_files';
     92    $filename = 'recorded_file' . $post_id;
     93    if ( file_exists( $upload_path.'/'.$filename.'.wav' ) )
     94        $file_url = fopen( $upload_path.'/'.$filename.'.wav', 'rb' );
     95    else
     96        $file_url = '';
     97    if ( ! empty ( $file_url ) && is_single() )
    11998        require( 'lib/wpvr-jplayer-interface.php' );       
    120     }
    121     // Add play and record buttons to each post
    122     // Returns the content.
    12399    return $content;
    124100}
     
    126102
    127103function wpvr_run_script() {
    128     global $file_urls;
    129     global $post_ids;
     104    $post_id = get_the_id();
     105    $file_url = get_post_meta($post_id, 'record_file', true );
    130106    $site_parameters = array(
    131                 'file_url' => $file_urls,
     107                'file_url' => $file_url,
    132108                'plugin_url' => plugins_url(),
    133109                'theme_directory' => get_template_directory_uri(),
    134                 'post_id' => $post_ids,
     110                'post_id' => $post_id,
    135111            );
    136             //echo $file_url;
    137112    wp_localize_script( 'jplayerjs', 'wpvr_var', $site_parameters );
    138113}
    139114add_action( 'wp_footer' , 'wpvr_run_script' );
    140 /*
    141 * Add a submenu in the settings for wpvr_recorder to add options
    142 *
    143 */
    144 function wpvr_recorder_submenu() {
    145     add_submenu_page( 'options-general.php', 'WP Voice Recoder Settings', 'WP Voice Recoder Settings', 'manage_options', 'wpvr-recorder-submenu-page', 'wpvr_recorder_submenu_page_callback' );
    146 }
    147 add_action( 'admin_menu', 'wpvr_recorder_submenu' );
    148 /*
    149 * function to add the Submenu for WP Voice Recorder settings page under Settings and add the fields in it.
    150 * @param none
    151 * @return none
    152 */
    153 function wpvr_recorder_submenu_page_callback() {
    154     ?>
    155       <div class="wrap">
    156         <?php screen_icon( 'themes' ); ?> <h2>WP Voice Recorder Settings</h2>
    157         <?php if ( isset( $_POST['update_settings'] ) && ! empty ( $_POST['update_settings'] ) ) {
    158                 // Do the saving
    159                 $dropbox_api_token = esc_attr( $_POST['dropbox_api_token'] );   
    160                 update_option( 'dropbox_api_token', $dropbox_api_token );
    161                 echo '<div id="message" class="updated">Settings saved</div>';
    162                 if ( empty( $_POST['dropbox_api_token'] ) )
    163                     echo '<div id="message" class="error">Please fill in your Dropbox credential</div>';
    164             }
    165             $dropbox_api_token = get_option( 'dropbox_api_token' );   
    166         ?>
    167         <form method="POST" action="">
    168             <table class="form-table">
    169                 <tr valign="top">
    170                     <th scope="row">
    171                         <label for="dropbox_api_token">
    172                             Enter the API token for the Dropbox account
    173                         </label>
    174                     </th>
    175                     <td>
    176                         <input type="text" name="dropbox_api_token" value="<?php echo ( isset( $dropbox_api_token ) ) ? $dropbox_api_token : '' ?>" size="25" />               
    177                         <input type="hidden" name="update_settings" value="Y" />
    178                     </td>
    179                 </tr>
    180                 <tr>
    181                     <td>
    182                         <div class="button-holder"><input class="button-primary" name="submit" type="submit" value="Save Changes" /></div>
    183                     </td>
    184                 </tr>
    185             </table>
    186         </form>
    187     </div>
    188     <?php
    189 }
     115
     116
Note: See TracChangeset for help on using the changeset viewer.