PluginProbe
Depicter — Popup & Slider Builder / 1.6.2
Depicter — Popup & Slider Builder v1.6.2
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Document / Models / Elements / Svg.php

Svg.php in Depicter — Popup & Slider Builder 1.6.2, at app/src/Document/Models/Elements/Svg.php

64 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Document\Models\Elements;
3
4 use Depicter\Document\Models;
5 use Depicter\Html\Html;
6
7 class Svg extends Models\Element
8 {
9
10 public function render() {
11 $shapeContent = '';
12
13 if( ! empty( $this->options->content ) ){
14 $shapeContent = $this->options->content;
15 } elseif ( ! empty( $this->options->source ) && $shapeUrl = wp_get_attachment_url( $this->options->source ) ) {
16 $shapeContent = file_get_contents( $shapeUrl );
17 }
18
19 $args = $this->getDefaultAttributes();
20 $div = Html::div( $args, "\n\t" . $shapeContent . "\n" );
21
22 if ( false !== $a = $this->getLinkTag() ) {
23 return $a->nest( "\n" .$div ) . "\n";
24 }
25
26 return $div . "\n";
27 }
28
29 /**
30 * Get svg selector
31 *
32 * @return string
33 */
34 protected function getSvgSelector() {
35 return '.' . $this->getSelector() . ' svg, .' . $this->getSelector() . ' path';
36 }
37
38 /**
39 * Get styles of svg
40 *
41 * @return array|array[]
42 * @throws \JsonMapper_Exception
43 */
44 protected function getSvgCss() {
45 // Get styles list from styles property
46 return ! empty( $this->styles ) ? $this->styles->getSvgCss() : [];
47 }
48
49 /**
50 * Get list of selector and CSS for element
51 *
52 * @return array
53 * @throws \JsonMapper_Exception
54 */
55 public function getSelectorAndCssList(){
56 parent::getSelectorAndCssList();
57
58 // Add SVG selector and css
59 $this->selectorCssList[ $this->getSvgSelector() ] = $this->getSvgCss();
60
61 return $this->selectorCssList;
62 }
63 }
64