| Server IP : 82.208.35.60 / Your IP : 216.73.216.168 Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31 System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64 User : studiokobylisy_cz ( 1008) PHP Version : 7.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/d2m/sofident_cz/wp-content/plugins/shortpixel-image-optimiser/class/external/ |
Upload File : |
<?php
namespace ShortPixel;
// Gravity Forms integrations.
class gravityForms
{
public function __construct()
{
add_filter( 'gform_save_field_value', array($this,'shortPixelGravityForms'), 10, 5 );
}
function shortPixelGravityForms( $value, $lead, $field, $form ) {
if($field->type == 'post_image') {
$this->handleGravityFormsImageField($value);
}
return $value;
}
public function handleGravityFormsImageField($value) {
$shortPixelObj = wpSPIO()->getShortPixel();
if(!($folder = $shortPixelObj->getSpMetaDao()->getFolder(SHORTPIXEL_UPLOADS_BASE . '/gravity_forms'))) {
return;
}
if(strpos($value , '|:|')) {
$cleanup = explode('|:|', $value);
$value = $cleanup[0];
}
//ShortPixel is monitoring the gravity forms folder, add the image to queue
$uploadDir = wp_upload_dir();
$localPath = str_replace($uploadDir['baseurl'], SHORTPIXEL_UPLOADS_BASE, $value);
return $shortPixelObj->addPathToCustomFolder($localPath, $folder->getId(), 0);
}
} // class
$g = new gravityForms();