admin
3 months ago
field-groups
3 months ago
fields
1 week ago
fields-settings
3 months ago
forms
3 months ago
locations
3 months ago
modules
1 week ago
screens
3 months ago
acfe-deprecated-functions.php
2 years ago
acfe-field-functions.php
3 months ago
acfe-field-group-functions.php
3 months ago
acfe-file-functions.php
1 year ago
acfe-form-functions.php
3 months ago
acfe-helper-array-functions.php
3 months ago
acfe-helper-functions.php
3 months ago
acfe-helper-multi-functions.php
3 months ago
acfe-helper-string-functions.php
3 months ago
acfe-meta-functions.php
3 months ago
acfe-post-functions.php
3 months ago
acfe-screen-functions.php
3 months ago
acfe-template-functions.php
3 months ago
acfe-term-functions.php
3 months ago
acfe-user-functions.php
3 months ago
acfe-wp-functions.php
3 years ago
assets.php
3 months ago
compatibility-acf-5.8.php
4 months ago
compatibility-acf-5.9.php
3 months ago
compatibility-acf-6.5.php
3 months ago
compatibility-acf-6.8.6.php
1 week ago
compatibility.php
3 months ago
field-extend.php
4 months ago
field.php
4 months ago
hooks.php
3 months ago
init.php
3 months ago
local-meta.php
3 years ago
media.php
3 months ago
module-acf.php
3 months ago
module-db.php
3 months ago
module-l10n.php
3 months ago
module-legacy.php
3 years ago
module-manager.php
4 months ago
module-post.php
3 months ago
module-posts.php
4 months ago
module-upgrades.php
3 years ago
module.php
3 months ago
multilang.php
3 months ago
revisions.php
4 months ago
screen.php
3 months ago
settings.php
3 months ago
template-tags.php
3 months ago
third-party.php
3 years ago
upgrades.php
3 months ago
media.php
97 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')){ |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | if(!class_exists('acfe_media')): |
| 8 | |
| 9 | class acfe_media{ |
| 10 | |
| 11 | public $upload_field = false; |
| 12 | |
| 13 | /** |
| 14 | * construct |
| 15 | */ |
| 16 | function __construct(){ |
| 17 | |
| 18 | // hooks |
| 19 | add_filter('acf/upload_prefilter', array($this, 'attachment_upload'), 10, 3); |
| 20 | |
| 21 | // variations |
| 22 | acf_add_filter_variations('acfe/upload_dir', array('type', 'name', 'key'), 1); |
| 23 | acf_add_filter_variations('acfe/upload_file', array('type', 'name', 'key'), 1); |
| 24 | |
| 25 | } |
| 26 | |
| 27 | |
| 28 | /** |
| 29 | * attachment_upload |
| 30 | * |
| 31 | * acf/upload_prefilter |
| 32 | * |
| 33 | * @param $errors |
| 34 | * @param $file |
| 35 | * @param $field |
| 36 | * |
| 37 | * @return mixed |
| 38 | */ |
| 39 | function attachment_upload($errors, $file, $field){ |
| 40 | |
| 41 | // vars |
| 42 | $this->upload_field = $field; |
| 43 | |
| 44 | // filters |
| 45 | add_filter('upload_dir', array($this, 'handle_upload_dir'), 20); |
| 46 | add_filter('wp_handle_upload_prefilter', array($this, 'handle_upload_file'), 20); |
| 47 | |
| 48 | // return |
| 49 | return $errors; |
| 50 | |
| 51 | } |
| 52 | |
| 53 | |
| 54 | /** |
| 55 | * handle_upload_dir |
| 56 | * |
| 57 | * upload_dir:20 |
| 58 | * |
| 59 | * @param $uploads |
| 60 | * |
| 61 | * @return mixed|void |
| 62 | */ |
| 63 | function handle_upload_dir($uploads){ |
| 64 | |
| 65 | // vars |
| 66 | $field = $this->upload_field; |
| 67 | |
| 68 | // return |
| 69 | return apply_filters('acfe/upload_dir', $uploads, $field); |
| 70 | |
| 71 | } |
| 72 | |
| 73 | |
| 74 | /** |
| 75 | * handle_upload_file |
| 76 | * |
| 77 | * wp_handle_upload_prefilter:20 |
| 78 | * |
| 79 | * @param $file |
| 80 | * |
| 81 | * @return mixed|void |
| 82 | */ |
| 83 | function handle_upload_file($file){ |
| 84 | |
| 85 | // vars |
| 86 | $field = $this->upload_field; |
| 87 | |
| 88 | // return |
| 89 | return apply_filters('acfe/upload_file', $file, $field); |
| 90 | |
| 91 | } |
| 92 | |
| 93 | } |
| 94 | |
| 95 | acf_new_instance('acfe_media'); |
| 96 | |
| 97 | endif; |