From a71eec1dfe0242dbe3da4bb51d180f02b1bda718 Mon Sep 17 00:00:00 2001 From: Jerome Barbato Date: Fri, 20 Jan 2023 10:03:27 +0100 Subject: [PATCH] bugfix UPLOADS contant usage --- acf-extensions.php | 5 +++-- changelog.md | 4 ++++ composer.json | 4 ++-- fields/class-acf-field-components.php | 1 - fields/class-acf-field-instagram_post.php | 11 +++++++---- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/acf-extensions.php b/acf-extensions.php index 52450cc..cc4bae0 100644 --- a/acf-extensions.php +++ b/acf-extensions.php @@ -2,15 +2,16 @@ /* Plugin Name: Advanced Custom Fields Extensions Description: Advanced Custom Fields add on. Create components, component field, hidden field and latest post field - Version: 1.3.1 + Version: 1.3.2 Author: Metabolism + Author URI: https://github.com/wearemetabolism License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html */ defined('ABSPATH') or die('No script kiddies please!'); -define('ACF_EXTENSIONS_VERSION', '1.3.1'); +define('ACF_EXTENSIONS_VERSION', '1.3.2'); /** * Load up the translation files diff --git a/changelog.md b/changelog.md index 09af3f5..f869b8e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,10 @@ CHANGELOG --------- +##1.3.2 +#### Bugfix +- replaced use of UPLOAD constant + ## 1.3.1 #### Bugfix - slug on component for ACF >= 6 diff --git a/composer.json b/composer.json index 224d5f0..a74c20b 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name":"metabolism/acf-extensions", - "version": "1.3.1", - "homepage": "https://www.akhela.fr", + "version": "1.3.2", + "homepage": "https://github.com/wearemetabolism/wp-steroids", "type": "wordpress-plugin", "description": "ACF Extensions plugin with components, hidden field, dynamic select, inline micro editor, Instagram post, children and latest posts field", "license": "GPL-3.0-or-later", diff --git a/fields/class-acf-field-components.php b/fields/class-acf-field-components.php index 11f177b..e7f2556 100644 --- a/fields/class-acf-field-components.php +++ b/fields/class-acf-field-components.php @@ -758,7 +758,6 @@ protected function fetch_available_field_groups() /** * Display slug form * - * @param $post * @return void * @since 1.0.0 */ diff --git a/fields/class-acf-field-instagram_post.php b/fields/class-acf-field-instagram_post.php index 22bea5a..ee246bd 100644 --- a/fields/class-acf-field-instagram_post.php +++ b/fields/class-acf-field-instagram_post.php @@ -28,12 +28,13 @@ public function updateValue($value, $post_id=0, $field=array()){ if( !count($matches) || count($matches[0]) != 2) return false; - $filepath = ABSPATH . UPLOADS.'/instagram/'.$matches[0][1].'.jpg'; + $wp_upload_dir = wp_upload_dir(); + + $filepath = $wp_upload_dir['basedir'].'/instagram/'.$matches[0][1].'.jpg'; @file_put_contents($filepath, @file_get_contents('https://www.instagram.com/p/'.$matches[0][1].'/media?size='.($field['size']??'m'))); if( file_exists($filepath) ){ - $wp_upload_dir = wp_upload_dir(); $file_url = str_replace($wp_upload_dir['basedir'], $wp_upload_dir['baseurl'], $filepath); $body['thumbnail_url'] = $file_url; @@ -110,8 +111,10 @@ public function __construct() { parent::__construct(); - if( defined(UPLOADS) && !is_dir(ABSPATH . UPLOADS.'/instagram') ) - mkdir(ABSPATH . UPLOADS.'/instagram', 0777, true); + $wp_upload_dir = wp_upload_dir(); + + if( !is_dir($wp_upload_dir['basedir'] .'/instagram') ) + @mkdir($wp_upload_dir['basedir'].'/instagram', 0777, true); add_filter('acf/update_value', [$this, 'updateValue'], 10, 3); }