Skip to content

Commit

Permalink
bugfix UPLOADS contant usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jerome-barbato committed Jan 20, 2023
1 parent a962fbb commit a71eec1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
5 changes: 3 additions & 2 deletions acf-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
---------

##1.3.2
#### Bugfix
- replaced use of UPLOAD constant

## 1.3.1
#### Bugfix
- slug on component for ACF >= 6
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 0 additions & 1 deletion fields/class-acf-field-components.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,6 @@ protected function fetch_available_field_groups()
/**
* Display slug form
*
* @param $post
* @return void
* @since 1.0.0
*/
Expand Down
11 changes: 7 additions & 4 deletions fields/class-acf-field-instagram_post.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit a71eec1

Please sign in to comment.