This repository has been archived by the owner on Feb 2, 2020. It is now read-only.
/
nano-progga-settings.php
312 lines (296 loc) · 11.3 KB
/
nano-progga-settings.php
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<?php
/**
* nano progga Settings Page.
*
* To let the user control site settings from admin panel.
*
* @package nano progga
*/
/**
* Make an <option> array for the admin framework.
* @return array Array with term_id and term_name with term_count.
* --------------------------------------------------------------------------
*/
function make_series_options() {
$series_terms = get_terms( array('series'), array('hide_empty' => false ) );
$_result = array();
if( $series_terms && is_array($series_terms) ) :
foreach( $series_terms as $series ) :
$_result[$series->term_id] = $series->name ." ({$series->count})";
endforeach;
endif;
return $_result;
}
function home_widgets_positioning_options() {
$posts_per_page = get_option( 'posts_per_page' );
$_result = array();
for( $iteration = 1; $iteration <= $posts_per_page; $iteration++ ) :
$_result[$iteration] = $iteration;
endfor;
return $_result;
}
/**
* Initiating Theme Options Framework.
*
* @since 3.0.0
*
* @param array $settings Options Framework Default Settings array.
* @return array Settings as per our need.
* --------------------------------------------------------------------------
*/
function nano_progga_theme_options_settings( $settings ) {
$settings = array(
'menu_title' => __( 'Theme Options', 'nano-progga' ),
'menu_type' => 'add_theme_page',
'menu_slug' => 'np-options',
'ajax_save' => false,
);
return $settings;
}
add_filter( 'cs_framework_settings', 'nano_progga_theme_options_settings' );
/**
* Theme Options Options Fields.
* @param array $options Options Framework Default Option Fields' array.
* @return array Options as per our need.
* --------------------------------------------------------------------------
*/
function nano_progga_theme_options( $options ) {
$options = array(); // remove old options
$options[] = array(
'name' => 'basic_settings',
'title' => __( 'Basic Settings', 'nano-progga' ),
'icon' => 'fa fa-cogs',
'fields' => array(
array(
'id' => 'logo',
'type' => 'image',
'title' => __( 'Site Logo', 'nano-progga' ),
'desc' => __( 'Set a site logo to show on the header of the site. Upload an image of minimum <code>40px</code> × <code>40px</code>', 'nano-progga' ),
'add_title' => 'Add Logo',
),
array(
'id' => 'bangla',
'type' => 'switcher',
'title' => __( 'Enable Bengali', 'nano-progga' ),
'default' => false,
'label' => __( 'Control whether to enable/disable Bengali (<em>Bangla</em>) support to your blog', 'nano-progga' ),
),
array(
'type' => 'notice',
'class' => 'info',
'content' => __( '<strong>Featured Post Series</strong> Control the Featured Post Series from here', 'nano-progga' ),
),
array(
'id' => 'showseries',
'type' => 'switcher',
'title' => __( 'Show series', 'nano-progga' ),
'default' => false,
'label' => __( 'Control whether to show the featured series on the Home page or not', 'nano-progga' ),
),
array(
'id' => 'serieschoice',
'type' => 'select',
'title' => __( 'Choice Featured Series', 'nano-progga' ),
'desc' => __( 'Control which 4 series to show on home page as featured (Select multiple)', 'nano-progga' ),
'dependency' => array(
'showseries',
'==',
'true'
), // dependent on switch
'options' => make_series_options(), //custom function
'attributes' => array(
'multiple' => 'multiple',
),
'class' => 'chosen',
),
array(
'id' => 'showseriesblog',
'type' => 'switcher',
'title' => __( 'Show series in Blog Template', 'nano-progga' ),
'default' => false,
'dependency' => array(
'showseries',
'==',
'true'
), // dependent on switch
'label' => __( 'Control whether to show the featured series on the Blog Template page or not', 'nano-progga' ),
),
array(
'type' => 'notice',
'class' => 'info',
'content' => sprintf( __( '<strong>Home Page Widgets</strong> You can alter the placement of home page widgets by setting their individual values from here, and you can set places within <strong>%s</strong>', 'nano-progga' ), get_option('posts_per_page') ),
),
array(
'id' => 'widgets_positioning',
'type' => 'fieldset',
'title' => __( "Widgets' Positioning", 'nano-progga' ),
'fields' => array(
array(
'id' => 'home_widget_1',
'type' => 'select',
'title' => __( 'Home Widget 1 : Position', 'nano-progga' ),
'options' => home_widgets_positioning_options(), //custom function
'default_option' => 'Select position',
),
array(
'id' => 'home_widget_2',
'type' => 'select',
'title' => __( 'Home Widget 2 : Position', 'nano-progga' ),
'options' => home_widgets_positioning_options(), //custom function
'default_option' => 'Select position',
),
array(
'id' => 'home_widget_3',
'type' => 'select',
'title' => __( 'Home Widget 3 : Position', 'nano-progga' ),
'options' => home_widgets_positioning_options(), //custom function
'default_option' => 'Select position',
),
array(
'id' => 'home_widget_4',
'type' => 'select',
'title' => __( 'Home Widget 4 : Position', 'nano-progga' ),
'options' => home_widgets_positioning_options(), //custom function
'default_option' => 'Select position',
),
array(
'id' => 'home_widget_5',
'type' => 'select',
'title' => __( 'Home Widget 5 : Position', 'nano-progga' ),
'options' => home_widgets_positioning_options(), //custom function
'default_option' => 'Select position',
),
),
),
array(
'id' => 'widgets_in_pages',
'type' => 'switcher',
'title' => __( 'Show widgets in paginated pages too', 'nano-progga' ),
'default' => false,
'desc' => __( 'Home widgets are visible only on the first paginated page of home page.', 'nano-progga' ),
'label' => __( 'If you want to show them in other pages too, enable here', 'nano-progga' ),
)
)
);
$options[] = array(
'name' => 'other_settings',
'title' => __( 'Other Settings', 'nano-progga' ),
'icon' => 'fa fa-wrench',
'fields' => array(
array(
'id' => 'author_bio',
'type' => 'switcher',
'title' => __( 'Show Author Bio', 'nano-progga' ),
'default' => false,
'label' => __( 'Control whether to show/hide author bio in <em>Author</em> archives', 'nano-progga' ),
),
array(
'id' => 'related_posts',
'type' => 'switcher',
'title' => __( 'Show Related Posts', 'nano-progga' ),
'default' => false,
'label' => __( 'Control whether to show/hide related posts in post detail page', 'nano-progga' ),
),
array(
'id' => 'noselfping',
'type' => 'switcher',
'title' => __( "Don't Ping on Self Links", 'nano-progga' ),
'default' => false,
'label' => __( "Activating this will not notify you on self ping. Based on 'No Self Ping' WordPress Plugin", 'nano-progga' ),
),
)
);
$options[] = array(
'name' => 'seo_settings',
'title' => __( 'SEO Settings', 'nano-progga' ),
'icon' => 'fa fa-shield',
'fields' => array(
array(
'id' => 'nofollow',
'type' => 'switcher',
'title' => __( 'NoFollow External Links', 'nano-progga' ),
'default' => false,
'label' => __( 'Control whether to show <code>rel="nofollow"</code> in external links in post/page content', 'nano-progga' ),
)
)
);
$options[] = array(
'name' => 'social_settings',
'title' => __( 'Social Settings', 'nano-progga' ),
'icon' => 'fa fa-share-square',
'fields' => array(
array(
'id' => 'rss',
'type' => 'text',
'title' => sprintf( __( '%s RSS Feed URL', 'nano-progga' ), '<span class="fa fa-rss-square"></span>' ),
'default' => get_bloginfo('rss_url'),
),
array(
'id' => 'facebook',
'type' => 'text',
'title' => sprintf( __( '%s Facebook URL', 'nano-progga' ), '<span class="fa fa-facebook-official"></span>' ),
'attributes' => array(
'placeholder' => 'http://facebook.com/page-url',
),
),
array(
'id' => 'twitter',
'type' => 'text',
'title' => sprintf( __( '%s Twitter URL', 'nano-progga' ), '<span class="fa fa-twitter-square"></span>' ),
'attributes' => array(
'placeholder' => 'http://twitter.com/username',
),
),
array(
'id' => 'linkedin',
'type' => 'text',
'title' => sprintf( __( '%s LinkedIn Page URL', 'nano-progga' ), '<span class="fa fa-linkedin-square"></span>' ),
'attributes' => array(
'placeholder' => 'http://linkedin.com/pageurl',
),
),
array(
'id' => 'googleplus',
'type' => 'text',
'title' => sprintf( __( '%s Google+ Page URL', 'nano-progga' ), '<span class="fa fa-google-plus-square"></span>' ),
'attributes' => array(
'placeholder' => 'http://plus.google.com/pageurl',
),
),
array(
'id' => 'flickr',
'type' => 'text',
'title' => sprintf( __( '%s Flickr URL', 'nano-progga' ), '<span class="fa fa-flickr"></span>' ),
'attributes' => array(
'placeholder' => 'http://flickr.com/username',
),
),
array(
'id' => 'pinterest',
'type' => 'text',
'title' => sprintf( __( '%s Pinterest Profile URL', 'nano-progga' ), '<span class="fa fa-pinterest-square"></span>' ),
'attributes' => array(
'placeholder' => 'http://pinterest.com/username',
),
),
array(
'id' => 'tumblr',
'type' => 'text',
'title' => sprintf( __( '%s Tumblr Blog URL', 'nano-progga' ), '<span class="fa fa-tumblr-square"></span>' ),
'attributes' => array(
'placeholder' => 'http://tumblr.com/username',
),
),
array(
'id' => 'youtube',
'type' => 'text',
'title' => sprintf( __( '%s YouTube Channel URL', 'nano-progga' ), '<span class="fa fa-youtube-square"></span>' ),
'attributes' => array(
'placeholder' => 'http://youtube.com/channel/channelname',
),
),
)
);
return $options;
}
add_filter( 'cs_framework_options', 'nano_progga_theme_options' );