Example #1
0
 public function __toString()
 {
     $semantics = Helpers\Utils::get_attrs_as_string($this->semantics);
     $viewbox = $this->viewbox;
     $classes = implode(' ', $this->classes);
     if ('img' === $this->semantics['role']) {
         $title = $this->title;
         $desc = $this->desc;
     }
     $identifier = !empty($this->file) ? $this->file . '#' . $this->id : '#' . $this->id;
     $output = '';
     $output .= "\r\n\t<svg xmlns='http://www.w3.org/2000/svg' {$semantics} viewbox='{$viewbox}' class='{$classes}'>";
     if (isset($title)) {
         $output .= "\r\n\t\t<title>{$title}</title>";
         if ($desc) {
             $output .= "\r\n\t\t<description>{$desc}</description>";
         }
     }
     $output .= "\r\n\t\t<use xlink:href='{$identifier}'></use>";
     $output .= "\r\n\t</svg>\r\n";
     return $output;
 }
 public function register_assets_by_manifest($manifest_subpath)
 {
     $url = static::get_url($manifest_subpath, true);
     $data = Helpers\Utils::read_json($url, array(), true, true);
     static::$asset_register->register_by_manifest($data);
     return $this;
 }
 public function _add_attr_helper($good_protocol_url, $original_url, $_context)
 {
     static::$test++;
     /*
     if (static::$test > 1) {
     	throw new \Exception("Called again");
     }
     */
     // RETURN, if no signs of script in SRC
     if (false === strpos($original_url, $this->current_script_attrs['url_identifier'])) {
         return $good_protocol_url;
     }
     // Remove this filter, to be used only if check above works
     remove_filter('clean_url', array($this, '_add_attr_helper'), 10, 3);
     // Create URL
     $url_parts = parse_url($good_protocol_url);
     $url = $url_parts['scheme'] . '://' . $url_parts['host'] . $url_parts['path'];
     // Get attr array
     $attrs = $this->current_script_attrs['attrs'];
     $attrs = \Cibulka\Plugin\Base\Helpers\Utils::get_attrs_as_string($attrs);
     $attr_as_string = rtrim("{$url}' {$attrs}", "'");
     // RETURN
     return $attr_as_string;
 }
 /**
  * Checks if value exists.
  *
  * - NOTE: Allows deep get. See $this->get().
  *
  * @param string $key
  * @param string|array $subkeys
  * @return bool
  */
 protected function exists($key, $subkeys = null)
 {
     $exists = isset($this->data[$key]);
     if ($exists && !empty($subkeys)) {
         $exists = UTILS::array_splat((array) $this->data[$key], $subkeys);
     }
     return $exists;
 }