1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
<?php
namespace MatthiasWeb\RealMediaLibrary\attachment;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
class Upload {
private static $me = null;
private function __construct() {
}
public function add_attachment($postID) {
$rmlFolder = isset($_REQUEST["rmlFolder"]) ? $_REQUEST["rmlFolder"] : null;
if ($rmlFolder !== null) {
$r = wp_rml_move($rmlFolder, array($postID));
}else{
_wp_rml_synchronize_attachment($postID, _wp_rml_root());
}
}
public function pre_upload_ui() {
global $pagenow;
if ($pagenow === "media-new.php") {
$options = '<select class="attachments-filter-preUploadUi">' . wp_rml_dropdown(Filter::getInstance()->lastQueriedFolder(), array(RML_TYPE_COLLECTION, RML_TYPE_ALL)) . '</select>';
$label = __("You can simply upload files directly to a folder. Select a folder and upload files.", RML_TD);
}else{
$options = '<select class="rml-wprfc-visible" data-wprfc="preUploadUi"><option selected="true" value="-1">' . __("Loading...", RML_TD) . '</option></select>';
$label = __("upload to folder", RML_TD);
}
echo '<p class="attachments-filter-upload-chooser">' . $label . '</p><p>' . $options . '</p>';
}
public static function getInstance() {
if (self::$me == null) {
self::$me = new Upload();
}
return self::$me;
}
}
?>