You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.0 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <?php
  2. /**
  3. * Plugin Name: Wpstudio Media Cloud Transform
  4. * Plugin URI: PLUGIN SITE HERE
  5. * Description: PLUGIN DESCRIPTION HERE
  6. * Author: YOUR NAME HERE
  7. * Author URI: YOUR SITE HERE
  8. * Text Domain: wpstudio-media-cloud-transform
  9. * Domain Path: /languages
  10. * Version: 0.1.0
  11. *
  12. * @package Wpstudio_Media_Cloud_Transform
  13. */
  14. use WpsMcloud\Actions;
  15. use WpsMcloud\Exceptions\VendorAutoloadException;
  16. use WpsMcloud\Pages;
  17. use WpsMcloud\Logger;
  18. define('WPSTUDIO_MEDIA_CLOUD_TRANFORM_BASE_PATH', dirname(__FILE__));
  19. add_action('admin_menu', fn () => add_submenu_page(
  20. 'media-cloud',
  21. 'Convert local to S3',
  22. 'Convert local to S3',
  23. 'manage_options',
  24. 'convert_local_to_s3',
  25. function () {
  26. // $ilabLoader = require dirname(__FILE__) . '/../ilab-media-tools/vendor/autoload.php';
  27. //
  28. // $ilabClassLoader = new Composer\Autoload\ClassLoader();
  29. // $ilabLoader->unregister();
  30. include __DIR__ . '/src/Support/helpers.php';
  31. $localVendorAutoloadPath = 'vendor/autoload.php';
  32. $projectVendorAutoloadPath = ABSPATH . 'vendor/autoload.php';
  33. if (file_exists($localVendorAutoloadPath)) {
  34. include $localVendorAutoloadPath;
  35. } elseif (file_exists($projectVendorAutoloadPath)) {
  36. include $projectVendorAutoloadPath;
  37. } else {
  38. throw new VendorAutoloadException('Unable to find appropriate composer autoloader');
  39. }
  40. $dotEnvFile = __DIR__ . '/.env';
  41. if (file_exists($dotEnvFile)) {
  42. $dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
  43. $dotenv->load();
  44. }
  45. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  46. $loggerConfig = include __DIR__ . '/config/logger.php';
  47. $logger = new Logger($loggerConfig['log_type']);
  48. echo '<pre>';
  49. (new Actions\Convert())->run();
  50. echo '</pre>';
  51. }
  52. (new Pages\Converter())->render();
  53. },
  54. 6
  55. ), 99);