/** * Constructor. */ public function __construct($src, array $args, $output = 'STRING') { $this->src = $src; $this->args = $args; $this->output = $output; $local_source = beans_url_to_path($this->src); // Treat internal files as such if possible. if (file_exists($local_source)) { $this->src = $local_source; } }
/** * Setup image data. */ private function setup() { $wp_upload_dir = wp_upload_dir(); $upload_dir = beans_get_images_dir(); $path = beans_url_to_path($this->src); $info = pathinfo($path); $query = substr(md5(@serialize($this->args)), 0, 7); $extension = $info['extension']; $filename = str_replace('.' . $extension, '', $info['basename']); $this->path = $path; $this->rebuilt_path = "{$upload_dir}{$filename}-{$query}.{$extension}"; }
/** * Get internal file content. */ public function get_internal_content() { // Replace url with path. $fragment = beans_url_to_path($this->current_fragment); // Stop here if it isn't a valid file. if (!file_exists($fragment) || filesize($fragment) === 0) { return false; } // Handle content. $temp_handler = fopen($fragment, 'r'); $content = $this->replace_css_url(fread($temp_handler, filesize($fragment))); fclose($temp_handler); return $content; }
/** * Register a UIkit theme. * * The theme must not contain sub-folders. Component files in the theme will be automatically combined to * the UIkit compiler if that component is used. * * This function must be called in the 'beans_uikit_enqueue_scripts' action hook. * * @since 1.0.0 * * @param string $id A unique string used as a reference. Similar to the WordPress scripts $handle argument. * @param string $path Path to the UIkit theme folder. * * @return bool False on error or if already exists, true on success. */ function beans_uikit_register_theme($id, $path) { global $_beans_uikit_registered_items; // Stop here if already registered. if (beans_get($id, $_beans_uikit_registered_items['themes'])) { return true; } if (!$path) { return false; } if (stripos($path, 'http') !== false) { $path = beans_url_to_path($path); } $_beans_uikit_registered_items['themes'][$id] = trailingslashit($path); return true; }
/** * Get internal file content. */ public function get_internal_content() { $fragment = $this->current_fragment; if (!file_exists($fragment)) { // Replace url with path. $fragment = beans_url_to_path($fragment); // Stop here if it isn't a valid file. if (!file_exists($fragment) || 0 === @filesize($fragment)) { return false; } } // Safe to access filesystem since we made sure it was set. return $GLOBALS['wp_filesystem']->get_contents($fragment); }