Changeset 40733
- Timestamp:
- 04/15/08 11:34:26 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
add-from-server/trunk/add-from-server.php
r39143 r40733 15 15 if( function_exists('deactivate_plugins') ) 16 16 deactivate_plugins(__FILE__); 17 wp_die( '<h1>Add From Server</h1> Sorry, This plugin requires WordPress 2.5+');17 wp_die(__('<h1>Add From Server</h1> Sorry, This plugin requires WordPress 2.5+', 'add-from-server')); 18 18 } 19 19 if( ! get_option('frmsvr_last_folder') ) … … 26 26 } 27 27 28 add_action('init', 'frmsvr_init'); 29 function frmsvr_init(){ 30 var_dump(PLUGINDIR . '/' . dirname(plugin_basename(__FILE__))); 31 load_plugin_textdomain('add-from-server', PLUGINDIR . '/' . dirname(plugin_basename(__FILE__))); 32 } 33 28 34 add_filter('media_upload_tabs', 'frmsvr_tabs'); 29 35 function frmsvr_tabs($tabs){ 30 36 if( current_user_can( 'unfiltered_upload' ) ) 31 $tabs['server'] = __('Add From Server' );37 $tabs['server'] = __('Add From Server', 'add-from-server'); 32 38 return $tabs; 33 39 } … … 89 95 $return = "<form action='$folderurl$base' method='POST'><table>"; 90 96 $return .= "<tr> 91 <th> Import</th>92 <th> Filename</th>97 <th>" . __('Import', 'add-from-server') . "</th> 98 <th>" . __('Filename', 'add-from-server') . "</th> 93 99 </tr>"; 94 100 $parent = realpath($base . '/..'); … … 96 102 $return .= "<tr> 97 103 <td> </td> 98 <td><strong><a href='$folderurl$parent'> Parent Folder</a></strong></td>104 <td><strong><a href='$folderurl$parent'>" . __('Parent Folder', 'add-from-server') . "</a></strong></td> 99 105 </tr>"; 100 106 foreach($files as $file){ … … 122 128 $ret = pu_checkbox(false); 123 129 if( $ret ) 124 $ret .= '(<em>Note: Will not take effect if selected file is within an upload folder at present</em>)<br />';130 $ret .= sprintf('(<em>%s</em>)<br />', __('Note: Will not take effect if selected file is within an upload folder at present', 'add-from-server')); 125 131 $return .= $ret; 126 132 } 127 133 128 134 $return .= ' 129 <input type="submit" name="submit" value=" Import selected files" />135 <input type="submit" name="submit" value=" ' . __('Import selected files', 'add-from-server') . '" /> 130 136 </form>'; 131 137 … … 141 147 if( $id ){ 142 148 echo "<script type='text/javascript'>jQuery('#attachments-count').text(1 * jQuery('#attachments-count').text() + 1);</script>"; 143 echo "<div class='updated'><p><em>$file</em> has been added to Media library</p></div>";149 echo '<div class="updated"><p>' . sprintf(__('<em>%s</em> has been added to Media library', 'add-from-server'), $file) . '</p></div>'; 144 150 } 145 151 } … … 175 181 176 182 global $wpdb; 177 $results = $wpdb->get_col( "SELECT ID FROM `{$wpdb->posts}` WHERE `guid` = '$url' AND `post_type` = 'attachment'");183 $results = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM `{$wpdb->posts}` WHERE `guid` = '%s' AND `post_type` = 'attachment'", $url) ); 178 184 if( count($results) > 0 ) 179 185 return $results[0]; //Kill function off at this point.. It exists in the media library allready. … … 184 190 $new_file = $uploads['path'] . '/' . $filename; 185 191 if ( false === @ copy( $file, $new_file ) ) 186 wp_die( printf( __('The uploaded file could not be copied to %s.' ), $uploads['path'] ));192 return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) ); 187 193 188 194 // Set correct file permissions … … 238 244 239 245 ?> 240 <h3><?php _e('Add From Server' ); ?></h3>241 242 <p><?php printf(__('Once you have selected files to be imported, Head over to the <a href="%s">Media Library tab</a> to add them to your post.' ), 'media-upload.php?type=image&tab=library&post_id=' . $post_id ); ?></p>243 244 <p><strong><?php _e('Current Directory' ); ?>: </strong><span id="cwd"><?php echo $cwd; ?></span></p>246 <h3><?php _e('Add From Server', 'add-from-server'); ?></h3> 247 248 <p><?php printf(__('Once you have selected files to be imported, Head over to the <a href="%s">Media Library tab</a> to add them to your post.', 'add-from-server'), 'media-upload.php?type=image&tab=library&post_id=' . $post_id ); ?></p> 249 250 <p><strong><?php _e('Current Directory', 'add-from-server'); ?>: </strong><span id="cwd"><?php echo $cwd; ?></span></p> 245 251 <div id="filesystem-list"> 246 252 <?php frmsvr_list_files('display') ?>
