Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
jerome-barbato committed Sep 18, 2024
1 parent ff4cd9b commit 0d378bb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions acf-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
/*
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.10
Version: 1.3.11
Author: Metabolism
License: MIT
*/

defined('ABSPATH') or die('No script kiddies please!');

define('ACF_EXTENSIONS_VERSION', '1.3.10');
define('ACF_EXTENSIONS_VERSION', '1.3.11');

/**
* Load up the translation files
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
CHANGELOG
---------

## 1.3.11
- Use curl with agent to download Instagram image

## 1.3.10
- Added aria label input on link selector

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name":"metabolism/acf-extensions",
"version": "1.3.10",
"version": "1.3.11",
"type": "wordpress-plugin",
"description": "ACF Extensions plugin with components, hidden field, dynamic select, inline micro editor, Instagram post, children and latest posts field",
"license": "MIT",
Expand Down
12 changes: 11 additions & 1 deletion fields/class-acf-field-instagram_post.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ public function update_value($value, $post_id=0, $field=array()){
$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')));

$ch = curl_init('https://www.instagram.com/p/'.$matches[0][1].'/media?size='.($field['size']??'m'));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36");

$imageContent = curl_exec($ch);

@file_put_contents($filepath, $imageContent);
curl_close($ch);

if( file_exists($filepath) )
$file_url = str_replace($wp_upload_dir['basedir'], $wp_upload_dir['baseurl'], $filepath);
Expand Down

0 comments on commit 0d378bb

Please sign in to comment.