@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | 'cancel_text' => 'Cancel', |
| 40 | 40 | 'show_buttons' => true, |
| 41 | 41 | 'use_extended_classes' => true, |
| 42 | - 'palette' => null, // show default. |
|
| 42 | + 'palette' => null, // show default. |
|
| 43 | 43 | ), |
| 44 | 44 | 'groups' => array( |
| 45 | 45 | esc_html__( 'Header', 'your-textdomain-here' ) => array( |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | 'group' => esc_html__( 'Header', 'your-textdomain-here' ), |
| 77 | 77 | ), |
| 78 | 78 | array( |
| 79 | - 'id' => 'home-link', // ID. |
|
| 80 | - 'title' => 'home link', // Display text. |
|
| 81 | - 'color' => '#fdfdfd', // Default colour. |
|
| 82 | - 'alpha' => 1, // Default alpha. |
|
| 83 | - 'selector' => '.home-link,.wp-block-site-title a', // CSS selector. |
|
| 84 | - 'mode' => 'color', // CSS mode. |
|
| 85 | - 'important' => true, // CSS important. |
|
| 79 | + 'id' => 'home-link', // ID. |
|
| 80 | + 'title' => 'home link', // Display text. |
|
| 81 | + 'color' => '#fdfdfd', // Default colour. |
|
| 82 | + 'alpha' => 1, // Default alpha. |
|
| 83 | + 'selector' => '.home-link,.wp-block-site-title a', // CSS selector. |
|
| 84 | + 'mode' => 'color', // CSS mode. |
|
| 85 | + 'important' => true, // CSS important. |
|
| 86 | 86 | 'group' => esc_html__( 'Header', 'your-textdomain-here' ), |
| 87 | 87 | ), |
| 88 | 88 | array( |
@@ -11,214 +11,214 @@ |
||
| 11 | 11 | defined( 'ABSPATH' ) || exit; |
| 12 | 12 | |
| 13 | 13 | Redux::set_section( |
| 14 | - $opt_name, |
|
| 15 | - array( |
|
| 16 | - 'title' => esc_html__( 'Color Schemes', 'your-textdomain-here' ), |
|
| 17 | - 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-extensions/color-schemes.html" target="_blank">https://devs.redux.io/core-extensions/color-schemes.html</a>', |
|
| 18 | - 'subsection' => true, |
|
| 19 | - 'fields' => array( |
|
| 20 | - array( |
|
| 21 | - 'id' => 'opt-color-scheme', |
|
| 22 | - 'type' => 'color_scheme', |
|
| 23 | - 'title' => esc_html__( 'Color Schemes', 'your-textdomain-here' ), |
|
| 24 | - 'subtitle' => esc_html__( 'Save and load color schemes', 'your-textdomain-here' ), |
|
| 25 | - 'desc' => esc_html__( 'If you\'re using the theme 2023, you will be able to see many changes on the current site.', 'your-textdomain-here' ), |
|
| 26 | - 'output' => true, |
|
| 27 | - 'compiler' => true, |
|
| 28 | - 'simple' => false, |
|
| 29 | - 'options' => array( |
|
| 30 | - 'show_input' => true, |
|
| 31 | - 'show_initial' => true, |
|
| 32 | - 'show_alpha' => true, |
|
| 33 | - 'show_palette' => true, |
|
| 34 | - 'show_palette_only' => false, |
|
| 35 | - 'show_selection_palette' => true, |
|
| 36 | - 'max_palette_size' => 10, |
|
| 37 | - 'allow_empty' => true, |
|
| 38 | - 'clickout_fires_change' => false, |
|
| 39 | - 'choose_text' => 'Choose', |
|
| 40 | - 'cancel_text' => 'Cancel', |
|
| 41 | - 'show_buttons' => true, |
|
| 42 | - 'use_extended_classes' => true, |
|
| 43 | - 'palette' => null, // show default. |
|
| 44 | - ), |
|
| 45 | - 'groups' => array( |
|
| 46 | - esc_html__( 'Header', 'your-textdomain-here' ) => array( |
|
| 47 | - 'desc' => esc_html__( 'Set header and nav colors here. (Group open by default)', 'your-textdomain-here' ), |
|
| 48 | - 'hidden' => false, |
|
| 49 | - 'accordion_open' => true, |
|
| 50 | - ), |
|
| 51 | - esc_html__( 'Body', 'your-textdomain-here' ) => esc_html__( 'Set body and content colors here.', 'your-textdomain-here' ), |
|
| 52 | - esc_html__( 'Widget', 'your-textdomain-here' ) => '', |
|
| 53 | - '' => esc_html__( 'These colors are not assigned to any group.', 'your-textdomain-here' ), |
|
| 54 | - ), |
|
| 55 | - 'default' => array( |
|
| 56 | - array( |
|
| 57 | - 'id' => 'site-header', |
|
| 58 | - 'title' => 'site header', |
|
| 59 | - 'color' => '#980000', |
|
| 60 | - 'alpha' => 1, |
|
| 61 | - 'selector' => array( |
|
| 62 | - 'background' => '.site-header-main,header', |
|
| 63 | - 'color' => '.tester', |
|
| 64 | - ), |
|
| 65 | - 'mode' => 'background-color', |
|
| 66 | - 'important' => true, |
|
| 67 | - 'group' => esc_html__( 'Header', 'your-textdomain-here' ), |
|
| 68 | - ), |
|
| 69 | - array( |
|
| 70 | - 'id' => 'site-header-border', |
|
| 71 | - 'title' => 'site header border', |
|
| 72 | - 'color' => '#ff0000', |
|
| 73 | - 'alpha' => 1, |
|
| 74 | - 'selector' => '.site-header,header', |
|
| 75 | - 'mode' => 'border-color', |
|
| 76 | - 'important' => true, |
|
| 77 | - 'group' => esc_html__( 'Header', 'your-textdomain-here' ), |
|
| 78 | - ), |
|
| 79 | - array( |
|
| 80 | - 'id' => 'home-link', // ID. |
|
| 81 | - 'title' => 'home link', // Display text. |
|
| 82 | - 'color' => '#fdfdfd', // Default colour. |
|
| 83 | - 'alpha' => 1, // Default alpha. |
|
| 84 | - 'selector' => '.home-link,.wp-block-site-title a', // CSS selector. |
|
| 85 | - 'mode' => 'color', // CSS mode. |
|
| 86 | - 'important' => true, // CSS important. |
|
| 87 | - 'group' => esc_html__( 'Header', 'your-textdomain-here' ), |
|
| 88 | - ), |
|
| 89 | - array( |
|
| 90 | - 'id' => 'site-description', |
|
| 91 | - 'title' => 'site description', |
|
| 92 | - 'color' => '#ededed', |
|
| 93 | - 'alpha' => 1, |
|
| 94 | - 'selector' => 'h2.site-description,.wp-block-site-tagline', |
|
| 95 | - 'mode' => 'color', |
|
| 96 | - 'important' => true, |
|
| 97 | - 'group' => esc_html__( 'Header', 'your-textdomain-here' ), |
|
| 98 | - ), |
|
| 99 | - array( |
|
| 100 | - 'id' => 'navbar', |
|
| 101 | - 'title' => 'navbar', |
|
| 102 | - 'color' => '#e06666', |
|
| 103 | - 'alpha' => 1, |
|
| 104 | - 'selector' => '.navbar,.wp-block-navigation', |
|
| 105 | - 'mode' => 'background-color', |
|
| 106 | - 'group' => esc_html__( 'Header', 'your-textdomain-here' ), |
|
| 14 | + $opt_name, |
|
| 15 | + array( |
|
| 16 | + 'title' => esc_html__( 'Color Schemes', 'your-textdomain-here' ), |
|
| 17 | + 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-extensions/color-schemes.html" target="_blank">https://devs.redux.io/core-extensions/color-schemes.html</a>', |
|
| 18 | + 'subsection' => true, |
|
| 19 | + 'fields' => array( |
|
| 20 | + array( |
|
| 21 | + 'id' => 'opt-color-scheme', |
|
| 22 | + 'type' => 'color_scheme', |
|
| 23 | + 'title' => esc_html__( 'Color Schemes', 'your-textdomain-here' ), |
|
| 24 | + 'subtitle' => esc_html__( 'Save and load color schemes', 'your-textdomain-here' ), |
|
| 25 | + 'desc' => esc_html__( 'If you\'re using the theme 2023, you will be able to see many changes on the current site.', 'your-textdomain-here' ), |
|
| 26 | + 'output' => true, |
|
| 27 | + 'compiler' => true, |
|
| 28 | + 'simple' => false, |
|
| 29 | + 'options' => array( |
|
| 30 | + 'show_input' => true, |
|
| 31 | + 'show_initial' => true, |
|
| 32 | + 'show_alpha' => true, |
|
| 33 | + 'show_palette' => true, |
|
| 34 | + 'show_palette_only' => false, |
|
| 35 | + 'show_selection_palette' => true, |
|
| 36 | + 'max_palette_size' => 10, |
|
| 37 | + 'allow_empty' => true, |
|
| 38 | + 'clickout_fires_change' => false, |
|
| 39 | + 'choose_text' => 'Choose', |
|
| 40 | + 'cancel_text' => 'Cancel', |
|
| 41 | + 'show_buttons' => true, |
|
| 42 | + 'use_extended_classes' => true, |
|
| 43 | + 'palette' => null, // show default. |
|
| 44 | + ), |
|
| 45 | + 'groups' => array( |
|
| 46 | + esc_html__( 'Header', 'your-textdomain-here' ) => array( |
|
| 47 | + 'desc' => esc_html__( 'Set header and nav colors here. (Group open by default)', 'your-textdomain-here' ), |
|
| 48 | + 'hidden' => false, |
|
| 49 | + 'accordion_open' => true, |
|
| 50 | + ), |
|
| 51 | + esc_html__( 'Body', 'your-textdomain-here' ) => esc_html__( 'Set body and content colors here.', 'your-textdomain-here' ), |
|
| 52 | + esc_html__( 'Widget', 'your-textdomain-here' ) => '', |
|
| 53 | + '' => esc_html__( 'These colors are not assigned to any group.', 'your-textdomain-here' ), |
|
| 54 | + ), |
|
| 55 | + 'default' => array( |
|
| 56 | + array( |
|
| 57 | + 'id' => 'site-header', |
|
| 58 | + 'title' => 'site header', |
|
| 59 | + 'color' => '#980000', |
|
| 60 | + 'alpha' => 1, |
|
| 61 | + 'selector' => array( |
|
| 62 | + 'background' => '.site-header-main,header', |
|
| 63 | + 'color' => '.tester', |
|
| 64 | + ), |
|
| 65 | + 'mode' => 'background-color', |
|
| 66 | + 'important' => true, |
|
| 67 | + 'group' => esc_html__( 'Header', 'your-textdomain-here' ), |
|
| 68 | + ), |
|
| 69 | + array( |
|
| 70 | + 'id' => 'site-header-border', |
|
| 71 | + 'title' => 'site header border', |
|
| 72 | + 'color' => '#ff0000', |
|
| 73 | + 'alpha' => 1, |
|
| 74 | + 'selector' => '.site-header,header', |
|
| 75 | + 'mode' => 'border-color', |
|
| 76 | + 'important' => true, |
|
| 77 | + 'group' => esc_html__( 'Header', 'your-textdomain-here' ), |
|
| 78 | + ), |
|
| 79 | + array( |
|
| 80 | + 'id' => 'home-link', // ID. |
|
| 81 | + 'title' => 'home link', // Display text. |
|
| 82 | + 'color' => '#fdfdfd', // Default colour. |
|
| 83 | + 'alpha' => 1, // Default alpha. |
|
| 84 | + 'selector' => '.home-link,.wp-block-site-title a', // CSS selector. |
|
| 85 | + 'mode' => 'color', // CSS mode. |
|
| 86 | + 'important' => true, // CSS important. |
|
| 87 | + 'group' => esc_html__( 'Header', 'your-textdomain-here' ), |
|
| 88 | + ), |
|
| 89 | + array( |
|
| 90 | + 'id' => 'site-description', |
|
| 91 | + 'title' => 'site description', |
|
| 92 | + 'color' => '#ededed', |
|
| 93 | + 'alpha' => 1, |
|
| 94 | + 'selector' => 'h2.site-description,.wp-block-site-tagline', |
|
| 95 | + 'mode' => 'color', |
|
| 96 | + 'important' => true, |
|
| 97 | + 'group' => esc_html__( 'Header', 'your-textdomain-here' ), |
|
| 98 | + ), |
|
| 99 | + array( |
|
| 100 | + 'id' => 'navbar', |
|
| 101 | + 'title' => 'navbar', |
|
| 102 | + 'color' => '#e06666', |
|
| 103 | + 'alpha' => 1, |
|
| 104 | + 'selector' => '.navbar,.wp-block-navigation', |
|
| 105 | + 'mode' => 'background-color', |
|
| 106 | + 'group' => esc_html__( 'Header', 'your-textdomain-here' ), |
|
| 107 | 107 | |
| 108 | - ), |
|
| 109 | - array( |
|
| 110 | - 'id' => 'body-text', |
|
| 111 | - 'title' => 'body text', |
|
| 112 | - 'color' => '#000000', |
|
| 113 | - 'alpha' => 1, |
|
| 114 | - 'selector' => 'body p', |
|
| 115 | - 'mode' => 'color', |
|
| 116 | - 'group' => esc_html__( 'Body', 'your-textdomain-here' ), |
|
| 117 | - ), |
|
| 118 | - array( |
|
| 119 | - 'id' => 'site-content', |
|
| 120 | - 'title' => 'site content', |
|
| 121 | - 'color' => '#a4c2f4', |
|
| 122 | - 'alpha' => 1, |
|
| 123 | - 'selector' => '.site-content', |
|
| 124 | - 'mode' => 'background-color', |
|
| 125 | - 'group' => esc_html__( 'Body', 'your-textdomain-here' ), |
|
| 126 | - ), |
|
| 127 | - array( |
|
| 128 | - 'id' => 'entry-content', |
|
| 129 | - 'title' => 'entry content', |
|
| 130 | - 'color' => '#93c47d', |
|
| 131 | - 'alpha' => 1, |
|
| 132 | - 'selector' => '.entry-content', |
|
| 133 | - 'mode' => 'background-color', |
|
| 134 | - 'group' => esc_html__( 'Body', 'your-textdomain-here' ), |
|
| 135 | - ), |
|
| 136 | - array( |
|
| 137 | - 'id' => 'entry-title', |
|
| 138 | - 'title' => 'entry title', |
|
| 139 | - 'color' => '#000000', |
|
| 140 | - 'alpha' => 1, |
|
| 141 | - 'selector' => '.entry-title a', |
|
| 142 | - 'mode' => 'color', |
|
| 143 | - 'group' => esc_html__( 'Body', 'your-textdomain-here' ), |
|
| 144 | - ), |
|
| 145 | - array( |
|
| 146 | - 'id' => 'entry-title-hover', |
|
| 147 | - 'title' => 'entry title hover', |
|
| 148 | - 'color' => '#ffffff', |
|
| 149 | - 'alpha' => 1, |
|
| 150 | - 'selector' => '.entry-title a:hover', |
|
| 151 | - 'mode' => 'color', |
|
| 152 | - 'group' => esc_html__( 'Body', 'your-textdomain-here' ), |
|
| 153 | - ), |
|
| 154 | - array( |
|
| 155 | - 'id' => 'entry-meta', |
|
| 156 | - 'title' => 'entry meta', |
|
| 157 | - 'color' => '#0b5394', |
|
| 158 | - 'alpha' => 1, |
|
| 159 | - 'selector' => '.entry-meta a', |
|
| 160 | - 'mode' => 'color', |
|
| 161 | - 'group' => esc_html__( 'Body', 'your-textdomain-here' ), |
|
| 162 | - ), |
|
| 163 | - array( |
|
| 164 | - 'id' => 'widget-container', |
|
| 165 | - 'title' => 'widget container', |
|
| 166 | - 'color' => '#f1c232', |
|
| 167 | - 'alpha' => .5, |
|
| 168 | - 'selector' => '.widget', |
|
| 169 | - 'mode' => 'background-color', |
|
| 170 | - 'group' => esc_html__( 'Widget', 'your-textdomain-here' ), |
|
| 171 | - ), |
|
| 172 | - array( |
|
| 173 | - 'id' => 'widget-title', |
|
| 174 | - 'title' => 'widget title', |
|
| 175 | - 'color' => '#741b47', |
|
| 176 | - 'alpha' => 1, |
|
| 177 | - 'selector' => '.widget-title', |
|
| 178 | - 'mode' => 'color', |
|
| 179 | - 'important' => true, |
|
| 180 | - 'group' => esc_html__( 'Widget', 'your-textdomain-here' ), |
|
| 181 | - ), |
|
| 182 | - array( |
|
| 183 | - 'id' => 'widget-text', |
|
| 184 | - 'title' => 'widget text', |
|
| 185 | - 'color' => '#fdfdfd', |
|
| 186 | - 'alpha' => 1, |
|
| 187 | - 'selector' => '.widget a', |
|
| 188 | - 'mode' => 'color', |
|
| 189 | - 'important' => true, |
|
| 190 | - 'group' => esc_html__( 'Widget', 'your-textdomain-here' ), |
|
| 191 | - ), |
|
| 192 | - array( |
|
| 193 | - 'id' => 'sidebar-container', |
|
| 194 | - 'title' => 'sidebar container', |
|
| 195 | - 'color' => '#d5a6bd', |
|
| 196 | - 'alpha' => 1, |
|
| 197 | - 'selector' => '.sidebar-container', |
|
| 198 | - 'mode' => 'background-color', |
|
| 199 | - 'important' => true, |
|
| 200 | - 'group' => '', |
|
| 201 | - ), |
|
| 202 | - array( |
|
| 203 | - 'id' => 'site-footer', |
|
| 204 | - 'title' => 'site footer', |
|
| 205 | - 'color' => '#ededed', |
|
| 206 | - 'alpha' => 1, |
|
| 207 | - 'selector' => '.site-footer,footer', |
|
| 208 | - 'mode' => 'background-color', |
|
| 209 | - 'group' => '', |
|
| 210 | - ), |
|
| 211 | - array( |
|
| 212 | - 'id' => 'site-footer-text', |
|
| 213 | - 'title' => 'site footer text', |
|
| 214 | - 'color' => '#000000', |
|
| 215 | - 'alpha' => 1, |
|
| 216 | - 'selector' => '.site-footer a, footer a', |
|
| 217 | - 'group' => '', |
|
| 218 | - ), |
|
| 219 | - ), |
|
| 220 | - ), |
|
| 221 | - ), |
|
| 222 | - ) |
|
| 108 | + ), |
|
| 109 | + array( |
|
| 110 | + 'id' => 'body-text', |
|
| 111 | + 'title' => 'body text', |
|
| 112 | + 'color' => '#000000', |
|
| 113 | + 'alpha' => 1, |
|
| 114 | + 'selector' => 'body p', |
|
| 115 | + 'mode' => 'color', |
|
| 116 | + 'group' => esc_html__( 'Body', 'your-textdomain-here' ), |
|
| 117 | + ), |
|
| 118 | + array( |
|
| 119 | + 'id' => 'site-content', |
|
| 120 | + 'title' => 'site content', |
|
| 121 | + 'color' => '#a4c2f4', |
|
| 122 | + 'alpha' => 1, |
|
| 123 | + 'selector' => '.site-content', |
|
| 124 | + 'mode' => 'background-color', |
|
| 125 | + 'group' => esc_html__( 'Body', 'your-textdomain-here' ), |
|
| 126 | + ), |
|
| 127 | + array( |
|
| 128 | + 'id' => 'entry-content', |
|
| 129 | + 'title' => 'entry content', |
|
| 130 | + 'color' => '#93c47d', |
|
| 131 | + 'alpha' => 1, |
|
| 132 | + 'selector' => '.entry-content', |
|
| 133 | + 'mode' => 'background-color', |
|
| 134 | + 'group' => esc_html__( 'Body', 'your-textdomain-here' ), |
|
| 135 | + ), |
|
| 136 | + array( |
|
| 137 | + 'id' => 'entry-title', |
|
| 138 | + 'title' => 'entry title', |
|
| 139 | + 'color' => '#000000', |
|
| 140 | + 'alpha' => 1, |
|
| 141 | + 'selector' => '.entry-title a', |
|
| 142 | + 'mode' => 'color', |
|
| 143 | + 'group' => esc_html__( 'Body', 'your-textdomain-here' ), |
|
| 144 | + ), |
|
| 145 | + array( |
|
| 146 | + 'id' => 'entry-title-hover', |
|
| 147 | + 'title' => 'entry title hover', |
|
| 148 | + 'color' => '#ffffff', |
|
| 149 | + 'alpha' => 1, |
|
| 150 | + 'selector' => '.entry-title a:hover', |
|
| 151 | + 'mode' => 'color', |
|
| 152 | + 'group' => esc_html__( 'Body', 'your-textdomain-here' ), |
|
| 153 | + ), |
|
| 154 | + array( |
|
| 155 | + 'id' => 'entry-meta', |
|
| 156 | + 'title' => 'entry meta', |
|
| 157 | + 'color' => '#0b5394', |
|
| 158 | + 'alpha' => 1, |
|
| 159 | + 'selector' => '.entry-meta a', |
|
| 160 | + 'mode' => 'color', |
|
| 161 | + 'group' => esc_html__( 'Body', 'your-textdomain-here' ), |
|
| 162 | + ), |
|
| 163 | + array( |
|
| 164 | + 'id' => 'widget-container', |
|
| 165 | + 'title' => 'widget container', |
|
| 166 | + 'color' => '#f1c232', |
|
| 167 | + 'alpha' => .5, |
|
| 168 | + 'selector' => '.widget', |
|
| 169 | + 'mode' => 'background-color', |
|
| 170 | + 'group' => esc_html__( 'Widget', 'your-textdomain-here' ), |
|
| 171 | + ), |
|
| 172 | + array( |
|
| 173 | + 'id' => 'widget-title', |
|
| 174 | + 'title' => 'widget title', |
|
| 175 | + 'color' => '#741b47', |
|
| 176 | + 'alpha' => 1, |
|
| 177 | + 'selector' => '.widget-title', |
|
| 178 | + 'mode' => 'color', |
|
| 179 | + 'important' => true, |
|
| 180 | + 'group' => esc_html__( 'Widget', 'your-textdomain-here' ), |
|
| 181 | + ), |
|
| 182 | + array( |
|
| 183 | + 'id' => 'widget-text', |
|
| 184 | + 'title' => 'widget text', |
|
| 185 | + 'color' => '#fdfdfd', |
|
| 186 | + 'alpha' => 1, |
|
| 187 | + 'selector' => '.widget a', |
|
| 188 | + 'mode' => 'color', |
|
| 189 | + 'important' => true, |
|
| 190 | + 'group' => esc_html__( 'Widget', 'your-textdomain-here' ), |
|
| 191 | + ), |
|
| 192 | + array( |
|
| 193 | + 'id' => 'sidebar-container', |
|
| 194 | + 'title' => 'sidebar container', |
|
| 195 | + 'color' => '#d5a6bd', |
|
| 196 | + 'alpha' => 1, |
|
| 197 | + 'selector' => '.sidebar-container', |
|
| 198 | + 'mode' => 'background-color', |
|
| 199 | + 'important' => true, |
|
| 200 | + 'group' => '', |
|
| 201 | + ), |
|
| 202 | + array( |
|
| 203 | + 'id' => 'site-footer', |
|
| 204 | + 'title' => 'site footer', |
|
| 205 | + 'color' => '#ededed', |
|
| 206 | + 'alpha' => 1, |
|
| 207 | + 'selector' => '.site-footer,footer', |
|
| 208 | + 'mode' => 'background-color', |
|
| 209 | + 'group' => '', |
|
| 210 | + ), |
|
| 211 | + array( |
|
| 212 | + 'id' => 'site-footer-text', |
|
| 213 | + 'title' => 'site footer text', |
|
| 214 | + 'color' => '#000000', |
|
| 215 | + 'alpha' => 1, |
|
| 216 | + 'selector' => '.site-footer a, footer a', |
|
| 217 | + 'group' => '', |
|
| 218 | + ), |
|
| 219 | + ), |
|
| 220 | + ), |
|
| 221 | + ), |
|
| 222 | + ) |
|
| 223 | 223 | ); |
| 224 | 224 | // phpcs:enable |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | $field['default'] = $field['default'] ?? ''; |
| 112 | - $value = $core->options[ $field['id'] ] ?? $field['default']; |
|
| 112 | + $value = $core->options[$field['id']] ?? $field['default']; |
|
| 113 | 113 | $style_data = ''; |
| 114 | 114 | |
| 115 | 115 | if ( empty( $field_class ) ) { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $field_object = new $field_class( $field, $value, $core ); |
| 120 | 120 | |
| 121 | - if ( ! empty( $core->options[ $field['id'] ] ) && class_exists( $field_class ) && method_exists( $field_class, 'output' ) && $this->can_output_css( $core, $field ) ) { |
|
| 121 | + if ( ! empty( $core->options[$field['id']] ) && class_exists( $field_class ) && method_exists( $field_class, 'output' ) && $this->can_output_css( $core, $field ) ) { |
|
| 122 | 122 | |
| 123 | 123 | // phpcs:ignore WordPress.NamingConventions.ValidHookName |
| 124 | 124 | $field = apply_filters( "redux/field/{$core->args['opt_name']}/output_css", $field ); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | // Revamp thanks to Harry: https://csswizardry.com/2020/05/the-fastest-google-fonts/. |
| 224 | 224 | $href = str_replace( array( '|', ' ' ), array( '%7C', '%20' ), urldecode( $href ) ); |
| 225 | 225 | $new_html = '<link rel="preload" as="style" href="' . esc_attr( $href ) . '" />'; |
| 226 | - $new_html .= '<link rel="stylesheet" href="' . esc_attr( $href ) . '" media="print" onload="this.media=\'all\'">'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet |
|
| 226 | + $new_html .= '<link rel="stylesheet" href="' . esc_attr( $href ) . '" media="print" onload="this.media=\'all\'">'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet |
|
| 227 | 227 | $new_html .= '<noscript><link rel="stylesheet" href="' . esc_attr( $href ) . '" /></noscript>'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet |
| 228 | 228 | $html = $new_html; |
| 229 | 229 | } |
@@ -269,19 +269,19 @@ discard block |
||
| 269 | 269 | |
| 270 | 270 | foreach ( $val_pieces as $val_key => $val_val ) { |
| 271 | 271 | $val_key = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] ) . '-' . $val_key; |
| 272 | - $core->output_variables[ $val_key ] = $val_val; |
|
| 272 | + $core->output_variables[$val_key] = $val_val; |
|
| 273 | 273 | if ( ! empty( $style_data ) ) { |
| 274 | 274 | $val_key = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] ); |
| 275 | - $core->output_variables[ $val_key ] = $style_data; |
|
| 275 | + $core->output_variables[$val_key] = $style_data; |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | } else { |
| 279 | 279 | $val_key = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] ); |
| 280 | 280 | |
| 281 | 281 | if ( ! empty( $style_data ) ) { |
| 282 | - $core->output_variables[ $val_key ] = $style_data; |
|
| 282 | + $core->output_variables[$val_key] = $style_data; |
|
| 283 | 283 | } else { |
| 284 | - $core->output_variables[ $val_key ] = $value; |
|
| 284 | + $core->output_variables[$val_key] = $value; |
|
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | } |
@@ -344,14 +344,14 @@ discard block |
||
| 344 | 344 | if ( ! empty( $field['required'] ) ) { |
| 345 | 345 | if ( isset( $field['required'][0] ) ) { |
| 346 | 346 | if ( ! is_array( $field['required'][0] ) && 3 === count( $field['required'] ) ) { |
| 347 | - $parent_value = $GLOBALS[ $core->args['global_variable'] ][ $field['required'][0] ] ?? ''; |
|
| 347 | + $parent_value = $GLOBALS[$core->args['global_variable']][$field['required'][0]] ?? ''; |
|
| 348 | 348 | $check_value = $field['required'][2]; |
| 349 | 349 | $operation = $field['required'][1]; |
| 350 | 350 | $return = $core->required_class->compare_value_dependencies( $parent_value, $check_value, $operation ); |
| 351 | 351 | } elseif ( is_array( $field['required'][0] ) ) { |
| 352 | 352 | foreach ( $field['required'] as $required ) { |
| 353 | 353 | if ( isset( $required[0] ) && ! is_array( $required[0] ) && 3 === count( $required ) ) { |
| 354 | - $parent_value = $GLOBALS[ $core->args['global_variable'] ][ $required[0] ] ?? ''; |
|
| 354 | + $parent_value = $GLOBALS[$core->args['global_variable']][$required[0]] ?? ''; |
|
| 355 | 355 | $check_value = $required[2]; |
| 356 | 356 | $operation = $required[1]; |
| 357 | 357 | $return = $core->required_class->compare_value_dependencies( $parent_value, $check_value, $operation ); |
@@ -12,362 +12,362 @@ |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_Output', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_Output |
|
| 17 | - */ |
|
| 18 | - class Redux_Output extends Redux_Class { |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Redux_Output constructor. |
|
| 22 | - * |
|
| 23 | - * @param object $redux ReduxFramework pointer. |
|
| 24 | - */ |
|
| 25 | - public function __construct( $redux ) { |
|
| 26 | - parent::__construct( $redux ); |
|
| 27 | - |
|
| 28 | - // Output dynamic CSS. |
|
| 29 | - // Frontend: Maybe enqueue dynamic CSS and Google fonts. |
|
| 30 | - if ( empty( $this->args['output_location'] ) || in_array( 'frontend', $this->args['output_location'], true ) ) { |
|
| 31 | - add_action( 'wp_head', array( $this, 'output_css' ), 150 ); |
|
| 32 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 150 ); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - // Login page: Maybe enqueue dynamic CSS and Google fonts. |
|
| 36 | - if ( in_array( 'login', $this->args['output_location'], true ) ) { |
|
| 37 | - add_action( 'login_head', array( $this, 'output_css' ), 150 ); |
|
| 38 | - add_action( 'login_enqueue_scripts', array( $this, 'enqueue' ), 150 ); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - // Admin area: Maybe enqueue dynamic CSS and Google fonts. |
|
| 42 | - if ( in_array( 'admin', $this->args['output_location'], true ) ) { |
|
| 43 | - add_action( 'admin_head', array( $this, 'output_css' ), 150 ); |
|
| 44 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 150 ); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 48 | - do_action( "redux/output/{$this->parent->args['opt_name']}/construct", $this ); |
|
| 49 | - // Useful for adding different locations for CSS output. |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Enqueue CSS and Google fonts for front end |
|
| 54 | - * |
|
| 55 | - * @return void |
|
| 56 | - * @throws ReflectionException Exception. |
|
| 57 | - * @since 1.0.0 |
|
| 58 | - * @access public |
|
| 59 | - */ |
|
| 60 | - public function enqueue() { |
|
| 61 | - $core = $this->core(); |
|
| 62 | - |
|
| 63 | - if ( false === $core->args['output'] && false === $core->args['compiler'] ) { |
|
| 64 | - return; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - foreach ( $core->sections as $k => $section ) { |
|
| 68 | - if ( isset( $section['type'] ) && ( 'divide' === $section['type'] ) ) { |
|
| 69 | - continue; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - if ( isset( $section['fields'] ) ) { |
|
| 73 | - foreach ( $section['fields'] as $fieldk => $field ) { |
|
| 74 | - if ( isset( $field['type'] ) && 'callback' !== $field['type'] ) { |
|
| 75 | - $field_classes = array( 'Redux_' . $field['type'], 'ReduxFramework_' . $field['type'] ); |
|
| 76 | - |
|
| 77 | - $field_class = Redux_Functions::class_exists_ex( $field_classes ); |
|
| 78 | - |
|
| 79 | - if ( false === $field_class ) { |
|
| 80 | - if ( ! isset( $field['compiler'] ) ) { |
|
| 81 | - $field['compiler'] = ''; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - $field_type = str_replace( '_', '-', $field['type'] ); |
|
| 85 | - $core_path = Redux_Core::$dir . "inc/fields/{$field['type']}/class-redux-$field_type.php"; |
|
| 86 | - |
|
| 87 | - if ( ! file_exists( $core_path ) ) { |
|
| 88 | - $core_path = Redux_Core::$dir . "inc/fields/{$field['type']}/field_{$field['type']}.php"; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - $filter_path = $core_path; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Field class file |
|
| 95 | - * filter 'redux/{opt_name}/field/class/{field.type}' |
|
| 96 | - * |
|
| 97 | - * @param string $file field class file. |
|
| 98 | - * @param array $field field config data |
|
| 99 | - */ |
|
| 100 | - |
|
| 101 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 102 | - $class_file = apply_filters( "redux/{$core->args['opt_name']}/field/class/{$field['type']}", $filter_path, $field ); |
|
| 103 | - |
|
| 104 | - if ( $class_file && file_exists( $class_file ) ) { |
|
| 105 | - require_once $class_file; |
|
| 106 | - |
|
| 107 | - $field_class = Redux_Functions::class_exists_ex( $field_classes ); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - $field['default'] = $field['default'] ?? ''; |
|
| 112 | - $value = $core->options[ $field['id'] ] ?? $field['default']; |
|
| 113 | - $style_data = ''; |
|
| 114 | - |
|
| 115 | - if ( empty( $field_class ) ) { |
|
| 116 | - continue; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - $field_object = new $field_class( $field, $value, $core ); |
|
| 120 | - |
|
| 121 | - if ( ! empty( $core->options[ $field['id'] ] ) && class_exists( $field_class ) && method_exists( $field_class, 'output' ) && $this->can_output_css( $core, $field ) ) { |
|
| 122 | - |
|
| 123 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 124 | - $field = apply_filters( "redux/field/{$core->args['opt_name']}/output_css", $field ); |
|
| 125 | - |
|
| 126 | - if ( ! empty( $field['output'] ) && ! is_array( $field['output'] ) ) { |
|
| 127 | - $field['output'] = array( $field['output'] ); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - if ( ( ( isset( $field['output'] ) && ! empty( $field['output'] ) ) || ( isset( $field['compiler'] ) && ! empty( $field['compiler'] ) ) || ( isset( $field['media_query'] ) && ! empty( $field['media_query'] ) ) || 'typography' === $field['type'] || 'icon_select' === $field['type'] || 'social_profiles' === $field['type'] ) ) { |
|
| 131 | - if ( method_exists( $field_class, 'css_style' ) ) { |
|
| 132 | - $style_data = $field_object->css_style( $field_object->value ); |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - if ( null !== $style_data ) { |
|
| 137 | - if ( ( ( isset( $field['output'] ) && ! empty( $field['output'] ) ) || ( isset( $field['compiler'] ) && ! empty( $field['compiler'] ) ) || 'typography' === $field['type'] || 'icon_select' === $field['type'] || 'social_profiles' === $field['type'] ) ) { |
|
| 138 | - $field_object->output( $style_data ); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - if ( isset( $field['media_query'] ) && ! empty( $field['media_query'] ) ) { |
|
| 142 | - $field_object->media_query( $style_data ); |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 148 | - do_action( "redux/field/{$core->args['opt_name']}/output_loop", $core, $field, $value, $style_data ); |
|
| 149 | - |
|
| 150 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 151 | - do_action( "redux/field/{$core->args['opt_name']}/output_loop/{$field['type']}", $core, $field, $value, $style_data ); |
|
| 152 | - |
|
| 153 | - if ( method_exists( $field_class, 'output_variables' ) && $this->can_output_css( $core, $field ) ) { |
|
| 154 | - $passed_style_data = $field_object->output_variables( $style_data ); |
|
| 155 | - $this->output_variables( $core, $section, $field, $value, $passed_style_data ); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - if ( ! empty( $core->outputCSS ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 161 | - // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 162 | - $core->outputCSS = html_entity_decode( $core->outputCSS, ENT_QUOTES, 'UTF-8' ); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // For use like in the customizer. Stops the output, but passes the CSS in the variable for the compiler. |
|
| 168 | - if ( true === Redux_Core::$no_output ) { |
|
| 169 | - return; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - if ( ! empty( Redux_Core::$typography ) && filter_var( $core->args['output'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
| 173 | - $version = ! empty( $core->transients['last_save'] ) ? $core->transients['last_save'] : ''; |
|
| 174 | - if ( ! class_exists( 'Redux_Typography' ) ) { |
|
| 175 | - require_once Redux_Core::$dir . '/inc/fields/typography/class-redux-typography.php'; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - $typography = new Redux_Typography( null, null, $core ); |
|
| 179 | - |
|
| 180 | - $core->args['disable_google_fonts_link'] = ( ! isset( $core->args['disable_google_fonts_link'] ) ? false : $core->args['disable_google_fonts_link'] ); |
|
| 181 | - |
|
| 182 | - if ( ! $core->args['disable_google_fonts_link'] ) { |
|
| 183 | - $url = $typography->make_google_web_font_link( Redux_Core::$typography ); |
|
| 184 | - wp_enqueue_style( 'redux-google-fonts-' . $core->args['opt_name'], $url, array(), $version ); |
|
| 185 | - add_filter( 'style_loader_tag', array( $this, 'add_style_attributes' ), 10, 4 ); |
|
| 186 | - add_filter( 'wp_resource_hints', array( $this, 'google_fonts_preconnect' ), 10, 2 ); |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Add a Google Fonts preconnect link. |
|
| 193 | - * |
|
| 194 | - * @param array $urls HTML to be added. |
|
| 195 | - * @param string $relationship_type Handle name. |
|
| 196 | - * |
|
| 197 | - * @return array |
|
| 198 | - * @since 4.1.15 |
|
| 199 | - * @access public |
|
| 200 | - */ |
|
| 201 | - public function google_fonts_preconnect( array $urls, string $relationship_type ): array { |
|
| 202 | - if ( 'preconnect' !== $relationship_type ) { |
|
| 203 | - return $urls; |
|
| 204 | - } |
|
| 205 | - $urls[] = array( |
|
| 206 | - 'rel' => 'preconnect', |
|
| 207 | - 'href' => 'https://fonts.gstatic.com', |
|
| 208 | - 'crossorigin', |
|
| 209 | - ); |
|
| 210 | - return $urls; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * Filter to enhance the google fonts enqueue. |
|
| 215 | - * |
|
| 216 | - * @param string $html HTML to be added. |
|
| 217 | - * @param string $handle Handle name. |
|
| 218 | - * @param string $href HREF URL of a script. |
|
| 219 | - * |
|
| 220 | - * @return string |
|
| 221 | - * @since 4.1.15 |
|
| 222 | - * @access public |
|
| 223 | - */ |
|
| 224 | - public function add_style_attributes( string $html = '', string $handle = '', string $href = '' ): string { |
|
| 225 | - if ( Redux_Functions_Ex::string_starts_with( $handle, 'redux-google-fonts-' ) ) { |
|
| 226 | - // Revamp thanks to Harry: https://csswizardry.com/2020/05/the-fastest-google-fonts/. |
|
| 227 | - $href = str_replace( array( '|', ' ' ), array( '%7C', '%20' ), urldecode( $href ) ); |
|
| 228 | - $new_html = '<link rel="preload" as="style" href="' . esc_attr( $href ) . '" />'; |
|
| 229 | - $new_html .= '<link rel="stylesheet" href="' . esc_attr( $href ) . '" media="print" onload="this.media=\'all\'">'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet |
|
| 230 | - $new_html .= '<noscript><link rel="stylesheet" href="' . esc_attr( $href ) . '" /></noscript>'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet |
|
| 231 | - $html = $new_html; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - return $html; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Function to output output_variables to the dynamic output. |
|
| 239 | - * |
|
| 240 | - * @param ReduxFramework $core ReduxFramework core pointer. |
|
| 241 | - * @param array $section Section containing this field. |
|
| 242 | - * @param array $field Field object. |
|
| 243 | - * @param array|string $value Current value of field. |
|
| 244 | - * @param string|null $style_data CSS output string to append to the root output variable. |
|
| 245 | - * |
|
| 246 | - * @return void |
|
| 247 | - * @since 4.0.3 |
|
| 248 | - * @access public |
|
| 249 | - */ |
|
| 250 | - private function output_variables( ReduxFramework $core, array $section = array(), array $field = array(), $value = array(), ?string $style_data = '' ) { |
|
| 251 | - // Let's allow section overrides, please. |
|
| 252 | - if ( isset( $section['output_variables'] ) && ! isset( $field['output_variables'] ) ) { |
|
| 253 | - $field['output_variables'] = $section['output_variables']; |
|
| 254 | - } |
|
| 255 | - if ( isset( $section['output_variables_prefix'] ) && ! isset( $field['output_variables_prefix'] ) ) { |
|
| 256 | - $field['output_variables_prefix'] = $section['output_variables_prefix']; |
|
| 257 | - } |
|
| 258 | - if ( isset( $field['output_variables'] ) && $field['output_variables'] ) { |
|
| 259 | - $output_variables_prefix = $core->args['output_variables_prefix']; |
|
| 260 | - if ( isset( $field['output_variables_prefix'] ) && ! empty( $field['output_variables_prefix'] ) ) { |
|
| 261 | - $output_variables_prefix = $field['output_variables_prefix']; |
|
| 262 | - } elseif ( isset( $section['output_variables_prefix'] ) && ! empty( $section['output_variables_prefix'] ) ) { |
|
| 263 | - $output_variables_prefix = $section['output_variables_prefix']; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - if ( is_array( $value ) ) { |
|
| 267 | - $val_pieces = array_filter( $value, 'strlen' ); |
|
| 268 | - // We don't need to show the Google boolean. |
|
| 269 | - if ( 'typography' === $field['type'] && isset( $val_pieces['google'] ) ) { |
|
| 270 | - unset( $val_pieces['google'] ); |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - foreach ( $val_pieces as $val_key => $val_val ) { |
|
| 274 | - $val_key = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] ) . '-' . $val_key; |
|
| 275 | - $core->output_variables[ $val_key ] = $val_val; |
|
| 276 | - if ( ! empty( $style_data ) ) { |
|
| 277 | - $val_key = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] ); |
|
| 278 | - $core->output_variables[ $val_key ] = $style_data; |
|
| 279 | - } |
|
| 280 | - } |
|
| 281 | - } else { |
|
| 282 | - $val_key = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] ); |
|
| 283 | - |
|
| 284 | - if ( ! empty( $style_data ) ) { |
|
| 285 | - $core->output_variables[ $val_key ] = $style_data; |
|
| 286 | - } else { |
|
| 287 | - $core->output_variables[ $val_key ] = $value; |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - } |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * Output dynamic CSS at the bottom of HEAD |
|
| 295 | - * |
|
| 296 | - * @return void |
|
| 297 | - * @since 3.2.8 |
|
| 298 | - * @access public |
|
| 299 | - */ |
|
| 300 | - public function output_css() { |
|
| 301 | - $core = $this->core(); |
|
| 302 | - |
|
| 303 | - if ( false === $core->args['output'] && false === $core->args['compiler'] && empty( $core->output_variables ) ) { |
|
| 304 | - return; |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - if ( true === Redux_Core::$no_output ) { |
|
| 308 | - return; |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - if ( ! empty( $core->output_variables ) ) { |
|
| 312 | - $root_css = ':root{'; |
|
| 313 | - foreach ( $core->output_variables as $key => $value ) { |
|
| 314 | - $root_css .= "$key:$value;"; |
|
| 315 | - } |
|
| 316 | - $root_css .= '}'; |
|
| 317 | - // phpcs:ignore WordPress.NamingConventions.ValidVariableName, WordPress.Security.EscapeOutput |
|
| 318 | - $core->outputCSS = $root_css . $core->outputCSS; |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - // phpcs:ignore WordPress.NamingConventions.ValidVariableName |
|
| 322 | - if ( ! empty( $core->outputCSS ) && ( true === $core->args['output_tag'] || ( isset( $_POST['customized'] ) && isset( $_POST['nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'preview-customize_' . wp_get_theme()->get_stylesheet() ) ) ) ) { |
|
| 323 | - // phpcs:ignore WordPress.NamingConventions.ValidVariableName, WordPress.Security.EscapeOutput |
|
| 324 | - echo '<style id="' . esc_attr( $core->args['opt_name'] ) . '-dynamic-css" title="dynamic-css" class="redux-options-output">' . $core->outputCSS . '</style>'; |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * Can Output CSS |
|
| 330 | - * Check if a field meets its requirements before outputting to CSS |
|
| 331 | - * |
|
| 332 | - * @param ReduxFramework $core ReduxFramework core pointer. |
|
| 333 | - * @param array $field Field array. |
|
| 334 | - * |
|
| 335 | - * @return bool |
|
| 336 | - */ |
|
| 337 | - private function can_output_css( ReduxFramework $core, array $field ): ?bool { |
|
| 338 | - $return = true; |
|
| 339 | - |
|
| 340 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 341 | - $field = apply_filters( "redux/field/{$core->args['opt_name']}/_can_output_css", $field ); |
|
| 342 | - |
|
| 343 | - if ( isset( $field['force_output'] ) && true === $field['force_output'] ) { |
|
| 344 | - return true; |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - if ( ! empty( $field['required'] ) ) { |
|
| 348 | - if ( isset( $field['required'][0] ) ) { |
|
| 349 | - if ( ! is_array( $field['required'][0] ) && 3 === count( $field['required'] ) ) { |
|
| 350 | - $parent_value = $GLOBALS[ $core->args['global_variable'] ][ $field['required'][0] ] ?? ''; |
|
| 351 | - $check_value = $field['required'][2]; |
|
| 352 | - $operation = $field['required'][1]; |
|
| 353 | - $return = $core->required_class->compare_value_dependencies( $parent_value, $check_value, $operation ); |
|
| 354 | - } elseif ( is_array( $field['required'][0] ) ) { |
|
| 355 | - foreach ( $field['required'] as $required ) { |
|
| 356 | - if ( isset( $required[0] ) && ! is_array( $required[0] ) && 3 === count( $required ) ) { |
|
| 357 | - $parent_value = $GLOBALS[ $core->args['global_variable'] ][ $required[0] ] ?? ''; |
|
| 358 | - $check_value = $required[2]; |
|
| 359 | - $operation = $required[1]; |
|
| 360 | - $return = $core->required_class->compare_value_dependencies( $parent_value, $check_value, $operation ); |
|
| 361 | - } |
|
| 362 | - if ( ! $return ) { |
|
| 363 | - return $return; |
|
| 364 | - } |
|
| 365 | - } |
|
| 366 | - } |
|
| 367 | - } |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - return $return; |
|
| 371 | - } |
|
| 372 | - } |
|
| 15 | + /** |
|
| 16 | + * Class Redux_Output |
|
| 17 | + */ |
|
| 18 | + class Redux_Output extends Redux_Class { |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Redux_Output constructor. |
|
| 22 | + * |
|
| 23 | + * @param object $redux ReduxFramework pointer. |
|
| 24 | + */ |
|
| 25 | + public function __construct( $redux ) { |
|
| 26 | + parent::__construct( $redux ); |
|
| 27 | + |
|
| 28 | + // Output dynamic CSS. |
|
| 29 | + // Frontend: Maybe enqueue dynamic CSS and Google fonts. |
|
| 30 | + if ( empty( $this->args['output_location'] ) || in_array( 'frontend', $this->args['output_location'], true ) ) { |
|
| 31 | + add_action( 'wp_head', array( $this, 'output_css' ), 150 ); |
|
| 32 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 150 ); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + // Login page: Maybe enqueue dynamic CSS and Google fonts. |
|
| 36 | + if ( in_array( 'login', $this->args['output_location'], true ) ) { |
|
| 37 | + add_action( 'login_head', array( $this, 'output_css' ), 150 ); |
|
| 38 | + add_action( 'login_enqueue_scripts', array( $this, 'enqueue' ), 150 ); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + // Admin area: Maybe enqueue dynamic CSS and Google fonts. |
|
| 42 | + if ( in_array( 'admin', $this->args['output_location'], true ) ) { |
|
| 43 | + add_action( 'admin_head', array( $this, 'output_css' ), 150 ); |
|
| 44 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 150 ); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 48 | + do_action( "redux/output/{$this->parent->args['opt_name']}/construct", $this ); |
|
| 49 | + // Useful for adding different locations for CSS output. |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Enqueue CSS and Google fonts for front end |
|
| 54 | + * |
|
| 55 | + * @return void |
|
| 56 | + * @throws ReflectionException Exception. |
|
| 57 | + * @since 1.0.0 |
|
| 58 | + * @access public |
|
| 59 | + */ |
|
| 60 | + public function enqueue() { |
|
| 61 | + $core = $this->core(); |
|
| 62 | + |
|
| 63 | + if ( false === $core->args['output'] && false === $core->args['compiler'] ) { |
|
| 64 | + return; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + foreach ( $core->sections as $k => $section ) { |
|
| 68 | + if ( isset( $section['type'] ) && ( 'divide' === $section['type'] ) ) { |
|
| 69 | + continue; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + if ( isset( $section['fields'] ) ) { |
|
| 73 | + foreach ( $section['fields'] as $fieldk => $field ) { |
|
| 74 | + if ( isset( $field['type'] ) && 'callback' !== $field['type'] ) { |
|
| 75 | + $field_classes = array( 'Redux_' . $field['type'], 'ReduxFramework_' . $field['type'] ); |
|
| 76 | + |
|
| 77 | + $field_class = Redux_Functions::class_exists_ex( $field_classes ); |
|
| 78 | + |
|
| 79 | + if ( false === $field_class ) { |
|
| 80 | + if ( ! isset( $field['compiler'] ) ) { |
|
| 81 | + $field['compiler'] = ''; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + $field_type = str_replace( '_', '-', $field['type'] ); |
|
| 85 | + $core_path = Redux_Core::$dir . "inc/fields/{$field['type']}/class-redux-$field_type.php"; |
|
| 86 | + |
|
| 87 | + if ( ! file_exists( $core_path ) ) { |
|
| 88 | + $core_path = Redux_Core::$dir . "inc/fields/{$field['type']}/field_{$field['type']}.php"; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + $filter_path = $core_path; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Field class file |
|
| 95 | + * filter 'redux/{opt_name}/field/class/{field.type}' |
|
| 96 | + * |
|
| 97 | + * @param string $file field class file. |
|
| 98 | + * @param array $field field config data |
|
| 99 | + */ |
|
| 100 | + |
|
| 101 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 102 | + $class_file = apply_filters( "redux/{$core->args['opt_name']}/field/class/{$field['type']}", $filter_path, $field ); |
|
| 103 | + |
|
| 104 | + if ( $class_file && file_exists( $class_file ) ) { |
|
| 105 | + require_once $class_file; |
|
| 106 | + |
|
| 107 | + $field_class = Redux_Functions::class_exists_ex( $field_classes ); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + $field['default'] = $field['default'] ?? ''; |
|
| 112 | + $value = $core->options[ $field['id'] ] ?? $field['default']; |
|
| 113 | + $style_data = ''; |
|
| 114 | + |
|
| 115 | + if ( empty( $field_class ) ) { |
|
| 116 | + continue; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + $field_object = new $field_class( $field, $value, $core ); |
|
| 120 | + |
|
| 121 | + if ( ! empty( $core->options[ $field['id'] ] ) && class_exists( $field_class ) && method_exists( $field_class, 'output' ) && $this->can_output_css( $core, $field ) ) { |
|
| 122 | + |
|
| 123 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 124 | + $field = apply_filters( "redux/field/{$core->args['opt_name']}/output_css", $field ); |
|
| 125 | + |
|
| 126 | + if ( ! empty( $field['output'] ) && ! is_array( $field['output'] ) ) { |
|
| 127 | + $field['output'] = array( $field['output'] ); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + if ( ( ( isset( $field['output'] ) && ! empty( $field['output'] ) ) || ( isset( $field['compiler'] ) && ! empty( $field['compiler'] ) ) || ( isset( $field['media_query'] ) && ! empty( $field['media_query'] ) ) || 'typography' === $field['type'] || 'icon_select' === $field['type'] || 'social_profiles' === $field['type'] ) ) { |
|
| 131 | + if ( method_exists( $field_class, 'css_style' ) ) { |
|
| 132 | + $style_data = $field_object->css_style( $field_object->value ); |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + if ( null !== $style_data ) { |
|
| 137 | + if ( ( ( isset( $field['output'] ) && ! empty( $field['output'] ) ) || ( isset( $field['compiler'] ) && ! empty( $field['compiler'] ) ) || 'typography' === $field['type'] || 'icon_select' === $field['type'] || 'social_profiles' === $field['type'] ) ) { |
|
| 138 | + $field_object->output( $style_data ); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + if ( isset( $field['media_query'] ) && ! empty( $field['media_query'] ) ) { |
|
| 142 | + $field_object->media_query( $style_data ); |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 148 | + do_action( "redux/field/{$core->args['opt_name']}/output_loop", $core, $field, $value, $style_data ); |
|
| 149 | + |
|
| 150 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 151 | + do_action( "redux/field/{$core->args['opt_name']}/output_loop/{$field['type']}", $core, $field, $value, $style_data ); |
|
| 152 | + |
|
| 153 | + if ( method_exists( $field_class, 'output_variables' ) && $this->can_output_css( $core, $field ) ) { |
|
| 154 | + $passed_style_data = $field_object->output_variables( $style_data ); |
|
| 155 | + $this->output_variables( $core, $section, $field, $value, $passed_style_data ); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + if ( ! empty( $core->outputCSS ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 161 | + // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 162 | + $core->outputCSS = html_entity_decode( $core->outputCSS, ENT_QUOTES, 'UTF-8' ); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // For use like in the customizer. Stops the output, but passes the CSS in the variable for the compiler. |
|
| 168 | + if ( true === Redux_Core::$no_output ) { |
|
| 169 | + return; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + if ( ! empty( Redux_Core::$typography ) && filter_var( $core->args['output'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
| 173 | + $version = ! empty( $core->transients['last_save'] ) ? $core->transients['last_save'] : ''; |
|
| 174 | + if ( ! class_exists( 'Redux_Typography' ) ) { |
|
| 175 | + require_once Redux_Core::$dir . '/inc/fields/typography/class-redux-typography.php'; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + $typography = new Redux_Typography( null, null, $core ); |
|
| 179 | + |
|
| 180 | + $core->args['disable_google_fonts_link'] = ( ! isset( $core->args['disable_google_fonts_link'] ) ? false : $core->args['disable_google_fonts_link'] ); |
|
| 181 | + |
|
| 182 | + if ( ! $core->args['disable_google_fonts_link'] ) { |
|
| 183 | + $url = $typography->make_google_web_font_link( Redux_Core::$typography ); |
|
| 184 | + wp_enqueue_style( 'redux-google-fonts-' . $core->args['opt_name'], $url, array(), $version ); |
|
| 185 | + add_filter( 'style_loader_tag', array( $this, 'add_style_attributes' ), 10, 4 ); |
|
| 186 | + add_filter( 'wp_resource_hints', array( $this, 'google_fonts_preconnect' ), 10, 2 ); |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Add a Google Fonts preconnect link. |
|
| 193 | + * |
|
| 194 | + * @param array $urls HTML to be added. |
|
| 195 | + * @param string $relationship_type Handle name. |
|
| 196 | + * |
|
| 197 | + * @return array |
|
| 198 | + * @since 4.1.15 |
|
| 199 | + * @access public |
|
| 200 | + */ |
|
| 201 | + public function google_fonts_preconnect( array $urls, string $relationship_type ): array { |
|
| 202 | + if ( 'preconnect' !== $relationship_type ) { |
|
| 203 | + return $urls; |
|
| 204 | + } |
|
| 205 | + $urls[] = array( |
|
| 206 | + 'rel' => 'preconnect', |
|
| 207 | + 'href' => 'https://fonts.gstatic.com', |
|
| 208 | + 'crossorigin', |
|
| 209 | + ); |
|
| 210 | + return $urls; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * Filter to enhance the google fonts enqueue. |
|
| 215 | + * |
|
| 216 | + * @param string $html HTML to be added. |
|
| 217 | + * @param string $handle Handle name. |
|
| 218 | + * @param string $href HREF URL of a script. |
|
| 219 | + * |
|
| 220 | + * @return string |
|
| 221 | + * @since 4.1.15 |
|
| 222 | + * @access public |
|
| 223 | + */ |
|
| 224 | + public function add_style_attributes( string $html = '', string $handle = '', string $href = '' ): string { |
|
| 225 | + if ( Redux_Functions_Ex::string_starts_with( $handle, 'redux-google-fonts-' ) ) { |
|
| 226 | + // Revamp thanks to Harry: https://csswizardry.com/2020/05/the-fastest-google-fonts/. |
|
| 227 | + $href = str_replace( array( '|', ' ' ), array( '%7C', '%20' ), urldecode( $href ) ); |
|
| 228 | + $new_html = '<link rel="preload" as="style" href="' . esc_attr( $href ) . '" />'; |
|
| 229 | + $new_html .= '<link rel="stylesheet" href="' . esc_attr( $href ) . '" media="print" onload="this.media=\'all\'">'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet |
|
| 230 | + $new_html .= '<noscript><link rel="stylesheet" href="' . esc_attr( $href ) . '" /></noscript>'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet |
|
| 231 | + $html = $new_html; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + return $html; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Function to output output_variables to the dynamic output. |
|
| 239 | + * |
|
| 240 | + * @param ReduxFramework $core ReduxFramework core pointer. |
|
| 241 | + * @param array $section Section containing this field. |
|
| 242 | + * @param array $field Field object. |
|
| 243 | + * @param array|string $value Current value of field. |
|
| 244 | + * @param string|null $style_data CSS output string to append to the root output variable. |
|
| 245 | + * |
|
| 246 | + * @return void |
|
| 247 | + * @since 4.0.3 |
|
| 248 | + * @access public |
|
| 249 | + */ |
|
| 250 | + private function output_variables( ReduxFramework $core, array $section = array(), array $field = array(), $value = array(), ?string $style_data = '' ) { |
|
| 251 | + // Let's allow section overrides, please. |
|
| 252 | + if ( isset( $section['output_variables'] ) && ! isset( $field['output_variables'] ) ) { |
|
| 253 | + $field['output_variables'] = $section['output_variables']; |
|
| 254 | + } |
|
| 255 | + if ( isset( $section['output_variables_prefix'] ) && ! isset( $field['output_variables_prefix'] ) ) { |
|
| 256 | + $field['output_variables_prefix'] = $section['output_variables_prefix']; |
|
| 257 | + } |
|
| 258 | + if ( isset( $field['output_variables'] ) && $field['output_variables'] ) { |
|
| 259 | + $output_variables_prefix = $core->args['output_variables_prefix']; |
|
| 260 | + if ( isset( $field['output_variables_prefix'] ) && ! empty( $field['output_variables_prefix'] ) ) { |
|
| 261 | + $output_variables_prefix = $field['output_variables_prefix']; |
|
| 262 | + } elseif ( isset( $section['output_variables_prefix'] ) && ! empty( $section['output_variables_prefix'] ) ) { |
|
| 263 | + $output_variables_prefix = $section['output_variables_prefix']; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + if ( is_array( $value ) ) { |
|
| 267 | + $val_pieces = array_filter( $value, 'strlen' ); |
|
| 268 | + // We don't need to show the Google boolean. |
|
| 269 | + if ( 'typography' === $field['type'] && isset( $val_pieces['google'] ) ) { |
|
| 270 | + unset( $val_pieces['google'] ); |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + foreach ( $val_pieces as $val_key => $val_val ) { |
|
| 274 | + $val_key = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] ) . '-' . $val_key; |
|
| 275 | + $core->output_variables[ $val_key ] = $val_val; |
|
| 276 | + if ( ! empty( $style_data ) ) { |
|
| 277 | + $val_key = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] ); |
|
| 278 | + $core->output_variables[ $val_key ] = $style_data; |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | + } else { |
|
| 282 | + $val_key = $output_variables_prefix . sanitize_title_with_dashes( $field['id'] ); |
|
| 283 | + |
|
| 284 | + if ( ! empty( $style_data ) ) { |
|
| 285 | + $core->output_variables[ $val_key ] = $style_data; |
|
| 286 | + } else { |
|
| 287 | + $core->output_variables[ $val_key ] = $value; |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * Output dynamic CSS at the bottom of HEAD |
|
| 295 | + * |
|
| 296 | + * @return void |
|
| 297 | + * @since 3.2.8 |
|
| 298 | + * @access public |
|
| 299 | + */ |
|
| 300 | + public function output_css() { |
|
| 301 | + $core = $this->core(); |
|
| 302 | + |
|
| 303 | + if ( false === $core->args['output'] && false === $core->args['compiler'] && empty( $core->output_variables ) ) { |
|
| 304 | + return; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + if ( true === Redux_Core::$no_output ) { |
|
| 308 | + return; |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + if ( ! empty( $core->output_variables ) ) { |
|
| 312 | + $root_css = ':root{'; |
|
| 313 | + foreach ( $core->output_variables as $key => $value ) { |
|
| 314 | + $root_css .= "$key:$value;"; |
|
| 315 | + } |
|
| 316 | + $root_css .= '}'; |
|
| 317 | + // phpcs:ignore WordPress.NamingConventions.ValidVariableName, WordPress.Security.EscapeOutput |
|
| 318 | + $core->outputCSS = $root_css . $core->outputCSS; |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + // phpcs:ignore WordPress.NamingConventions.ValidVariableName |
|
| 322 | + if ( ! empty( $core->outputCSS ) && ( true === $core->args['output_tag'] || ( isset( $_POST['customized'] ) && isset( $_POST['nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'preview-customize_' . wp_get_theme()->get_stylesheet() ) ) ) ) { |
|
| 323 | + // phpcs:ignore WordPress.NamingConventions.ValidVariableName, WordPress.Security.EscapeOutput |
|
| 324 | + echo '<style id="' . esc_attr( $core->args['opt_name'] ) . '-dynamic-css" title="dynamic-css" class="redux-options-output">' . $core->outputCSS . '</style>'; |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * Can Output CSS |
|
| 330 | + * Check if a field meets its requirements before outputting to CSS |
|
| 331 | + * |
|
| 332 | + * @param ReduxFramework $core ReduxFramework core pointer. |
|
| 333 | + * @param array $field Field array. |
|
| 334 | + * |
|
| 335 | + * @return bool |
|
| 336 | + */ |
|
| 337 | + private function can_output_css( ReduxFramework $core, array $field ): ?bool { |
|
| 338 | + $return = true; |
|
| 339 | + |
|
| 340 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 341 | + $field = apply_filters( "redux/field/{$core->args['opt_name']}/_can_output_css", $field ); |
|
| 342 | + |
|
| 343 | + if ( isset( $field['force_output'] ) && true === $field['force_output'] ) { |
|
| 344 | + return true; |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + if ( ! empty( $field['required'] ) ) { |
|
| 348 | + if ( isset( $field['required'][0] ) ) { |
|
| 349 | + if ( ! is_array( $field['required'][0] ) && 3 === count( $field['required'] ) ) { |
|
| 350 | + $parent_value = $GLOBALS[ $core->args['global_variable'] ][ $field['required'][0] ] ?? ''; |
|
| 351 | + $check_value = $field['required'][2]; |
|
| 352 | + $operation = $field['required'][1]; |
|
| 353 | + $return = $core->required_class->compare_value_dependencies( $parent_value, $check_value, $operation ); |
|
| 354 | + } elseif ( is_array( $field['required'][0] ) ) { |
|
| 355 | + foreach ( $field['required'] as $required ) { |
|
| 356 | + if ( isset( $required[0] ) && ! is_array( $required[0] ) && 3 === count( $required ) ) { |
|
| 357 | + $parent_value = $GLOBALS[ $core->args['global_variable'] ][ $required[0] ] ?? ''; |
|
| 358 | + $check_value = $required[2]; |
|
| 359 | + $operation = $required[1]; |
|
| 360 | + $return = $core->required_class->compare_value_dependencies( $parent_value, $check_value, $operation ); |
|
| 361 | + } |
|
| 362 | + if ( ! $return ) { |
|
| 363 | + return $return; |
|
| 364 | + } |
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | + } |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + return $return; |
|
| 371 | + } |
|
| 372 | + } |
|
| 373 | 373 | } |
@@ -10,80 +10,80 @@ |
||
| 10 | 10 | |
| 11 | 11 | if ( ! class_exists( 'Redux_Extensions', false ) ) { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * Class Redux_Extensions |
|
| 15 | - */ |
|
| 16 | - class Redux_Extensions extends Redux_Class { |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * Redux_Extensions constructor. |
|
| 20 | - * |
|
| 21 | - * @param object $redux ReduxFramework object pointer. |
|
| 22 | - * |
|
| 23 | - * @throws ReflectionException Exception. |
|
| 24 | - */ |
|
| 25 | - public function __construct( $redux ) { |
|
| 26 | - parent::__construct( $redux ); |
|
| 27 | - |
|
| 28 | - $this->load(); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Class load functions. |
|
| 33 | - * |
|
| 34 | - * @throws ReflectionException For fallback. |
|
| 35 | - */ |
|
| 36 | - private function load() { |
|
| 37 | - $core = $this->core(); |
|
| 38 | - |
|
| 39 | - $max = 1; |
|
| 40 | - |
|
| 41 | - for ( $i = 1; $i <= $max; $i++ ) { |
|
| 42 | - $path = Redux_Core::$dir . 'inc/extensions/'; |
|
| 43 | - |
|
| 44 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 45 | - $path = apply_filters( 'redux/' . $core->args['opt_name'] . '/extensions/dir', $path ); |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Action 'redux/extensions/before' |
|
| 49 | - * |
|
| 50 | - * @param object $this ReduxFramework |
|
| 51 | - */ |
|
| 52 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 53 | - do_action( 'redux/extensions/before', $core ); |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Action 'redux/extensions/{opt_name}/before' |
|
| 57 | - * |
|
| 58 | - * @param object $this ReduxFramework |
|
| 59 | - */ |
|
| 60 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 61 | - do_action( "redux/extensions/{$core->args['opt_name']}/before", $core ); |
|
| 62 | - |
|
| 63 | - if ( isset( $core->old_opt_name ) ) { |
|
| 64 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 65 | - do_action( 'redux/extensions/' . $core->old_opt_name . '/before', $core ); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - require_once Redux_Core::$dir . 'inc/classes/class-redux-extension-abstract.php'; |
|
| 69 | - |
|
| 70 | - $path = untrailingslashit( $path ); |
|
| 71 | - |
|
| 72 | - Redux::set_extensions( $core->args['opt_name'], $path, true ); |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * Action 'redux/extensions/{opt_name}' |
|
| 76 | - * |
|
| 77 | - * @param object $this ReduxFramework |
|
| 78 | - */ |
|
| 79 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 80 | - do_action( "redux/extensions/{$core->args['opt_name']}", $core ); |
|
| 81 | - |
|
| 82 | - if ( isset( $core->old_opt_name ) ) { |
|
| 83 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 84 | - do_action( 'redux/extensions/' . $core->old_opt_name, $core ); |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - } |
|
| 13 | + /** |
|
| 14 | + * Class Redux_Extensions |
|
| 15 | + */ |
|
| 16 | + class Redux_Extensions extends Redux_Class { |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * Redux_Extensions constructor. |
|
| 20 | + * |
|
| 21 | + * @param object $redux ReduxFramework object pointer. |
|
| 22 | + * |
|
| 23 | + * @throws ReflectionException Exception. |
|
| 24 | + */ |
|
| 25 | + public function __construct( $redux ) { |
|
| 26 | + parent::__construct( $redux ); |
|
| 27 | + |
|
| 28 | + $this->load(); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Class load functions. |
|
| 33 | + * |
|
| 34 | + * @throws ReflectionException For fallback. |
|
| 35 | + */ |
|
| 36 | + private function load() { |
|
| 37 | + $core = $this->core(); |
|
| 38 | + |
|
| 39 | + $max = 1; |
|
| 40 | + |
|
| 41 | + for ( $i = 1; $i <= $max; $i++ ) { |
|
| 42 | + $path = Redux_Core::$dir . 'inc/extensions/'; |
|
| 43 | + |
|
| 44 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 45 | + $path = apply_filters( 'redux/' . $core->args['opt_name'] . '/extensions/dir', $path ); |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Action 'redux/extensions/before' |
|
| 49 | + * |
|
| 50 | + * @param object $this ReduxFramework |
|
| 51 | + */ |
|
| 52 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 53 | + do_action( 'redux/extensions/before', $core ); |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Action 'redux/extensions/{opt_name}/before' |
|
| 57 | + * |
|
| 58 | + * @param object $this ReduxFramework |
|
| 59 | + */ |
|
| 60 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 61 | + do_action( "redux/extensions/{$core->args['opt_name']}/before", $core ); |
|
| 62 | + |
|
| 63 | + if ( isset( $core->old_opt_name ) ) { |
|
| 64 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 65 | + do_action( 'redux/extensions/' . $core->old_opt_name . '/before', $core ); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + require_once Redux_Core::$dir . 'inc/classes/class-redux-extension-abstract.php'; |
|
| 69 | + |
|
| 70 | + $path = untrailingslashit( $path ); |
|
| 71 | + |
|
| 72 | + Redux::set_extensions( $core->args['opt_name'], $path, true ); |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * Action 'redux/extensions/{opt_name}' |
|
| 76 | + * |
|
| 77 | + * @param object $this ReduxFramework |
|
| 78 | + */ |
|
| 79 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 80 | + do_action( "redux/extensions/{$core->args['opt_name']}", $core ); |
|
| 81 | + |
|
| 82 | + if ( isset( $core->old_opt_name ) ) { |
|
| 83 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 84 | + do_action( 'redux/extensions/' . $core->old_opt_name, $core ); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | 89 | } |
@@ -11,27 +11,27 @@ |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Path', false ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Path |
|
| 16 | - */ |
|
| 17 | - class Redux_Path { |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Path |
|
| 16 | + */ |
|
| 17 | + class Redux_Path { |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Class init |
|
| 21 | - */ |
|
| 22 | - public static function init() {} |
|
| 19 | + /** |
|
| 20 | + * Class init |
|
| 21 | + */ |
|
| 22 | + public static function init() {} |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Gets Redux path. |
|
| 26 | - * |
|
| 27 | - * @param string $relative_path Self-explanatory. |
|
| 28 | - * |
|
| 29 | - * @return string |
|
| 30 | - */ |
|
| 31 | - public static function get_path( string $relative_path ): string { |
|
| 32 | - return Redux_Core::$redux_path . $relative_path; |
|
| 33 | - } |
|
| 34 | - } |
|
| 24 | + /** |
|
| 25 | + * Gets Redux path. |
|
| 26 | + * |
|
| 27 | + * @param string $relative_path Self-explanatory. |
|
| 28 | + * |
|
| 29 | + * @return string |
|
| 30 | + */ |
|
| 31 | + public static function get_path( string $relative_path ): string { |
|
| 32 | + return Redux_Core::$redux_path . $relative_path; |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - Redux_Path::init(); |
|
| 36 | + Redux_Path::init(); |
|
| 37 | 37 | } |
@@ -12,100 +12,100 @@ |
||
| 12 | 12 | // Don't duplicate me! |
| 13 | 13 | if ( ! class_exists( 'Redux_Content', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Main Redux_Content class |
|
| 17 | - * |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - */ |
|
| 20 | - class Redux_Content extends Redux_Field { |
|
| 15 | + /** |
|
| 16 | + * Main Redux_Content class |
|
| 17 | + * |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + */ |
|
| 20 | + class Redux_Content extends Redux_Field { |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Set field and value defaults. |
|
| 24 | - */ |
|
| 25 | - public function set_defaults() { |
|
| 26 | - $defaults = array( |
|
| 27 | - 'content' => '', |
|
| 28 | - 'class' => '', |
|
| 29 | - 'mode' => 'content', |
|
| 30 | - 'icon' => '', |
|
| 31 | - 'style' => 'normal', |
|
| 32 | - ); |
|
| 22 | + /** |
|
| 23 | + * Set field and value defaults. |
|
| 24 | + */ |
|
| 25 | + public function set_defaults() { |
|
| 26 | + $defaults = array( |
|
| 27 | + 'content' => '', |
|
| 28 | + 'class' => '', |
|
| 29 | + 'mode' => 'content', |
|
| 30 | + 'icon' => '', |
|
| 31 | + 'style' => 'normal', |
|
| 32 | + ); |
|
| 33 | 33 | |
| 34 | - $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 35 | - } |
|
| 34 | + $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Field Render Function. |
|
| 39 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 40 | - * |
|
| 41 | - * @since 1.0.0 |
|
| 42 | - * @access public |
|
| 43 | - * @return void |
|
| 44 | - */ |
|
| 45 | - public function render() { |
|
| 46 | - echo '</td></tr></table>'; |
|
| 37 | + /** |
|
| 38 | + * Field Render Function. |
|
| 39 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 40 | + * |
|
| 41 | + * @since 1.0.0 |
|
| 42 | + * @access public |
|
| 43 | + * @return void |
|
| 44 | + */ |
|
| 45 | + public function render() { |
|
| 46 | + echo '</td></tr></table>'; |
|
| 47 | 47 | |
| 48 | - if ( 'content' === $this->field['mode'] ) { |
|
| 49 | - echo '<div |
|
| 48 | + if ( 'content' === $this->field['mode'] ) { |
|
| 49 | + echo '<div |
|
| 50 | 50 | id="content-' . esc_attr( $this->field['id'] ) . '" |
| 51 | 51 | class="redux-field redux-field-borders ' . esc_attr( $this->field['class'] ) . ' redux-field-' . esc_attr( $this->field['mode'] ) . '"' . |
| 52 | - '>'; |
|
| 52 | + '>'; |
|
| 53 | 53 | |
| 54 | - echo wp_kses_post( $this->field['content'] ); |
|
| 55 | - } elseif ( 'heading' === $this->field['mode'] ) { |
|
| 56 | - $has_icon = isset( $this->field['icon'] ) && ! empty( $this->field['icon'] ) && true !== $this->field['icon'] ? 'hasIcon ' : ''; |
|
| 54 | + echo wp_kses_post( $this->field['content'] ); |
|
| 55 | + } elseif ( 'heading' === $this->field['mode'] ) { |
|
| 56 | + $has_icon = isset( $this->field['icon'] ) && ! empty( $this->field['icon'] ) && true !== $this->field['icon'] ? 'hasIcon ' : ''; |
|
| 57 | 57 | |
| 58 | - echo '<div |
|
| 58 | + echo '<div |
|
| 59 | 59 | id="heading-' . esc_attr( $this->field['id'] ) . '" |
| 60 | 60 | class="redux-field redux-field-borders ' . esc_attr( $has_icon ) . esc_attr( $this->field['class'] ) . ' redux-field-' . esc_attr( $this->field['mode'] ) . '"' . |
| 61 | - '>'; |
|
| 61 | + '>'; |
|
| 62 | 62 | |
| 63 | - if ( isset( $this->field['icon'] ) && ! empty( $this->field['icon'] ) && true !== $this->field['icon'] ) { |
|
| 64 | - echo '<p class="redux-heading-icon"><i class="' . esc_attr( $this->field['icon'] ) . ' icon-large"></i></p>'; |
|
| 65 | - } |
|
| 63 | + if ( isset( $this->field['icon'] ) && ! empty( $this->field['icon'] ) && true !== $this->field['icon'] ) { |
|
| 64 | + echo '<p class="redux-heading-icon"><i class="' . esc_attr( $this->field['icon'] ) . ' icon-large"></i></p>'; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - echo '<h2 class="redux-heading-text">' . wp_kses_post( $this->field['content'] ) . '</h2>'; |
|
| 68 | - } elseif ( 'subheading' === $this->field['mode'] ) { |
|
| 69 | - echo '<div |
|
| 67 | + echo '<h2 class="redux-heading-text">' . wp_kses_post( $this->field['content'] ) . '</h2>'; |
|
| 68 | + } elseif ( 'subheading' === $this->field['mode'] ) { |
|
| 69 | + echo '<div |
|
| 70 | 70 | id="subheading-' . esc_attr( $this->field['id'] ) . '" |
| 71 | 71 | class="redux-field redux-field-borders ' . esc_attr( $this->field['class'] ) . ' redux-field-' . esc_attr( $this->field['mode'] ) . '"' . |
| 72 | - '>'; |
|
| 72 | + '>'; |
|
| 73 | 73 | |
| 74 | - echo wp_kses_post( $this->field['content'] ); |
|
| 75 | - } elseif ( 'submessage' === $this->field['mode'] ) { |
|
| 76 | - echo '<div |
|
| 74 | + echo wp_kses_post( $this->field['content'] ); |
|
| 75 | + } elseif ( 'submessage' === $this->field['mode'] ) { |
|
| 76 | + echo '<div |
|
| 77 | 77 | id="submessage-' . esc_attr( $this->field['id'] ) . '" |
| 78 | 78 | class="redux-field redux-field-no-borders redux-submessage-' . esc_attr( $this->field['style'] ) . ' ' . esc_attr( $this->field['class'] ) . ' redux-field-' . esc_attr( $this->field['mode'] ) . '"' . |
| 79 | - '>'; |
|
| 79 | + '>'; |
|
| 80 | 80 | |
| 81 | - echo wp_kses_post( $this->field['content'] ); |
|
| 82 | - } |
|
| 81 | + echo wp_kses_post( $this->field['content'] ); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - echo '</div>'; |
|
| 85 | - echo '<table class="form-table no-border" style="display:none;">'; |
|
| 86 | - echo '<tbody>'; |
|
| 87 | - echo '<tr style="border-bottom:0; display:none;">'; |
|
| 88 | - echo '<th style="padding-top:0;"></th>'; |
|
| 89 | - echo '<td style="padding-top:0;">'; |
|
| 90 | - } |
|
| 84 | + echo '</div>'; |
|
| 85 | + echo '<table class="form-table no-border" style="display:none;">'; |
|
| 86 | + echo '<tbody>'; |
|
| 87 | + echo '<tr style="border-bottom:0; display:none;">'; |
|
| 88 | + echo '<th style="padding-top:0;"></th>'; |
|
| 89 | + echo '<td style="padding-top:0;">'; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Enqueue Function. |
|
| 94 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 95 | - * |
|
| 96 | - * @since 1.0.0 |
|
| 97 | - * @access public |
|
| 98 | - * @return void |
|
| 99 | - */ |
|
| 100 | - public function enqueue() { |
|
| 101 | - if ( $this->parent->args['dev_mode'] ) { |
|
| 102 | - wp_enqueue_style( |
|
| 103 | - 'redux-field-content', |
|
| 104 | - Redux_Core::$url . 'inc/fields/content/redux-content.css', |
|
| 105 | - array(), |
|
| 106 | - $this->timestamp |
|
| 107 | - ); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - } |
|
| 92 | + /** |
|
| 93 | + * Enqueue Function. |
|
| 94 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 95 | + * |
|
| 96 | + * @since 1.0.0 |
|
| 97 | + * @access public |
|
| 98 | + * @return void |
|
| 99 | + */ |
|
| 100 | + public function enqueue() { |
|
| 101 | + if ( $this->parent->args['dev_mode'] ) { |
|
| 102 | + wp_enqueue_style( |
|
| 103 | + 'redux-field-content', |
|
| 104 | + Redux_Core::$url . 'inc/fields/content/redux-content.css', |
|
| 105 | + array(), |
|
| 106 | + $this->timestamp |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | } |
@@ -12,133 +12,133 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_Dimensions', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_Dimensions |
|
| 17 | - */ |
|
| 18 | - class Redux_Dimensions extends Redux_Field { |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Set field and value defaults. |
|
| 22 | - */ |
|
| 23 | - public function set_defaults() { |
|
| 24 | - // No errors, please. |
|
| 25 | - $defaults = array( |
|
| 26 | - 'width' => true, |
|
| 27 | - 'height' => true, |
|
| 28 | - 'units_extended' => false, |
|
| 29 | - 'units' => 'px', |
|
| 30 | - 'mode' => array( |
|
| 31 | - 'width' => false, |
|
| 32 | - 'height' => false, |
|
| 33 | - ), |
|
| 34 | - ); |
|
| 35 | - |
|
| 36 | - $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 37 | - |
|
| 38 | - $defaults = array( |
|
| 39 | - 'width' => '', |
|
| 40 | - 'height' => '', |
|
| 41 | - 'units' => 'px', |
|
| 42 | - ); |
|
| 43 | - |
|
| 44 | - $this->value = wp_parse_args( $this->value, $defaults ); |
|
| 45 | - |
|
| 46 | - if ( isset( $this->value['unit'] ) ) { |
|
| 47 | - $this->value['units'] = $this->value['unit']; |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Field Render Function. |
|
| 53 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 54 | - * |
|
| 55 | - * @since ReduxFramework 1.0.0 |
|
| 56 | - */ |
|
| 57 | - public function render() { |
|
| 58 | - /* |
|
| 15 | + /** |
|
| 16 | + * Class Redux_Dimensions |
|
| 17 | + */ |
|
| 18 | + class Redux_Dimensions extends Redux_Field { |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Set field and value defaults. |
|
| 22 | + */ |
|
| 23 | + public function set_defaults() { |
|
| 24 | + // No errors, please. |
|
| 25 | + $defaults = array( |
|
| 26 | + 'width' => true, |
|
| 27 | + 'height' => true, |
|
| 28 | + 'units_extended' => false, |
|
| 29 | + 'units' => 'px', |
|
| 30 | + 'mode' => array( |
|
| 31 | + 'width' => false, |
|
| 32 | + 'height' => false, |
|
| 33 | + ), |
|
| 34 | + ); |
|
| 35 | + |
|
| 36 | + $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 37 | + |
|
| 38 | + $defaults = array( |
|
| 39 | + 'width' => '', |
|
| 40 | + 'height' => '', |
|
| 41 | + 'units' => 'px', |
|
| 42 | + ); |
|
| 43 | + |
|
| 44 | + $this->value = wp_parse_args( $this->value, $defaults ); |
|
| 45 | + |
|
| 46 | + if ( isset( $this->value['unit'] ) ) { |
|
| 47 | + $this->value['units'] = $this->value['unit']; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Field Render Function. |
|
| 53 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 54 | + * |
|
| 55 | + * @since ReduxFramework 1.0.0 |
|
| 56 | + */ |
|
| 57 | + public function render() { |
|
| 58 | + /* |
|
| 59 | 59 | * Acceptable values checks. If the passed variable doesn't pass muster, we unset them |
| 60 | 60 | * and reset them with default values to avoid errors. |
| 61 | 61 | */ |
| 62 | 62 | |
| 63 | - $arr_units = Redux_Helpers::$array_units; |
|
| 63 | + $arr_units = Redux_Helpers::$array_units; |
|
| 64 | 64 | |
| 65 | - $unit_check = $arr_units; |
|
| 66 | - $unit_check[] = false; |
|
| 65 | + $unit_check = $arr_units; |
|
| 66 | + $unit_check[] = false; |
|
| 67 | 67 | |
| 68 | - // If units field has a value but is not an acceptable value, unset the variable. |
|
| 69 | - if ( isset( $this->field['units'] ) && ! Redux_Helpers::array_in_array( $this->field['units'], $unit_check ) ) { |
|
| 70 | - unset( $this->field['units'] ); |
|
| 71 | - } |
|
| 68 | + // If units field has a value but is not an acceptable value, unset the variable. |
|
| 69 | + if ( isset( $this->field['units'] ) && ! Redux_Helpers::array_in_array( $this->field['units'], $unit_check ) ) { |
|
| 70 | + unset( $this->field['units'] ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - // If there is a default unit value but is not an accepted value, unset the variable. |
|
| 74 | - if ( isset( $this->value['units'] ) && ! Redux_Helpers::array_in_array( $this->value['units'], $unit_check ) ) { |
|
| 75 | - unset( $this->value['units'] ); |
|
| 76 | - } |
|
| 73 | + // If there is a default unit value but is not an accepted value, unset the variable. |
|
| 74 | + if ( isset( $this->value['units'] ) && ! Redux_Helpers::array_in_array( $this->value['units'], $unit_check ) ) { |
|
| 75 | + unset( $this->value['units'] ); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /* |
|
| 78 | + /* |
|
| 79 | 79 | * Since the unit field could be an array, string value or bool (to hide the unit field) |
| 80 | 80 | * we need to separate our functions to avoid those nasty PHP index notices! |
| 81 | 81 | */ |
| 82 | 82 | |
| 83 | - // if field units have a value and ARE an array, then evaluate as needed. |
|
| 84 | - if ( isset( $this->field['units'] ) && ! is_array( $this->field['units'] ) ) { |
|
| 85 | - |
|
| 86 | - // If units fields has a value but units value does not then make units value the field value. |
|
| 87 | - if ( isset( $this->field['units'] ) && ! isset( $this->value['units'] ) || false === $this->field['units'] ) { |
|
| 88 | - $this->value['units'] = $this->field['units']; |
|
| 89 | - |
|
| 90 | - // If unit field does NOT have a value and units value does NOT have a value, set both to blank (default?). |
|
| 91 | - } elseif ( ! isset( $this->field['units'] ) && ! isset( $this->value['units'] ) ) { |
|
| 92 | - $this->field['units'] = 'px'; |
|
| 93 | - $this->value['units'] = 'px'; |
|
| 94 | - |
|
| 95 | - // If unit field has NO value but units value does, then set unit field to value field. |
|
| 96 | - } elseif ( ! isset( $this->field['units'] ) && isset( $this->value['units'] ) ) { |
|
| 97 | - $this->field['units'] = $this->value['units']; |
|
| 98 | - |
|
| 99 | - // if unit value is set and unit value doesn't equal unit field (coz who knows why) |
|
| 100 | - // then set unit value to unit field. |
|
| 101 | - } elseif ( isset( $this->value['units'] ) && $this->value['units'] !== $this->field['units'] ) { |
|
| 102 | - $this->value['units'] = $this->field['units']; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - // do stuff based on unit field NOT set as an array. |
|
| 106 | - // phpcs:ignore Generic.CodeAnalysis.EmptyStatement |
|
| 107 | - } elseif ( isset( $this->field['units'] ) && is_array( $this->field['units'] ) ) { |
|
| 108 | - // nothing to do here, but I'm leaving the construct just in case I have to debug this again. |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - echo '<fieldset id="' . esc_attr( $this->field['id'] ) . '-fieldset" class="redux-dimensions-container" data-id="' . esc_attr( $this->field['id'] ) . '">'; |
|
| 112 | - |
|
| 113 | - $this->select2_config['allowClear'] = false; |
|
| 114 | - |
|
| 115 | - if ( isset( $this->field['select2'] ) ) { |
|
| 116 | - $this->field['select2'] = wp_parse_args( $this->field['select2'], $this->select2_config ); |
|
| 117 | - } else { |
|
| 118 | - $this->field['select2'] = $this->select2_config; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - $this->field['select2'] = Redux_Functions::sanitize_camel_case_array_keys( $this->field['select2'] ); |
|
| 122 | - |
|
| 123 | - $select2_data = Redux_Functions::create_data_string( $this->field['select2'] ); |
|
| 124 | - |
|
| 125 | - // This used to be unit field, but was giving the PHP index error when it was an array, |
|
| 126 | - // so I changed it. |
|
| 127 | - echo '<input type="hidden" id="' . esc_attr( $this->field['id'] ) . '-units" class="field-units" value="' . esc_attr( $this->value['units'] ) . '">'; |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * Width |
|
| 131 | - * */ |
|
| 132 | - if ( true === $this->field['width'] ) { |
|
| 133 | - if ( ! empty( $this->value['width'] ) && false !== $this->value['units'] && strpos( $this->value['width'], strval( $this->value['units'] ) ) === false ) { |
|
| 134 | - $this->value['width'] = filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
| 135 | - if ( false !== $this->field['units'] ) { |
|
| 136 | - $this->value['width'] .= $this->value['units']; |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - echo '<div class="field-dimensions-input input-prepend">'; |
|
| 140 | - echo '<span class="add-on"><i class="el el-resize-horizontal icon-large"></i></span>'; |
|
| 141 | - echo '<input |
|
| 83 | + // if field units have a value and ARE an array, then evaluate as needed. |
|
| 84 | + if ( isset( $this->field['units'] ) && ! is_array( $this->field['units'] ) ) { |
|
| 85 | + |
|
| 86 | + // If units fields has a value but units value does not then make units value the field value. |
|
| 87 | + if ( isset( $this->field['units'] ) && ! isset( $this->value['units'] ) || false === $this->field['units'] ) { |
|
| 88 | + $this->value['units'] = $this->field['units']; |
|
| 89 | + |
|
| 90 | + // If unit field does NOT have a value and units value does NOT have a value, set both to blank (default?). |
|
| 91 | + } elseif ( ! isset( $this->field['units'] ) && ! isset( $this->value['units'] ) ) { |
|
| 92 | + $this->field['units'] = 'px'; |
|
| 93 | + $this->value['units'] = 'px'; |
|
| 94 | + |
|
| 95 | + // If unit field has NO value but units value does, then set unit field to value field. |
|
| 96 | + } elseif ( ! isset( $this->field['units'] ) && isset( $this->value['units'] ) ) { |
|
| 97 | + $this->field['units'] = $this->value['units']; |
|
| 98 | + |
|
| 99 | + // if unit value is set and unit value doesn't equal unit field (coz who knows why) |
|
| 100 | + // then set unit value to unit field. |
|
| 101 | + } elseif ( isset( $this->value['units'] ) && $this->value['units'] !== $this->field['units'] ) { |
|
| 102 | + $this->value['units'] = $this->field['units']; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + // do stuff based on unit field NOT set as an array. |
|
| 106 | + // phpcs:ignore Generic.CodeAnalysis.EmptyStatement |
|
| 107 | + } elseif ( isset( $this->field['units'] ) && is_array( $this->field['units'] ) ) { |
|
| 108 | + // nothing to do here, but I'm leaving the construct just in case I have to debug this again. |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + echo '<fieldset id="' . esc_attr( $this->field['id'] ) . '-fieldset" class="redux-dimensions-container" data-id="' . esc_attr( $this->field['id'] ) . '">'; |
|
| 112 | + |
|
| 113 | + $this->select2_config['allowClear'] = false; |
|
| 114 | + |
|
| 115 | + if ( isset( $this->field['select2'] ) ) { |
|
| 116 | + $this->field['select2'] = wp_parse_args( $this->field['select2'], $this->select2_config ); |
|
| 117 | + } else { |
|
| 118 | + $this->field['select2'] = $this->select2_config; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + $this->field['select2'] = Redux_Functions::sanitize_camel_case_array_keys( $this->field['select2'] ); |
|
| 122 | + |
|
| 123 | + $select2_data = Redux_Functions::create_data_string( $this->field['select2'] ); |
|
| 124 | + |
|
| 125 | + // This used to be unit field, but was giving the PHP index error when it was an array, |
|
| 126 | + // so I changed it. |
|
| 127 | + echo '<input type="hidden" id="' . esc_attr( $this->field['id'] ) . '-units" class="field-units" value="' . esc_attr( $this->value['units'] ) . '">'; |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * Width |
|
| 131 | + * */ |
|
| 132 | + if ( true === $this->field['width'] ) { |
|
| 133 | + if ( ! empty( $this->value['width'] ) && false !== $this->value['units'] && strpos( $this->value['width'], strval( $this->value['units'] ) ) === false ) { |
|
| 134 | + $this->value['width'] = filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
| 135 | + if ( false !== $this->field['units'] ) { |
|
| 136 | + $this->value['width'] .= $this->value['units']; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + echo '<div class="field-dimensions-input input-prepend">'; |
|
| 140 | + echo '<span class="add-on"><i class="el el-resize-horizontal icon-large"></i></span>'; |
|
| 141 | + echo '<input |
|
| 142 | 142 | type="text" |
| 143 | 143 | id="' . esc_attr( $this->field['id'] ) . '-width" |
| 144 | 144 | class="redux-dimensions-input redux-dimensions-width mini ' . esc_attr( $this->field['class'] ) . '" |
@@ -146,29 +146,29 @@ discard block |
||
| 146 | 146 | rel="' . esc_attr( $this->field['id'] ) . '-width-hidden" |
| 147 | 147 | value="' . esc_attr( filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) ) . '">'; |
| 148 | 148 | |
| 149 | - echo '<input |
|
| 149 | + echo '<input |
|
| 150 | 150 | data-id="' . esc_attr( $this->field['id'] ) . '" |
| 151 | 151 | type="hidden" |
| 152 | 152 | id="' . esc_attr( $this->field['id'] ) . '-width-hidden" |
| 153 | 153 | name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[width]" |
| 154 | 154 | value="' . esc_attr( $this->value['width'] ) . '">'; |
| 155 | 155 | |
| 156 | - echo '</div>'; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Height |
|
| 161 | - * */ |
|
| 162 | - if ( true === $this->field['height'] ) { |
|
| 163 | - if ( ! empty( $this->value['height'] ) && false !== $this->value['units'] && strpos( $this->value['height'], strval( $this->value['units'] ) ) === false ) { |
|
| 164 | - $this->value['height'] = filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
| 165 | - if ( false !== $this->field['units'] ) { |
|
| 166 | - $this->value['height'] .= $this->value['units']; |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - echo '<div class="field-dimensions-input input-prepend">'; |
|
| 170 | - echo '<span class="add-on"><i class="el el-resize-vertical icon-large"></i></span>'; |
|
| 171 | - echo '<input |
|
| 156 | + echo '</div>'; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Height |
|
| 161 | + * */ |
|
| 162 | + if ( true === $this->field['height'] ) { |
|
| 163 | + if ( ! empty( $this->value['height'] ) && false !== $this->value['units'] && strpos( $this->value['height'], strval( $this->value['units'] ) ) === false ) { |
|
| 164 | + $this->value['height'] = filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
| 165 | + if ( false !== $this->field['units'] ) { |
|
| 166 | + $this->value['height'] .= $this->value['units']; |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + echo '<div class="field-dimensions-input input-prepend">'; |
|
| 170 | + echo '<span class="add-on"><i class="el el-resize-vertical icon-large"></i></span>'; |
|
| 171 | + echo '<input |
|
| 172 | 172 | type="text" |
| 173 | 173 | id="' . esc_attr( $this->field['id'] ) . '-height" |
| 174 | 174 | class="redux-dimensions-input redux-dimensions-height mini ' . esc_attr( $this->field['class'] ) . '" |
@@ -176,156 +176,156 @@ discard block |
||
| 176 | 176 | rel="' . esc_attr( $this->field['id'] ) . '-height-hidden" |
| 177 | 177 | value="' . esc_attr( filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) ) . '">'; |
| 178 | 178 | |
| 179 | - echo '<input |
|
| 179 | + echo '<input |
|
| 180 | 180 | data-id="' . esc_attr( $this->field['id'] ) . '" |
| 181 | 181 | type="hidden" |
| 182 | 182 | id="' . esc_attr( $this->field['id'] ) . '-height-hidden" |
| 183 | 183 | name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[height]" |
| 184 | 184 | value="' . esc_attr( $this->value['height'] ) . '">'; |
| 185 | - echo '</div>'; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Units |
|
| 190 | - * */ |
|
| 191 | - // If units field is set and units field NOT false then fill out the options object and show it, otherwise it's hidden |
|
| 192 | - // and the default units value will apply. |
|
| 193 | - if ( isset( $this->field['units'] ) && false !== $this->field['units'] ) { |
|
| 194 | - echo '<div |
|
| 185 | + echo '</div>'; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Units |
|
| 190 | + * */ |
|
| 191 | + // If units field is set and units field NOT false then fill out the options object and show it, otherwise it's hidden |
|
| 192 | + // and the default units value will apply. |
|
| 193 | + if ( isset( $this->field['units'] ) && false !== $this->field['units'] ) { |
|
| 194 | + echo '<div |
|
| 195 | 195 | class="select_wrapper dimensions-units" |
| 196 | 196 | original-title="' . esc_html__( 'Units', 'redux-framework' ) . '">'; |
| 197 | 197 | |
| 198 | - echo '<select |
|
| 198 | + echo '<select |
|
| 199 | 199 | data-id="' . esc_attr( $this->field['id'] ) . '" |
| 200 | 200 | data-placeholder="' . esc_html__( 'Units', 'redux-framework' ) . '" |
| 201 | 201 | class="redux-dimensions redux-dimensions-units select ' . esc_attr( $this->field['class'] ) . '" |
| 202 | 202 | original-title="' . esc_html__( 'Units', 'redux-framework' ) . '" |
| 203 | 203 | name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[units]"' . esc_attr( $select2_data ) . '>'; |
| 204 | 204 | |
| 205 | - // Extended units, show 'em all. |
|
| 206 | - if ( $this->field['units_extended'] ) { |
|
| 207 | - $test_units = $arr_units; |
|
| 208 | - } else { |
|
| 209 | - $test_units = array( 'px', 'em', 'rem', '%' ); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - if ( '' !== $this->field['units'] && is_array( $this->field['units'] ) ) { |
|
| 213 | - $test_units = $this->field['units']; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - if ( in_array( $this->field['units'], $test_units, true ) ) { |
|
| 217 | - echo '<option value="' . esc_attr( $this->field['units'] ) . '" selected="selected">' . esc_attr( $this->field['units'] ) . '</option>'; |
|
| 218 | - } else { |
|
| 219 | - foreach ( $test_units as $a_unit ) { |
|
| 220 | - echo '<option value="' . esc_attr( $a_unit ) . '" ' . selected( $this->value['units'], $a_unit, false ) . '>' . esc_attr( $a_unit ) . '</option>'; |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - echo '</select></div>'; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - echo '</fieldset>'; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * Enqueue Function. |
|
| 231 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 232 | - * |
|
| 233 | - * @since ReduxFramework 1.0.0 |
|
| 234 | - */ |
|
| 235 | - public function enqueue() { |
|
| 236 | - wp_enqueue_style( 'select2-css' ); |
|
| 237 | - |
|
| 238 | - wp_enqueue_script( |
|
| 239 | - 'redux-field-dimensions', |
|
| 240 | - Redux_Core::$url . 'inc/fields/dimensions/redux-dimensions' . Redux_Functions::is_min() . '.js', |
|
| 241 | - array( 'jquery', 'select2-js', 'redux-js' ), |
|
| 242 | - $this->timestamp, |
|
| 243 | - true |
|
| 244 | - ); |
|
| 245 | - |
|
| 246 | - if ( $this->parent->args['dev_mode'] ) { |
|
| 247 | - wp_enqueue_style( |
|
| 248 | - 'redux-field-dimensions', |
|
| 249 | - Redux_Core::$url . 'inc/fields/dimensions/redux-dimensions.css', |
|
| 250 | - array(), |
|
| 251 | - $this->timestamp |
|
| 252 | - ); |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * Compile CSS styles for output. |
|
| 258 | - * |
|
| 259 | - * @param string $data CSS data. |
|
| 260 | - * |
|
| 261 | - * @return string |
|
| 262 | - */ |
|
| 263 | - public function css_style( $data ): string { |
|
| 264 | - $style = ''; |
|
| 265 | - |
|
| 266 | - // If field units has a value and IS an array, then evaluate as needed. |
|
| 267 | - if ( isset( $this->field['units'] ) && ! is_array( $this->field['units'] ) ) { |
|
| 268 | - |
|
| 269 | - // If units fields has a value but units value does not then make units value the field value. |
|
| 270 | - if ( isset( $this->field['units'] ) && ! isset( $this->value['units'] ) || false === $this->field['units'] ) { |
|
| 271 | - $this->value['units'] = $this->field['units']; |
|
| 272 | - |
|
| 273 | - // If units field does NOT have a value and units value does NOT have a value, set both to blank (default?). |
|
| 274 | - } elseif ( ! isset( $this->field['units'] ) && ! isset( $this->value['units'] ) ) { |
|
| 275 | - $this->field['units'] = 'px'; |
|
| 276 | - $this->value['units'] = 'px'; |
|
| 277 | - |
|
| 278 | - // If units field has NO value but units value does, then set unit field to value field. |
|
| 279 | - } elseif ( ! isset( $this->field['units'] ) && isset( $this->value['units'] ) ) { |
|
| 280 | - $this->field['units'] = $this->value['units']; |
|
| 281 | - |
|
| 282 | - // If unit value is set and unit value doesn't equal unit field (coz who knows why) |
|
| 283 | - // then set unit value to unit field. |
|
| 284 | - } elseif ( isset( $this->value['units'] ) && $this->field['units'] !== $this->value['units'] ) { |
|
| 285 | - $this->value['units'] = $this->field['units']; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - // Do stuff based on unit field NOT set as an array. |
|
| 289 | - // phpcs:ignore Generic.CodeAnalysis.EmptyStatement |
|
| 290 | - } elseif ( isset( $this->field['units'] ) && is_array( $this->field['units'] ) ) { |
|
| 291 | - // nothing to do here, but I'm leaving the construct just in case I have to debug this again. |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - $units = $this->value['units'] ?? ''; |
|
| 295 | - |
|
| 296 | - if ( ! is_array( $this->field['mode'] ) ) { |
|
| 297 | - $height = isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'height'; |
|
| 298 | - $width = isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'width'; |
|
| 299 | - } else { |
|
| 300 | - $height = false !== $this->field['mode']['height'] ? $this->field['mode']['height'] : 'height'; |
|
| 301 | - $width = false !== $this->field['mode']['width'] ? $this->field['mode']['width'] : 'width'; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - $clean_value = array( |
|
| 305 | - $height => isset( $this->value['height'] ) ? filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : '', |
|
| 306 | - $width => isset( $this->value['width'] ) ? filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : '', |
|
| 307 | - ); |
|
| 308 | - |
|
| 309 | - foreach ( $clean_value as $key => $value ) { |
|
| 310 | - // Output if it's a numeric entry. |
|
| 311 | - if ( isset( $value ) && is_numeric( $value ) ) { |
|
| 312 | - $style .= $key . ':' . $value . $units . ';'; |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - return $style; |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - /** |
|
| 320 | - * Enable output_variables to be generated. |
|
| 321 | - * |
|
| 322 | - * @since 4.0.3 |
|
| 323 | - * @return void |
|
| 324 | - */ |
|
| 325 | - public function output_variables() { |
|
| 326 | - // No code needed, just defining the method is enough. |
|
| 327 | - } |
|
| 328 | - } |
|
| 205 | + // Extended units, show 'em all. |
|
| 206 | + if ( $this->field['units_extended'] ) { |
|
| 207 | + $test_units = $arr_units; |
|
| 208 | + } else { |
|
| 209 | + $test_units = array( 'px', 'em', 'rem', '%' ); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + if ( '' !== $this->field['units'] && is_array( $this->field['units'] ) ) { |
|
| 213 | + $test_units = $this->field['units']; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + if ( in_array( $this->field['units'], $test_units, true ) ) { |
|
| 217 | + echo '<option value="' . esc_attr( $this->field['units'] ) . '" selected="selected">' . esc_attr( $this->field['units'] ) . '</option>'; |
|
| 218 | + } else { |
|
| 219 | + foreach ( $test_units as $a_unit ) { |
|
| 220 | + echo '<option value="' . esc_attr( $a_unit ) . '" ' . selected( $this->value['units'], $a_unit, false ) . '>' . esc_attr( $a_unit ) . '</option>'; |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + echo '</select></div>'; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + echo '</fieldset>'; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * Enqueue Function. |
|
| 231 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 232 | + * |
|
| 233 | + * @since ReduxFramework 1.0.0 |
|
| 234 | + */ |
|
| 235 | + public function enqueue() { |
|
| 236 | + wp_enqueue_style( 'select2-css' ); |
|
| 237 | + |
|
| 238 | + wp_enqueue_script( |
|
| 239 | + 'redux-field-dimensions', |
|
| 240 | + Redux_Core::$url . 'inc/fields/dimensions/redux-dimensions' . Redux_Functions::is_min() . '.js', |
|
| 241 | + array( 'jquery', 'select2-js', 'redux-js' ), |
|
| 242 | + $this->timestamp, |
|
| 243 | + true |
|
| 244 | + ); |
|
| 245 | + |
|
| 246 | + if ( $this->parent->args['dev_mode'] ) { |
|
| 247 | + wp_enqueue_style( |
|
| 248 | + 'redux-field-dimensions', |
|
| 249 | + Redux_Core::$url . 'inc/fields/dimensions/redux-dimensions.css', |
|
| 250 | + array(), |
|
| 251 | + $this->timestamp |
|
| 252 | + ); |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * Compile CSS styles for output. |
|
| 258 | + * |
|
| 259 | + * @param string $data CSS data. |
|
| 260 | + * |
|
| 261 | + * @return string |
|
| 262 | + */ |
|
| 263 | + public function css_style( $data ): string { |
|
| 264 | + $style = ''; |
|
| 265 | + |
|
| 266 | + // If field units has a value and IS an array, then evaluate as needed. |
|
| 267 | + if ( isset( $this->field['units'] ) && ! is_array( $this->field['units'] ) ) { |
|
| 268 | + |
|
| 269 | + // If units fields has a value but units value does not then make units value the field value. |
|
| 270 | + if ( isset( $this->field['units'] ) && ! isset( $this->value['units'] ) || false === $this->field['units'] ) { |
|
| 271 | + $this->value['units'] = $this->field['units']; |
|
| 272 | + |
|
| 273 | + // If units field does NOT have a value and units value does NOT have a value, set both to blank (default?). |
|
| 274 | + } elseif ( ! isset( $this->field['units'] ) && ! isset( $this->value['units'] ) ) { |
|
| 275 | + $this->field['units'] = 'px'; |
|
| 276 | + $this->value['units'] = 'px'; |
|
| 277 | + |
|
| 278 | + // If units field has NO value but units value does, then set unit field to value field. |
|
| 279 | + } elseif ( ! isset( $this->field['units'] ) && isset( $this->value['units'] ) ) { |
|
| 280 | + $this->field['units'] = $this->value['units']; |
|
| 281 | + |
|
| 282 | + // If unit value is set and unit value doesn't equal unit field (coz who knows why) |
|
| 283 | + // then set unit value to unit field. |
|
| 284 | + } elseif ( isset( $this->value['units'] ) && $this->field['units'] !== $this->value['units'] ) { |
|
| 285 | + $this->value['units'] = $this->field['units']; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + // Do stuff based on unit field NOT set as an array. |
|
| 289 | + // phpcs:ignore Generic.CodeAnalysis.EmptyStatement |
|
| 290 | + } elseif ( isset( $this->field['units'] ) && is_array( $this->field['units'] ) ) { |
|
| 291 | + // nothing to do here, but I'm leaving the construct just in case I have to debug this again. |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + $units = $this->value['units'] ?? ''; |
|
| 295 | + |
|
| 296 | + if ( ! is_array( $this->field['mode'] ) ) { |
|
| 297 | + $height = isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'height'; |
|
| 298 | + $width = isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'width'; |
|
| 299 | + } else { |
|
| 300 | + $height = false !== $this->field['mode']['height'] ? $this->field['mode']['height'] : 'height'; |
|
| 301 | + $width = false !== $this->field['mode']['width'] ? $this->field['mode']['width'] : 'width'; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + $clean_value = array( |
|
| 305 | + $height => isset( $this->value['height'] ) ? filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : '', |
|
| 306 | + $width => isset( $this->value['width'] ) ? filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : '', |
|
| 307 | + ); |
|
| 308 | + |
|
| 309 | + foreach ( $clean_value as $key => $value ) { |
|
| 310 | + // Output if it's a numeric entry. |
|
| 311 | + if ( isset( $value ) && is_numeric( $value ) ) { |
|
| 312 | + $style .= $key . ':' . $value . $units . ';'; |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + return $style; |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + /** |
|
| 320 | + * Enable output_variables to be generated. |
|
| 321 | + * |
|
| 322 | + * @since 4.0.3 |
|
| 323 | + * @return void |
|
| 324 | + */ |
|
| 325 | + public function output_variables() { |
|
| 326 | + // No code needed, just defining the method is enough. |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | class_alias( 'Redux_Dimensions', 'ReduxFramework_Dimensions' ); |
@@ -12,370 +12,370 @@ |
||
| 12 | 12 | // Don't duplicate me! |
| 13 | 13 | if ( ! class_exists( 'Redux_Border', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_Border |
|
| 17 | - */ |
|
| 18 | - class Redux_Border extends Redux_Field { |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Set field and value defaults. |
|
| 22 | - */ |
|
| 23 | - public function set_defaults() { |
|
| 24 | - // No errors, please. |
|
| 25 | - $defaults = array( |
|
| 26 | - 'top' => true, |
|
| 27 | - 'bottom' => true, |
|
| 28 | - 'all' => true, |
|
| 29 | - 'style' => true, |
|
| 30 | - 'color' => true, |
|
| 31 | - 'left' => true, |
|
| 32 | - 'right' => true, |
|
| 33 | - ); |
|
| 34 | - |
|
| 35 | - $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 36 | - |
|
| 37 | - $defaults = array( |
|
| 38 | - 'top' => '', |
|
| 39 | - 'right' => '', |
|
| 40 | - 'bottom' => '', |
|
| 41 | - 'left' => '', |
|
| 42 | - 'color' => '', |
|
| 43 | - 'style' => '', |
|
| 44 | - ); |
|
| 45 | - |
|
| 46 | - $this->value = wp_parse_args( $this->value, $defaults ); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Field Render Function. |
|
| 51 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 52 | - * |
|
| 53 | - * @since ReduxFramework 1.0.0 |
|
| 54 | - */ |
|
| 55 | - public function render() { |
|
| 56 | - $value = array( |
|
| 57 | - 'top' => isset( $this->value['border-top'] ) ? filter_var( $this->value['border-top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ), |
|
| 58 | - 'right' => isset( $this->value['border-right'] ) ? filter_var( $this->value['border-right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ), |
|
| 59 | - 'bottom' => isset( $this->value['border-bottom'] ) ? filter_var( $this->value['border-bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ), |
|
| 60 | - 'left' => isset( $this->value['border-left'] ) ? filter_var( $this->value['border-left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ), |
|
| 61 | - 'color' => $this->value['border-color'] ?? $this->value['color'], |
|
| 62 | - 'style' => $this->value['border-style'] ?? $this->value['style'], |
|
| 63 | - ); |
|
| 64 | - |
|
| 65 | - if ( ( isset( $this->value['width'] ) || isset( $this->value['border-width'] ) ) ) { |
|
| 66 | - if ( isset( $this->value['border-width'] ) && ! empty( $this->value['border-width'] ) ) { |
|
| 67 | - $this->value['width'] = $this->value['border-width']; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - $this->value['width'] = $this->strip_alphas( $this->value['width'] ); |
|
| 71 | - |
|
| 72 | - $value['top'] = $this->value['width']; |
|
| 73 | - $value['right'] = $this->value['width']; |
|
| 74 | - $value['bottom'] = $this->value['width']; |
|
| 75 | - $value['left'] = $this->value['width']; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $this->value = $value; |
|
| 79 | - |
|
| 80 | - $defaults = array( |
|
| 81 | - 'top' => '', |
|
| 82 | - 'right' => '', |
|
| 83 | - 'bottom' => '', |
|
| 84 | - 'left' => '', |
|
| 85 | - ); |
|
| 86 | - |
|
| 87 | - $this->check_for_all(); |
|
| 88 | - |
|
| 89 | - $this->value = wp_parse_args( $this->value, $defaults ); |
|
| 90 | - |
|
| 91 | - $this->select2_config['allowClear'] = false; |
|
| 92 | - |
|
| 93 | - if ( isset( $this->field['select2'] ) ) { |
|
| 94 | - $this->field['select2'] = wp_parse_args( $this->field['select2'], $this->select2_config ); |
|
| 95 | - } else { |
|
| 96 | - $this->field['select2'] = $this->select2_config; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - $this->field['select2'] = Redux_Functions::sanitize_camel_case_array_keys( $this->field['select2'] ); |
|
| 100 | - |
|
| 101 | - $select2_data = Redux_Functions::create_data_string( $this->field['select2'] ); |
|
| 102 | - |
|
| 103 | - echo '<input type="hidden" class="field-units" value="px">'; |
|
| 104 | - |
|
| 105 | - if ( isset( $this->field['all'] ) && true === $this->field['all'] ) { |
|
| 106 | - echo '<div class="field-border-input input-prepend"><span class="add-on"><i class="el el-fullscreen icon-large"></i></span><input type="text" class="redux-border-all redux-border-input mini ' . esc_attr( $this->field['class'] ) . '" placeholder="' . esc_html__( 'All', 'redux-framework' ) . '" rel="' . esc_attr( $this->field['id'] ) . '-all" value="' . esc_attr( $this->value['top'] ) . '"></div>'; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-top-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-top]" value="' . ( isset( $this->value['top'] ) && '' !== $this->value['top'] ? esc_attr( $this->value['top'] ) . 'px' : '' ) . '">'; |
|
| 110 | - echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-right-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-right]" value="' . ( isset( $this->value['right'] ) && '' !== $this->value['right'] ? esc_attr( $this->value['right'] ) . 'px' : '' ) . '">'; |
|
| 111 | - echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-bottom-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-bottom]" value="' . ( isset( $this->value['bottom'] ) && '' !== $this->value['bottom'] ? esc_attr( $this->value['bottom'] ) . 'px' : '' ) . '">'; |
|
| 112 | - echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-left-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-left]" value="' . ( isset( $this->value['left'] ) && '' !== $this->value['left'] ? esc_attr( $this->value['left'] ) . 'px' : '' ) . '">'; |
|
| 113 | - |
|
| 114 | - if ( ! isset( $this->field['all'] ) || true !== $this->field['all'] ) { |
|
| 115 | - /** |
|
| 116 | - * Top |
|
| 117 | - * */ |
|
| 118 | - if ( true === $this->field['top'] ) { |
|
| 119 | - echo '<div class="field-border-input input-prepend"> |
|
| 15 | + /** |
|
| 16 | + * Class Redux_Border |
|
| 17 | + */ |
|
| 18 | + class Redux_Border extends Redux_Field { |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Set field and value defaults. |
|
| 22 | + */ |
|
| 23 | + public function set_defaults() { |
|
| 24 | + // No errors, please. |
|
| 25 | + $defaults = array( |
|
| 26 | + 'top' => true, |
|
| 27 | + 'bottom' => true, |
|
| 28 | + 'all' => true, |
|
| 29 | + 'style' => true, |
|
| 30 | + 'color' => true, |
|
| 31 | + 'left' => true, |
|
| 32 | + 'right' => true, |
|
| 33 | + ); |
|
| 34 | + |
|
| 35 | + $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 36 | + |
|
| 37 | + $defaults = array( |
|
| 38 | + 'top' => '', |
|
| 39 | + 'right' => '', |
|
| 40 | + 'bottom' => '', |
|
| 41 | + 'left' => '', |
|
| 42 | + 'color' => '', |
|
| 43 | + 'style' => '', |
|
| 44 | + ); |
|
| 45 | + |
|
| 46 | + $this->value = wp_parse_args( $this->value, $defaults ); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Field Render Function. |
|
| 51 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 52 | + * |
|
| 53 | + * @since ReduxFramework 1.0.0 |
|
| 54 | + */ |
|
| 55 | + public function render() { |
|
| 56 | + $value = array( |
|
| 57 | + 'top' => isset( $this->value['border-top'] ) ? filter_var( $this->value['border-top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ), |
|
| 58 | + 'right' => isset( $this->value['border-right'] ) ? filter_var( $this->value['border-right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ), |
|
| 59 | + 'bottom' => isset( $this->value['border-bottom'] ) ? filter_var( $this->value['border-bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ), |
|
| 60 | + 'left' => isset( $this->value['border-left'] ) ? filter_var( $this->value['border-left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ), |
|
| 61 | + 'color' => $this->value['border-color'] ?? $this->value['color'], |
|
| 62 | + 'style' => $this->value['border-style'] ?? $this->value['style'], |
|
| 63 | + ); |
|
| 64 | + |
|
| 65 | + if ( ( isset( $this->value['width'] ) || isset( $this->value['border-width'] ) ) ) { |
|
| 66 | + if ( isset( $this->value['border-width'] ) && ! empty( $this->value['border-width'] ) ) { |
|
| 67 | + $this->value['width'] = $this->value['border-width']; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + $this->value['width'] = $this->strip_alphas( $this->value['width'] ); |
|
| 71 | + |
|
| 72 | + $value['top'] = $this->value['width']; |
|
| 73 | + $value['right'] = $this->value['width']; |
|
| 74 | + $value['bottom'] = $this->value['width']; |
|
| 75 | + $value['left'] = $this->value['width']; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $this->value = $value; |
|
| 79 | + |
|
| 80 | + $defaults = array( |
|
| 81 | + 'top' => '', |
|
| 82 | + 'right' => '', |
|
| 83 | + 'bottom' => '', |
|
| 84 | + 'left' => '', |
|
| 85 | + ); |
|
| 86 | + |
|
| 87 | + $this->check_for_all(); |
|
| 88 | + |
|
| 89 | + $this->value = wp_parse_args( $this->value, $defaults ); |
|
| 90 | + |
|
| 91 | + $this->select2_config['allowClear'] = false; |
|
| 92 | + |
|
| 93 | + if ( isset( $this->field['select2'] ) ) { |
|
| 94 | + $this->field['select2'] = wp_parse_args( $this->field['select2'], $this->select2_config ); |
|
| 95 | + } else { |
|
| 96 | + $this->field['select2'] = $this->select2_config; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + $this->field['select2'] = Redux_Functions::sanitize_camel_case_array_keys( $this->field['select2'] ); |
|
| 100 | + |
|
| 101 | + $select2_data = Redux_Functions::create_data_string( $this->field['select2'] ); |
|
| 102 | + |
|
| 103 | + echo '<input type="hidden" class="field-units" value="px">'; |
|
| 104 | + |
|
| 105 | + if ( isset( $this->field['all'] ) && true === $this->field['all'] ) { |
|
| 106 | + echo '<div class="field-border-input input-prepend"><span class="add-on"><i class="el el-fullscreen icon-large"></i></span><input type="text" class="redux-border-all redux-border-input mini ' . esc_attr( $this->field['class'] ) . '" placeholder="' . esc_html__( 'All', 'redux-framework' ) . '" rel="' . esc_attr( $this->field['id'] ) . '-all" value="' . esc_attr( $this->value['top'] ) . '"></div>'; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-top-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-top]" value="' . ( isset( $this->value['top'] ) && '' !== $this->value['top'] ? esc_attr( $this->value['top'] ) . 'px' : '' ) . '">'; |
|
| 110 | + echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-right-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-right]" value="' . ( isset( $this->value['right'] ) && '' !== $this->value['right'] ? esc_attr( $this->value['right'] ) . 'px' : '' ) . '">'; |
|
| 111 | + echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-bottom-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-bottom]" value="' . ( isset( $this->value['bottom'] ) && '' !== $this->value['bottom'] ? esc_attr( $this->value['bottom'] ) . 'px' : '' ) . '">'; |
|
| 112 | + echo '<input type="hidden" class="redux-border-value" id="' . esc_attr( $this->field['id'] ) . '-left-hidden" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-left]" value="' . ( isset( $this->value['left'] ) && '' !== $this->value['left'] ? esc_attr( $this->value['left'] ) . 'px' : '' ) . '">'; |
|
| 113 | + |
|
| 114 | + if ( ! isset( $this->field['all'] ) || true !== $this->field['all'] ) { |
|
| 115 | + /** |
|
| 116 | + * Top |
|
| 117 | + * */ |
|
| 118 | + if ( true === $this->field['top'] ) { |
|
| 119 | + echo '<div class="field-border-input input-prepend"> |
|
| 120 | 120 | <span class="add-on"> |
| 121 | 121 | <i class="el el-arrow-up icon-large"></i> |
| 122 | 122 | </span> |
| 123 | 123 | <input type="text" id="' . esc_attr( $this->field['id'] ) . '-top" class="redux-border-top redux-border-input mini ' . esc_attr( $this->field['class'] ) . '" placeholder="' . esc_html__( 'Top', 'redux-framework' ) . '" rel="' . esc_attr( $this->field['id'] ) . '-top-hidden" value="' . esc_attr( $this->value['top'] ) . '"> |
| 124 | 124 | </div>'; |
| 125 | - } |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Right |
|
| 129 | - * */ |
|
| 130 | - if ( true === $this->field['right'] ) { |
|
| 131 | - echo '<div class="field-border-input input-prepend"> |
|
| 127 | + /** |
|
| 128 | + * Right |
|
| 129 | + * */ |
|
| 130 | + if ( true === $this->field['right'] ) { |
|
| 131 | + echo '<div class="field-border-input input-prepend"> |
|
| 132 | 132 | <span class="add-on"> |
| 133 | 133 | <i class="el el-arrow-right icon-large"></i> |
| 134 | 134 | </span> |
| 135 | 135 | <input type="text" id="' . esc_attr( $this->field['id'] ) . '-right" class="redux-border-right redux-border-input mini ' . esc_attr( $this->field['class'] ) . '" placeholder="' . esc_html__( 'Right', 'redux-framework' ) . '" rel="' . esc_attr( $this->field['id'] ) . '-right-hidden" value="' . esc_attr( $this->value['right'] ) . '"> |
| 136 | 136 | </div>'; |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Bottom |
|
| 141 | - * */ |
|
| 142 | - if ( true === $this->field['bottom'] ) { |
|
| 143 | - echo '<div class="field-border-input input-prepend"> |
|
| 139 | + /** |
|
| 140 | + * Bottom |
|
| 141 | + * */ |
|
| 142 | + if ( true === $this->field['bottom'] ) { |
|
| 143 | + echo '<div class="field-border-input input-prepend"> |
|
| 144 | 144 | <span class="add-on"> |
| 145 | 145 | <i class="el el-arrow-down icon-large"></i> |
| 146 | 146 | </span> |
| 147 | 147 | <input type="text" id="' . esc_attr( $this->field['id'] ) . '-bottom" class="redux-border-bottom redux-border-input mini ' . esc_attr( $this->field['class'] ) . '" placeholder="' . esc_html__( 'Bottom', 'redux-framework' ) . '" rel="' . esc_attr( $this->field['id'] ) . '-bottom-hidden" value="' . esc_attr( $this->value['bottom'] ) . '"> |
| 148 | 148 | </div>'; |
| 149 | - } |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * Left |
|
| 153 | - * */ |
|
| 154 | - if ( true === $this->field['left'] ) { |
|
| 155 | - echo '<div class="field-border-input input-prepend"> |
|
| 151 | + /** |
|
| 152 | + * Left |
|
| 153 | + * */ |
|
| 154 | + if ( true === $this->field['left'] ) { |
|
| 155 | + echo '<div class="field-border-input input-prepend"> |
|
| 156 | 156 | <span class="add-on"> |
| 157 | 157 | <i class="el el-arrow-left icon-large"></i> |
| 158 | 158 | </span> |
| 159 | 159 | <input type="text" id="' . esc_attr( $this->field['id'] ) . '-left" class="redux-border-left redux-border-input mini ' . esc_attr( $this->field['class'] ) . '" placeholder="' . esc_html__( 'Left', 'redux-framework' ) . '" rel="' . esc_attr( $this->field['id'] ) . '-left-hidden" value="' . esc_attr( $this->value['left'] ) . '"> |
| 160 | 160 | </div>'; |
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Border-style |
|
| 166 | - * */ |
|
| 167 | - if ( false !== $this->field['style'] ) { |
|
| 168 | - $options = array( |
|
| 169 | - 'solid' => esc_html__( 'Solid', 'redux-framework' ), |
|
| 170 | - 'dashed' => esc_html__( 'Dashed', 'redux-framework' ), |
|
| 171 | - 'dotted' => esc_html__( 'Dotted', 'redux-framework' ), |
|
| 172 | - 'double' => esc_html__( 'Double', 'redux-framework' ), |
|
| 173 | - 'none' => esc_html__( 'None', 'redux-framework' ), |
|
| 174 | - ); |
|
| 175 | - |
|
| 176 | - echo '<select data-placeholder="' . esc_html__( 'Border style', 'redux-framework' ) . '" id="' . esc_attr( $this->field['id'] ) . '[border-style]" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-style]" class="tips redux-border-style ' . esc_attr( $this->field['class'] ) . '" rows="6" data-id="' . esc_attr( $this->field['id'] ) . '"' . esc_attr( $select2_data ) . '>'; |
|
| 177 | - |
|
| 178 | - foreach ( $options as $k => $v ) { |
|
| 179 | - echo '<option value="' . esc_attr( $k ) . '" ' . selected( $value['style'], $k, false ) . '>' . esc_html( $v ) . '</option>'; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - echo '</select>'; |
|
| 183 | - } else { |
|
| 184 | - echo '<input type="hidden" id="' . esc_attr( $this->field['id'] ) . '[border-style]" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-style]" value="' . esc_attr( $this->value['style'] ) . '" data-id="' . esc_attr( $this->field['id'] ) . '">'; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Color |
|
| 189 | - * */ |
|
| 190 | - if ( false !== $this->field['color'] ) { |
|
| 191 | - $default = $this->field['default']['border-color'] ?? ''; |
|
| 192 | - |
|
| 193 | - if ( empty( $default ) ) { |
|
| 194 | - $default = ( isset( $this->field['default']['color'] ) ) ? $this->field['default']['color'] : '#ffffff'; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - echo '<input '; |
|
| 198 | - echo 'name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-color]"'; |
|
| 199 | - echo 'id="' . esc_attr( $this->field['id'] ) . '-border"'; |
|
| 200 | - echo 'class="color-picker redux-border-color redux-color redux-color-init ' . esc_attr( $this->field['class'] ) . '"'; |
|
| 201 | - echo 'type="text"'; |
|
| 202 | - echo 'value="' . esc_attr( $this->value['color'] ) . '"'; |
|
| 203 | - echo 'data-default-color="' . esc_attr( $default ) . '"'; |
|
| 204 | - echo 'data-id="' . esc_attr( $this->field['id'] ) . '"'; |
|
| 205 | - |
|
| 206 | - $data = array( |
|
| 207 | - 'field' => $this->field, |
|
| 208 | - 'index' => '', |
|
| 209 | - ); |
|
| 210 | - |
|
| 211 | - echo Redux_Functions_Ex::output_alpha_data( $data ); // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 212 | - |
|
| 213 | - echo '>'; |
|
| 214 | - } else { |
|
| 215 | - echo '<input type="hidden" id="' . esc_attr( $this->field['id'] ) . '[border-color]" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-color]" value="' . esc_attr( $this->value['color'] ) . '" data-id="' . esc_attr( $this->field['id'] ) . '">'; |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Do enqueue for each field instance. |
|
| 222 | - * |
|
| 223 | - * @return void |
|
| 224 | - */ |
|
| 225 | - public function always_enqueue() { |
|
| 226 | - if ( isset( $this->field['color_alpha'] ) && $this->field['color_alpha'] ) { |
|
| 227 | - if ( ! wp_script_is( 'redux-wp-color-picker-alpha' ) ) { |
|
| 228 | - wp_enqueue_script( 'redux-wp-color-picker-alpha' ); |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * Enqueue Function. |
|
| 235 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 236 | - * |
|
| 237 | - * @since ReduxFramework 1.0.0 |
|
| 238 | - */ |
|
| 239 | - public function enqueue() { |
|
| 240 | - $min = Redux_Functions::is_min(); |
|
| 241 | - |
|
| 242 | - if ( ! wp_style_is( 'select2-css' ) ) { |
|
| 243 | - wp_enqueue_style( 'select2-css' ); |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - if ( ! wp_style_is( 'wp-color-picker' ) ) { |
|
| 247 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - $dep_array = array( 'jquery', 'select2-js', 'wp-color-picker', 'redux-js' ); |
|
| 251 | - |
|
| 252 | - wp_enqueue_script( |
|
| 253 | - 'redux-field-border', |
|
| 254 | - Redux_Core::$url . 'inc/fields/border/redux-border' . $min . '.js', |
|
| 255 | - $dep_array, |
|
| 256 | - $this->timestamp, |
|
| 257 | - true |
|
| 258 | - ); |
|
| 259 | - |
|
| 260 | - if ( $this->parent->args['dev_mode'] ) { |
|
| 261 | - if ( ! wp_style_is( 'redux-color-picker' ) ) { |
|
| 262 | - wp_enqueue_style( 'redux-color-picker' ); |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - wp_enqueue_style( |
|
| 266 | - 'redux-field-border', |
|
| 267 | - Redux_Core::$url . 'inc/fields/border/redux-border.css', |
|
| 268 | - array(), |
|
| 269 | - $this->timestamp |
|
| 270 | - ); |
|
| 271 | - } |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * Check to make sure all is properly set. |
|
| 276 | - * |
|
| 277 | - * @return void |
|
| 278 | - */ |
|
| 279 | - private function check_for_all() { |
|
| 280 | - if ( true === $this->field['all'] ) { |
|
| 281 | - if ( 1 !== $this->field['top'] || 1 !== $this->field['bottom'] || 1 !== $this->field['left'] || 1 !== $this->field['right'] ) { |
|
| 282 | - $this->field['all'] = false; |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * Output CSS styling. |
|
| 289 | - * |
|
| 290 | - * @param mixed $data Value array. |
|
| 291 | - * |
|
| 292 | - * @return string |
|
| 293 | - */ |
|
| 294 | - public function css_style( $data ): string { |
|
| 295 | - $style = ''; |
|
| 296 | - |
|
| 297 | - $this->check_for_all(); |
|
| 298 | - |
|
| 299 | - if ( isset( $this->field['all'] ) && true === $this->field['all'] ) { |
|
| 300 | - $border_width = $data['border-width'] ?? '0px'; |
|
| 301 | - $val = $data['border-top'] ?? $border_width; |
|
| 302 | - |
|
| 303 | - $data['border-top'] = $val; |
|
| 304 | - $data['border-bottom'] = $val; |
|
| 305 | - $data['border-left'] = $val; |
|
| 306 | - $data['border-right'] = $val; |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - $clean_value = array( |
|
| 310 | - 'color' => ! empty( $data['border-color'] ) ? $data['border-color'] : '', |
|
| 311 | - 'style' => ! empty( $data['border-style'] ) ? $data['border-style'] : '', |
|
| 312 | - ); |
|
| 313 | - |
|
| 314 | - $border_width = ''; |
|
| 315 | - if ( isset( $data['border-width'] ) ) { |
|
| 316 | - $border_width = $data['border-width']; |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - $this->field['top'] = $this->field['top'] ?? true; |
|
| 320 | - $this->field['bottom'] = $this->field['bottom'] ?? true; |
|
| 321 | - $this->field['left'] = $this->field['left'] ?? true; |
|
| 322 | - $this->field['right'] = $this->field['right'] ?? true; |
|
| 323 | - |
|
| 324 | - if ( true === $this->field['top'] ) { |
|
| 325 | - $clean_value['top'] = ! empty( $data['border-top'] ) ? $data['border-top'] : $border_width; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - if ( true === $this->field['bottom'] ) { |
|
| 329 | - $clean_value['bottom'] = ! empty( $data['border-bottom'] ) ? $data['border-bottom'] : $border_width; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - if ( true === $this->field['left'] ) { |
|
| 333 | - $clean_value['left'] = ! empty( $data['border-left'] ) ? $data['border-left'] : $border_width; |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - if ( true === $this->field['right'] ) { |
|
| 337 | - $clean_value['right'] = ! empty( $data['border-right'] ) ? $data['border-right'] : $border_width; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - // absolute, padding, margin. |
|
| 341 | - if ( ! isset( $this->field['all'] ) || true !== $this->field['all'] ) { |
|
| 342 | - foreach ( $clean_value as $key => $value ) { |
|
| 343 | - if ( 'color' === $key || 'style' === $key ) { |
|
| 344 | - continue; |
|
| 345 | - } |
|
| 346 | - if ( ! empty( $value ) ) { |
|
| 347 | - $style .= 'border-' . $key . ':' . $value . ' ' . $clean_value['style'] . ' ' . $clean_value['color'] . ';'; |
|
| 348 | - } |
|
| 349 | - } |
|
| 350 | - } elseif ( ! empty( $clean_value['top'] ) ) { |
|
| 351 | - $style .= 'border:' . $clean_value['top'] . ' ' . $clean_value['style'] . ' ' . $clean_value['color'] . ';'; |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - return $style; |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * Strip alpha chars. |
|
| 359 | - * |
|
| 360 | - * @param string $s Criteria. |
|
| 361 | - * |
|
| 362 | - * @return null|string|string[] |
|
| 363 | - */ |
|
| 364 | - private function strip_alphas( string $s ) { |
|
| 365 | - // Regex is our friend. THERE ARE FOUR LIGHTS!! |
|
| 366 | - return preg_replace( '/[^\d.-]/', '', $s ); |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * Enable output_variables to be generated. |
|
| 371 | - * |
|
| 372 | - * @since 4.0.3 |
|
| 373 | - * @return void |
|
| 374 | - */ |
|
| 375 | - public function output_variables() { |
|
| 376 | - // No code needed, just defining the method is enough. |
|
| 377 | - } |
|
| 378 | - } |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Border-style |
|
| 166 | + * */ |
|
| 167 | + if ( false !== $this->field['style'] ) { |
|
| 168 | + $options = array( |
|
| 169 | + 'solid' => esc_html__( 'Solid', 'redux-framework' ), |
|
| 170 | + 'dashed' => esc_html__( 'Dashed', 'redux-framework' ), |
|
| 171 | + 'dotted' => esc_html__( 'Dotted', 'redux-framework' ), |
|
| 172 | + 'double' => esc_html__( 'Double', 'redux-framework' ), |
|
| 173 | + 'none' => esc_html__( 'None', 'redux-framework' ), |
|
| 174 | + ); |
|
| 175 | + |
|
| 176 | + echo '<select data-placeholder="' . esc_html__( 'Border style', 'redux-framework' ) . '" id="' . esc_attr( $this->field['id'] ) . '[border-style]" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-style]" class="tips redux-border-style ' . esc_attr( $this->field['class'] ) . '" rows="6" data-id="' . esc_attr( $this->field['id'] ) . '"' . esc_attr( $select2_data ) . '>'; |
|
| 177 | + |
|
| 178 | + foreach ( $options as $k => $v ) { |
|
| 179 | + echo '<option value="' . esc_attr( $k ) . '" ' . selected( $value['style'], $k, false ) . '>' . esc_html( $v ) . '</option>'; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + echo '</select>'; |
|
| 183 | + } else { |
|
| 184 | + echo '<input type="hidden" id="' . esc_attr( $this->field['id'] ) . '[border-style]" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-style]" value="' . esc_attr( $this->value['style'] ) . '" data-id="' . esc_attr( $this->field['id'] ) . '">'; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Color |
|
| 189 | + * */ |
|
| 190 | + if ( false !== $this->field['color'] ) { |
|
| 191 | + $default = $this->field['default']['border-color'] ?? ''; |
|
| 192 | + |
|
| 193 | + if ( empty( $default ) ) { |
|
| 194 | + $default = ( isset( $this->field['default']['color'] ) ) ? $this->field['default']['color'] : '#ffffff'; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + echo '<input '; |
|
| 198 | + echo 'name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-color]"'; |
|
| 199 | + echo 'id="' . esc_attr( $this->field['id'] ) . '-border"'; |
|
| 200 | + echo 'class="color-picker redux-border-color redux-color redux-color-init ' . esc_attr( $this->field['class'] ) . '"'; |
|
| 201 | + echo 'type="text"'; |
|
| 202 | + echo 'value="' . esc_attr( $this->value['color'] ) . '"'; |
|
| 203 | + echo 'data-default-color="' . esc_attr( $default ) . '"'; |
|
| 204 | + echo 'data-id="' . esc_attr( $this->field['id'] ) . '"'; |
|
| 205 | + |
|
| 206 | + $data = array( |
|
| 207 | + 'field' => $this->field, |
|
| 208 | + 'index' => '', |
|
| 209 | + ); |
|
| 210 | + |
|
| 211 | + echo Redux_Functions_Ex::output_alpha_data( $data ); // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 212 | + |
|
| 213 | + echo '>'; |
|
| 214 | + } else { |
|
| 215 | + echo '<input type="hidden" id="' . esc_attr( $this->field['id'] ) . '[border-color]" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[border-color]" value="' . esc_attr( $this->value['color'] ) . '" data-id="' . esc_attr( $this->field['id'] ) . '">'; |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Do enqueue for each field instance. |
|
| 222 | + * |
|
| 223 | + * @return void |
|
| 224 | + */ |
|
| 225 | + public function always_enqueue() { |
|
| 226 | + if ( isset( $this->field['color_alpha'] ) && $this->field['color_alpha'] ) { |
|
| 227 | + if ( ! wp_script_is( 'redux-wp-color-picker-alpha' ) ) { |
|
| 228 | + wp_enqueue_script( 'redux-wp-color-picker-alpha' ); |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * Enqueue Function. |
|
| 235 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 236 | + * |
|
| 237 | + * @since ReduxFramework 1.0.0 |
|
| 238 | + */ |
|
| 239 | + public function enqueue() { |
|
| 240 | + $min = Redux_Functions::is_min(); |
|
| 241 | + |
|
| 242 | + if ( ! wp_style_is( 'select2-css' ) ) { |
|
| 243 | + wp_enqueue_style( 'select2-css' ); |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + if ( ! wp_style_is( 'wp-color-picker' ) ) { |
|
| 247 | + wp_enqueue_style( 'wp-color-picker' ); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + $dep_array = array( 'jquery', 'select2-js', 'wp-color-picker', 'redux-js' ); |
|
| 251 | + |
|
| 252 | + wp_enqueue_script( |
|
| 253 | + 'redux-field-border', |
|
| 254 | + Redux_Core::$url . 'inc/fields/border/redux-border' . $min . '.js', |
|
| 255 | + $dep_array, |
|
| 256 | + $this->timestamp, |
|
| 257 | + true |
|
| 258 | + ); |
|
| 259 | + |
|
| 260 | + if ( $this->parent->args['dev_mode'] ) { |
|
| 261 | + if ( ! wp_style_is( 'redux-color-picker' ) ) { |
|
| 262 | + wp_enqueue_style( 'redux-color-picker' ); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + wp_enqueue_style( |
|
| 266 | + 'redux-field-border', |
|
| 267 | + Redux_Core::$url . 'inc/fields/border/redux-border.css', |
|
| 268 | + array(), |
|
| 269 | + $this->timestamp |
|
| 270 | + ); |
|
| 271 | + } |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * Check to make sure all is properly set. |
|
| 276 | + * |
|
| 277 | + * @return void |
|
| 278 | + */ |
|
| 279 | + private function check_for_all() { |
|
| 280 | + if ( true === $this->field['all'] ) { |
|
| 281 | + if ( 1 !== $this->field['top'] || 1 !== $this->field['bottom'] || 1 !== $this->field['left'] || 1 !== $this->field['right'] ) { |
|
| 282 | + $this->field['all'] = false; |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * Output CSS styling. |
|
| 289 | + * |
|
| 290 | + * @param mixed $data Value array. |
|
| 291 | + * |
|
| 292 | + * @return string |
|
| 293 | + */ |
|
| 294 | + public function css_style( $data ): string { |
|
| 295 | + $style = ''; |
|
| 296 | + |
|
| 297 | + $this->check_for_all(); |
|
| 298 | + |
|
| 299 | + if ( isset( $this->field['all'] ) && true === $this->field['all'] ) { |
|
| 300 | + $border_width = $data['border-width'] ?? '0px'; |
|
| 301 | + $val = $data['border-top'] ?? $border_width; |
|
| 302 | + |
|
| 303 | + $data['border-top'] = $val; |
|
| 304 | + $data['border-bottom'] = $val; |
|
| 305 | + $data['border-left'] = $val; |
|
| 306 | + $data['border-right'] = $val; |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + $clean_value = array( |
|
| 310 | + 'color' => ! empty( $data['border-color'] ) ? $data['border-color'] : '', |
|
| 311 | + 'style' => ! empty( $data['border-style'] ) ? $data['border-style'] : '', |
|
| 312 | + ); |
|
| 313 | + |
|
| 314 | + $border_width = ''; |
|
| 315 | + if ( isset( $data['border-width'] ) ) { |
|
| 316 | + $border_width = $data['border-width']; |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + $this->field['top'] = $this->field['top'] ?? true; |
|
| 320 | + $this->field['bottom'] = $this->field['bottom'] ?? true; |
|
| 321 | + $this->field['left'] = $this->field['left'] ?? true; |
|
| 322 | + $this->field['right'] = $this->field['right'] ?? true; |
|
| 323 | + |
|
| 324 | + if ( true === $this->field['top'] ) { |
|
| 325 | + $clean_value['top'] = ! empty( $data['border-top'] ) ? $data['border-top'] : $border_width; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + if ( true === $this->field['bottom'] ) { |
|
| 329 | + $clean_value['bottom'] = ! empty( $data['border-bottom'] ) ? $data['border-bottom'] : $border_width; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + if ( true === $this->field['left'] ) { |
|
| 333 | + $clean_value['left'] = ! empty( $data['border-left'] ) ? $data['border-left'] : $border_width; |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + if ( true === $this->field['right'] ) { |
|
| 337 | + $clean_value['right'] = ! empty( $data['border-right'] ) ? $data['border-right'] : $border_width; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + // absolute, padding, margin. |
|
| 341 | + if ( ! isset( $this->field['all'] ) || true !== $this->field['all'] ) { |
|
| 342 | + foreach ( $clean_value as $key => $value ) { |
|
| 343 | + if ( 'color' === $key || 'style' === $key ) { |
|
| 344 | + continue; |
|
| 345 | + } |
|
| 346 | + if ( ! empty( $value ) ) { |
|
| 347 | + $style .= 'border-' . $key . ':' . $value . ' ' . $clean_value['style'] . ' ' . $clean_value['color'] . ';'; |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | + } elseif ( ! empty( $clean_value['top'] ) ) { |
|
| 351 | + $style .= 'border:' . $clean_value['top'] . ' ' . $clean_value['style'] . ' ' . $clean_value['color'] . ';'; |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + return $style; |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * Strip alpha chars. |
|
| 359 | + * |
|
| 360 | + * @param string $s Criteria. |
|
| 361 | + * |
|
| 362 | + * @return null|string|string[] |
|
| 363 | + */ |
|
| 364 | + private function strip_alphas( string $s ) { |
|
| 365 | + // Regex is our friend. THERE ARE FOUR LIGHTS!! |
|
| 366 | + return preg_replace( '/[^\d.-]/', '', $s ); |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * Enable output_variables to be generated. |
|
| 371 | + * |
|
| 372 | + * @since 4.0.3 |
|
| 373 | + * @return void |
|
| 374 | + */ |
|
| 375 | + public function output_variables() { |
|
| 376 | + // No code needed, just defining the method is enough. |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | class_alias( 'Redux_Border', 'ReduxFramework_Border' ); |
@@ -12,104 +12,104 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_Box_Shadow', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Main Redux_Box_Shadow class |
|
| 17 | - * |
|
| 18 | - * @since 4.0.0 |
|
| 19 | - */ |
|
| 20 | - class Redux_Box_Shadow extends Redux_Field { |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Set defaults. |
|
| 24 | - */ |
|
| 25 | - public function set_defaults() { |
|
| 26 | - |
|
| 27 | - $defaults = array( |
|
| 28 | - 'inset-shadow' => true, |
|
| 29 | - 'drop-shadow' => true, |
|
| 30 | - 'preview-color' => '#f1f1f1', |
|
| 31 | - ); |
|
| 32 | - |
|
| 33 | - $this->field = Redux_Functions::parse_args( $this->field, $defaults ); |
|
| 34 | - |
|
| 35 | - $defaults = array( |
|
| 36 | - 'inset' => true, |
|
| 37 | - 'drop' => true, |
|
| 38 | - 'inset-shadow' => array( |
|
| 39 | - 'checked' => false, |
|
| 40 | - 'color' => '#ABABAB', |
|
| 41 | - 'horizontal' => 0, |
|
| 42 | - 'vertical' => 0, |
|
| 43 | - 'blur' => 10, |
|
| 44 | - 'spread' => 0, |
|
| 45 | - ), |
|
| 46 | - 'drop-shadow' => array( |
|
| 47 | - 'checked' => true, |
|
| 48 | - 'color' => '#dddddd', |
|
| 49 | - 'horizontal' => 5, |
|
| 50 | - 'vertical' => 5, |
|
| 51 | - 'blur' => 5, |
|
| 52 | - 'spread' => 1, |
|
| 53 | - ), |
|
| 54 | - ); |
|
| 55 | - |
|
| 56 | - $this->value = Redux_Functions::parse_args( $this->value, $defaults ); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Field Render Function. |
|
| 61 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 62 | - * |
|
| 63 | - * @since 1.0.0 |
|
| 64 | - * @access public |
|
| 65 | - * @return void |
|
| 66 | - */ |
|
| 67 | - public function render() { |
|
| 68 | - $shadow_arr = array( |
|
| 69 | - 'inset', |
|
| 70 | - 'drop', |
|
| 71 | - ); |
|
| 72 | - |
|
| 73 | - echo '<div class="box-shadow-inset">'; |
|
| 74 | - echo '<div class="box-shadow-controls row">'; |
|
| 75 | - |
|
| 76 | - foreach ( $shadow_arr as $shadow_type ) { |
|
| 77 | - if ( $this->field[ $shadow_type . '-shadow' ] ) { |
|
| 78 | - $disabled = ' shadow-disabled'; |
|
| 79 | - |
|
| 80 | - if ( $this->value[ $shadow_type . '-shadow' ]['checked'] ) { |
|
| 81 | - $disabled = ''; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - $slider_disable = disabled( filter_var( $this->value[ $shadow_type . '-shadow' ]['checked'], FILTER_VALIDATE_BOOLEAN ), false, false ); |
|
| 85 | - |
|
| 86 | - echo '<div class="col-2 shadow-' . esc_attr( $shadow_type ) . ' " data-shadow="' . esc_attr( $shadow_type ) . '">'; |
|
| 87 | - echo '<ul>'; |
|
| 88 | - echo '<li>'; |
|
| 89 | - echo '<label for="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-shadow" class="' . esc_attr( $disabled ) . '">'; |
|
| 90 | - echo '<input type="checkbox" id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-shadow" class="checkbox" value="1"' . checked( $this->value[ $shadow_type . '-shadow' ]['checked'], '1', false ) . '/>'; |
|
| 91 | - echo '<input type="hidden" data-val="1" value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['checked'] ) . '" class="checkbox-check" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[' . esc_attr( $shadow_type ) . '-shadow][checked]"/>'; |
|
| 92 | - echo esc_html( ucfirst( $shadow_type ) ) . ' ' . esc_html__( 'Shadow', 'redux-framework' ); |
|
| 93 | - echo '</label>'; |
|
| 94 | - echo '</li>'; |
|
| 95 | - echo '<li>'; |
|
| 96 | - |
|
| 97 | - $def_color = $this->field['default'][ $shadow_type . '-shadow' ]['color'] ?? ''; |
|
| 98 | - |
|
| 99 | - echo '<input '; |
|
| 100 | - echo 'data-id="' . esc_attr( $this->field['id'] ) . '"'; |
|
| 101 | - echo 'name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[' . esc_attr( $shadow_type ) . '-shadow][color]"'; |
|
| 102 | - echo 'id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-color"'; |
|
| 103 | - echo 'class="color-picker redux-color redux-box-shadow-' . esc_attr( $shadow_type ) . '-input redux-color-init ' . esc_attr( $this->field['class'] ) . '"'; |
|
| 104 | - echo 'type="text" value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['color'] ) . '"'; |
|
| 105 | - echo 'data-default-color="' . esc_attr( $def_color ) . '"'; |
|
| 106 | - |
|
| 107 | - echo '/>'; |
|
| 108 | - echo '</li>'; |
|
| 109 | - echo '<li>'; |
|
| 110 | - echo '<div class="slider-' . esc_attr( $shadow_type ) . '-horizontal">'; |
|
| 111 | - echo esc_html__( 'Horizontal Length', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[ $shadow_type . '-shadow' ]['horizontal'] ) . 'px</strong>'; |
|
| 112 | - echo '<div |
|
| 15 | + /** |
|
| 16 | + * Main Redux_Box_Shadow class |
|
| 17 | + * |
|
| 18 | + * @since 4.0.0 |
|
| 19 | + */ |
|
| 20 | + class Redux_Box_Shadow extends Redux_Field { |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Set defaults. |
|
| 24 | + */ |
|
| 25 | + public function set_defaults() { |
|
| 26 | + |
|
| 27 | + $defaults = array( |
|
| 28 | + 'inset-shadow' => true, |
|
| 29 | + 'drop-shadow' => true, |
|
| 30 | + 'preview-color' => '#f1f1f1', |
|
| 31 | + ); |
|
| 32 | + |
|
| 33 | + $this->field = Redux_Functions::parse_args( $this->field, $defaults ); |
|
| 34 | + |
|
| 35 | + $defaults = array( |
|
| 36 | + 'inset' => true, |
|
| 37 | + 'drop' => true, |
|
| 38 | + 'inset-shadow' => array( |
|
| 39 | + 'checked' => false, |
|
| 40 | + 'color' => '#ABABAB', |
|
| 41 | + 'horizontal' => 0, |
|
| 42 | + 'vertical' => 0, |
|
| 43 | + 'blur' => 10, |
|
| 44 | + 'spread' => 0, |
|
| 45 | + ), |
|
| 46 | + 'drop-shadow' => array( |
|
| 47 | + 'checked' => true, |
|
| 48 | + 'color' => '#dddddd', |
|
| 49 | + 'horizontal' => 5, |
|
| 50 | + 'vertical' => 5, |
|
| 51 | + 'blur' => 5, |
|
| 52 | + 'spread' => 1, |
|
| 53 | + ), |
|
| 54 | + ); |
|
| 55 | + |
|
| 56 | + $this->value = Redux_Functions::parse_args( $this->value, $defaults ); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Field Render Function. |
|
| 61 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 62 | + * |
|
| 63 | + * @since 1.0.0 |
|
| 64 | + * @access public |
|
| 65 | + * @return void |
|
| 66 | + */ |
|
| 67 | + public function render() { |
|
| 68 | + $shadow_arr = array( |
|
| 69 | + 'inset', |
|
| 70 | + 'drop', |
|
| 71 | + ); |
|
| 72 | + |
|
| 73 | + echo '<div class="box-shadow-inset">'; |
|
| 74 | + echo '<div class="box-shadow-controls row">'; |
|
| 75 | + |
|
| 76 | + foreach ( $shadow_arr as $shadow_type ) { |
|
| 77 | + if ( $this->field[ $shadow_type . '-shadow' ] ) { |
|
| 78 | + $disabled = ' shadow-disabled'; |
|
| 79 | + |
|
| 80 | + if ( $this->value[ $shadow_type . '-shadow' ]['checked'] ) { |
|
| 81 | + $disabled = ''; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + $slider_disable = disabled( filter_var( $this->value[ $shadow_type . '-shadow' ]['checked'], FILTER_VALIDATE_BOOLEAN ), false, false ); |
|
| 85 | + |
|
| 86 | + echo '<div class="col-2 shadow-' . esc_attr( $shadow_type ) . ' " data-shadow="' . esc_attr( $shadow_type ) . '">'; |
|
| 87 | + echo '<ul>'; |
|
| 88 | + echo '<li>'; |
|
| 89 | + echo '<label for="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-shadow" class="' . esc_attr( $disabled ) . '">'; |
|
| 90 | + echo '<input type="checkbox" id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-shadow" class="checkbox" value="1"' . checked( $this->value[ $shadow_type . '-shadow' ]['checked'], '1', false ) . '/>'; |
|
| 91 | + echo '<input type="hidden" data-val="1" value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['checked'] ) . '" class="checkbox-check" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[' . esc_attr( $shadow_type ) . '-shadow][checked]"/>'; |
|
| 92 | + echo esc_html( ucfirst( $shadow_type ) ) . ' ' . esc_html__( 'Shadow', 'redux-framework' ); |
|
| 93 | + echo '</label>'; |
|
| 94 | + echo '</li>'; |
|
| 95 | + echo '<li>'; |
|
| 96 | + |
|
| 97 | + $def_color = $this->field['default'][ $shadow_type . '-shadow' ]['color'] ?? ''; |
|
| 98 | + |
|
| 99 | + echo '<input '; |
|
| 100 | + echo 'data-id="' . esc_attr( $this->field['id'] ) . '"'; |
|
| 101 | + echo 'name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[' . esc_attr( $shadow_type ) . '-shadow][color]"'; |
|
| 102 | + echo 'id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-color"'; |
|
| 103 | + echo 'class="color-picker redux-color redux-box-shadow-' . esc_attr( $shadow_type ) . '-input redux-color-init ' . esc_attr( $this->field['class'] ) . '"'; |
|
| 104 | + echo 'type="text" value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['color'] ) . '"'; |
|
| 105 | + echo 'data-default-color="' . esc_attr( $def_color ) . '"'; |
|
| 106 | + |
|
| 107 | + echo '/>'; |
|
| 108 | + echo '</li>'; |
|
| 109 | + echo '<li>'; |
|
| 110 | + echo '<div class="slider-' . esc_attr( $shadow_type ) . '-horizontal">'; |
|
| 111 | + echo esc_html__( 'Horizontal Length', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[ $shadow_type . '-shadow' ]['horizontal'] ) . 'px</strong>'; |
|
| 112 | + echo '<div |
|
| 113 | 113 | class="redux-box-shadow-slider redux-box-shadow-' . esc_attr( $shadow_type ) . ' redux-' . esc_attr( $shadow_type ) . '-horizontal ' . esc_attr( $shadow_type ) . '-horizontal-input ' . esc_attr( $this->field['class'] ) . '" |
| 114 | 114 | id="' . esc_attr( $this->field['id'] ) . '" |
| 115 | 115 | data-id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-horizontal" |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | data-label="' . esc_attr__( 'Horizontal Length', 'redux-framework' ) . '" |
| 121 | 121 | data-default = "' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['horizontal'] ) . '" ' . esc_html( $slider_disable ) . '> |
| 122 | 122 | </div>'; |
| 123 | - echo '<input |
|
| 123 | + echo '<input |
|
| 124 | 124 | type="hidden" |
| 125 | 125 | id="redux-slider-value-' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-horizontal" |
| 126 | 126 | class="' . esc_attr( $shadow_type ) . '-horizontal" |
@@ -128,12 +128,12 @@ discard block |
||
| 128 | 128 | value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['horizontal'] ) . '" |
| 129 | 129 | data-id="' . esc_attr( $this->field['id'] ) . '" |
| 130 | 130 | />'; |
| 131 | - echo '</div>'; |
|
| 132 | - echo '</li>'; |
|
| 133 | - echo '<li>'; |
|
| 134 | - echo '<div class="slider-' . esc_attr( $shadow_type ) . '-vertical">'; |
|
| 135 | - echo esc_html__( 'Vertical Length', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[ $shadow_type . '-shadow' ]['vertical'] ) . 'px</strong>'; |
|
| 136 | - echo '<div |
|
| 131 | + echo '</div>'; |
|
| 132 | + echo '</li>'; |
|
| 133 | + echo '<li>'; |
|
| 134 | + echo '<div class="slider-' . esc_attr( $shadow_type ) . '-vertical">'; |
|
| 135 | + echo esc_html__( 'Vertical Length', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[ $shadow_type . '-shadow' ]['vertical'] ) . 'px</strong>'; |
|
| 136 | + echo '<div |
|
| 137 | 137 | class="redux-box-shadow-slider redux-box-shadow-' . esc_attr( $shadow_type ) . ' redux-' . esc_attr( $shadow_type ) . '-vertical ' . esc_attr( $shadow_type ) . '-vertical-input ' . esc_attr( $this->field['class'] ) . '" |
| 138 | 138 | id="' . esc_attr( $this->field['id'] ) . '" |
| 139 | 139 | data-id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-vertical" |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | data-label="' . esc_attr__( 'Vertical Length', 'redux-framework' ) . '" |
| 145 | 145 | data-default = "' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['vertical'] ) . '" ' . esc_html( $slider_disable ) . '> |
| 146 | 146 | </div>'; |
| 147 | - echo '<input |
|
| 147 | + echo '<input |
|
| 148 | 148 | type="hidden" |
| 149 | 149 | id="redux-slider-value-' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-vertical" |
| 150 | 150 | class="' . esc_attr( $shadow_type ) . '-vertical" |
@@ -152,12 +152,12 @@ discard block |
||
| 152 | 152 | value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['vertical'] ) . '" |
| 153 | 153 | data-id="' . esc_attr( $this->field['id'] ) . '" |
| 154 | 154 | />'; |
| 155 | - echo '</div>'; |
|
| 156 | - echo '</li>'; |
|
| 157 | - echo '<li>'; |
|
| 158 | - echo '<div class="slider-' . esc_attr( $shadow_type ) . '-blur">'; |
|
| 159 | - echo esc_html__( 'Blur Radius', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[ $shadow_type . '-shadow' ]['blur'] ) . 'px</strong>'; |
|
| 160 | - echo '<div |
|
| 155 | + echo '</div>'; |
|
| 156 | + echo '</li>'; |
|
| 157 | + echo '<li>'; |
|
| 158 | + echo '<div class="slider-' . esc_attr( $shadow_type ) . '-blur">'; |
|
| 159 | + echo esc_html__( 'Blur Radius', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[ $shadow_type . '-shadow' ]['blur'] ) . 'px</strong>'; |
|
| 160 | + echo '<div |
|
| 161 | 161 | class="redux-box-shadow-slider redux-box-shadow-' . esc_attr( $shadow_type ) . ' redux-' . esc_attr( $shadow_type ) . '-blur ' . esc_attr( $shadow_type ) . '-blur-input ' . esc_attr( $this->field['class'] ) . '" |
| 162 | 162 | id="' . esc_attr( $this->field['id'] ) . '" |
| 163 | 163 | data-id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-blur" |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | data-label="' . esc_attr__( 'Blur Radius', 'redux-framework' ) . '" |
| 169 | 169 | data-default = "' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['blur'] ) . '" ' . esc_html( $slider_disable ) . '> |
| 170 | 170 | </div>'; |
| 171 | - echo '<input |
|
| 171 | + echo '<input |
|
| 172 | 172 | type="hidden" |
| 173 | 173 | id="redux-slider-value-' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-blur" |
| 174 | 174 | class="' . esc_attr( $shadow_type ) . '-blur" |
@@ -176,12 +176,12 @@ discard block |
||
| 176 | 176 | value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['blur'] ) . '" |
| 177 | 177 | data-id="' . esc_attr( $this->field['id'] ) . '" |
| 178 | 178 | />'; |
| 179 | - echo '</div>'; |
|
| 180 | - echo '</li>'; |
|
| 181 | - echo '<li>'; |
|
| 182 | - echo '<div class="slider-' . esc_attr( $shadow_type ) . '-spread">'; |
|
| 183 | - echo esc_html__( 'Spread', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[ $shadow_type . '-shadow' ]['spread'] ) . 'px</strong>'; |
|
| 184 | - echo '<div |
|
| 179 | + echo '</div>'; |
|
| 180 | + echo '</li>'; |
|
| 181 | + echo '<li>'; |
|
| 182 | + echo '<div class="slider-' . esc_attr( $shadow_type ) . '-spread">'; |
|
| 183 | + echo esc_html__( 'Spread', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[ $shadow_type . '-shadow' ]['spread'] ) . 'px</strong>'; |
|
| 184 | + echo '<div |
|
| 185 | 185 | class="redux-box-shadow-slider redux-box-shadow-' . esc_attr( $shadow_type ) . ' redux-' . esc_attr( $shadow_type ) . '-spread ' . esc_attr( $shadow_type ) . '-spread-input ' . esc_attr( $this->field['class'] ) . '" |
| 186 | 186 | id="' . esc_attr( $this->field['id'] ) . '" |
| 187 | 187 | data-id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-spread" |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | data-label="' . esc_attr__( 'Spread', 'redux-framework' ) . '" |
| 193 | 193 | data-default = "' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['spread'] ) . '" ' . esc_html( $slider_disable ) . '> |
| 194 | 194 | </div>'; |
| 195 | - echo '<input |
|
| 195 | + echo '<input |
|
| 196 | 196 | type="hidden" |
| 197 | 197 | id="redux-slider-value-' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-spread" |
| 198 | 198 | class="' . esc_attr( $shadow_type ) . '-spread" |
@@ -200,131 +200,131 @@ discard block |
||
| 200 | 200 | value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['spread'] ) . '" |
| 201 | 201 | data-id="' . esc_attr( $this->field['id'] ) . '" |
| 202 | 202 | />'; |
| 203 | - echo '</div>'; |
|
| 204 | - echo '</li>'; |
|
| 205 | - echo '</ul>'; |
|
| 206 | - echo '</div>'; |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - $css = $this->css_style( $this->value ); |
|
| 211 | - $css .= 'background:' . esc_html( $this->field['preview-color'] ); |
|
| 212 | - |
|
| 213 | - echo '</div>'; |
|
| 214 | - echo '<div class="" id="shadow-result" style="' . $css . '"></div>'; // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 215 | - echo '</div>'; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * Compile CSS output. |
|
| 220 | - * |
|
| 221 | - * @param mixed $data Data. |
|
| 222 | - * |
|
| 223 | - * @return string |
|
| 224 | - */ |
|
| 225 | - public function css_style( $data ): string { |
|
| 226 | - $css = ''; |
|
| 227 | - |
|
| 228 | - if ( $this->field['inset-shadow'] ) { |
|
| 229 | - $inset = $data['inset-shadow']; |
|
| 230 | - |
|
| 231 | - if ( filter_var( $inset['checked'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
| 232 | - $h = $inset['horizontal']; |
|
| 233 | - $v = $inset['vertical']; |
|
| 234 | - $b = $inset['blur']; |
|
| 235 | - $s = $inset['spread']; |
|
| 236 | - $color = $inset['color']; |
|
| 237 | - |
|
| 238 | - $css .= 'inset ' . $h . 'px ' . $v . 'px ' . $b . 'px ' . $s . 'px ' . $color; |
|
| 239 | - } |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - if ( $this->field['drop-shadow'] ) { |
|
| 243 | - $drop = $data['drop-shadow']; |
|
| 244 | - |
|
| 245 | - if ( filter_var( $drop['checked'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
| 246 | - $h = $drop['horizontal']; |
|
| 247 | - $v = $drop['vertical']; |
|
| 248 | - $b = $drop['blur']; |
|
| 249 | - $s = $drop['spread']; |
|
| 250 | - $color = $drop['color']; |
|
| 251 | - |
|
| 252 | - if ( '' !== $css ) { |
|
| 253 | - $css .= ','; |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - $css .= $h . 'px ' . $v . 'px ' . $b . 'px ' . $s . 'px ' . $color; |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - if ( '' !== $css ) { |
|
| 261 | - $css = 'box-shadow:' . $css . ';-webkit-box-shadow:' . $css . ';-moz-box-shadow:' . $css . ';-o-box-shadow:' . $css . ';'; |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - return $css; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * Do enqueue for each field instance. |
|
| 269 | - * |
|
| 270 | - * @return void |
|
| 271 | - */ |
|
| 272 | - public function always_enqueue() { |
|
| 273 | - if ( isset( $this->field['color_alpha'] ) && ( $this->field['color_alpha'] || ( $this->field['color_alpha']['inset-shadow'] || $this->field['color_alpha']['drop-shadow'] ) ) ) { |
|
| 274 | - wp_enqueue_script( 'redux-wp-color-picker-alpha' ); |
|
| 275 | - } |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * Enqueue Function. |
|
| 280 | - * If this field requires any scripts, or CSS define this function and register/enqueue the scripts/css |
|
| 281 | - * |
|
| 282 | - * @since 1.0.0 |
|
| 283 | - * @access public |
|
| 284 | - * @return void |
|
| 285 | - */ |
|
| 286 | - public function enqueue() { |
|
| 287 | - $min = Redux_Functions::is_min(); |
|
| 288 | - |
|
| 289 | - if ( ! wp_style_is( 'wp-color-picker' ) ) { |
|
| 290 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - $dep_array = array( 'jquery', 'wp-color-picker', 'redux-js' ); |
|
| 294 | - |
|
| 295 | - wp_enqueue_script( |
|
| 296 | - 'redux-field-box-shadow', |
|
| 297 | - Redux_Core::$url . 'inc/fields/box_shadow/redux-box-shadow' . $min . '.js', |
|
| 298 | - $dep_array, |
|
| 299 | - $this->timestamp, |
|
| 300 | - true |
|
| 301 | - ); |
|
| 302 | - |
|
| 303 | - wp_enqueue_style( |
|
| 304 | - 'redux-nouislider', |
|
| 305 | - Redux_Core::$url . 'assets/css/vendor/nouislider' . $min . '.css', |
|
| 306 | - array(), |
|
| 307 | - '5.0.0' |
|
| 308 | - ); |
|
| 309 | - |
|
| 310 | - wp_enqueue_script( |
|
| 311 | - 'redux-nouislider', |
|
| 312 | - Redux_Core::$url . 'assets/js/vendor/nouislider/redux.jquery.nouislider' . $min . '.js', |
|
| 313 | - array( 'jquery' ), |
|
| 314 | - '5.0.0', |
|
| 315 | - true |
|
| 316 | - ); |
|
| 317 | - |
|
| 318 | - if ( $this->parent->args['dev_mode'] ) { |
|
| 319 | - wp_enqueue_style( |
|
| 320 | - 'redux-field-box-shadow', |
|
| 321 | - Redux_Core::$url . 'inc/fields/box_shadow/redux-box-shadow.css', |
|
| 322 | - array(), |
|
| 323 | - time() |
|
| 324 | - ); |
|
| 325 | - |
|
| 326 | - wp_enqueue_style( 'redux-color-picker' ); |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - } |
|
| 203 | + echo '</div>'; |
|
| 204 | + echo '</li>'; |
|
| 205 | + echo '</ul>'; |
|
| 206 | + echo '</div>'; |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + $css = $this->css_style( $this->value ); |
|
| 211 | + $css .= 'background:' . esc_html( $this->field['preview-color'] ); |
|
| 212 | + |
|
| 213 | + echo '</div>'; |
|
| 214 | + echo '<div class="" id="shadow-result" style="' . $css . '"></div>'; // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 215 | + echo '</div>'; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * Compile CSS output. |
|
| 220 | + * |
|
| 221 | + * @param mixed $data Data. |
|
| 222 | + * |
|
| 223 | + * @return string |
|
| 224 | + */ |
|
| 225 | + public function css_style( $data ): string { |
|
| 226 | + $css = ''; |
|
| 227 | + |
|
| 228 | + if ( $this->field['inset-shadow'] ) { |
|
| 229 | + $inset = $data['inset-shadow']; |
|
| 230 | + |
|
| 231 | + if ( filter_var( $inset['checked'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
| 232 | + $h = $inset['horizontal']; |
|
| 233 | + $v = $inset['vertical']; |
|
| 234 | + $b = $inset['blur']; |
|
| 235 | + $s = $inset['spread']; |
|
| 236 | + $color = $inset['color']; |
|
| 237 | + |
|
| 238 | + $css .= 'inset ' . $h . 'px ' . $v . 'px ' . $b . 'px ' . $s . 'px ' . $color; |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + if ( $this->field['drop-shadow'] ) { |
|
| 243 | + $drop = $data['drop-shadow']; |
|
| 244 | + |
|
| 245 | + if ( filter_var( $drop['checked'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
| 246 | + $h = $drop['horizontal']; |
|
| 247 | + $v = $drop['vertical']; |
|
| 248 | + $b = $drop['blur']; |
|
| 249 | + $s = $drop['spread']; |
|
| 250 | + $color = $drop['color']; |
|
| 251 | + |
|
| 252 | + if ( '' !== $css ) { |
|
| 253 | + $css .= ','; |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + $css .= $h . 'px ' . $v . 'px ' . $b . 'px ' . $s . 'px ' . $color; |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + if ( '' !== $css ) { |
|
| 261 | + $css = 'box-shadow:' . $css . ';-webkit-box-shadow:' . $css . ';-moz-box-shadow:' . $css . ';-o-box-shadow:' . $css . ';'; |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + return $css; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * Do enqueue for each field instance. |
|
| 269 | + * |
|
| 270 | + * @return void |
|
| 271 | + */ |
|
| 272 | + public function always_enqueue() { |
|
| 273 | + if ( isset( $this->field['color_alpha'] ) && ( $this->field['color_alpha'] || ( $this->field['color_alpha']['inset-shadow'] || $this->field['color_alpha']['drop-shadow'] ) ) ) { |
|
| 274 | + wp_enqueue_script( 'redux-wp-color-picker-alpha' ); |
|
| 275 | + } |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * Enqueue Function. |
|
| 280 | + * If this field requires any scripts, or CSS define this function and register/enqueue the scripts/css |
|
| 281 | + * |
|
| 282 | + * @since 1.0.0 |
|
| 283 | + * @access public |
|
| 284 | + * @return void |
|
| 285 | + */ |
|
| 286 | + public function enqueue() { |
|
| 287 | + $min = Redux_Functions::is_min(); |
|
| 288 | + |
|
| 289 | + if ( ! wp_style_is( 'wp-color-picker' ) ) { |
|
| 290 | + wp_enqueue_style( 'wp-color-picker' ); |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + $dep_array = array( 'jquery', 'wp-color-picker', 'redux-js' ); |
|
| 294 | + |
|
| 295 | + wp_enqueue_script( |
|
| 296 | + 'redux-field-box-shadow', |
|
| 297 | + Redux_Core::$url . 'inc/fields/box_shadow/redux-box-shadow' . $min . '.js', |
|
| 298 | + $dep_array, |
|
| 299 | + $this->timestamp, |
|
| 300 | + true |
|
| 301 | + ); |
|
| 302 | + |
|
| 303 | + wp_enqueue_style( |
|
| 304 | + 'redux-nouislider', |
|
| 305 | + Redux_Core::$url . 'assets/css/vendor/nouislider' . $min . '.css', |
|
| 306 | + array(), |
|
| 307 | + '5.0.0' |
|
| 308 | + ); |
|
| 309 | + |
|
| 310 | + wp_enqueue_script( |
|
| 311 | + 'redux-nouislider', |
|
| 312 | + Redux_Core::$url . 'assets/js/vendor/nouislider/redux.jquery.nouislider' . $min . '.js', |
|
| 313 | + array( 'jquery' ), |
|
| 314 | + '5.0.0', |
|
| 315 | + true |
|
| 316 | + ); |
|
| 317 | + |
|
| 318 | + if ( $this->parent->args['dev_mode'] ) { |
|
| 319 | + wp_enqueue_style( |
|
| 320 | + 'redux-field-box-shadow', |
|
| 321 | + Redux_Core::$url . 'inc/fields/box_shadow/redux-box-shadow.css', |
|
| 322 | + array(), |
|
| 323 | + time() |
|
| 324 | + ); |
|
| 325 | + |
|
| 326 | + wp_enqueue_style( 'redux-color-picker' ); |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | 330 | } |
@@ -74,41 +74,41 @@ discard block |
||
| 74 | 74 | echo '<div class="box-shadow-controls row">'; |
| 75 | 75 | |
| 76 | 76 | foreach ( $shadow_arr as $shadow_type ) { |
| 77 | - if ( $this->field[ $shadow_type . '-shadow' ] ) { |
|
| 77 | + if ( $this->field[$shadow_type . '-shadow'] ) { |
|
| 78 | 78 | $disabled = ' shadow-disabled'; |
| 79 | 79 | |
| 80 | - if ( $this->value[ $shadow_type . '-shadow' ]['checked'] ) { |
|
| 80 | + if ( $this->value[$shadow_type . '-shadow']['checked'] ) { |
|
| 81 | 81 | $disabled = ''; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - $slider_disable = disabled( filter_var( $this->value[ $shadow_type . '-shadow' ]['checked'], FILTER_VALIDATE_BOOLEAN ), false, false ); |
|
| 84 | + $slider_disable = disabled( filter_var( $this->value[$shadow_type . '-shadow']['checked'], FILTER_VALIDATE_BOOLEAN ), false, false ); |
|
| 85 | 85 | |
| 86 | 86 | echo '<div class="col-2 shadow-' . esc_attr( $shadow_type ) . ' " data-shadow="' . esc_attr( $shadow_type ) . '">'; |
| 87 | 87 | echo '<ul>'; |
| 88 | 88 | echo '<li>'; |
| 89 | 89 | echo '<label for="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-shadow" class="' . esc_attr( $disabled ) . '">'; |
| 90 | - echo '<input type="checkbox" id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-shadow" class="checkbox" value="1"' . checked( $this->value[ $shadow_type . '-shadow' ]['checked'], '1', false ) . '/>'; |
|
| 91 | - echo '<input type="hidden" data-val="1" value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['checked'] ) . '" class="checkbox-check" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[' . esc_attr( $shadow_type ) . '-shadow][checked]"/>'; |
|
| 90 | + echo '<input type="checkbox" id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-shadow" class="checkbox" value="1"' . checked( $this->value[$shadow_type . '-shadow']['checked'], '1', false ) . '/>'; |
|
| 91 | + echo '<input type="hidden" data-val="1" value="' . esc_attr( $this->value[$shadow_type . '-shadow']['checked'] ) . '" class="checkbox-check" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[' . esc_attr( $shadow_type ) . '-shadow][checked]"/>'; |
|
| 92 | 92 | echo esc_html( ucfirst( $shadow_type ) ) . ' ' . esc_html__( 'Shadow', 'redux-framework' ); |
| 93 | 93 | echo '</label>'; |
| 94 | 94 | echo '</li>'; |
| 95 | 95 | echo '<li>'; |
| 96 | 96 | |
| 97 | - $def_color = $this->field['default'][ $shadow_type . '-shadow' ]['color'] ?? ''; |
|
| 97 | + $def_color = $this->field['default'][$shadow_type . '-shadow']['color'] ?? ''; |
|
| 98 | 98 | |
| 99 | 99 | echo '<input '; |
| 100 | 100 | echo 'data-id="' . esc_attr( $this->field['id'] ) . '"'; |
| 101 | 101 | echo 'name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[' . esc_attr( $shadow_type ) . '-shadow][color]"'; |
| 102 | 102 | echo 'id="' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-color"'; |
| 103 | 103 | echo 'class="color-picker redux-color redux-box-shadow-' . esc_attr( $shadow_type ) . '-input redux-color-init ' . esc_attr( $this->field['class'] ) . '"'; |
| 104 | - echo 'type="text" value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['color'] ) . '"'; |
|
| 104 | + echo 'type="text" value="' . esc_attr( $this->value[$shadow_type . '-shadow']['color'] ) . '"'; |
|
| 105 | 105 | echo 'data-default-color="' . esc_attr( $def_color ) . '"'; |
| 106 | 106 | |
| 107 | 107 | echo '/>'; |
| 108 | 108 | echo '</li>'; |
| 109 | 109 | echo '<li>'; |
| 110 | 110 | echo '<div class="slider-' . esc_attr( $shadow_type ) . '-horizontal">'; |
| 111 | - echo esc_html__( 'Horizontal Length', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[ $shadow_type . '-shadow' ]['horizontal'] ) . 'px</strong>'; |
|
| 111 | + echo esc_html__( 'Horizontal Length', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[$shadow_type . '-shadow']['horizontal'] ) . 'px</strong>'; |
|
| 112 | 112 | echo '<div |
| 113 | 113 | class="redux-box-shadow-slider redux-box-shadow-' . esc_attr( $shadow_type ) . ' redux-' . esc_attr( $shadow_type ) . '-horizontal ' . esc_attr( $shadow_type ) . '-horizontal-input ' . esc_attr( $this->field['class'] ) . '" |
| 114 | 114 | id="' . esc_attr( $this->field['id'] ) . '" |
@@ -118,21 +118,21 @@ discard block |
||
| 118 | 118 | data-step="1" |
| 119 | 119 | data-rtl="' . esc_attr( is_rtl() ) . '" |
| 120 | 120 | data-label="' . esc_attr__( 'Horizontal Length', 'redux-framework' ) . '" |
| 121 | - data-default = "' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['horizontal'] ) . '" ' . esc_html( $slider_disable ) . '> |
|
| 121 | + data-default = "' . esc_attr( $this->value[$shadow_type . '-shadow']['horizontal'] ) . '" ' . esc_html( $slider_disable ) . '> |
|
| 122 | 122 | </div>'; |
| 123 | 123 | echo '<input |
| 124 | 124 | type="hidden" |
| 125 | 125 | id="redux-slider-value-' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-horizontal" |
| 126 | 126 | class="' . esc_attr( $shadow_type ) . '-horizontal" |
| 127 | 127 | name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[' . esc_attr( $shadow_type ) . '-shadow][horizontal]" |
| 128 | - value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['horizontal'] ) . '" |
|
| 128 | + value="' . esc_attr( $this->value[$shadow_type . '-shadow']['horizontal'] ) . '" |
|
| 129 | 129 | data-id="' . esc_attr( $this->field['id'] ) . '" |
| 130 | 130 | />'; |
| 131 | 131 | echo '</div>'; |
| 132 | 132 | echo '</li>'; |
| 133 | 133 | echo '<li>'; |
| 134 | 134 | echo '<div class="slider-' . esc_attr( $shadow_type ) . '-vertical">'; |
| 135 | - echo esc_html__( 'Vertical Length', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[ $shadow_type . '-shadow' ]['vertical'] ) . 'px</strong>'; |
|
| 135 | + echo esc_html__( 'Vertical Length', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[$shadow_type . '-shadow']['vertical'] ) . 'px</strong>'; |
|
| 136 | 136 | echo '<div |
| 137 | 137 | class="redux-box-shadow-slider redux-box-shadow-' . esc_attr( $shadow_type ) . ' redux-' . esc_attr( $shadow_type ) . '-vertical ' . esc_attr( $shadow_type ) . '-vertical-input ' . esc_attr( $this->field['class'] ) . '" |
| 138 | 138 | id="' . esc_attr( $this->field['id'] ) . '" |
@@ -142,21 +142,21 @@ discard block |
||
| 142 | 142 | data-step="1" |
| 143 | 143 | data-rtl="' . esc_attr( is_rtl() ) . '" |
| 144 | 144 | data-label="' . esc_attr__( 'Vertical Length', 'redux-framework' ) . '" |
| 145 | - data-default = "' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['vertical'] ) . '" ' . esc_html( $slider_disable ) . '> |
|
| 145 | + data-default = "' . esc_attr( $this->value[$shadow_type . '-shadow']['vertical'] ) . '" ' . esc_html( $slider_disable ) . '> |
|
| 146 | 146 | </div>'; |
| 147 | 147 | echo '<input |
| 148 | 148 | type="hidden" |
| 149 | 149 | id="redux-slider-value-' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-vertical" |
| 150 | 150 | class="' . esc_attr( $shadow_type ) . '-vertical" |
| 151 | 151 | name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[' . esc_attr( $shadow_type ) . '-shadow][vertical]" |
| 152 | - value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['vertical'] ) . '" |
|
| 152 | + value="' . esc_attr( $this->value[$shadow_type . '-shadow']['vertical'] ) . '" |
|
| 153 | 153 | data-id="' . esc_attr( $this->field['id'] ) . '" |
| 154 | 154 | />'; |
| 155 | 155 | echo '</div>'; |
| 156 | 156 | echo '</li>'; |
| 157 | 157 | echo '<li>'; |
| 158 | 158 | echo '<div class="slider-' . esc_attr( $shadow_type ) . '-blur">'; |
| 159 | - echo esc_html__( 'Blur Radius', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[ $shadow_type . '-shadow' ]['blur'] ) . 'px</strong>'; |
|
| 159 | + echo esc_html__( 'Blur Radius', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[$shadow_type . '-shadow']['blur'] ) . 'px</strong>'; |
|
| 160 | 160 | echo '<div |
| 161 | 161 | class="redux-box-shadow-slider redux-box-shadow-' . esc_attr( $shadow_type ) . ' redux-' . esc_attr( $shadow_type ) . '-blur ' . esc_attr( $shadow_type ) . '-blur-input ' . esc_attr( $this->field['class'] ) . '" |
| 162 | 162 | id="' . esc_attr( $this->field['id'] ) . '" |
@@ -166,21 +166,21 @@ discard block |
||
| 166 | 166 | data-step="1" |
| 167 | 167 | data-rtl="' . esc_attr( is_rtl() ) . '" |
| 168 | 168 | data-label="' . esc_attr__( 'Blur Radius', 'redux-framework' ) . '" |
| 169 | - data-default = "' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['blur'] ) . '" ' . esc_html( $slider_disable ) . '> |
|
| 169 | + data-default = "' . esc_attr( $this->value[$shadow_type . '-shadow']['blur'] ) . '" ' . esc_html( $slider_disable ) . '> |
|
| 170 | 170 | </div>'; |
| 171 | 171 | echo '<input |
| 172 | 172 | type="hidden" |
| 173 | 173 | id="redux-slider-value-' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-blur" |
| 174 | 174 | class="' . esc_attr( $shadow_type ) . '-blur" |
| 175 | 175 | name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[' . esc_attr( $shadow_type ) . '-shadow][blur]" |
| 176 | - value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['blur'] ) . '" |
|
| 176 | + value="' . esc_attr( $this->value[$shadow_type . '-shadow']['blur'] ) . '" |
|
| 177 | 177 | data-id="' . esc_attr( $this->field['id'] ) . '" |
| 178 | 178 | />'; |
| 179 | 179 | echo '</div>'; |
| 180 | 180 | echo '</li>'; |
| 181 | 181 | echo '<li>'; |
| 182 | 182 | echo '<div class="slider-' . esc_attr( $shadow_type ) . '-spread">'; |
| 183 | - echo esc_html__( 'Spread', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[ $shadow_type . '-shadow' ]['spread'] ) . 'px</strong>'; |
|
| 183 | + echo esc_html__( 'Spread', 'redux-framework' ) . ': <strong>' . esc_html( $this->value[$shadow_type . '-shadow']['spread'] ) . 'px</strong>'; |
|
| 184 | 184 | echo '<div |
| 185 | 185 | class="redux-box-shadow-slider redux-box-shadow-' . esc_attr( $shadow_type ) . ' redux-' . esc_attr( $shadow_type ) . '-spread ' . esc_attr( $shadow_type ) . '-spread-input ' . esc_attr( $this->field['class'] ) . '" |
| 186 | 186 | id="' . esc_attr( $this->field['id'] ) . '" |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | data-step="1" |
| 191 | 191 | data-rtl="' . esc_attr( is_rtl() ) . '" |
| 192 | 192 | data-label="' . esc_attr__( 'Spread', 'redux-framework' ) . '" |
| 193 | - data-default = "' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['spread'] ) . '" ' . esc_html( $slider_disable ) . '> |
|
| 193 | + data-default = "' . esc_attr( $this->value[$shadow_type . '-shadow']['spread'] ) . '" ' . esc_html( $slider_disable ) . '> |
|
| 194 | 194 | </div>'; |
| 195 | 195 | echo '<input |
| 196 | 196 | type="hidden" |
| 197 | 197 | id="redux-slider-value-' . esc_attr( $this->field['id'] ) . '-' . esc_attr( $shadow_type ) . '-spread" |
| 198 | 198 | class="' . esc_attr( $shadow_type ) . '-spread" |
| 199 | 199 | name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[' . esc_attr( $shadow_type ) . '-shadow][spread]" |
| 200 | - value="' . esc_attr( $this->value[ $shadow_type . '-shadow' ]['spread'] ) . '" |
|
| 200 | + value="' . esc_attr( $this->value[$shadow_type . '-shadow']['spread'] ) . '" |
|
| 201 | 201 | data-id="' . esc_attr( $this->field['id'] ) . '" |
| 202 | 202 | />'; |
| 203 | 203 | echo '</div>'; |
@@ -11,179 +11,179 @@ |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Image_Filters' ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Image_Filters |
|
| 16 | - */ |
|
| 17 | - class Redux_Image_Filters { |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * Render preview. |
|
| 21 | - * |
|
| 22 | - * @param array $data Data. |
|
| 23 | - * |
|
| 24 | - * @return string |
|
| 25 | - */ |
|
| 26 | - public static function render( array $data ): string { |
|
| 27 | - extract( $data ); // phpcs:ignore WordPress.PHP.DontExtract |
|
| 28 | - |
|
| 29 | - $output = ''; |
|
| 30 | - |
|
| 31 | - $filter_arr = array( |
|
| 32 | - 'grayscale', |
|
| 33 | - 'blur', |
|
| 34 | - 'sepia', |
|
| 35 | - 'saturate', |
|
| 36 | - 'opacity', |
|
| 37 | - 'brightness', |
|
| 38 | - 'contrast', |
|
| 39 | - 'hue-rotate', |
|
| 40 | - 'invert', |
|
| 41 | - ); |
|
| 42 | - |
|
| 43 | - // Make an array of in use filters. |
|
| 44 | - $in_use_filters = array(); |
|
| 45 | - |
|
| 46 | - foreach ( $filter_arr as $filter ) { |
|
| 47 | - if ( $field['filter'][ $filter ] ) { |
|
| 48 | - $in_use_filters[] = $filter; |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - $filters = rawurlencode( wp_json_encode( $in_use_filters ) ); |
|
| 53 | - |
|
| 54 | - $output .= '<div class="redux-' . $mode . '-filter-container" data-filters="' . $filters . '">'; |
|
| 55 | - $output .= '<div class="container-label">' . esc_html__( 'Filters', 'redux-framework' ) . '</div>'; |
|
| 56 | - |
|
| 57 | - foreach ( $in_use_filters as $filter ) { |
|
| 58 | - $step = 1; |
|
| 59 | - $unit = self::get_filter_unit( $filter ); |
|
| 60 | - |
|
| 61 | - if ( 'grayscale' === $filter || 'invert' === $filter ) { |
|
| 62 | - $min = 0; |
|
| 63 | - $max = 100; |
|
| 64 | - } elseif ( 'blur' === $filter ) { |
|
| 65 | - $min = 0; |
|
| 66 | - $max = 30; |
|
| 67 | - } elseif ( 'sepia' === $filter || 'saturate' === $filter || 'opacity' === $filter ) { |
|
| 68 | - $min = 0; |
|
| 69 | - $max = 1; |
|
| 70 | - $step = .01; |
|
| 71 | - } elseif ( 'brightness' === $filter || 'contrast' === $filter ) { |
|
| 72 | - $min = 0; |
|
| 73 | - $max = 200; |
|
| 74 | - } elseif ( 'hue-rotate' === $filter ) { |
|
| 75 | - $min = 0; |
|
| 76 | - $max = 360; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - $disabled = 'filters-disabled'; |
|
| 80 | - if ( $value['filter'][ $filter ]['checked'] ) { |
|
| 81 | - $disabled = ''; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - $output .= '<div class="filter filter-' . $filter . '">'; |
|
| 85 | - $output .= '<label for="' . esc_attr( $field['id'] ) . '-' . $filter . '" class="' . $disabled . '">'; |
|
| 86 | - $output .= '<input type="checkbox" id="' . esc_attr( $field['id'] ) . '-' . $filter . '" class="checkbox" value="1"' . checked( $value['filter'][ $filter ]['checked'], '1', false ) . '/>'; |
|
| 87 | - $output .= '<input type="hidden" data-val="1" value="' . esc_attr( $value['filter'][ $filter ]['checked'] ) . '" class="checkbox-check" name="' . esc_attr( $field['name'] . $field['name_suffix'] ) . '[filter][' . $filter . '][checked]"/>'; |
|
| 88 | - $output .= ucfirst( $filter ) . ': '; |
|
| 89 | - $output .= '<span class="filter-value"><strong>' . $value['filter'][ $filter ]['value'] . $unit . '</strong></span>'; |
|
| 90 | - $output .= '</label>'; |
|
| 91 | - |
|
| 92 | - $output .= '<div '; |
|
| 93 | - $output .= 'class="redux-' . $mode . '-slider redux-' . $mode . '-filter redux-filter redux-filter-' . $filter . esc_attr( $field['class'] ) . '"'; |
|
| 94 | - $output .= 'id="' . esc_attr( $field['id'] ) . '"'; |
|
| 95 | - $output .= 'data-id="' . esc_attr( $field['id'] . '-' . $filter ) . '"'; |
|
| 96 | - $output .= 'data-min="' . $min . '"'; |
|
| 97 | - $output .= 'data-max="' . $max . '"'; |
|
| 98 | - $output .= 'data-step="' . $step . '"'; |
|
| 99 | - $output .= 'data-rtl="' . esc_attr( is_rtl() ) . '"'; |
|
| 100 | - $output .= 'data-unit="' . $unit . '"'; |
|
| 101 | - $output .= 'data-default = "' . esc_attr( $value['filter'][ $filter ]['value'] ) . '" '; |
|
| 102 | - $output .= disabled( filter_var( $value['filter'][ $filter ]['checked'], FILTER_VALIDATE_BOOLEAN ), false, false ); |
|
| 103 | - $output .= '>'; |
|
| 104 | - $output .= '</div>'; |
|
| 105 | - |
|
| 106 | - if ( '°' === $unit ) { |
|
| 107 | - $unit = 'deg'; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - $output .= '<input '; |
|
| 111 | - $output .= 'type="hidden"'; |
|
| 112 | - $output .= 'id="redux-slider-value-' . esc_attr( $field['id'] ) . '-' . $filter . '"'; |
|
| 113 | - $output .= 'class="' . $mode . '-filter-' . $filter . '"'; |
|
| 114 | - $output .= 'name="' . esc_attr( $field['name'] . $field['name_suffix'] ) . '[filter][' . $filter . '][value]"'; |
|
| 115 | - $output .= 'value="' . esc_attr( $value['filter'][ $filter ]['value'] ) . '"'; |
|
| 116 | - $output .= 'data-id="' . esc_attr( $field['id'] ) . '"'; |
|
| 117 | - $output .= 'data-unit="' . $unit . '"'; |
|
| 118 | - $output .= '/>'; |
|
| 119 | - $output .= '</div>'; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - $output .= '</div>'; |
|
| 123 | - |
|
| 124 | - return $output; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Get filter unit. |
|
| 129 | - * |
|
| 130 | - * @param string $filter Filter type. |
|
| 131 | - * |
|
| 132 | - * @return string |
|
| 133 | - */ |
|
| 134 | - public static function get_filter_unit( string $filter ): string { |
|
| 135 | - if ( 'grayscale' === $filter || 'invert' === $filter || 'brightness' === $filter || 'contrast' === $filter ) { |
|
| 136 | - return '%'; |
|
| 137 | - } elseif ( 'blur' === $filter ) { |
|
| 138 | - return 'px'; |
|
| 139 | - } elseif ( 'hue-rotate' === $filter ) { |
|
| 140 | - return '°'; |
|
| 141 | - } else { |
|
| 142 | - return ''; |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Enqueue support files. |
|
| 148 | - * |
|
| 149 | - * @param bool $filters_enabled Filtered enabled bit. |
|
| 150 | - */ |
|
| 151 | - public static function enqueue( bool $filters_enabled ) { |
|
| 152 | - $min = Redux_Functions::is_min(); |
|
| 153 | - |
|
| 154 | - if ( $filters_enabled ) { |
|
| 155 | - if ( ! wp_style_is( 'redux-nouislider' ) ) { |
|
| 156 | - wp_enqueue_style( |
|
| 157 | - 'redux-nouislider', |
|
| 158 | - Redux_Core::$url . 'assets/css/vendor/nouislider/redux.jquery.nouislider.css', |
|
| 159 | - array(), |
|
| 160 | - '5.0.0' |
|
| 161 | - ); |
|
| 162 | - |
|
| 163 | - wp_enqueue_script( |
|
| 164 | - 'redux-nouislider', |
|
| 165 | - Redux_Core::$url . 'assets/js/vendor/nouislider/redux.jquery.nouislider' . $min . '.js', |
|
| 166 | - array( 'jquery' ), |
|
| 167 | - '5.0.0', |
|
| 168 | - true |
|
| 169 | - ); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - wp_enqueue_script( |
|
| 173 | - 'redux-image-filters', |
|
| 174 | - Redux_Core::$url . 'inc/lib/image-filters/image-filters' . $min . '.js', |
|
| 175 | - array( 'jquery' ), |
|
| 176 | - Redux_Core::$version, |
|
| 177 | - true |
|
| 178 | - ); |
|
| 179 | - |
|
| 180 | - wp_enqueue_style( |
|
| 181 | - 'redux-image-filters', |
|
| 182 | - Redux_Core::$url . 'inc/lib/image-filters/image-filters.css', |
|
| 183 | - array(), |
|
| 184 | - Redux_Core::$version |
|
| 185 | - ); |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - } |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Image_Filters |
|
| 16 | + */ |
|
| 17 | + class Redux_Image_Filters { |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * Render preview. |
|
| 21 | + * |
|
| 22 | + * @param array $data Data. |
|
| 23 | + * |
|
| 24 | + * @return string |
|
| 25 | + */ |
|
| 26 | + public static function render( array $data ): string { |
|
| 27 | + extract( $data ); // phpcs:ignore WordPress.PHP.DontExtract |
|
| 28 | + |
|
| 29 | + $output = ''; |
|
| 30 | + |
|
| 31 | + $filter_arr = array( |
|
| 32 | + 'grayscale', |
|
| 33 | + 'blur', |
|
| 34 | + 'sepia', |
|
| 35 | + 'saturate', |
|
| 36 | + 'opacity', |
|
| 37 | + 'brightness', |
|
| 38 | + 'contrast', |
|
| 39 | + 'hue-rotate', |
|
| 40 | + 'invert', |
|
| 41 | + ); |
|
| 42 | + |
|
| 43 | + // Make an array of in use filters. |
|
| 44 | + $in_use_filters = array(); |
|
| 45 | + |
|
| 46 | + foreach ( $filter_arr as $filter ) { |
|
| 47 | + if ( $field['filter'][ $filter ] ) { |
|
| 48 | + $in_use_filters[] = $filter; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + $filters = rawurlencode( wp_json_encode( $in_use_filters ) ); |
|
| 53 | + |
|
| 54 | + $output .= '<div class="redux-' . $mode . '-filter-container" data-filters="' . $filters . '">'; |
|
| 55 | + $output .= '<div class="container-label">' . esc_html__( 'Filters', 'redux-framework' ) . '</div>'; |
|
| 56 | + |
|
| 57 | + foreach ( $in_use_filters as $filter ) { |
|
| 58 | + $step = 1; |
|
| 59 | + $unit = self::get_filter_unit( $filter ); |
|
| 60 | + |
|
| 61 | + if ( 'grayscale' === $filter || 'invert' === $filter ) { |
|
| 62 | + $min = 0; |
|
| 63 | + $max = 100; |
|
| 64 | + } elseif ( 'blur' === $filter ) { |
|
| 65 | + $min = 0; |
|
| 66 | + $max = 30; |
|
| 67 | + } elseif ( 'sepia' === $filter || 'saturate' === $filter || 'opacity' === $filter ) { |
|
| 68 | + $min = 0; |
|
| 69 | + $max = 1; |
|
| 70 | + $step = .01; |
|
| 71 | + } elseif ( 'brightness' === $filter || 'contrast' === $filter ) { |
|
| 72 | + $min = 0; |
|
| 73 | + $max = 200; |
|
| 74 | + } elseif ( 'hue-rotate' === $filter ) { |
|
| 75 | + $min = 0; |
|
| 76 | + $max = 360; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + $disabled = 'filters-disabled'; |
|
| 80 | + if ( $value['filter'][ $filter ]['checked'] ) { |
|
| 81 | + $disabled = ''; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + $output .= '<div class="filter filter-' . $filter . '">'; |
|
| 85 | + $output .= '<label for="' . esc_attr( $field['id'] ) . '-' . $filter . '" class="' . $disabled . '">'; |
|
| 86 | + $output .= '<input type="checkbox" id="' . esc_attr( $field['id'] ) . '-' . $filter . '" class="checkbox" value="1"' . checked( $value['filter'][ $filter ]['checked'], '1', false ) . '/>'; |
|
| 87 | + $output .= '<input type="hidden" data-val="1" value="' . esc_attr( $value['filter'][ $filter ]['checked'] ) . '" class="checkbox-check" name="' . esc_attr( $field['name'] . $field['name_suffix'] ) . '[filter][' . $filter . '][checked]"/>'; |
|
| 88 | + $output .= ucfirst( $filter ) . ': '; |
|
| 89 | + $output .= '<span class="filter-value"><strong>' . $value['filter'][ $filter ]['value'] . $unit . '</strong></span>'; |
|
| 90 | + $output .= '</label>'; |
|
| 91 | + |
|
| 92 | + $output .= '<div '; |
|
| 93 | + $output .= 'class="redux-' . $mode . '-slider redux-' . $mode . '-filter redux-filter redux-filter-' . $filter . esc_attr( $field['class'] ) . '"'; |
|
| 94 | + $output .= 'id="' . esc_attr( $field['id'] ) . '"'; |
|
| 95 | + $output .= 'data-id="' . esc_attr( $field['id'] . '-' . $filter ) . '"'; |
|
| 96 | + $output .= 'data-min="' . $min . '"'; |
|
| 97 | + $output .= 'data-max="' . $max . '"'; |
|
| 98 | + $output .= 'data-step="' . $step . '"'; |
|
| 99 | + $output .= 'data-rtl="' . esc_attr( is_rtl() ) . '"'; |
|
| 100 | + $output .= 'data-unit="' . $unit . '"'; |
|
| 101 | + $output .= 'data-default = "' . esc_attr( $value['filter'][ $filter ]['value'] ) . '" '; |
|
| 102 | + $output .= disabled( filter_var( $value['filter'][ $filter ]['checked'], FILTER_VALIDATE_BOOLEAN ), false, false ); |
|
| 103 | + $output .= '>'; |
|
| 104 | + $output .= '</div>'; |
|
| 105 | + |
|
| 106 | + if ( '°' === $unit ) { |
|
| 107 | + $unit = 'deg'; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + $output .= '<input '; |
|
| 111 | + $output .= 'type="hidden"'; |
|
| 112 | + $output .= 'id="redux-slider-value-' . esc_attr( $field['id'] ) . '-' . $filter . '"'; |
|
| 113 | + $output .= 'class="' . $mode . '-filter-' . $filter . '"'; |
|
| 114 | + $output .= 'name="' . esc_attr( $field['name'] . $field['name_suffix'] ) . '[filter][' . $filter . '][value]"'; |
|
| 115 | + $output .= 'value="' . esc_attr( $value['filter'][ $filter ]['value'] ) . '"'; |
|
| 116 | + $output .= 'data-id="' . esc_attr( $field['id'] ) . '"'; |
|
| 117 | + $output .= 'data-unit="' . $unit . '"'; |
|
| 118 | + $output .= '/>'; |
|
| 119 | + $output .= '</div>'; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + $output .= '</div>'; |
|
| 123 | + |
|
| 124 | + return $output; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Get filter unit. |
|
| 129 | + * |
|
| 130 | + * @param string $filter Filter type. |
|
| 131 | + * |
|
| 132 | + * @return string |
|
| 133 | + */ |
|
| 134 | + public static function get_filter_unit( string $filter ): string { |
|
| 135 | + if ( 'grayscale' === $filter || 'invert' === $filter || 'brightness' === $filter || 'contrast' === $filter ) { |
|
| 136 | + return '%'; |
|
| 137 | + } elseif ( 'blur' === $filter ) { |
|
| 138 | + return 'px'; |
|
| 139 | + } elseif ( 'hue-rotate' === $filter ) { |
|
| 140 | + return '°'; |
|
| 141 | + } else { |
|
| 142 | + return ''; |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Enqueue support files. |
|
| 148 | + * |
|
| 149 | + * @param bool $filters_enabled Filtered enabled bit. |
|
| 150 | + */ |
|
| 151 | + public static function enqueue( bool $filters_enabled ) { |
|
| 152 | + $min = Redux_Functions::is_min(); |
|
| 153 | + |
|
| 154 | + if ( $filters_enabled ) { |
|
| 155 | + if ( ! wp_style_is( 'redux-nouislider' ) ) { |
|
| 156 | + wp_enqueue_style( |
|
| 157 | + 'redux-nouislider', |
|
| 158 | + Redux_Core::$url . 'assets/css/vendor/nouislider/redux.jquery.nouislider.css', |
|
| 159 | + array(), |
|
| 160 | + '5.0.0' |
|
| 161 | + ); |
|
| 162 | + |
|
| 163 | + wp_enqueue_script( |
|
| 164 | + 'redux-nouislider', |
|
| 165 | + Redux_Core::$url . 'assets/js/vendor/nouislider/redux.jquery.nouislider' . $min . '.js', |
|
| 166 | + array( 'jquery' ), |
|
| 167 | + '5.0.0', |
|
| 168 | + true |
|
| 169 | + ); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + wp_enqueue_script( |
|
| 173 | + 'redux-image-filters', |
|
| 174 | + Redux_Core::$url . 'inc/lib/image-filters/image-filters' . $min . '.js', |
|
| 175 | + array( 'jquery' ), |
|
| 176 | + Redux_Core::$version, |
|
| 177 | + true |
|
| 178 | + ); |
|
| 179 | + |
|
| 180 | + wp_enqueue_style( |
|
| 181 | + 'redux-image-filters', |
|
| 182 | + Redux_Core::$url . 'inc/lib/image-filters/image-filters.css', |
|
| 183 | + array(), |
|
| 184 | + Redux_Core::$version |
|
| 185 | + ); |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | 189 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $in_use_filters = array(); |
| 45 | 45 | |
| 46 | 46 | foreach ( $filter_arr as $filter ) { |
| 47 | - if ( $field['filter'][ $filter ] ) { |
|
| 47 | + if ( $field['filter'][$filter] ) { |
|
| 48 | 48 | $in_use_filters[] = $filter; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -77,16 +77,16 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $disabled = 'filters-disabled'; |
| 80 | - if ( $value['filter'][ $filter ]['checked'] ) { |
|
| 80 | + if ( $value['filter'][$filter]['checked'] ) { |
|
| 81 | 81 | $disabled = ''; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $output .= '<div class="filter filter-' . $filter . '">'; |
| 85 | 85 | $output .= '<label for="' . esc_attr( $field['id'] ) . '-' . $filter . '" class="' . $disabled . '">'; |
| 86 | - $output .= '<input type="checkbox" id="' . esc_attr( $field['id'] ) . '-' . $filter . '" class="checkbox" value="1"' . checked( $value['filter'][ $filter ]['checked'], '1', false ) . '/>'; |
|
| 87 | - $output .= '<input type="hidden" data-val="1" value="' . esc_attr( $value['filter'][ $filter ]['checked'] ) . '" class="checkbox-check" name="' . esc_attr( $field['name'] . $field['name_suffix'] ) . '[filter][' . $filter . '][checked]"/>'; |
|
| 86 | + $output .= '<input type="checkbox" id="' . esc_attr( $field['id'] ) . '-' . $filter . '" class="checkbox" value="1"' . checked( $value['filter'][$filter]['checked'], '1', false ) . '/>'; |
|
| 87 | + $output .= '<input type="hidden" data-val="1" value="' . esc_attr( $value['filter'][$filter]['checked'] ) . '" class="checkbox-check" name="' . esc_attr( $field['name'] . $field['name_suffix'] ) . '[filter][' . $filter . '][checked]"/>'; |
|
| 88 | 88 | $output .= ucfirst( $filter ) . ': '; |
| 89 | - $output .= '<span class="filter-value"><strong>' . $value['filter'][ $filter ]['value'] . $unit . '</strong></span>'; |
|
| 89 | + $output .= '<span class="filter-value"><strong>' . $value['filter'][$filter]['value'] . $unit . '</strong></span>'; |
|
| 90 | 90 | $output .= '</label>'; |
| 91 | 91 | |
| 92 | 92 | $output .= '<div '; |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | $output .= 'data-step="' . $step . '"'; |
| 99 | 99 | $output .= 'data-rtl="' . esc_attr( is_rtl() ) . '"'; |
| 100 | 100 | $output .= 'data-unit="' . $unit . '"'; |
| 101 | - $output .= 'data-default = "' . esc_attr( $value['filter'][ $filter ]['value'] ) . '" '; |
|
| 102 | - $output .= disabled( filter_var( $value['filter'][ $filter ]['checked'], FILTER_VALIDATE_BOOLEAN ), false, false ); |
|
| 101 | + $output .= 'data-default = "' . esc_attr( $value['filter'][$filter]['value'] ) . '" '; |
|
| 102 | + $output .= disabled( filter_var( $value['filter'][$filter]['checked'], FILTER_VALIDATE_BOOLEAN ), false, false ); |
|
| 103 | 103 | $output .= '>'; |
| 104 | 104 | $output .= '</div>'; |
| 105 | 105 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $output .= 'id="redux-slider-value-' . esc_attr( $field['id'] ) . '-' . $filter . '"'; |
| 113 | 113 | $output .= 'class="' . $mode . '-filter-' . $filter . '"'; |
| 114 | 114 | $output .= 'name="' . esc_attr( $field['name'] . $field['name_suffix'] ) . '[filter][' . $filter . '][value]"'; |
| 115 | - $output .= 'value="' . esc_attr( $value['filter'][ $filter ]['value'] ) . '"'; |
|
| 115 | + $output .= 'value="' . esc_attr( $value['filter'][$filter]['value'] ) . '"'; |
|
| 116 | 116 | $output .= 'data-id="' . esc_attr( $field['id'] ) . '"'; |
| 117 | 117 | $output .= 'data-unit="' . $unit . '"'; |
| 118 | 118 | $output .= '/>'; |