| @@ -1,15 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | -// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped,WordPress.Security.EscapeOutput.ExceptionNotEscaped,WordPress.Security.EscapeOutput.UnsafePrintingFunction -- Legacy Customify view output contains trusted config HTML, dynamic CSS/JS, or WordPress Customizer binding attributes. | |
| 3 | 2 | /** |
| 4 | 3 | * Extra functionality. |
| 5 | 4 | */ |
| 6 | 5 | |
| 7 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 8 | - exit; | |
| 9 | -} | |
| 10 | - | |
| 11 | -if ( ! function_exists( 'add_customify_base_options' ) ) { | |
| 6 | +if ( ! function_exists('add_customify_base_options') ) { | |
| 12 | 7 | /** |
| 13 | 8 | * This filter is used to change the Customizer Options |
| 14 | 9 | * You can also copy this function inside your functions.php |
| 15 | 10 | * file but DO NOT FORGET TO CHANGE ITS NAME |
| @@ -14,9 +9,8 @@ | ||
| 14 | 9 | * You can also copy this function inside your functions.php |
| 15 | 10 | * file but DO NOT FORGET TO CHANGE ITS NAME |
| 16 | 11 | * |
| 17 | 12 | * @param $config array This holds required keys for the plugin config like 'opt-name', 'panels', 'settings' |
| 18 | - * | |
| 19 | 13 | * @return $config |
| 20 | 14 | */ |
| 21 | 15 | function add_customify_base_options( $config ) { |
| 22 | 16 | |
| @@ -25,193 +19,194 @@ | ||
| 25 | 19 | $config['sections'] = array( |
| 26 | 20 | /** |
| 27 | 21 | * Presets - This section will handle other options |
| 28 | 22 | */ |
| 29 | - 'presets_section' => array( | |
| 30 | - 'title' => esc_html__( 'Style Presets', 'customify' ), | |
| 23 | + 'presets_section' => array( | |
| 24 | + 'title' => esc_html__( 'Style Presets', 'customify' ), | |
| 31 | 25 | 'options' => array( |
| 32 | - 'theme_style' => array( | |
| 33 | - 'type' => 'preset', | |
| 34 | - 'label' => esc_html__( 'Select a style:', 'customify' ), | |
| 35 | - 'desc' => esc_html__( 'Conveniently change the design of your site with built-in style presets. Easy as pie.', 'customify' ), | |
| 36 | - 'default' => 'royal', | |
| 26 | + 'theme_style' => array( | |
| 27 | + 'type' => 'preset', | |
| 28 | + 'label' => esc_html__( 'Select a style:', 'customify' ), | |
| 29 | + 'desc' => esc_html__( 'Conveniently change the design of your site with built-in style presets. Easy as pie.', 'customify' ), | |
| 30 | + 'default' => 'royal', | |
| 37 | 31 | 'choices_type' => 'awesome', |
| 38 | - 'choices' => array( | |
| 39 | - 'royal' => array( | |
| 40 | - 'label' => esc_html__( 'Royal', 'customify' ), | |
| 32 | + 'choices' => array( | |
| 33 | + 'royal' => array( | |
| 34 | + 'label' => esc_html__( 'Royal', 'customify' ), | |
| 41 | 35 | 'preview' => array( |
| 42 | - 'color-text' => '#ffffff', | |
| 43 | - 'background-card' => '#615375', | |
| 36 | + 'color-text' => '#ffffff', | |
| 37 | + 'background-card' => '#615375', | |
| 44 | 38 | 'background-label' => '#46414c', |
| 45 | - 'font-main' => 'Abril Fatface', | |
| 46 | - 'font-alt' => 'PT Serif', | |
| 39 | + 'font-main' => 'Abril Fatface', | |
| 40 | + 'font-alt' => 'PT Serif', | |
| 47 | 41 | ), |
| 48 | 42 | 'options' => array( |
| 49 | - 'links_color' => '#8eb2c5', | |
| 50 | - 'headings_color' => '#725c92', | |
| 51 | - 'body_color' => '#6f8089', | |
| 43 | + 'links_color' => '#8eb2c5', | |
| 44 | + 'headings_color' => '#725c92', | |
| 45 | + 'body_color' => '#6f8089', | |
| 52 | 46 | 'page_background' => '#615375', |
| 53 | - 'headings_font' => 'Abril Fatface', | |
| 54 | - 'body_font' => 'PT Serif', | |
| 55 | - ), | |
| 47 | + 'headings_font' => 'Abril Fatface', | |
| 48 | + 'body_font' => 'PT Serif', | |
| 49 | + ) | |
| 56 | 50 | ), |
| 57 | 51 | 'lovely' => array( |
| 58 | - 'label' => esc_html__( 'Lovely', 'customify' ), | |
| 52 | + 'label' => esc_html__( 'Lovely', 'customify' ), | |
| 59 | 53 | 'preview' => array( |
| 60 | - 'color-text' => '#ffffff', | |
| 61 | - 'background-card' => '#d15c57', | |
| 54 | + 'color-text' => '#ffffff', | |
| 55 | + 'background-card' => '#d15c57', | |
| 62 | 56 | 'background-label' => '#5c374b', |
| 63 | - 'font-main' => 'Playfair Display', | |
| 64 | - 'font-alt' => 'Playfair Display', | |
| 57 | + 'font-main' => 'Playfair Display', | |
| 58 | + 'font-alt' => 'Playfair Display', | |
| 65 | 59 | ), |
| 66 | 60 | 'options' => array( |
| 67 | - 'links_color' => '#cc3747', | |
| 68 | - 'headings_color' => '#d15c57', | |
| 69 | - 'body_color' => '#5c374b', | |
| 61 | + 'links_color' => '#cc3747', | |
| 62 | + 'headings_color' => '#d15c57', | |
| 63 | + 'body_color' => '#5c374b', | |
| 70 | 64 | 'page_background' => '#d15c57', |
| 71 | - 'headings_font' => 'Playfair Display', | |
| 72 | - 'body_font' => 'Playfair Display', | |
| 73 | - ), | |
| 65 | + 'headings_font' => 'Playfair Display', | |
| 66 | + 'body_font' => 'Playfair Display', | |
| 67 | + ) | |
| 74 | 68 | ), |
| 75 | - 'queen' => array( | |
| 76 | - 'label' => esc_html__( 'Queen', 'customify' ), | |
| 69 | + 'queen' => array( | |
| 70 | + 'label' => esc_html__( 'Queen', 'customify' ), | |
| 77 | 71 | 'preview' => array( |
| 78 | - 'color-text' => '#fbedec', | |
| 79 | - 'background-card' => '#773347', | |
| 72 | + 'color-text' => '#fbedec', | |
| 73 | + 'background-card' => '#773347', | |
| 80 | 74 | 'background-label' => '#41212a', |
| 81 | - 'font-main' => 'Cinzel Decorative', | |
| 82 | - 'font-alt' => 'Gentium Basic', | |
| 75 | + 'font-main' => 'Cinzel Decorative', | |
| 76 | + 'font-alt' => 'Gentium Basic', | |
| 83 | 77 | ), |
| 84 | 78 | 'options' => array( |
| 85 | - 'links_color' => '#cd8085', | |
| 86 | - 'headings_color' => '#54323c', | |
| 87 | - 'body_color' => '#cd8085', | |
| 79 | + 'links_color' => '#cd8085', | |
| 80 | + 'headings_color' => '#54323c', | |
| 81 | + 'body_color' => '#cd8085', | |
| 88 | 82 | 'page_background' => '#fff', |
| 89 | - 'headings_font' => 'Cinzel Decorative', | |
| 90 | - 'body_font' => 'Gentium Basic', | |
| 91 | - ), | |
| 83 | + 'headings_font' => 'Cinzel Decorative', | |
| 84 | + 'body_font' => 'Gentium Basic', | |
| 85 | + ) | |
| 92 | 86 | ), |
| 93 | 87 | 'carrot' => array( |
| 94 | - 'label' => esc_html__( 'Carrot', 'customify' ), | |
| 88 | + 'label' => esc_html__( 'Carrot', 'customify' ), | |
| 95 | 89 | 'preview' => array( |
| 96 | - 'color-text' => '#ffffff', | |
| 97 | - 'background-card' => '#df421d', | |
| 90 | + 'color-text' => '#ffffff', | |
| 91 | + 'background-card' => '#df421d', | |
| 98 | 92 | 'background-label' => '#85210a', |
| 99 | - 'font-main' => 'Oswald', | |
| 100 | - 'font-alt' => 'PT Sans Narrow', | |
| 93 | + 'font-main' => 'Oswald', | |
| 94 | + 'font-alt' => 'PT Sans Narrow', | |
| 101 | 95 | ), |
| 102 | 96 | 'options' => array( |
| 103 | - 'links_color' => '#df421d', | |
| 104 | - 'headings_color' => '#df421d', | |
| 105 | - 'body_color' => '#7e7e7e', | |
| 97 | + 'links_color' => '#df421d', | |
| 98 | + 'headings_color' => '#df421d', | |
| 99 | + 'body_color' => '#7e7e7e', | |
| 106 | 100 | 'page_background' => '#fff', |
| 107 | - 'headings_font' => 'Oswald', | |
| 108 | - 'body_font' => 'PT Sans Narrow', | |
| 109 | - ), | |
| 101 | + 'headings_font' => 'Oswald', | |
| 102 | + 'body_font' => 'PT Sans Narrow', | |
| 103 | + ) | |
| 110 | 104 | ), |
| 111 | 105 | |
| 112 | 106 | |
| 113 | - 'adler' => array( | |
| 114 | - 'label' => esc_html__( 'Adler', 'customify' ), | |
| 107 | + | |
| 108 | + 'adler' => array( | |
| 109 | + 'label' => esc_html__( 'Adler', 'customify' ), | |
| 115 | 110 | 'preview' => array( |
| 116 | - 'color-text' => '#fff', | |
| 117 | - 'background-card' => '#0e364f', | |
| 111 | + 'color-text' => '#fff', | |
| 112 | + 'background-card' => '#0e364f', | |
| 118 | 113 | 'background-label' => '#000000', |
| 119 | - 'font-main' => 'Permanent Marker', | |
| 120 | - 'font-alt' => 'Droid Sans Mono', | |
| 114 | + 'font-main' => 'Permanent Marker', | |
| 115 | + 'font-alt' => 'Droid Sans Mono', | |
| 121 | 116 | ), |
| 122 | 117 | 'options' => array( |
| 123 | - 'links_color' => '#68f3c8', | |
| 124 | - 'headings_color' => '#0e364f', | |
| 125 | - 'body_color' => '#45525a', | |
| 118 | + 'links_color' => '#68f3c8', | |
| 119 | + 'headings_color' => '#0e364f', | |
| 120 | + 'body_color' => '#45525a', | |
| 126 | 121 | 'page_background' => '#ffffff', |
| 127 | - 'headings_font' => 'Permanent Marker', | |
| 128 | - 'body_font' => 'Droid Sans Mono', | |
| 129 | - ), | |
| 122 | + 'headings_font' => 'Permanent Marker', | |
| 123 | + 'body_font' => 'Droid Sans Mono' | |
| 124 | + ) | |
| 130 | 125 | ), |
| 131 | 126 | 'velvet' => array( |
| 132 | - 'label' => esc_html__( 'Velvet', 'customify' ), | |
| 127 | + 'label' => esc_html__( 'Velvet', 'customify' ), | |
| 133 | 128 | 'preview' => array( |
| 134 | - 'color-text' => '#ffffff', | |
| 135 | - 'background-card' => '#282828', | |
| 129 | + 'color-text' => '#ffffff', | |
| 130 | + 'background-card' => '#282828', | |
| 136 | 131 | 'background-label' => '#000000', |
| 137 | - 'font-main' => 'Pinyon Script', | |
| 138 | - 'font-alt' => 'Josefin Sans', | |
| 132 | + 'font-main' => 'Pinyon Script', | |
| 133 | + 'font-alt' => 'Josefin Sans', | |
| 139 | 134 | ), |
| 140 | 135 | 'options' => array( |
| 141 | - 'links_color' => '#000000', | |
| 142 | - 'headings_color' => '#000000', | |
| 143 | - 'body_color' => '#000000', | |
| 136 | + 'links_color' => '#000000', | |
| 137 | + 'headings_color' => '#000000', | |
| 138 | + 'body_color' => '#000000', | |
| 144 | 139 | 'page_background' => '#000000', |
| 145 | - 'headings_font' => 'Pinyon Script', | |
| 146 | - 'body_font' => 'Josefin Sans', | |
| 147 | - ), | |
| 140 | + 'headings_font' => 'Pinyon Script', | |
| 141 | + 'body_font' => 'Josefin Sans', | |
| 142 | + ) | |
| 148 | 143 | ), |
| 149 | 144 | |
| 150 | - ), | |
| 145 | + ) | |
| 151 | 146 | ), |
| 152 | - ), | |
| 147 | + ) | |
| 153 | 148 | ), |
| 154 | 149 | |
| 155 | 150 | /** |
| 156 | 151 | * COLORS - This section will handle different elements colors (eg. links, headings) |
| 157 | 152 | */ |
| 158 | - 'colors_section' => array( | |
| 159 | - 'title' => esc_html__( 'Colors', 'customify' ), | |
| 153 | + 'colors_section' => array( | |
| 154 | + 'title' => esc_html__( 'Colors', 'customify' ), | |
| 160 | 155 | 'options' => array( |
| 161 | - 'links_color' => array( | |
| 162 | - 'type' => 'color', | |
| 163 | - 'label' => esc_html__( 'Links Color', 'customify' ), | |
| 164 | - 'live' => true, | |
| 165 | - 'default' => '#6c6e70', | |
| 166 | - 'css' => array( | |
| 156 | + 'links_color' => array( | |
| 157 | + 'type' => 'color', | |
| 158 | + 'label' => esc_html__( 'Links Color', 'customify' ), | |
| 159 | + 'live' => true, | |
| 160 | + 'default' => '#6c6e70', | |
| 161 | + 'css' => array( | |
| 167 | 162 | array( |
| 168 | - 'property' => 'color', | |
| 163 | + 'property' => 'color', | |
| 169 | 164 | 'selector' => 'a, .entry-meta a', |
| 170 | 165 | ), |
| 171 | - ), | |
| 166 | + ) | |
| 172 | 167 | ), |
| 173 | 168 | 'headings_color' => array( |
| 174 | - 'type' => 'color', | |
| 175 | - 'label' => esc_html__( 'Headings Color', 'customify' ), | |
| 176 | - 'live' => true, | |
| 177 | - 'default' => '#0aa0d9', | |
| 178 | - 'css' => array( | |
| 169 | + 'type' => 'color', | |
| 170 | + 'label' => esc_html__( 'Headings Color', 'customify' ), | |
| 171 | + 'live' => true, | |
| 172 | + 'default' => '#0aa0d9', | |
| 173 | + 'css' => array( | |
| 179 | 174 | array( |
| 180 | - 'property' => 'color', | |
| 175 | + 'property' => 'color', | |
| 181 | 176 | 'selector' => '.site-title a, h1, h2, h3, h4, h5, h6, |
| 182 | 177 | h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, |
| 183 | 178 | .widget-title, |
| 184 | - a:hover, .entry-meta a:hover', | |
| 185 | - ), | |
| 186 | - ), | |
| 179 | + a:hover, .entry-meta a:hover' | |
| 180 | + ) | |
| 181 | + ) | |
| 187 | 182 | ), |
| 188 | 183 | 'body_color' => array( |
| 189 | - 'type' => 'color', | |
| 190 | - 'label' => esc_html__( 'Body Color', 'customify' ), | |
| 191 | - 'live' => true, | |
| 192 | - 'default' => '#2d3033', | |
| 193 | - 'css' => array( | |
| 184 | + 'type' => 'color', | |
| 185 | + 'label' => esc_html__( 'Body Color', 'customify' ), | |
| 186 | + 'live' => true, | |
| 187 | + 'default' => '#2d3033', | |
| 188 | + 'css' => array( | |
| 194 | 189 | array( |
| 195 | 190 | 'selector' => 'body', |
| 196 | - 'property' => 'color', | |
| 197 | - ), | |
| 198 | - ), | |
| 199 | - ), | |
| 200 | - ), | |
| 191 | + 'property' => 'color' | |
| 192 | + ) | |
| 193 | + ) | |
| 194 | + ) | |
| 195 | + ) | |
| 201 | 196 | ), |
| 202 | 197 | |
| 203 | 198 | /** |
| 204 | 199 | * FONTS - This section will handle different elements fonts (eg. headings, body) |
| 205 | 200 | */ |
| 206 | - 'typography_section' => array( | |
| 207 | - 'title' => esc_html__( 'Fonts', 'customify' ), | |
| 201 | + 'typography_section' => array( | |
| 202 | + 'title' => esc_html__( 'Fonts', 'customify' ), | |
| 208 | 203 | 'options' => array( |
| 209 | 204 | 'headings_font' => array( |
| 210 | - 'type' => 'font', | |
| 211 | - 'label' => esc_html__( 'Headings', 'customify' ), | |
| 212 | - 'default' => 'Playfair Display', | |
| 213 | - 'selector' => '.site-title a, h1, h2, h3, h4, h5, h6, | |
| 205 | + 'type' => 'font', | |
| 206 | + 'label' => esc_html__( 'Headings', 'customify' ), | |
| 207 | + 'default' => 'Playfair Display', | |
| 208 | + 'selector' => '.site-title a, h1, h2, h3, h4, h5, h6, | |
| 214 | 209 | h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, |
| 215 | 210 | .widget-title', |
| 216 | 211 | 'font_weight' => true, |
| 217 | 212 | 'recommended' => array( |
| @@ -232,16 +227,16 @@ | ||
| 232 | 227 | 'The Girl Next Door', |
| 233 | 228 | 'Pacifico', |
| 234 | 229 | 'Handlee', |
| 235 | 230 | 'Satify', |
| 236 | - 'Pompiere', | |
| 237 | - ), | |
| 231 | + 'Pompiere' | |
| 232 | + ) | |
| 238 | 233 | ), |
| 239 | 234 | 'body_font' => array( |
| 240 | - 'type' => 'font', | |
| 241 | - 'label' => esc_html__( 'Body Text', 'customify' ), | |
| 242 | - 'default' => 'Lato', | |
| 243 | - 'selector' => 'html body', | |
| 235 | + 'type' => 'font', | |
| 236 | + 'label' => esc_html__( 'Body Text', 'customify' ), | |
| 237 | + 'default' => 'Lato', | |
| 238 | + 'selector' => 'html body', | |
| 244 | 239 | 'recommended' => array( |
| 245 | 240 | 'Lato', |
| 246 | 241 | 'Open Sans', |
| 247 | 242 | 'PT Sans', |
| @@ -247,12 +242,12 @@ | ||
| 247 | 242 | 'PT Sans', |
| 248 | 243 | 'Cabin', |
| 249 | 244 | 'Gentium Book Basic', |
| 250 | 245 | 'PT Serif', |
| 251 | - 'Droid Serif', | |
| 252 | - ), | |
| 253 | - ), | |
| 254 | - ), | |
| 246 | + 'Droid Serif' | |
| 247 | + ) | |
| 248 | + ) | |
| 249 | + ) | |
| 255 | 250 | ), |
| 256 | 251 | |
| 257 | 252 | /** |
| 258 | 253 | * BACKGROUNDS - This section will handle different elements colors (eg. links, headings) |
| @@ -257,71 +252,71 @@ | ||
| 257 | 252 | /** |
| 258 | 253 | * BACKGROUNDS - This section will handle different elements colors (eg. links, headings) |
| 259 | 254 | */ |
| 260 | 255 | 'backgrounds_section' => array( |
| 261 | - 'title' => esc_html__( 'Backgrounds', 'customify' ), | |
| 256 | + 'title' => esc_html__( 'Backgrounds', 'customify' ), | |
| 262 | 257 | 'options' => array( |
| 263 | - 'page_background' => array( | |
| 264 | - 'type' => 'color', | |
| 265 | - 'label' => esc_html__( 'Page Background', 'customify' ), | |
| 266 | - 'live' => true, | |
| 267 | - 'default' => '#ffffff', | |
| 268 | - 'css' => array( | |
| 258 | + 'page_background' => array( | |
| 259 | + 'type' => 'color', | |
| 260 | + 'label' => esc_html__( 'Page Background', 'customify' ), | |
| 261 | + 'live' => true, | |
| 262 | + 'default' => '#ffffff', | |
| 263 | + 'css' => array( | |
| 269 | 264 | array( |
| 270 | - 'property' => 'background', | |
| 265 | + 'property' => 'background', | |
| 271 | 266 | 'selector' => 'body, .site', |
| 272 | - ), | |
| 273 | - ), | |
| 267 | + ) | |
| 268 | + ) | |
| 274 | 269 | ), |
| 275 | - ), | |
| 270 | + ) | |
| 276 | 271 | ), |
| 277 | 272 | /** |
| 278 | 273 | * LAYOUTS - This section will handle different elements colors (eg. links, headings) |
| 279 | 274 | */ |
| 280 | - 'layout_options' => array( | |
| 281 | - 'title' => esc_html__( 'Layout', 'customify' ), | |
| 275 | + 'layout_options' => array( | |
| 276 | + 'title' => esc_html__( 'Layout', 'customify' ), | |
| 282 | 277 | 'options' => array( |
| 283 | - 'site_title_size' => array( | |
| 284 | - 'type' => 'range', | |
| 285 | - 'label' => esc_html__( 'Site Title Size', 'customify' ), | |
| 286 | - 'live' => true, | |
| 278 | + 'site_title_size' => array( | |
| 279 | + 'type' => 'range', | |
| 280 | + 'label' => esc_html__( 'Site Title Size', 'customify' ), | |
| 281 | + 'live' => true, | |
| 287 | 282 | 'input_attrs' => array( |
| 288 | - 'min' => 24, | |
| 289 | - 'max' => 100, | |
| 290 | - 'step' => 1, | |
| 291 | - 'data-preview' => true, | |
| 283 | + 'min' => 24, | |
| 284 | + 'max' => 100, | |
| 285 | + 'step' => 1, | |
| 286 | + 'data-preview' => true | |
| 292 | 287 | ), |
| 293 | - 'default' => 24, | |
| 294 | - 'css' => array( | |
| 288 | + 'default' => 24, | |
| 289 | + 'css' => array( | |
| 295 | 290 | array( |
| 296 | 291 | 'property' => 'font-size', |
| 297 | 292 | 'selector' => '.site-title', |
| 298 | - 'media' => 'screen and (min-width: 1000px)', | |
| 299 | - 'unit' => 'px', | |
| 300 | - ), | |
| 301 | - ), | |
| 293 | + 'media' => 'screen and (min-width: 1000px)', | |
| 294 | + 'unit' => 'px', | |
| 295 | + ) | |
| 296 | + ) | |
| 302 | 297 | ), |
| 303 | 298 | 'page_content_spacing' => array( |
| 304 | - 'type' => 'range', | |
| 305 | - 'label' => 'Page Content Spacing', | |
| 306 | - 'live' => true, | |
| 299 | + 'type' => 'range', | |
| 300 | + 'label' => 'Page Content Spacing', | |
| 301 | + 'live' => true, | |
| 307 | 302 | 'input_attrs' => array( |
| 308 | - 'min' => 0, | |
| 309 | - 'max' => 100, | |
| 310 | - 'step' => 1, | |
| 303 | + 'min' => 0, | |
| 304 | + 'max' => 100, | |
| 305 | + 'step' => 1, | |
| 311 | 306 | ), |
| 312 | - 'default' => 18, | |
| 313 | - 'css' => array( | |
| 307 | + 'default' => 18, | |
| 308 | + 'css' => array( | |
| 314 | 309 | array( |
| 315 | 310 | 'property' => 'padding', |
| 316 | 311 | 'selector' => '.site-content', |
| 317 | - 'media' => 'screen and (min-width: 1000px)', | |
| 318 | - 'unit' => 'px', | |
| 319 | - ), | |
| 320 | - ), | |
| 321 | - ), | |
| 322 | - ), | |
| 323 | - ), | |
| 312 | + 'media' => 'screen and (min-width: 1000px)', | |
| 313 | + 'unit' => 'px', | |
| 314 | + ) | |
| 315 | + ) | |
| 316 | + ) | |
| 317 | + ) | |
| 318 | + ) | |
| 324 | 319 | ); |
| 325 | 320 | |
| 326 | 321 | return $config; |
| 327 | 322 | } |
| @@ -327,9 +322,9 @@ | ||
| 327 | 322 | } |
| 328 | 323 | } |
| 329 | 324 | add_filter( 'customify_filter_fields', 'add_customify_base_options', 5, 1 ); |
| 330 | 325 | |
| 331 | -add_action( 'after_switch_theme', function ( $old_theme_name, $old_theme ) { | |
| 326 | +add_action( 'after_switch_theme', function( $old_theme_name, $old_theme ) { | |
| 332 | 327 | $current_theme = wp_get_theme(); |
| 333 | 328 | // If the current theme is a child theme, show a notice. |
| 334 | 329 | if ( $current_theme->exists() |
| 335 | 330 | && $old_theme->exists() |
| @@ -359,14 +354,9 @@ | ||
| 359 | 354 | } |
| 360 | 355 | |
| 361 | 356 | ob_start(); ?> |
| 362 | 357 | <div class="customify-notice__container updated notice fade is-dismissible"> |
| 363 | - <h3> | |
| 364 | - <?php | |
| 365 | - /* translators: %s: parent theme name. */ | |
| 366 | - printf( esc_html__( 'You have activated a child theme for "%s". Good for you!', 'customify' ), esc_html( $parent_theme->get( 'Name' ) ) ); | |
| 367 | - ?> | |
| 368 | - </h3> | |
| 358 | + <h3><?php echo sprintf( __( 'You have activated a child theme for "%s". Good for you!', 'customify' ), $parent_theme->get('Name') ); ?></h3> | |
| 369 | 359 | <p> |
| 370 | 360 | <?php echo wp_kses_post( __( 'If you have already <strong>set up things in the Customizer,</strong> you may want to <strong>keep those customizations</strong> so you don\'t start over.', 'customify' ) ); ?> |
| 371 | 361 | </p> |
| 372 | 362 | <p> |
| @@ -379,13 +369,11 @@ | ||
| 379 | 369 | <noscript><input type="hidden" name="customify-notice-no-js" value="1"/></noscript> |
| 380 | 370 | |
| 381 | 371 | <p> |
| 382 | 372 | <button class="customify-notice-button button button-primary js-handle-customify"> |
| 383 | - <span | |
| 384 | - class="customify-notice-button__text"><?php esc_html_e( 'Yes, migrate customizations', 'customify' ); ?></span> | |
| 373 | + <span class="customify-notice-button__text"><?php esc_html_e( 'Yes, migrate customizations', 'customify' ); ?></span> | |
| 385 | 374 | </button> |
| 386 | - <button type="submit" | |
| 387 | - class="customify-dismiss-button button button-secondary js-dismiss-customify"><?php esc_html_e( 'No, thank you', 'customify' ); ?></button> | |
| 375 | + <button type="submit" class="customify-dismiss-button button button-secondary js-dismiss-customify"><?php esc_html_e( 'No, thank you', 'customify' ); ?></button> | |
| 388 | 376 | <span class="message js-plugin-message" style="font-style:italic"></span> |
| 389 | 377 | </p> |
| 390 | 378 | |
| 391 | 379 | <?php wp_nonce_field( 'customify_migrate_customizations_from_parent_to_child_theme', 'nonce-customify_theme_mods_migrate' ); ?> |
| @@ -400,11 +388,11 @@ | ||
| 400 | 388 | $dismissButton = $noticeContainer.find('.js-dismiss-customify'), |
| 401 | 389 | $statusMessage = $noticeContainer.find('.js-plugin-message') |
| 402 | 390 | |
| 403 | 391 | $button.on('click', function (e) { |
| 404 | - e.preventDefault() | |
| 392 | + e.preventDefault(); | |
| 405 | 393 | |
| 406 | - $buttonText.html("<?php esc_html_e( 'Migrating customizations..', 'customify' ); ?>") | |
| 394 | + $buttonText.html("<?php esc_html_e( 'Migrating customizations..' ,'customify'); ?>") | |
| 407 | 395 | $button.attr('disabled', true) |
| 408 | 396 | $dismissButton.hide() |
| 409 | 397 | |
| 410 | 398 | // Do an AJAX call to migrate the theme_mods. |
| @@ -415,28 +403,28 @@ | ||
| 415 | 403 | action: 'customify_migrate_customizations_from_parent_to_child_theme', |
| 416 | 404 | nonce_migrate: $noticeContainer.find('#nonce-customify_theme_mods_migrate').val() |
| 417 | 405 | } |
| 418 | 406 | }) |
| 419 | - .done(function (response) { | |
| 420 | - if (typeof response.success !== 'undefined' && response.success) { | |
| 421 | - $statusMessage.html("<?php esc_html_e( 'Successfully migrated the parent customizations! Enjoy crafting your site!', 'customify' ); ?>") | |
| 422 | - $buttonText.html("<?php esc_html_e( 'Finished migration', 'customify' ); ?>") | |
| 423 | - } else { | |
| 424 | - $statusMessage.html("<?php esc_html_e( 'Something went wrong and we couldn\'t migrate the customizations.', 'customify' ); ?>") | |
| 425 | - $buttonText.html("<?php esc_html_e( 'Migration error', 'customify' ); ?>") | |
| 426 | - } | |
| 427 | - }) | |
| 428 | - .fail(function () { | |
| 429 | - $statusMessage.html("<?php esc_html_e( 'Something went wrong and we couldn\'t migrate the customizations.', 'customify' ); ?>") | |
| 430 | - $buttonText.html("<?php esc_html_e( 'Migration error', 'customify' ); ?>") | |
| 431 | - }) | |
| 407 | + .done(function(response) { | |
| 408 | + if (typeof response.success !== 'undefined' && response.success) { | |
| 409 | + $statusMessage.html("<?php esc_html_e( 'Successfully migrated the parent customizations! Enjoy crafting your site!', 'customify' ); ?>") | |
| 410 | + $buttonText.html("<?php esc_html_e( 'Finished migration', 'customify' ); ?>") | |
| 411 | + } else { | |
| 412 | + $statusMessage.html("<?php esc_html_e( 'Something went wrong and we couldn\'t migrate the customizations.' ,'customify'); ?>") | |
| 413 | + $buttonText.html("<?php esc_html_e( 'Migration error' ,'customify'); ?>") | |
| 414 | + } | |
| 415 | + }) | |
| 416 | + .fail(function() { | |
| 417 | + $statusMessage.html("<?php esc_html_e( 'Something went wrong and we couldn\'t migrate the customizations.' ,'customify'); ?>") | |
| 418 | + $buttonText.html("<?php esc_html_e( 'Migration error' ,'customify'); ?>") | |
| 419 | + }) | |
| 432 | 420 | }) |
| 433 | 421 | |
| 434 | 422 | // Dismiss the notice. |
| 435 | 423 | $dismissButton.on('click', function (e) { |
| 436 | - e.preventDefault() | |
| 424 | + e.preventDefault(); | |
| 437 | 425 | |
| 438 | - $noticeContainer.slideUp() | |
| 426 | + $noticeContainer.slideUp(); | |
| 439 | 427 | }) |
| 440 | 428 | }) |
| 441 | 429 | })(jQuery) |
| 442 | 430 | </script> |
| @@ -450,12 +438,8 @@ | ||
| 450 | 438 | function customify_migrate_customizations_from_parent_to_child_theme() { |
| 451 | 439 | // Check nonce. |
| 452 | 440 | check_ajax_referer( 'customify_migrate_customizations_from_parent_to_child_theme', 'nonce_migrate' ); |
| 453 | 441 | |
| 454 | - if ( ! current_user_can( 'manage_options' ) ) { | |
| 455 | - wp_send_json_error( esc_html__( 'You do not have permission to perform this action.', 'customify' ) ); | |
| 456 | - } | |
| 457 | - | |
| 458 | 442 | $parent_theme = wp_get_theme( get_template() ); |
| 459 | 443 | if ( ! $parent_theme->exists() ) { |
| 460 | 444 | wp_send_json_error(); |
| 461 | 445 | } |
| @@ -467,12 +451,10 @@ | ||
| 467 | 451 | 'pixcare_license', |
| 468 | 452 | 'pixcare_new_theme_version', |
| 469 | 453 | 'pixcare_install_notice_dismissed', |
| 470 | 454 | ]; |
| 471 | - if ( is_array( $parent_theme_mods ) ) { | |
| 472 | - foreach ( $excluded as $exclude ) { | |
| 473 | - unset( $parent_theme_mods[ $exclude ] ); | |
| 474 | - } | |
| 455 | + foreach ( $excluded as $exclude ) { | |
| 456 | + unset( $parent_theme_mods[ $exclude ] ); | |
| 475 | 457 | } |
| 476 | 458 | // Finally, write the new theme mods for the active child theme. |
| 477 | 459 | if ( ! update_option( "theme_mods_" . get_option( 'stylesheet' ), $parent_theme_mods ) ) { |
| 478 | 460 | wp_send_json_error( esc_html__( 'Could not update the child theme theme_mods.', 'customify' ) ); |
| @@ -487,9 +469,8 @@ | ||
| 487 | 469 | } |
| 488 | 470 | |
| 489 | 471 | wp_send_json_success(); |
| 490 | 472 | } |
| 491 | - | |
| 492 | 473 | add_action( 'wp_ajax_customify_migrate_customizations_from_parent_to_child_theme', 'customify_migrate_customizations_from_parent_to_child_theme' ); |
| 493 | 474 | |
| 494 | 475 | /** |
| 495 | 476 | * Migrate data from the simple Dark Mode control to Advanced Dark Mode Control, if the current theme supports it. |
| @@ -533,70 +514,5 @@ | ||
| 533 | 514 | } else { |
| 534 | 515 | update_option( 'sm_dark_mode_advanced', 'off' ); |
| 535 | 516 | } |
| 536 | 517 | } |
| 537 | - | |
| 538 | 518 | add_action( 'admin_init', 'customify_migrate_to_advanced_dark_mode_control' ); |
| 539 | - | |
| 540 | -if ( ! function_exists( 'pixelgrade_option' ) ) { | |
| 541 | - /** | |
| 542 | - * Get option from the database | |
| 543 | - * | |
| 544 | - * @param string $option_id The option name. | |
| 545 | - * @param mixed $default Optional. The default value to return when the option was not found or saved. | |
| 546 | - * @param bool $force_given_default Optional. When true, we will use the $default value provided for when the option was not saved at least once. | |
| 547 | - * When false, we will let the option's default set value (in the Customify settings) kick in first, then our $default. | |
| 548 | - * It basically, reverses the order of fallback, first the option's default, then our own. | |
| 549 | - * This is ignored when $default is null. | |
| 550 | - * | |
| 551 | - * @return mixed | |
| 552 | - */ | |
| 553 | - function pixelgrade_option( $option_id, $default = null, $force_given_default = false ) { | |
| 554 | - | |
| 555 | - // We need to account for the case where a option has an 'active_callback' defined in it's config | |
| 556 | - $options_config = PixCustomifyPlugin()->get_options_configs(); | |
| 557 | - if ( ! empty( $options_config ) && ! empty( $options_config[ $option_id ] ) ) { | |
| 558 | - if ( ! empty( $options_config[ $option_id ]['active_callback'] ) ) { | |
| 559 | - // This option has an active callback | |
| 560 | - // We need to "question" it | |
| 561 | - // | |
| 562 | - // IMPORTANT NOTICE: | |
| 563 | - // | |
| 564 | - // Be extra careful when setting up the options to not end up in a circular logic | |
| 565 | - // due to callbacks that get an option and that option has a callback that gets the initial option - INFINITE LOOPS :( | |
| 566 | - if ( is_callable( $options_config[ $option_id ]['active_callback'] ) ) { | |
| 567 | - // Now we call the function and if it returns false, this means that the control is not active | |
| 568 | - // Hence it's saved value doesn't matter | |
| 569 | - $active = call_user_func( $options_config[ $option_id ]['active_callback'] ); | |
| 570 | - if ( empty( $active ) ) { | |
| 571 | - // If we need to force the default received; we respect that | |
| 572 | - if ( true === $force_given_default && null !== $default ) { | |
| 573 | - return $default; | |
| 574 | - } else { | |
| 575 | - // Else we return false | |
| 576 | - // because we treat the case when the active callback returns false as if the option would be non-existent | |
| 577 | - // We do not return the default configured value in this case | |
| 578 | - return false; | |
| 579 | - } | |
| 580 | - } | |
| 581 | - } | |
| 582 | - } | |
| 583 | - | |
| 584 | - // Now that the option is truly active, we need to see if we are not supposed to force over the option's default value | |
| 585 | - if ( $default !== null && false === $force_given_default ) { | |
| 586 | - // We will not pass the received $default here so Customify will fallback on the option's default value, if set | |
| 587 | - $customify_value = PixCustomifyPlugin()->get_option( $option_id ); | |
| 588 | - | |
| 589 | - // We only fallback on the $default if none was given from Customify | |
| 590 | - if ( null === $customify_value ) { | |
| 591 | - return $default; | |
| 592 | - } | |
| 593 | - } else { | |
| 594 | - $customify_value = PixCustomifyPlugin()->get_option( $option_id, $default ); | |
| 595 | - } | |
| 596 | - | |
| 597 | - return $customify_value; | |
| 598 | - } | |
| 599 | - | |
| 600 | - return $default; | |
| 601 | - } | |
| 602 | -} | |