Пример #1
0
    /**
     * Adds tab with AWS Elastic Transcoder configuration options
     */
    protected function __addAwsElasticTranscoderConfigTab()
    {
        $this->admin_page->addTab('AWS Elastic Transcoder', function ($data) {
            $config = Config::getInstance();
            $enabled = $config->get('elastic_transcoder.enabled');
            $config_file = $config->get('elastic_transcoder.config_file');
            ?>

      <br>
      <h3>Amazon Elastic Transcoder</h3>

      <input type="checkbox" name="<?php 
            echo Config::ELASTIC_TRANSCODER_CONFIG_OPTION_KEY;
            ?>
[enabled]" value="1" <?php 
            if ($enabled) {
                echo 'checked="checked"';
            }
            ?>
 <?php 
            if ($config->hasEnv('elastic_transcoder.enabled')) {
                echo 'disabled="disabled"';
            }
            ?>
>
      <label for="">Enabled</label>

      <br><br>
      <label>Configuration file</label><br>
      <input type="text" class="regular-text" name="<?php 
            echo Config::ELASTIC_TRANSCODER_CONFIG_OPTION_KEY;
            ?>
[config_file]" value="<?php 
            echo $config_file;
            ?>
" <?php 
            if ($config->hasEnv('elastic_transcoder.config_file')) {
                echo 'disabled="disabled"';
            }
            ?>
>
      <br>
      <span class="description">This should the a relative path inside the active theme</span>

      <br><br>
      <button class="button button-primary">Save</button>

    <?php 
        });
    }
Пример #2
0
 /**
  * Returns Google Cloud Storage filesystem
  * 
  * @return object Google Cloud Storage
  */
 protected function __getGCSFilesystem()
 {
     $config = Config::getInstance();
     $project_id = $config->get('storage.gcs.project_id');
     $auth_json = $config->get('storage.gcs.auth_json');
     $bucket_name = $config->get('storage.gcs.bucket');
     $prefix = $config->get('storage.gcs.prefix');
     if (!$project_id || !$auth_json || !$bucket_name) {
         return null;
     }
     // Init Google Cloud Storage client
     $client = new StorageClient(['projectId' => $project_id, 'keyFile' => json_decode($auth_json, true)]);
     // Get bucket object
     $bucket = $client->bucket($bucket_name);
     // Init adapter
     $adapter = new GoogleStorageAdapter($client, $bucket, $prefix);
     // Return Google Cloud Storage filesystem
     return new FlyFilesystem($adapter, ['visibility' => AdapterInterface::VISIBILITY_PUBLIC]);
 }
Пример #3
0
 /**
  * Used to delete the remote version of the
  * local file being deleted via the 'wp_delete_file' filter
  *
  * The 'wp_delete_file' filter is called for all image sizes,
  * so all the right files will be deleted by using it
  *
  * @param  string $file Absolute path to the file being deleted
  * @return void
  */
 public function __deleteRemoteFile($file)
 {
     // Remove uploads base path so that we end up
     // with the "/YYYY/MM/filename.extension" format
     $path = str_replace(Config::getInstance()->get('local.base_dir'), '', $file);
     // Delete remote file
     $fs = Filesystem::getInstance();
     if ($fs->remoteHas($path)) {
         $fs->deleteRemote($path);
     }
     // We must return the absolute path,
     // otherwise the local file won't be deleted
     return $file;
 }
Пример #4
0
 /**
  * Deletes remote files
  *
  * @link   https://www.gravityhelp.com/documentation/article/gform_delete_lead/ Gravity Forms hook documentation
  * @param  string $entry_id Entry ID
  * @return void
  */
 public function __deleteFilesFromRemote($entry_id)
 {
     // Get entry and form objects
     $entry = \GFAPI::get_entry($entry_id);
     $form = \GFAPI::get_form($entry['form_id']);
     // Get local base URL
     $local_base_url = Config::getInstance()->get('local.base_url');
     foreach ($form['fields'] as $field) {
         // Delete remote file
         if ($field->type == 'fileupload' && isset($entry[$field->id]) && $entry[$field->id]) {
             do_action('po_bebop_media.delete_file_from_remote', str_replace($local_base_url, '', $entry[$field->id]));
         }
     }
 }