media-library-file.php
7 months ago
remote-url.php
2 years ago
server-file.php
3 years ago
upload-file.php
7 months ago
server-file.php
48 lines
| 1 | <?php |
| 2 | if(!defined("ABSPATH")) die("Shit happens!"); |
| 3 | |
| 4 | if(current_user_can('access_server_browser')) { ?> |
| 5 | <div class="w3eden"> |
| 6 | <button type="button" class="btn btn-warning btn-block" id="attachsf" |
| 7 | style="margin-top: 10px"><?php echo __("Select from server", "download-manager"); ?></button> |
| 8 | <script> |
| 9 | jQuery(function ($) { |
| 10 | $('body').on('click', '#attachsf', function (e) { |
| 11 | e.preventDefault(); |
| 12 | hide_asset_picker_frame(); |
| 13 | $(window.parent.document.body).append("<iframe id='wpdm-asset-picker' style='left:0;top:0;width: 100%;height: 100%;z-index: 999999999;position: fixed;background: rgba(255,255,255,0.4) url('<?php echo WPDM_ASSET_URL.'images/loader.svg'; ?>') center center no-repeat;background-size: 100px 100px;border: 0;' src='<?php echo admin_url('/index.php?assetpicker=1'); ?>'></iframe>"); |
| 14 | |
| 15 | }); |
| 16 | }); |
| 17 | |
| 18 | function hide_asset_picker_frame() { |
| 19 | jQuery('#wpdm-asset-picker').remove(); |
| 20 | } |
| 21 | |
| 22 | function attach_server_files(files) { |
| 23 | jQuery.each(files, function (index, file) { |
| 24 | var d = new Date(); |
| 25 | var ID = d.getTime(); |
| 26 | var html = jQuery('#wpdm-file-entry').html(); |
| 27 | var ext = file.name.split('.'); |
| 28 | ext = ext[ext.length - 1]; |
| 29 | if (ext.indexOf('://')) ext = 'url'; |
| 30 | else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == '') ext = '_blank'; |
| 31 | var icon = "<?php echo WPDM_BASE_URL; ?>file-type-icons/" + ext.toLowerCase() + ".png"; |
| 32 | var title = file.name; |
| 33 | title = title.split('/'); |
| 34 | title = title[title.length - 1]; |
| 35 | |
| 36 | var _file = {}; |
| 37 | _file.filetitle = file.name; |
| 38 | _file.filepath = file.path; |
| 39 | _file.fileindex = ID; |
| 40 | _file.preview = icon; |
| 41 | wpdm_attach_file(_file); |
| 42 | |
| 43 | }); |
| 44 | } |
| 45 | </script> |
| 46 | </div> |
| 47 | <?php |
| 48 | } |