Skip to content
This repository was archived by the owner on Dec 2, 2022. It is now read-only.

Commit 529bd01

Browse files
committed
#209 - Added 'important' arg to output/compile array to override theme default.
Signed-off-by: Kevin Provance <kevin.provance@gmail.com>
1 parent 031504b commit 529bd01

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

redux-core/inc/classes/class-redux-field.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,13 @@ public function output( $style = '' ) {
259259
$this->field['compiler'] = array( $this->field['compiler'] );
260260
}
261261

262+
if ( isset( $this->field['compiler']['important'] ) ) {
263+
if ( $this->field['compiler']['important'] ) {
264+
$style = str_replace( ';', ' !important;', $style );
265+
}
266+
unset( $this->field['compiler']['important'] );
267+
}
268+
262269
if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
263270
$keys = implode( ',', $this->field['compiler'] );
264271
$this->parent->compilerCSS .= $keys . '{' . $style . '}';

redux-core/inc/fields/link_color/class-redux-link-color.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ public function output( $style = '' ) {
272272
if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
273273
$style_string = '';
274274

275+
if ( isset( $this->field['output']['important'] ) ) {
276+
if ( $this->field['output']['important'] ) {
277+
$style = str_replace( ';', ' !important;', $style );
278+
}
279+
unset( $this->field['output']['important'] );
280+
}
281+
275282
foreach ( $style as $key => $value ) {
276283
if ( is_numeric( $key ) ) {
277284
$style_string .= implode( ',', $this->field['output'] ) . '{' . $value . '}';
@@ -316,6 +323,13 @@ public function output( $style = '' ) {
316323
if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
317324
$style_string = '';
318325

326+
if ( isset( $this->field['compiler']['important'] ) ) {
327+
if ( $this->field['compiler']['important'] ) {
328+
$style = str_replace( ';', ' !important;', $style );
329+
}
330+
unset( $this->field['compiler']['important'] );
331+
}
332+
319333
foreach ( $style as $key => $value ) {
320334
if ( is_numeric( $key ) ) {
321335
$style_string .= implode( ',', $this->field['compiler'] ) . '{' . $value . '}';

sample/sections/color-selection/link-color.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
'hover' => '#bbb',
2828
'active' => '#ccc',
2929
),
30-
'output' => 'a',
30+
'output' => array(
31+
'a',
32+
'important' => true,
33+
),
3134

3235
// phpcs:ignore Squiz.PHP.CommentedOutCode
3336
// 'regular' => false, // Disable Regular Color.

0 commit comments

Comments
 (0)