1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
<?php /** * Functions for configuring demo importer. * * @author ThemeGrill * @category Admin * @package Importer/Functions * @version 1.0.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; }
/** * Setup demo importer config. * * @param array $demo_config * * @return array */ function tg_demo_importer_config( $demo_config ) { $new_demo_config = array( 'colormag-free' => array( 'name' => 'ColorMag', 'theme' => 'ColorMag', 'template' => 'colormag', 'demo_url' => 'http://demo.themegrill.com/colormag/', 'demo_pack' => true, 'core_options' => array( 'blogname' => 'ColorMag', ), 'widgets_data_update' => array(
/** * Dropdown Categories - Handles widgets Category ID. * * A. Core Post Category: * 1. colormag_featured_posts_slider_widget * 2. colormag_highlighted_posts_widget * 3. colormag_featured_posts_widget * 4. colormag_featured_posts_vertical_widget * */ 'dropdown_categories' => array( 'category' => array( 'colormag_featured_posts_slider_widget' => array( 4 => array( 'category' => 'Latest' ) ), 'colormag_highlighted_posts_widget' => array( 3 => array( 'category' => 'FEATURED' ) ), 'colormag_featured_posts_widget' => array( 3 => array( 'category' => 'Health' ), 4 => array( 'category' => 'Technology' ) ), 'colormag_featured_posts_vertical_widget' => array( 3 => array( 'category' => 'Fashion' ), 4 => array( 'category' => 'Sports' ), 5 => array( 'category' => 'General' ), ), ) ) ), 'customizer_data_update' => array( 'nav_menu_locations' => array( 'primary' => 'Primary', ) ), 'plugins_list' => array( 'required' => array( 'everest-forms' => array( 'name' => __( 'Everest Forms – Easy Contact Form and Form Builder', 'colormag' ), 'slug' => 'everest-forms/everest-forms.php', ), ), ), ), );
return array_merge( $new_demo_config, $demo_config ); }
add_filter( 'themegrill_demo_importer_config', 'tg_demo_importer_config' );
/** * Set categories color settings in theme customizer. * * Note: Used rarely, if theme_mod keys are based on term ID. * * @param array $data * @param array $demo_data * @param string $demo_id * * @return array */ function colormag_set_cat_colors_free( $data, $demo_data, $demo_id ) { $cat_colors = array(); $cat_prevent = array(); $wp_categories = array();
// Format the data based on demo ID. switch ( $demo_id ) { case 'colormag-free': $wp_categories = array( 1 => 'Sports', 2 => 'Politics', 3 => 'Business', 4 => 'Technology', 5 => 'WordPress', 8 => 'General', 9 => 'Fashion', 10 => 'Food', 11 => 'Entertainment', 13 => 'FEATURED', 14 => 'TOP STORIES', 15 => 'TOP VIDEOS', 16 => 'Health', 18 => 'Latest', 19 => 'Drinks', 20 => 'Gadgets', 21 => 'Female', 22 => 'Style', 23 => 'News', ); break; }
// Fetch categories color settings. foreach ( $wp_categories as $term_id => $term_name ) { if ( ! empty( $data['mods'][ 'colormag_category_color_' . $term_id ] ) ) { $cat_colors[ 'colormag_category_color_' . $term_id ] = $data['mods'][ 'colormag_category_color_' . $term_id ]; } }
// Set categories color settings properly. foreach ( $wp_categories as $term_id => $term_name ) { if ( ! empty( $data['mods'][ 'colormag_category_color_' . $term_id ] ) ) { $term = get_term_by( 'name', $term_name, 'category' ); $color = $cat_colors[ 'colormag_category_color_' . $term_id ];
if ( is_object( $term ) && $term->term_id ) { $cat_prevent[] = $term->term_id; $data['mods'][ 'colormag_category_color_' . $term->term_id ] = $color;
// Prevent deleting stored color settings. if ( ! in_array( $term_id, $cat_prevent ) ) { unset( $data['mods'][ 'colormag_category_color_' . $term_id ] ); } } } }
return $data; }
add_filter( 'themegrill_customizer_demo_import_settings', 'colormag_set_cat_colors_free', 20, 3 );
|