PluginProbe
Depicter — Popup & Slider Builder / 1.9.2
Depicter — Popup & Slider Builder v1.9.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
← All changes | app/src/Document/Models/Elements/WooStockStatus.php +57 -2 1.3.0 → 1.9.2 View file →
@@ -2,8 +2,12 @@
2 2 namespace Depicter\Document\Models\Elements;
3 3
4 4 class WooStockStatus extends Text
5 5 {
6 +
7 + const IN_STOCK_CLASS= 'in-stock';
8 + const OUT_OF_STOCK_CLASS = 'out-of-stock';
9 +
6 10 /**
7 11 * Retrieves the content of element
8 12 *
9 13 * @return string
@@ -9,14 +13,65 @@
9 13 * @return string
10 14 */
11 15 protected function getContent(){
12 16 $content = $this->maybeReplaceDataSheetTags( $this->options->content );
17 + $statusClass = $this->maybeReplaceDataSheetTags( '{{{stockStatusClass}}}' );
13 18
14 - if( $content === 'In stock' ){
19 + if( $statusClass === self::IN_STOCK_CLASS ){
15 20 $content = $this->options->stockStatus->inStockText ?? $content;
16 - } elseif( $content === 'Out of stock' ) {
21 + } elseif( $statusClass === self::OUT_OF_STOCK_CLASS ) {
17 22 $content = $this->options->stockStatus->outOfStockText ?? $content;
18 23 }
19 24
20 25 return $content;
26 + }
27 +
28 + /**
29 + * Get element class names
30 + *
31 + * @return string
32 + */
33 + public function getClassNames() {
34 + return parent::getClassNames() . ' ' . $this->maybeReplaceDataSheetTags( '{{{stockStatusClass}}}' );
35 + }
36 +
37 + /**
38 + * Get list of selector and CSS for element
39 + *
40 + * @return array
41 + * @throws \JsonMapper_Exception
42 + */
43 + public function getSelectorAndCssList(){
44 +
45 + parent::getSelectorAndCssList();
46 +
47 + if ( !empty( $this->options->stockStatus->styles ) ) {
48 +
49 + $styles = $this->options->stockStatus->styles;
50 + foreach ( $this->devices as $device ) {
51 + if ( !empty( $styles->inStockTextColor->{$device} ) ) {
52 + $this->selectorCssList[ '.' . $this->getStyleSelector() . '.' . self::IN_STOCK_CLASS ][ $device ]['color'] = $styles->inStockTextColor->{$device};
53 + }
54 +
55 + if ( !empty( $styles->outOfStockTextColor->{$device} ) ) {
56 + $this->selectorCssList[ '.' . $this->getStyleSelector() . '.' . self::OUT_OF_STOCK_CLASS ][ $device ]['color'] = $styles->outOfStockTextColor->{$device};
57 + }
58 + }
59 + }
60 +
61 + if ( !empty( $this->options->stockStatus->hover ) ) {
62 +
63 + $styles = $this->options->stockStatus->hover;
64 + foreach ( $this->devices as $device ) {
65 + if ( !empty( $styles->inStockTextColor->{$device} ) ) {
66 + $this->selectorCssList[ '.' . $this->getStyleSelector() . '.' . self::IN_STOCK_CLASS ]['hover'][ $device ]['color'] = $styles->inStockTextColor->{$device};
67 + }
68 +
69 + if ( !empty( $styles->outOfStockTextColor->{$device} ) ) {
70 + $this->selectorCssList[ '.' . $this->getStyleSelector() . '.' . self::OUT_OF_STOCK_CLASS ]['hover'][ $device ]['color'] = $styles->outOfStockTextColor->{$device};
71 + }
72 + }
73 + }
74 +
75 + return $this->selectorCssList;
21 76 }
22 77 }