/** * Returns the singleton instance of the manager * @return mixed */ public static function instance() { if (!isset(self::$instance)) { $class = __CLASS__; self::$instance = new $class(); } return self::$instance; }
protected function task($item) { $index = $item['index']; $post_id = $item['post']; update_option('ilab_s3_import_current', $index + 1); $data = wp_get_attachment_metadata($post_id); $s3tool = ILabMediaToolsManager::instance()->tools['s3']; $data = $s3tool->updateAttachmentMetadata($data, $post_id); wp_update_attachment_metadata($post_id, $data); return false; }
/** * Determines if this tool is enabled or not */ public function enabled() { $enabled = get_option("ilab-media-tool-enabled-{$this->toolName}", true); if ($enabled && isset($this->toolInfo['dependencies'])) { foreach ($this->toolInfo['dependencies'] as $dep) { if (!$this->toolManager->toolEnabled($dep)) { return false; } } } return $enabled; }
<p><?php _e('ILAB Media Tools cannot be activated the same time as the <strong>Offload S3</strong>. Please deactive one before activating the other.', 'ilab-media-tools'); ?> </p> </div> <?php }); return; } // Directory defines define('ILAB_TOOLS_DIR', dirname(__FILE__)); define('ILAB_HELPERS_DIR', ILAB_TOOLS_DIR . '/helpers'); define('ILAB_CLASSES_DIR', ILAB_TOOLS_DIR . '/classes'); define('ILAB_VENDOR_DIR', ILAB_TOOLS_DIR . '/vendor'); define('ILAB_VIEW_DIR', ILAB_TOOLS_DIR . '/views'); // URL defines for CSS/JS $plug_url = plugin_dir_url(__FILE__); define('ILAB_PUB_JS_URL', $plug_url . 'public/js'); define('ILAB_PUB_CSS_URL', $plug_url . 'public/css'); define('ILAB_PUB_IMG_URL', $plug_url . 'public/img'); // Composer require_once ILAB_VENDOR_DIR . '/autoload.php'; // Helper functions require_once 'helpers/ilab-media-tool-helpers.php'; require_once 'helpers/ilab-media-tool-view.php'; require_once 'helpers/ilab-media-tool-wordpress-helpers.php'; require_once 'helpers/ilab-media-tool-geometry-helpers.php'; require_once 'classes/ilab-media-tools-manager.php'; register_activation_hook(__FILE__, [ILabMediaToolsManager::instance(), 'install']); register_deactivation_hook(__FILE__, [ILabMediaToolsManager::instance(), 'uninstall']);