attach-file
7 months ago
additional-preview-images.php
4 years ago
attach-file.php
6 months ago
changelog.php
6 months ago
icons.php
1 week ago
lock-options.php
1 week ago
package-settings.php
1 week ago
icons.php
253 lines
| 1 | |
| 2 | |
| 3 | |
| 4 | <div id="package-icons" class="tab-pane"> |
| 5 | <?php /* if(current_user_can('manage_options')){ ?> |
| 6 | <div id="icon-plupload-upload-ui" class="hide-if-no-js"> |
| 7 | <div id="icon-drag-drop-area"> |
| 8 | <div class="icon-drag-drop-inside"> |
| 9 | <input id="icon-plupload-browse-button" type="button" class="button-secondary" value="<?php echo __( "Upload New Icon" , "download-manager" ); ?>" class="btn" /> |
| 10 | </div> |
| 11 | </div> |
| 12 | </div> |
| 13 | |
| 14 | <?php |
| 15 | |
| 16 | $plupload_init = array( |
| 17 | 'runtimes' => 'html5,silverlight,flash,html4', |
| 18 | 'browse_button' => 'icon-plupload-browse-button', |
| 19 | 'container' => 'icon-plupload-upload-ui', |
| 20 | 'drop_element' => 'icon-drag-drop-area', |
| 21 | 'file_data_name' => 'icon-async-upload', |
| 22 | 'multiple_queues' => true, |
| 23 | 'url' => admin_url('admin-ajax.php'), |
| 24 | 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), |
| 25 | 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), |
| 26 | 'filters' => array(array('title' => __( "Allowed Files" , "download-manager" ), 'extensions' => 'png, jpg, gif')), |
| 27 | 'multipart' => true, |
| 28 | 'urlstream_upload' => true, |
| 29 | |
| 30 | // additional post data to send to our ajax hook |
| 31 | 'multipart_params' => array( |
| 32 | '_ajax_nonce' => wp_create_nonce('icon-upload'), |
| 33 | 'action' => 'icon_upload', // the ajax action name |
| 34 | ), |
| 35 | ); |
| 36 | |
| 37 | // we should probably not apply this filter, plugins may expect wp's media uploader... |
| 38 | $plupload_init = apply_filters('plupload_init', $plupload_init); |
| 39 | |
| 40 | ?> |
| 41 | |
| 42 | <script type="text/javascript"> |
| 43 | |
| 44 | jQuery(document).ready(function($){ |
| 45 | |
| 46 | // create the uploader and pass the config from above |
| 47 | var uploader = new plupload.Uploader(<?php echo json_encode($plupload_init); ?>); |
| 48 | |
| 49 | // checks if browser supports drag and drop upload, makes some css adjustments if necessary |
| 50 | uploader.bind('Init', function(up){ |
| 51 | var uploaddiv = jQuery('#icon-plupload-upload-ui'); |
| 52 | |
| 53 | if(up.features.dragdrop){ |
| 54 | uploaddiv.addClass('drag-drop'); |
| 55 | jQuery('#icon-drag-drop-area') |
| 56 | .bind('dragover.wp-uploader', function(){ uploaddiv.addClass('drag-over'); }) |
| 57 | .bind('dragleave.wp-uploader, drop.wp-uploader', function(){ uploaddiv.removeClass('drag-over'); }); |
| 58 | |
| 59 | }else{ |
| 60 | uploaddiv.removeClass('drag-drop'); |
| 61 | jQuery('#icon-drag-drop-area').unbind('.wp-uploader'); |
| 62 | } |
| 63 | }); |
| 64 | |
| 65 | uploader.init(); |
| 66 | |
| 67 | // a file was added in the queue |
| 68 | uploader.bind('FilesAdded', function(up, files){ |
| 69 | //var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10); |
| 70 | |
| 71 | jQuery('#icon-loading').slideDown(); |
| 72 | |
| 73 | |
| 74 | plupload.each(files, function(file){ |
| 75 | jQuery('#icon-filelist').html( |
| 76 | '<div class="file" id="' + file.id + '"><b>' + |
| 77 | |
| 78 | file.name + '</b> (<span>' + plupload.formatSize(0) + '</span>/' + plupload.formatSize(file.size) + ') ' + |
| 79 | '<div class="fileprogress"></div></div>'); |
| 80 | }); |
| 81 | |
| 82 | up.refresh(); |
| 83 | up.start(); |
| 84 | }); |
| 85 | |
| 86 | uploader.bind('UploadProgress', function(up, file) { |
| 87 | jQuery('#' + file.id + " .fileprogress").width(file.percent + "%"); |
| 88 | jQuery('#' + file.id + " span").html(plupload.formatSize(parseInt(file.size * file.percent / 100))); |
| 89 | }); |
| 90 | |
| 91 | |
| 92 | // a file was uploaded |
| 93 | uploader.bind('FileUploaded', function(up, file, response) { |
| 94 | |
| 95 | // this is your ajax response, update the DOM with it or something... |
| 96 | var jres = jQuery.parseJSON(response.response); |
| 97 | console.log(jres); |
| 98 | //response |
| 99 | jQuery('#' + file.id ).remove(); |
| 100 | var d = new Date(); |
| 101 | var ID = d.getTime(); |
| 102 | jQuery('#icon-loading').hide(); |
| 103 | jQuery('#w-icons').prepend("<img class='wdmiconfile' id='"+jres.fid+"' src='"+jres.url+"' style='padding:5px; margin:1px; float:left; border:#fff 2px solid;height: 32px;width:auto; ' /><input rel='wdmiconfile' style='display:none' type='radio' name='file[icon]' class='checkbox' value='"+jres.rpath+"' ></label>"); |
| 104 | |
| 105 | |
| 106 | }); |
| 107 | |
| 108 | }); |
| 109 | |
| 110 | </script> |
| 111 | <?php } */ ?> |
| 112 | <div class="w3eden"> |
| 113 | <div class="input-group input-group-lg"> |
| 114 | <input style="background: url(<?php echo esc_url(get_post_meta($post->ID,'__wpdm_icon', true)); ?>) no-repeat;background-size: 24px;padding-left: 40px;background-position:8px center;" id="wpdmiconurl" placeholder="<?php _e( "Icon URL" , "download-manager" ); ?>" value="<?php echo esc_url(get_post_meta($post->ID,'__wpdm_icon', true)); ?>" type="text" name="file[icon]" class="form-control input-lg" > |
| 115 | <div class="input-group-btn"> |
| 116 | <button type="button" class="btn btn-secondary wpdm-iconfinder">IconFinder</button> |
| 117 | </div> |
| 118 | </div> |
| 119 | |
| 120 | <script type="text/template" id="searchiconsmodal-tpl"> |
| 121 | <div class="modal-body"> |
| 122 | <div class="input-group input-group-lg"> |
| 123 | <input type="text" name="kw" id="sikw" class="form-control" placeholder="Type Something..."/> |
| 124 | <div class="input-group-btn"> |
| 125 | <button type="button" id="srci" class="btn btn-secondary">Search</button> |
| 126 | </div> |
| 127 | </div> |
| 128 | |
| 129 | <div id="srcdicons" style="margin-top: 20px"> |
| 130 | <div style="padding: 50px;text-align: center;color: #b7bdc9">— <?= __('Type Something & Search', 'download-manager'); ?> —</div> |
| 131 | </div> |
| 132 | </div> |
| 133 | <div class="text-muted" style="margin-top: 12px;font-size: 12px"> |
| 134 | <?= sprintf(__('Powered by %s', 'download-manager'), '<a target="_blank" href="https://www.iconfinder.com?ref=shaon">IconFinnder.com</a>'); ?> |
| 135 | </div> |
| 136 | </script> |
| 137 | |
| 138 | <script> |
| 139 | jQuery(function ($) { |
| 140 | $('body').on('click', '.wpdm-iconfinder', function (e) { |
| 141 | e.preventDefault(); |
| 142 | WPDM.dialog.show({ |
| 143 | title: '<?php echo esc_js(__('Search Icon', 'download-manager')); ?>', |
| 144 | content: document.getElementById('searchiconsmodal-tpl').innerHTML, |
| 145 | size: 'lg', icon: false |
| 146 | }); |
| 147 | }); |
| 148 | |
| 149 | function wpdmIconFinderSearch() { |
| 150 | WPDM.blockUI('#srcdicons'); |
| 151 | $.get(ajaxurl + '?action=wpdm_iconFinder&kw=' + $('#sikw').val(), function (res) { |
| 152 | $('#srcdicons').html(res); |
| 153 | WPDM.unblockUI('#srcdicons'); |
| 154 | }); |
| 155 | } |
| 156 | |
| 157 | $('body').on('keypress', '#sikw', function (e) { |
| 158 | if (e.keyCode === 13) { e.preventDefault(); wpdmIconFinderSearch(); return false; } |
| 159 | }); |
| 160 | $('body').on('click', '#srci', function (e) { |
| 161 | e.preventDefault(); wpdmIconFinderSearch(); return false; |
| 162 | }); |
| 163 | $('body').on('click', '.iconres', function () { |
| 164 | $('#wpdmiconurl').val($(this).data('icon')); |
| 165 | $('#wpdmiconurl').css('background-image', `url('${$(this).data('icon')}')`); |
| 166 | $(this).closest('.wpdm-dialog-wrapper').find('.wpdm-dialog__close').trigger('click'); |
| 167 | }); |
| 168 | }); |
| 169 | </script> |
| 170 | |
| 171 | </div> |
| 172 | <br clear="all" /> |
| 173 | <?php |
| 174 | $path = WPDM_BASE_DIR."assets/file-type-icons/"; |
| 175 | $_upload_dir = wp_upload_dir(); |
| 176 | $_upload_basedir = $_upload_dir['basedir']; |
| 177 | $c_path = $_upload_basedir.'/wpdm-file-type-icons/'; |
| 178 | $c_url = $_upload_dir['baseurl'].'/wpdm-file-type-icons/'; |
| 179 | $scan = scandir( $path ); |
| 180 | $k = 0; |
| 181 | $fileinfo = array(); |
| 182 | foreach( $scan as $v ) |
| 183 | { |
| 184 | if( $v=='.' or $v=='..' or is_dir($path.$v) ) continue; |
| 185 | |
| 186 | $fileinfo[$k]['file'] = 'download-manager/assets/file-type-icons/'.$v; |
| 187 | $fileinfo[$k]['name'] = $v; |
| 188 | $k++; |
| 189 | } |
| 190 | |
| 191 | if(file_exists($c_path)) { |
| 192 | $c_scan = scandir( $c_path ); |
| 193 | if(is_array($c_scan)) { |
| 194 | foreach ($c_scan as $v) { |
| 195 | if ($v == '.' or $v == '..' or is_dir($path . $v)) continue; |
| 196 | |
| 197 | $fileinfo[$k]['file'] = $c_url . $v; |
| 198 | $fileinfo[$k]['name'] = $v; |
| 199 | $k++; |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | |
| 205 | |
| 206 | ?> |
| 207 | <div id="w-icons"> |
| 208 | |
| 209 | <?php |
| 210 | $img = array('jpg','gif','jpeg','png', 'svg'); |
| 211 | foreach($fileinfo as $index=>$value): $tmpvar = explode(".",$value['file']); $ext = strtolower(end($tmpvar)); if(in_array($ext,$img)): ?> |
| 212 | <label> |
| 213 | <img class="wdmiconfile" id="<?php echo !strstr($value['file'], '://')?md5(plugins_url().'/'.$value['file']):md5($value['file']); ?>" src="<?php echo !strstr($value['file'], '://')?plugins_url().'/'.esc_attr($value['file']):esc_url($value['file']); ?>" alt="<?php echo $value['name'] ?>" style="padding:5px; margin:1px; float:left; border:#fff 2px solid;height: 32px;width:auto; " /> |
| 214 | </label> |
| 215 | <?php endif; endforeach; ?> |
| 216 | </div> |
| 217 | <script type="text/javascript"> |
| 218 | //border:#CCCCCC 2px solid |
| 219 | |
| 220 | <?php if(isset($_GET['action'])&&$_GET['action']=='edit'){ ?> |
| 221 | jQuery('#<?php echo md5(get_post_meta($post->ID,'__wpdm_icon', true)) ?>').addClass("iactive"); |
| 222 | <?php } ?> |
| 223 | jQuery('body').on('click', 'img.wdmiconfile',function(){ |
| 224 | jQuery('#wpdmiconurl').val(jQuery(this).attr('src')); |
| 225 | jQuery('#wpdmiconurl').css('background-image','url('+jQuery(this).attr('src')+')'); |
| 226 | jQuery('img.wdmiconfile').removeClass('iactive'); |
| 227 | jQuery(this).addClass('iactive'); |
| 228 | |
| 229 | |
| 230 | |
| 231 | }); |
| 232 | jQuery('#wpdmiconurl').on('change', function(){ |
| 233 | jQuery('#wpdmiconurl').css('background-image','url('+jQuery(this).val()+')'); |
| 234 | }); |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | </script> |
| 240 | <style> |
| 241 | |
| 242 | .iactive{ |
| 243 | -moz-box-shadow: inset 0 0 10px #5FAC4F; |
| 244 | -webkit-box-shadow: inset 0 0 10px #5FAC4F; |
| 245 | box-shadow: inset 0 0 10px #5FAC4F; |
| 246 | background: #D9FCD1; |
| 247 | } |
| 248 | </style> |
| 249 | |
| 250 | <div class="clear"></div> |
| 251 | </div> |
| 252 | |
| 253 |