Changeset 1355188
- Timestamp:
- 02/21/2016 01:36:11 PM (10 years ago)
- Location:
- wp-voice-recorder
- Files:
-
- 3 deleted
- 8 edited
-
assets/screenshot-1.png (modified) (previous)
-
assets/screenshot-2.png (modified) (previous)
-
assets/screenshot-3.png (deleted)
-
trunk/dropbox-sdk (deleted)
-
trunk/js/jRecorder.js (modified) (2 diffs)
-
trunk/js/mfsjplayer.js (modified) (1 diff)
-
trunk/js/wpvr-audio-recorder.js (modified) (1 diff)
-
trunk/lib/flash-fla/org (deleted)
-
trunk/lib/wpvr-voice-meta.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (5 diffs)
-
trunk/wpvr-recorder.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-voice-recorder/trunk/js/jRecorder.js
r1035822 r1355188 61 61 'rec_left': '0px', 62 62 'recorderlayout_id' : 'flashrecarea', 63 'recorder_id' : ' audiorecorder',64 'recorder_name': ' audiorecorder',63 'recorder_id' : 'record', 64 'recorder_name': 'record', 65 65 'wmode' : 'transparent', 66 66 'bgcolor': '#ff0000', 67 'swf_path': wpvr_variables.plugins_url + '/wp vr-recorder/js/jRecorder.swf',67 'swf_path': wpvr_variables.plugins_url + '/wp-voice-recorder/js/jRecorder.swf', 68 68 'host' : wpvr_variables.ajaxurl + '/filename=recorded_file' + wpvr_variables.post_id + '?action=wpvr_upload_file', 69 69 'callback_started_recording' : function(){}, … … 132 132 $.jRecorder.record = function(max_time){ 133 133 //change z-index to make it top 134 $( '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', 1000 );134 $( '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', 10000); 135 135 var recorder = getFlashMovie(jRecorderSettings['recorder_name']); 136 136 137 getFlashMovie(jRecorderSettings['recorder_name']).jStartRecording(max_time); 137 138 -
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 } 1 jQuery(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 }); 20 15 }); -
wp-voice-recorder/trunk/js/wpvr-audio-recorder.js
r1035822 r1355188 10 10 callback_activityTime: function(time){callback_activityTime(time); }, 11 11 callback_finished_sending: function(time){ callback_finished_sending(); }, 12 swf_path : wpvr_audio.plugins_url + '/wp vr-recorder/js/jRecorder.swf',12 swf_path : wpvr_audio.plugins_url + '/wp-voice-recorder/js/jRecorder.swf', 13 13 } 14 14 ); -
wp-voice-recorder/trunk/lib/wpvr-voice-meta.php
r1035822 r1355188 11 11 */ 12 12 function 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 ); 22 19 } 23 20 add_action( 'add_meta_boxes', 'add_audio_recorder' ); … … 28 25 function wpvr_record_box() { 29 26 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; 52 46 } 53 47 /* Function to save the meta data … … 56 50 */ 57 51 function 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' ); 65 56 } 66 57 add_action( 'save_post', 'wpvr_save_audio' ); -
wp-voice-recorder/trunk/readme.txt
r1036601 r1355188 3 3 Tags: WordPress,Voice Recorder, posts record 4 4 Requires at least: 3.1 5 Tested up to: 4. 06 Stable tag: 1. 05 Tested up to: 4.1 6 Stable tag: 1.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 12 12 == Description == 13 13 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. 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. 15 17 16 18 17 = Usage = … … 20 19 1. Download and extract `wp-voice-recorder.zip` to `wp-content/plugins/` 21 20 2. 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. 21 3. It will create a recorder in each posts editor and there you can record your voice and publish or update your posts. 24 22 25 23 Special Thanks to … … 33 31 1. Download and extract `wp-voice-recorder.zip` to `wp-content/plugins/` 34 32 2. 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. 33 3. It will create a recorder in each posts editor and there you can record your voice and publish or update your posts. 37 34 38 35 == Changelog == 36 # 1.1 - Removed the dropbox account feature. 39 37 40 = Version 1.0 = 38 39 = Version 1.1 = 41 40 42 41 * Initial public release. … … 46 45 47 46 == Screenshots == 48 1. screenshot-1.png 49 2. screenshot-2.png 50 3. screenshot-3.png 47 2. screenshot-1.png 48 3. screenshot-2.png -
wp-voice-recorder/trunk/wpvr-recorder.php
r1035822 r1355188 9 9 */ 10 10 include( '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 18 12 19 13 /* function to enqueue scripts for the plugin … … 36 30 } 37 31 add_action( 'wp_enqueue_style', 'wpvr_add_style' ); 32 38 33 /* Function for adding subdirectory for post recorded files into the uploads folder on plugin activation 39 34 * @param none … … 55 50 */ 56 51 function wpvr_admin_scripts( $hook_suffix ) { 57 $get_api_token = get_option( 'dropbox_api_token' );58 52 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 ); 73 62 } 74 63 } … … 78 67 add_action( 'wp_ajax_nopriv_wpvr_upload_file', 'wpvr_upload_file' ); 79 68 function 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 ); 101 80 } 102 81 … … 107 86 */ 108 87 function wpvr_content_filter( $content ) { 109 global $file_urls;110 global $post_ids;111 88 $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() ) 119 98 require( 'lib/wpvr-jplayer-interface.php' ); 120 }121 // Add play and record buttons to each post122 // Returns the content.123 99 return $content; 124 100 } … … 126 102 127 103 function 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 ); 130 106 $site_parameters = array( 131 'file_url' => $file_url s,107 'file_url' => $file_url, 132 108 'plugin_url' => plugins_url(), 133 109 'theme_directory' => get_template_directory_uri(), 134 'post_id' => $post_id s,110 'post_id' => $post_id, 135 111 ); 136 //echo $file_url;137 112 wp_localize_script( 'jplayerjs', 'wpvr_var', $site_parameters ); 138 113 } 139 114 add_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.