@@ -27,6 +27,7 @@ function __construct($field = array(), $value ='', $parent){
2727 * @since ReduxFramework 1.0.0
2828 */
2929 function render (){
30+ print_r ($ this ->value );
3031
3132 // No errors please
3233 $ defaults = array (
@@ -44,7 +45,6 @@ function render(){
4445 $ defaults = array (
4546 'top ' =>'' ,
4647 'right ' =>'' ,
47- 'mode ' => '' ,
4848 'bottom ' =>'' ,
4949 'left ' =>'' ,
5050 'mode ' =>'padding ' ,
@@ -70,13 +70,38 @@ function render(){
7070 if ( !empty ( $ this ->field ['mode ' ] ) ) {
7171 $ this ->field ['mode ' ] = $ this ->field ['mode ' ]."- " ;
7272 }
73-
7473
74+ $ oldval = $ this ->value ;
75+ $ this ->value = array ();
76+
77+ foreach ($ oldval as $ k =>$ v ) {
78+ if ($ k == "units " ) {
79+ continue ;
80+ }
81+ if (strpos ($ k , $ this ->field ['mode ' ]) === false ) {
82+ $ this ->value [$ k ] = str_replace ($ oldval ['units ' ], "" . $ v );
83+ } else {
84+ $ this ->value [$ str_replace ($ this ->field ['mode ' ].'- ' , "" , $ k )] = str_replace ($ oldval ['units ' ], "" . $ v );
85+ }
86+ }
87+
88+ $ defaults = array (
89+ 'top ' =>'' ,
90+ 'right ' =>'' ,
91+ 'bottom ' =>'' ,
92+ 'left ' =>'' ,
93+ 'units ' =>'' ,
94+ );
95+
96+ $ this ->value = wp_parse_args ( $ this ->value , $ defaults );
97+
98+
99+ print_r ($ this ->value );
75100 /**
76101 Top
77102 **/
78103 if ($ this ->field ['top ' ] === true ):
79- if ( !empty ($ this -> value [ ' top ' ] ) && strpos ( $ this ->value ['top ' ], $ this -> value [ ' units ' ] ) === false ) {
104+ if ( !empty ( $ this ->value ['top ' ] ) ) {
80105 $ this ->value ['top ' ] = filter_var ($ this ->value ['top ' ], FILTER_SANITIZE_NUMBER_INT );
81106 $ this ->value ['top ' ] = $ this ->value ['top ' ].$ this ->value ['units ' ];
82107 }
@@ -87,7 +112,7 @@ function render(){
87112 Right
88113 **/
89114 if ($ this ->field ['right ' ] === true ):
90- if ( !empty ($ this -> value [ ' right ' ] ) && strpos ( $ this ->value ['right ' ], $ this -> value [ ' units ' ] ) === false ) {
115+ if ( !empty ( $ this ->value ['right ' ] ) ) {
91116 $ this ->value ['right ' ] = filter_var ($ this ->value ['right ' ], FILTER_SANITIZE_NUMBER_INT );
92117 $ this ->value ['right ' ] = $ this ->value ['right ' ].$ this ->value ['units ' ];
93118 }
@@ -98,8 +123,11 @@ function render(){
98123 Bottom
99124 **/
100125 if ($ this ->field ['bottom ' ] === true ):
101- if ( !empty ($ this -> value [ ' bottom ' ] ) && strpos ( $ this ->value ['bottom ' ], $ this -> value [ ' units ' ] ) === false ) {
126+ if ( !empty ( $ this ->value ['bottom ' ] ) ) {
102127 $ this ->value ['bottom ' ] = filter_var ($ this ->value ['bottom ' ], FILTER_SANITIZE_NUMBER_INT );
128+ if ($ this ->field ['units ' ] !== false ) {
129+ $ this ->value ['bottom ' ] .= $ this ->value ['units ' ];
130+ }
103131 $ this ->value ['bottom ' ] = $ this ->value ['bottom ' ].$ this ->value ['units ' ];
104132 }
105133 echo '<div class="field-spacing-input input-prepend"><span class="add-on"><i class="icon-arrow-down icon-large"></i></span><input type="text" class="redux-spacing-bottom redux-spacing-input mini ' .$ this ->field ['class ' ].'" placeholder=" ' .__ ('Bottom ' ,'redux-framework ' ).'" rel=" ' .$ this ->field ['id ' ].'-bottom" value=" ' .filter_var ($ this ->value ['bottom ' ], FILTER_SANITIZE_NUMBER_INT ).'"><input type="hidden" class="redux-spacing-bottom mini ' .$ this ->field ['class ' ].'" placeholder=" ' .__ ('Bottom ' ,'redux-framework ' ).'" id=" ' .$ this ->field ['id ' ].'-bottom" name=" ' .$ this ->args ['opt_name ' ].'[ ' .$ this ->field ['id ' ].'][ ' .$ this ->field ['mode ' ].'bottom]" value=" ' .$ this ->value ['bottom ' ].'"></div> ' ;
@@ -109,7 +137,7 @@ function render(){
109137 Left
110138 **/
111139 if ($ this ->field ['left ' ] === true ):
112- if ( !empty ($ this -> value [ ' left ' ] ) && strpos ( $ this ->value ['left ' ], $ this -> value [ ' units ' ] ) === false ) {
140+ if ( !empty ( $ this ->value ['left ' ] ) ) {
113141 $ this ->value ['left ' ] = filter_var ($ this ->value ['left ' ], FILTER_SANITIZE_NUMBER_INT );
114142 $ this ->value ['left ' ] = $ this ->value ['left ' ].$ this ->value ['units ' ];
115143 }
@@ -121,7 +149,7 @@ function render(){
121149 Units
122150 **/
123151
124- // if ( $this->field['units'] !== false ):
152+ if ( $ this ->field ['units ' ] !== false ):
125153
126154 echo '<div class="select_wrapper spacing-units" original-title=" ' .__ ('Units ' ,'redux-framework ' ).'"> ' ;
127155 echo '<select data-placeholder=" ' .__ ('Units ' ,'redux-framework ' ).'" class="redux-spacing redux-spacing-units select ' .$ this ->field ['class ' ].'" original-title=" ' .__ ('Units ' ,'redux-framework ' ).'" name=" ' .$ this ->args ['opt_name ' ].'[ ' .$ this ->field ['id ' ].'][units]" id=" ' . $ this ->field ['id ' ].'_units"> ' ;
@@ -142,7 +170,7 @@ function render(){
142170 }
143171 echo '</select></div> ' ;
144172
145- // endif;
173+ endif ;
146174
147175
148176
0 commit comments