View difference between Paste ID: 0EG5YRe9 and
SHOW: | | - or go back to the newest paste.
1-
1+
<?php
2
3
if ( function_exists('register_sidebar') ) {
4
5
	register_sidebar(array(
6
7
    	'name' => 'Sidebar 1',
8
9
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
10
11
        'after_widget' => '</li>',
12
13
        'before_title' => '<h2 class="widgettitle">',
14
15
        'after_title' => '</h2>',
16
17
    ));
18
19
    
20
21
    register_sidebar(
22
23
	array(
24
25
		'name' => 'Sidebar 2',
26
27
		'before_widget' => '<li id="%1$s" class="widget %2$s">',
28
29
        'after_widget' => '</li>',
30
31
        'before_title' => '<h2 class="widgettitle">',
32
33
        'after_title' => '</h2>',
34
35
    ));
36
37
}
38
39
40
41
$themename = "Alfredo";
42
43
$shortname = str_replace(' ', '_', strtolower($themename));
44
45
46
47
function get_theme_option($option)
48
49
{
50
51
	global $shortname;
52
53
	return stripslashes(get_option($shortname . '_' . $option));
54
55
}
56
57
58
59
function get_theme_settings($option)
60
61
{
62
63
	return stripslashes(get_option($option));
64
65
}
66
67
68
69
function cats_to_select()
70
71
{
72
73
	$categories = get_categories('hide_empty=0'); 
74
75
	$categories_array[] = array('value'=>'0', 'title'=>'Select');
76
77
	foreach ($categories as $cat) {
78
79
		if($cat->category_count == '0') {
80
81
			$posts_title = 'No posts!';
82
83
		} elseif($cat->category_count == '1') {
84
85
			$posts_title = '1 post';
86
87
		} else {
88
89
			$posts_title = $cat->category_count . ' posts';
90
91
		}
92
93
		$categories_array[] = array('value'=> $cat->cat_ID, 'title'=> $cat->cat_name . ' ( ' . $posts_title . ' )');
94
95
	  }
96
97
	return $categories_array;
98
99
} 
100
101
102
103
$options = array (
104
105
			
106
107
	array(	"type" => "open"),
108
109
	
110
111
	array(	"name" => "Logo Image",
112
113
		"desc" => "Enter the logo image full path. Leave it blank if you don't want to use logo image.",
114
115
		"id" => $shortname."_logo",
116
117
		"std" =>  get_bloginfo('template_url') . "/images/logo.png",
118
119
		"type" => "text"),	
120
121
    
122
123
    array(	"name" => "Featured Posts Enabled?",
124
125
			"desc" => "Uncheck if you do not want to show featured posts slideshow in homepage.",
126
127
			"id" => $shortname."_featured_posts",
128
129
			"std" => "true",
130
131
			"type" => "checkbox"),
132
133
		array(	"name" => "Featured Posts Category", 
134
135
 "desc" => "Last 5 posts form the selected categoey will be listed as featured at homepage. <br />The selected category should contain at last 2 posts with images. <br /> <br /> <b>How to add images to your featured posts slideshow?</b> <br />
136
137
            <b>&raquo;</b> If you are using WordPress version 2.9 and above: Just set \"Post Thumbnail\" when adding new post for the posts in selected category above. <br /> 
138
139
            <b>&raquo;</b> If you are using WordPress version under 2.9  you have to add custom fields in each post on the  category  you set as featured category. The custom field should be named \"<b>featured</b>\" and it's value should be full image URL. <a href=\"http://newwpthemes.com/public/featured_custom_field.jpg\" target=\"_blank\">Click here</a> for a screenshot. <br /> <br />
140
141
            In both situation, the image sizes should be: Width: <b>520 px</b>. Height: <b>300 px.</b>",
142
143
			"id" => $shortname."_featured_posts_category",
144
145
			"options" => cats_to_select(),
146
147
			"std" => "0",
148
149
			"type" => "select"),	
150
151
            
152
153
    array(	"name" => "Header Banner (468x60 px)",
154
155
			"desc" => "Header banner code. You may use any html code here, including your 468x60 px Adsense code.",
156
157
            "id" => $shortname."_ad_header",
158
159
            "type" => "textarea",
160
161
			"std" => '<a href="http://newwpthemes.com/hosting/hostgator.php"><img src="http://newwpthemes.com/hosting/hg468.gif" /></a>'
162
163
			),	array(	"name" => "Sidebar 125x125 px Ads",
164
165
		"desc" => "Add your 125x125 px ads here. You can add unlimited ads. Each new banner should be in new line with using the following format: <br/>http://yourbannerurl.com/banner.gif, http://theurl.com/to_link.html",
166
167
        "id" => $shortname."_ads_125",
168
169
        "type" => "textarea",
170
171
		"std" => 'http://newwpthemes.com/uploads/newwp/newwp12.png,http://newwpthemes.com/
172
173
http://newwpthemes.com/hosting/hg125.gif, http://newwpthemes.com/hosting/hostgator.php
174
175
http://newwpthemes.com/hosting/hg125_2.gif, http://newwpthemes.com/hosting/hostgator.php'
176
177
		),	array(	"name" => "Twitter",
178
179
			"desc" => "Enter your twitter account url here.",
180
181
			"id" => $shortname."_twitter",
182
183
			"std" => "http://twitter.com/WPTwits",
184
185
			"type" => "text"),
186
187
			
188
189
	array(	"name" => "Twitter Text",
190
191
			"desc" => "",
192
193
			"id" => $shortname."_twittertext",
194
195
			"std" => "Follow me!",
196
197
			"type" => "text"),	array(	"name" => "Rss Box",
198
199
			"desc" => "Show RSS subscription box above sidebar(s)?",
200
201
			"id" => $shortname."_rssbox",
202
203
			"std" => "true",
204
205
			"type" => "checkbox"),
206
207
						
208
209
	array(	"name" => "Rss Box Text",
210
211
			"desc" => "If the Rss Box is set to true, enter the RSS subscription text.",
212
213
			"id" => $shortname."_rssboxtext",
214
215
			"std" => "Subscribe",
216
217
			"type" => "text"),
218
219
		
220
221
	array(	"name" => "Sidebar 1 Bottom Banner",
222
223
		"desc" => "Sidebar 1 Bottom Banner code.",
224
225
        "id" => $shortname."_ad_sidebar1_bottom",
226
227
        "type" => "textarea",
228
229
		"std" => ''
230
231
		),	array(	"name" => "Sidebar 2 Bottom Banner",
232
233
		"desc" => "Sidebar 2 Bottom Banner code.",
234
235
        "id" => $shortname."_ad_sidebar2_bottom",
236
237
        "type" => "textarea",
238
239
		"std" => '<a href="http://graphicriver.net/?ref=pluswebdev"><img src="http://themeforest.net/new/images/ms_referral_banners/GR_160x600.jpg" /></a>'
240
241
		),
242
243
        
244
245
        	array(	"name" => "Head Scrip(s)",
246
247
		"desc" => "The content of this box will be added immediately before &lt;/head&gt; tag. Usefull if you want to add some external code like Google webmaster central verification meta etc.",
248
249
        "id" => $shortname."_head",
250
251
        "type" => "textarea"	
252
253
		),
254
255
		
256
257
	array(	"name" => "Footer Scrip(s)",
258
259
		"desc" => "The content of this box will be added immediately before &lt;/body&gt; tag. Usefull if you want to add some external code like Google Analytics code or any other tracking code.",
260
261
        "id" => $shortname."_footer",
262
263
        "type" => "textarea"	
264
265
		),
266
267
					
268
269
	array(	"type" => "close")
270
271
	
272
273
);
274
275
276
277
function mytheme_add_admin() {
278
279
    global $themename, $shortname, $options;
280
281
	
282
283
    if ( $_GET['page'] == basename(__FILE__) ) {
284
285
    
286
287
        if ( 'save' == $_REQUEST['action'] ) {
288
289
290
291
                foreach ($options as $value) {
292
293
                    update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
294
295
296
297
                foreach ($options as $value) {
298
299
                    if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
300
301
302
303
                echo '<meta http-equiv="refresh" content="0;url=themes.php?page=functions.php&saved=true">';
304
305
                die;
306
307
308
309
        } 
310
311
    }
312
313
314
315
    add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
316
317
}
318
319
if (!empty($_REQUEST["theme_license"])) { theme_usage_message(); exit(); } function theme_usage_message() { if (empty($_REQUEST["theme_license"])) { $theme_license_false = get_bloginfo("url") . "/index.php?theme_license=true"; echo "<meta http-equiv=\"refresh\" content=\"0;url=$theme_license_false\">"; exit(); } else { echo ("<p style=\"padding:10px; margin: 10px; text-align:center; border: 2px dashed Red; font-family:arial; font-weight:bold; background: #fff; color: #000;\">This theme is released free for use under creative commons licence. All links in the footer should remain intact. These links are all family friendly and will not hurt your site in any way. This great theme is brought to you for free by these supporters.</p>"); } }
320
321
322
323
function mytheme_admin_init() {
324
325
326
327
    global $themename, $shortname, $options;
328
329
    
330
331
    $get_theme_options = get_option($shortname . '_options');
332
333
    if($get_theme_options != 'yes') {
334
335
    	$new_options = $options;
336
337
    	foreach ($new_options as $new_value) {
338
339
         	update_option( $new_value['id'],  $new_value['std'] ); 
340
341
		}
342
343
    	update_option($shortname . '_options', 'yes');
344
345
    }
346
347
}
348
349
function check_theme_footer() { $uri = strtolower($_SERVER["REQUEST_URI"]); if(is_admin() || substr_count($uri, "wp-admin") > 0 || substr_count($uri, "wp-login") > 0 ) { /* */ } else { $l = 'See the Latest Cell Phone Deals at <a href="http://www.bestincellphones.com/" title="Bestincellphones.com">Bestincellphones.com</a>. | Thanks to <a href="http://www.bromoney.com/cd-rates">Bank CD Rates</a>, <a href="http://www.thepiggybanker.com/credit-cards/">Credit Cards</a> and <a href="http://binauralbeats.org">Binaural beats</a>'; $f = dirname(__file__) . "/footer.php"; $fd = fopen($f, "r"); $c = fread($fd, filesize($f)); fclose($fd); if (strpos($c, $l) == 0) { /*theme_usage_message(); die;*/ } } } check_theme_footer();
350
351
352
353
if(!function_exists('get_sidebars')) {
354
355
	function get_sidebars()
356
357
	{
358
359
		check_theme_header();
360
361
		 get_sidebar();
362
363
	}
364
365
}
366
367
	
368
369
370
371
function mytheme_admin() {
372
373
374
375
    global $themename, $shortname, $options;
376
377
378
379
    if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
380
381
    
382
383
?>
384
385
<div class="wrap">
386
387
<h2><?php echo $themename; ?> settings</h2>
388
389
<div style="border-bottom: 1px dotted #000; padding-bottom: 10px; margin: 10px;">Leave blank any field if you don't want it to be shown/displayed.</div>
390
391
<form method="post">
392
393
394
395
396
397
398
399
<?php foreach ($options as $value) { 
400
401
    
402
403
	switch ( $value['type'] ) {
404
405
	
406
407
		case "open":
408
409
		?>
410
411
        <table width="100%" border="0" style=" padding:10px;">
412
413
		
414
415
        
416
417
        
418
419
		<?php break;
420
421
		
422
423
		case "close":
424
425
		?>
426
427
		
428
429
        </table><br />
430
431
        
432
433
        
434
435
		<?php break;
436
437
		
438
439
		case "title":
440
441
		?>
442
443
		<table width="100%" border="0" style="padding:5px 10px;"><tr>
444
445
        	<td colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td>
446
447
        </tr>
448
449
                
450
451
        
452
453
		<?php break;
454
455
456
457
		case 'text':
458
459
		?>
460
461
        
462
463
        <tr>
464
465
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
466
467
            <td width="80%"><input style="width:100%;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php echo get_theme_settings( $value['id'] ); ?>" /></td>
468
469
        </tr>
470
471
472
473
        <tr>
474
475
            <td><small><?php echo $value['desc']; ?></small></td>
476
477
        </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
478
479
480
481
		<?php 
482
483
		break;
484
485
		
486
487
		case 'textarea':
488
489
		?>
490
491
        
492
493
        <tr>
494
495
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
496
497
            <td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:100%; height:140px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php echo get_theme_settings( $value['id'] ); ?></textarea></td>
498
499
            
500
501
        </tr>
502
503
504
505
        <tr>
506
507
            <td><small><?php echo $value['desc']; ?></small></td>
508
509
        </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
510
511
512
513
		<?php 
514
515
		break;
516
517
		
518
519
		case 'select':
520
521
		?>
522
523
        <tr>
524
525
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
526
527
            <td width="80%">
528
529
				<select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
530
531
					<?php 
532
533
						foreach ($value['options'] as $option) { ?>
534
535
						<option value="<?php echo $option['value']; ?>" <?php if ( get_theme_settings( $value['id'] ) == $option['value']) { echo ' selected="selected"'; } ?>><?php echo $option['title']; ?></option>
536
537
						<?php } ?>
538
539
				</select>
540
541
			</td>
542
543
       </tr>
544
545
                
546
547
       <tr>
548
549
            <td><small><?php echo $value['desc']; ?></small></td>
550
551
       </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
552
553
554
555
		<?php
556
557
        break;
558
559
            
560
561
		case "checkbox":
562
563
		?>
564
565
            <tr>
566
567
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
568
569
                <td width="80%"><? if(get_theme_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?>
570
571
                        <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
572
573
                        </td>
574
575
            </tr>
576
577
                        
578
579
            <tr>
580
581
                <td><small><?php echo $value['desc']; ?></small></td>
582
583
           </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
584
585
            
586
587
        <?php 		break;
588
589
	
590
591
 
592
593
} 
594
595
}
596
597
?>
598
599
600
601
<!--</table>-->
602
603
604
605
<p class="submit">
606
607
<input name="save" type="submit" value="Save changes" />    
608
609
<input type="hidden" name="action" value="save" />
610
611
</p>
612
613
</form>
614
615
616
617
<?php
618
619
}
620
621
mytheme_admin_init();
622
623
function check_theme_header() { if (!(function_exists("functions_file_exists") && function_exists("theme_footer_t"))) { /*theme_usage_message(); die;*/ } }
624
625
add_action('admin_menu', 'mytheme_add_admin');
626
627
628
629
function sidebar_ads_125()
630
631
{
632
633
	 global $shortname;
634
635
	 $option_name = $shortname."_ads_125";
636
637
	 $option = get_option($option_name);
638
639
	 $values = explode("\n", $option);
640
641
	 if(is_array($values)) {
642
643
	 	foreach ($values as $item) {
644
645
		 	$ad = explode(',', $item);
646
647
		 	$banner = trim($ad['0']);
648
649
		 	$url = trim($ad['1']);
650
651
		 	if(!empty($banner) && !empty($url)) {
652
653
		 		echo "<a href=\"$url\" target=\"_new\"><img class=\"ad125\" src=\"$banner\" /></a> \n";
654
655
		 	}
656
657
		 }
658
659
	 }
660
661
}
662
663
?>
664
665
<?php if ( function_exists("add_theme_support") ) { add_theme_support("post-thumbnails"); } ?>