/** * Initialize the editing. */ public function init() { $this->setup(); // Try to create image if it doesn't exist. if (!file_exists($this->rebuilt_path)) { // Return orginial image source if it can't be edited. if (!$this->edit()) { return $this->src; } } $src = beans_path_to_url($this->rebuilt_path); // Simply return the source if dimensions are not requested if ($this->output == 'STRING') { return $src; } // Get the new image dimensions list($width, $height) = @getimagesize($this->rebuilt_path); $array = array('src' => $src, 'width' => $width, 'height' => $height); if ($this->output == 'ARRAY_N') { return array_values($array); } elseif ($this->output == 'OBJECT') { return (object) $array; } return $array; }
<?php /** * * Load components. * * @ignore * * @package Beans */ // Mode. if (!defined('SCRIPT_DEBUG')) { define('SCRIPT_DEBUG', false); } // Assets. define('BEANS_MIN_CSS', SCRIPT_DEBUG ? '' : '.min'); define('BEANS_MIN_JS', SCRIPT_DEBUG ? '' : '.min'); // Path. define('BEANS_API_COMPONENTS_PATH', trailingslashit(dirname(__FILE__))); define('BEANS_API_COMPONENTS_ADMIN_PATH', BEANS_API_COMPONENTS_PATH . 'admin/'); // Load dependencies here as it is used further down. require_once BEANS_API_COMPONENTS_PATH . 'utilities/functions.php'; require_once BEANS_API_COMPONENTS_PATH . 'components.php'; // Url. define('BEANS_API_COMPONENTS_URL', beans_path_to_url(BEANS_API_COMPONENTS_PATH));
/** * replace_css_url() callback. */ public function css_path_to_url($matches, $base_is_path = false) { $base = $this->current_fragment; // Stop here if it isn't a internal file or not a valid format. if (preg_match('#^(http|https|\\/\\/|data)#', $matches[1]) == true) { return $matches[0]; } $explode_path = explode('../', $matches[1]); // Replace the base part according to the path "../". foreach ($explode_path as $value) { $base = dirname($base); } // Rebuild path. $replace = preg_replace('#^\\/#', '', $explode_path); $rebuilt_path = end($replace); // Make sure it is a valid base. if ($base === '.') { $base = ''; } // Rebuild url and make sure it is a valid one using the beans_path_to_url function. $url = beans_path_to_url(trailingslashit($base) . $rebuilt_path); // Return the rebuilt path converted to url. return 'url("' . $url . '")'; }
*/ // Stop here if the API was already loaded. if (defined('BEANS_API')) { return; } // Declare Beans API. define('BEANS_API', true); // Mode. if (!defined('SCRIPT_DEBUG')) { define('SCRIPT_DEBUG', false); } // Assets. define('BEANS_MIN_CSS', SCRIPT_DEBUG ? '' : '.min'); define('BEANS_MIN_JS', SCRIPT_DEBUG ? '' : '.min'); // Path. if (!defined('BEANS_API_PATH')) { define('BEANS_API_PATH', wp_normalize_path(trailingslashit(dirname(__FILE__)))); } define('BEANS_API_ADMIN_PATH', BEANS_API_PATH . 'admin/'); // Load dependencies here as it is used further down. require_once BEANS_API_PATH . 'utilities/functions.php'; require_once BEANS_API_PATH . 'utilities/deprecated.php'; require_once BEANS_API_PATH . 'components.php'; // Url. if (!defined('BEANS_API_URL')) { define('BEANS_API_URL', beans_path_to_url(BEANS_API_PATH)); } // Backwards compatibility constants. define('BEANS_API_COMPONENTS_PATH', BEANS_API_PATH); define('BEANS_API_COMPONENTS_ADMIN_PATH', BEANS_API_PATH . 'admin/'); define('BEANS_API_COMPONENTS_URL', BEANS_API_URL);