sm:sync::syncFile

sm:sync::syncFile

Hook Type: action
See hook in action

See hook in core

Displaying hooks found in version: wp-stateless.3.4.1

do_action('sm:sync::syncFile') is found 33 times:

  • /lib/classes/compatibility/buddypress.php line 64
     
            $thumb_avatar_path = $wp_uploads_dir['basedir'] . '/' . apply_filters('wp_stateless_file_name', $thumb_avatar, false);
            $thumb_avatar = apply_filters('wp_stateless_file_name', $thumb_avatar, 0);
    
            do_action('sm:sync::syncFile', $full_avatar, $full_avatar_path, true, array('ephemeral' => false));
            do_action('sm:sync::syncFile', $thumb_avatar, $thumb_avatar_path, true, array('ephemeral' => false));
          }
    
          /**
           * Convert image url in image html to GCS URL.
           *
    
  • /lib/classes/compatibility/buddypress.php line 65
            $thumb_avatar_path = $wp_uploads_dir['basedir'] . '/' . apply_filters('wp_stateless_file_name', $thumb_avatar, false);
            $thumb_avatar = apply_filters('wp_stateless_file_name', $thumb_avatar, 0);
    
            do_action('sm:sync::syncFile', $full_avatar, $full_avatar_path, true, array('ephemeral' => false));
            do_action('sm:sync::syncFile', $thumb_avatar, $thumb_avatar_path, true, array('ephemeral' => false));
          }
    
          /**
           * Convert image url in image html to GCS URL.
           *
           * @param [type] $image_html html code for image.
    
  • /lib/classes/compatibility/buddypress.php line 112
              $full_avatar_path = WP_PLUGIN_DIR . '/' . $name;
            }
    
            if (strpos($name, "$root_dir/http") !== 0 && strpos($name, "http") !== 0 && $root_dir !== $name) {
              do_action('sm:sync::syncFile', $name, $full_avatar_path, false, array('ephemeral' => false));
              $url = ud_get_stateless_media()->get_gs_host() . '/' . $name;
            }
            return $url;
          }
    
          /**
    
  • /lib/classes/compatibility/buddypress.php line 173
                $root_dir = trim($root_dir, '/ '); // Remove any forward slash and empty space.
    
                if (!empty($name) && $root_dir . "/" != $name) {
                  $full_path = bp_attachments_get_attachment(false, $r);
                  do_action('sm:sync::syncFile', $name, $full_path, false, array('ephemeral' => false));
                  $return = ud_get_stateless_media()->get_gs_host() . '/' . $name;
                }
              }
            } catch (\Throwable $th) {
              //throw $th;
            }
    
  • /lib/classes/compatibility/elementor.php line 54
                $name = str_replace($wp_uploads_dir['baseurl'] . '/', '', $url);
                if ($name != $url) {
                  $absolutePath = $wp_uploads_dir['basedir'] . '/' . $name;
                  $name = apply_filters('wp_stateless_file_name', $name, 0);
                  do_action('sm:sync::syncFile', $name, $absolutePath);
    
                  if (!in_array(ud_get_stateless_media()->get('sm.mode'), ['disabled', 'backup'])) {
                    $url = ud_get_stateless_media()->get_gs_host() . '/' . $name;
                  }
                }
              }
    
  • /lib/classes/compatibility/ewww.php line 40
           */
          public function pre_optimization( $file, $type, $fullsize ) {
            // wp_stateless_file_name filter will remove the basedir from the path and prepend with root dir.
            $name = apply_filters( 'wp_stateless_file_name', $file );
            do_action( 'sm:sync::syncFile', $name, $file, true, array( 'ephemeral' => false, 'download' => true, 'use_root' => true ) );
          }
    
          /**
           * If image size not exist then upload it to GS.
           *
           * @param $file
    
  • /lib/classes/compatibility/ewww.php line 53
           */
          public function post_optimization( $file, $type, $fullsize ) {
            // wp_stateless_file_name filter will remove the basedir from the path and prepend with root dir.
            $name = apply_filters( 'wp_stateless_file_name', $file );
            do_action( 'sm:sync::syncFile', $name, $file, true, array( 'use_root' => true ) );
    
    
            // if($fullsize && file_exists($file . '.bak'))
            //     do_action( 'sm:sync::syncFile', $name . '.bak', $file . '.bak', true);
    
            if( file_exists( $file . '.webp' ) ) {
    
  • /lib/classes/compatibility/ewww.php line 57
            do_action( 'sm:sync::syncFile', $name, $file, true, array( 'use_root' => true ) );
    
    
            // if($fullsize && file_exists($file . '.bak'))
            //     do_action( 'sm:sync::syncFile', $name . '.bak', $file . '.bak', true);
    
            if( file_exists( $file . '.webp' ) ) {
              add_filter( 'upload_mimes', array( $this, 'add_webp_mime' ), 10, 2 );
              do_action( 'sm:sync::syncFile', $name . '.webp', $file . '.webp', true, array( 'use_root' => true ) );
              remove_filter( 'upload_mimes', array( $this, 'add_webp_mime' ), 10 );
            }
    
  • /lib/classes/compatibility/ewww.php line 61
            //     do_action( 'sm:sync::syncFile', $name . '.bak', $file . '.bak', true);
    
            if( file_exists( $file . '.webp' ) ) {
              add_filter( 'upload_mimes', array( $this, 'add_webp_mime' ), 10, 2 );
              do_action( 'sm:sync::syncFile', $name . '.webp', $file . '.webp', true, array( 'use_root' => true ) );
              remove_filter( 'upload_mimes', array( $this, 'add_webp_mime' ), 10 );
            }
          }
    
        }
    
    
  • /lib/classes/compatibility/gravity-forms-signature.php line 57
                $folder = \GFSignature::get_signatures_folder();
                $file_path = $folder . $value;
    
                $name = apply_filters('wp_stateless_file_name', $file_path);
                do_action('sm:sync::syncFile', $name, $file_path, true);
              } catch (\Throwable $th) {
                //throw $th;
              }
            }
            return $value;
          }
    
  • /lib/classes/compatibility/gravity-forms-signature.php line 80
                  $folder = \GFSignature::get_signatures_folder();
                  $name = $value['args'][0];
                  $file_path = $folder . $name . '.png';
                  $name = apply_filters('wp_stateless_file_name', $file_path);
                  do_action('sm:sync::syncFile', $name, $file_path);
                  $url = ud_get_stateless_media()->get_gs_host() . '/' . $name;
                  break;
                }
              }
            } catch (\Throwable $th) {
              //throw $th;
    
  • /lib/classes/compatibility/gravity-forms-signature.php line 128
            try {
              $folder = \GFSignature::get_signatures_folder();
              $absolute_path = $folder . $filename . '.png';
              $name = apply_filters('wp_stateless_file_name', $absolute_path, false);
              do_action('sm:sync::syncFile', $name, $absolute_path);
    
              if ( $mode !== 'backup' ) {
                $url = ud_get_stateless_media()->get_gs_host() . '/' . $name;
              }
            } catch (\Throwable $th) {
            }
    
  • /lib/classes/compatibility/gravity-forms.php line 77
                  $name = substr($v, $position);
                  $absolutePath = $dir['basedir'] . '/' .  $name;
                  $name = apply_filters('wp_stateless_file_name', $name, 0);
                  // doing sync
                  do_action('sm:sync::syncFile', $name, $absolutePath);
                  $value[$k] = ud_get_stateless_media()->get_gs_host() . '/' . $name;
                  // Todo add filter.
                }
              }
    
              if ($field->multipleFiles) {
    
  • /lib/classes/compatibility/gravity-forms.php line 105
     
                // doing sync
                $absolutePath = $dir['basedir'] . '/' .  $name;
                $name = apply_filters('wp_stateless_file_name', $name, 0);
                do_action('sm:sync::syncFile', $name, $absolutePath);
    
                $value = ud_get_stateless_media()->get_gs_host() . '/' . $name;
                // Todo add filter.
                if (version_compare($this->plugin_version, '2.3', '<')) { // older version
                  $result = $wpdb->update($lead_detail_table, array('value' => $value), array('lead_id' => $lead_detail_id, 'form_id' => $form['id'], 'field_number' => $field['id'],), array('%s'), array('%d'));
                } else { // New version
    
  • /lib/classes/compatibility/imagify.php line 199
              if (file_exists($backup_path)) {
                $overwrite = apply_filters('imagify_backup_overwrite_backup', false, $file_path, $backup_path);
                // wp_stateless_file_name filter will remove the basedir from the path and prepend with root dir.
                $name = apply_filters('wp_stateless_file_name', $backup_path);
                do_action('sm:sync::syncFile', $name, $backup_path, $overwrite);
              }
            }
          }
    
          /**
           * Restore backup file from GCS if not exist.
    
  • /lib/classes/compatibility/imagify.php line 215
            if (!file_exists($backup_path)) {
              $upload_dir = wp_upload_dir();
              $name = str_replace(trailingslashit($upload_dir['basedir']), '', $backup_path);
              $name = apply_filters('wp_stateless_file_name', $name);
              do_action('sm:sync::syncFile', $name, $backup_path, true);
            }
          }
    
          /**
           * Check if backup exists in GCS.
           * @param $return
    
  • /lib/classes/compatibility/imagify.php line 252
              add_filter('upload_mimes', array($this, 'add_webp_mime'), 10, 2);
              /**
               * Media already on GCS, so only replacing data on it. For webp format adding path and status to wp_sm_sync table
               */
              do_action('sm:sync::syncFile', $name, $file, true, array('use_root' => true, 'skip_db' => (substr($name, -4) == "webp" ? false : true)));
              remove_filter('upload_mimes', array($this, 'add_webp_mime'), 10);
            }
          }
    
          /**
           * @param $return
    
  • /lib/classes/compatibility/imagify.php line 274
              $attachment_id = $this->getProperties($this->getProperties($this->getProperties($process)['data'])['media'])['id'];
    
              $full_size_path = $file->get_path();
              $name = apply_filters('wp_stateless_file_name', basename($full_size_path), true, $attachment_id);
              do_action('sm:sync::syncFile', $name, $full_size_path, true, ['download' => true]);
              // error_log("\n\ndo_action( 'sm:sync::syncFile', $name, $full_size_path, true, ['download' => true] );");
            } catch (\Throwable $th) {
              //throw $th;
            }
            return $return;
          }
    
  • /lib/classes/compatibility/imagify.php line 275
     
              $full_size_path = $file->get_path();
              $name = apply_filters('wp_stateless_file_name', basename($full_size_path), true, $attachment_id);
              do_action('sm:sync::syncFile', $name, $full_size_path, true, ['download' => true]);
              // error_log("\n\ndo_action( 'sm:sync::syncFile', $name, $full_size_path, true, ['download' => true] );");
            } catch (\Throwable $th) {
              //throw $th;
            }
            return $return;
          }
    
    
  • /lib/classes/compatibility/lite-speed-cache.php line 105
            }
    
            $cloud_meta['fileMd5'][$gs_name] = md5_file($local_file);
            update_post_meta($row_img->post_id, 'sm_cloud', $cloud_meta);
            do_action('sm:sync::syncFile', $gs_name, $local_file, 2);
          }
    
          /**
           * Upload webp image after LS pulled the images.
           * @todo put md5_file hash creating here. $row_img might have attachment_id
           * @param $row_img
    
  • /lib/classes/compatibility/lite-speed-cache.php line 124
              $cloud_meta['fileMd5'][$gs_name] = md5_file($local_file);
              update_post_meta($row_img->post_id, 'sm_cloud', $cloud_meta);
    
              add_filter('upload_mimes', array($this, 'add_webp_mime'), 10, 2);
              do_action('sm:sync::syncFile', $gs_name, $local_file, 2, array('use_root' => true));
            }
          }
    
          /**
           * Bypassing the is_internal_file check on LiteSpeed Cache.
           * That check fails because we are replacing URL with GCS URL.
    
  • /lib/classes/compatibility/lite-speed-cache.php line 306
              foreach ($fileMd5 as $gs_name => $value) {
                $_gs_name = str_replace($root_dir, '', $gs_name);
                $local_file = $upload_dir['basedir'] . '/' . trim($_gs_name, '/');
    
                do_action('sm:sync::syncFile', $gs_name, $local_file, true);
              }
            }
          }
    
          /**
           * On manual sync/regenerate wp regenerate all image sizes.
    
  • /lib/classes/compatibility/lite-speed-cache.php line 349
                  $bk_file_optm = substr($file_path, 0, -strlen($extension)) . 'bk.optm.' . $extension;
                  if (file_exists($bk_file)) {
                    $gs_name = apply_filters('wp_stateless_file_name', $bk_file);
                    $cloud_meta['fileMd5'][$gs_name] = md5_file($bk_file);
                    do_action('sm:sync::syncFile', $gs_name, $bk_file);
                  } elseif (file_exists($bk_file_optm)) {
                    $gs_name = apply_filters('wp_stateless_file_name', $bk_file_optm);
                    $cloud_meta['fileMd5'][$gs_name] = md5_file($bk_file_optm);
                    do_action('sm:sync::syncFile', $gs_name, $bk_file_optm);
                  }
                }
    
  • /lib/classes/compatibility/lite-speed-cache.php line 353
                    do_action('sm:sync::syncFile', $gs_name, $bk_file);
                  } elseif (file_exists($bk_file_optm)) {
                    $gs_name = apply_filters('wp_stateless_file_name', $bk_file_optm);
                    $cloud_meta['fileMd5'][$gs_name] = md5_file($bk_file_optm);
                    do_action('sm:sync::syncFile', $gs_name, $bk_file_optm);
                  }
                }
    
                if ($optm_webp) {
                  $gs_name_webp = $file_path . '.webp';
                  $gs_name_webp_optm = $file_path . '.optm.webp';
    
  • /lib/classes/compatibility/lite-speed-cache.php line 363
                  $gs_name_webp_optm = $file_path . '.optm.webp';
                  if (file_exists($gs_name_webp)) {
                    $gs_name = apply_filters('wp_stateless_file_name', $gs_name_webp);
                    $cloud_meta['fileMd5'][$gs_name] = md5_file($gs_name_webp);
                    do_action('sm:sync::syncFile', $gs_name, $gs_name_webp);
                  } elseif (file_exists($gs_name_webp_optm)) {
                    $gs_name = apply_filters('wp_stateless_file_name', $gs_name_webp_optm);
                    $cloud_meta['fileMd5'][$gs_name] = md5_file($gs_name_webp_optm);
                    do_action('sm:sync::syncFile', $gs_name, $gs_name_webp_optm);
                  }
                }
    
  • /lib/classes/compatibility/lite-speed-cache.php line 367
                    do_action('sm:sync::syncFile', $gs_name, $gs_name_webp);
                  } elseif (file_exists($gs_name_webp_optm)) {
                    $gs_name = apply_filters('wp_stateless_file_name', $gs_name_webp_optm);
                    $cloud_meta['fileMd5'][$gs_name] = md5_file($gs_name_webp_optm);
                    do_action('sm:sync::syncFile', $gs_name, $gs_name_webp_optm);
                  }
                }
              }
            }
    
            update_post_meta($attachment_id, 'sm_cloud', $cloud_meta);
    
  • /lib/classes/compatibility/shortpixel.php line 292
              }
    
              $absolutePath = trailingslashit($backup_path) . basename($metadata['file']);
              $name = apply_filters('wp_stateless_file_name', SHORTPIXEL_BACKUP . '/' . $fullSubDir . basename($metadata['file']));
              do_action('sm:sync::syncFile', $name, $absolutePath, $force, $args);
    
              foreach ((array) $metadata['sizes'] as $image_size => $data) {
                $absolutePath = trailingslashit($backup_path) . $data['file'];
                $name = apply_filters('wp_stateless_file_name', SHORTPIXEL_BACKUP . '/' . $fullSubDir . $data['file']);
    
                do_action('sm:sync::syncFile', $name, $absolutePath, $force, $args);
    
  • /lib/classes/compatibility/shortpixel.php line 298
              foreach ((array) $metadata['sizes'] as $image_size => $data) {
                $absolutePath = trailingslashit($backup_path) . $data['file'];
                $name = apply_filters('wp_stateless_file_name', SHORTPIXEL_BACKUP . '/' . $fullSubDir . $data['file']);
    
                do_action('sm:sync::syncFile', $name, $absolutePath, $force, $args);
              }
            }
          }
    
          /**
           * Sync from sync tab
    
  • /lib/classes/compatibility/siteorigin-css.php line 67
              $name = substr($url, $position);
              // We need to get the absolute path before adding the bucket dir to name.
              $absolutePath = $upload_data['basedir'] . '/' . $name;
              $name = apply_filters('wp_stateless_file_name', $name, 0);
              do_action('sm:sync::syncFile', $name, $absolutePath);
              // echo "do_action( 'sm:sync::syncFile', $name, $absolutePath);\n";
              $url = ud_get_stateless_media()->get_gs_host() . '/' . $name;
            }
            return $url;
          }
        }
    
  • /lib/classes/compatibility/siteorigin-css.php line 68
              // We need to get the absolute path before adding the bucket dir to name.
              $absolutePath = $upload_data['basedir'] . '/' . $name;
              $name = apply_filters('wp_stateless_file_name', $name, 0);
              do_action('sm:sync::syncFile', $name, $absolutePath);
              // echo "do_action( 'sm:sync::syncFile', $name, $absolutePath);\n";
              $url = ud_get_stateless_media()->get_gs_host() . '/' . $name;
            }
            return $url;
          }
        }
      }
    
  • /lib/classes/compatibility/siteorigin-widget-bundle.php line 51
              $upload_data = wp_upload_dir();
              $name = substr($url, $position);
              $absolutePath = $upload_data['basedir'] . '/' . $name;
              $name = apply_filters('wp_stateless_file_name', $name, 0);
              do_action('sm:sync::syncFile', $name, $absolutePath);
              $url = ud_get_stateless_media()->get_gs_host() . '/' . $name;
            }
            return $url;
          }
    
          /**
    
  • /lib/classes/compatibility/wp-smush.php line 211
                $gs_name = $gs_dir . '/' . basename($data['file']);
                // Path of backup image
                $backup_path = $base_dir . '/' . basename($data['file']);
                // Sync backup image with GCS
                do_action('sm:sync::syncFile', apply_filters('wp_stateless_file_name', $gs_name), $backup_path);
                delete_transient('sm-wp-smush-backup-exists-' . $attachment_id);
              }
            }
          }
    
          /**
    
  • /lib/classes/sync/class-non-library-sync.php line 119
     
          $file_path = trim($item, '/');
          $fullsizepath = $upload_dir['basedir'] . '/' . $file_path;
    
          do_action('sm:sync::syncFile', $file_path, $fullsizepath, true, ['remove_from_queue' => true, 'manual_sync' => true]);
    
          $this->log(sprintf(__('%1$s (ID %2$s) was successfully synchronised in %3$s seconds.', ud_get_stateless_media()->domain), esc_html(get_the_title($file_path)), $file_path, timer_stop()));
    
          parent::task($item);
          return false;
        } catch (FatalException $e) {
    

See this hook used in plugins: