-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
334 lines (283 loc) · 8.62 KB
/
Copy pathfunctions.php
File metadata and controls
334 lines (283 loc) · 8.62 KB
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<?php
//let's be a fucking boss
require_once('hooks.php');
require_once('filters.php');
require_once('boss/boss.php');
add_theme_support( 'post-thumbnails' );
add_image_size( 'square_thumb', 300, 300, true );
wp_register_script(
'jquery.tools',
get_bloginfo('stylesheet_directory').'/js/jquery.tools.min.js',
array('jquery'),
'1.2.6',
true
);
wp_register_script(
'jquery.easing',
get_bloginfo('stylesheet_directory').'/js/jquery.easing.js',
array('jquery'),
'0.1',
true
);
wp_register_script(
'jquery.validate',
'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js',
array('jQuery'),
'1.9',
true
);
wp_register_script(
'jquery.placeholder',
get_bloginfo('stylesheet_directory').'/js/jquery.placeholder.1.2.min.js',
array('jquery'),
'0.1',
true
);
wp_register_script(
'jquery.waitforimages',
get_bloginfo('stylesheet_directory').'/js/jquery.waitforimages.js',
array('jquery'),
'0.1',
true
);
wp_register_script(
'jquery.onedayoneapp',
get_bloginfo('stylesheet_directory').'/js/jquery.onedayoneapp.js',
array('jquery', 'jquery.tools'),
'0.1',
true
);
wp_enqueue_script('jquery.tools');
wp_enqueue_script('jquery.easing');
wp_enqueue_script('jquery.validate');
wp_enqueue_script('jquery.placeholder');
wp_enqueue_script('jquery.waitforimages');
wp_enqueue_script('jquery.onedayoneapp');
function pr($array){
echo '<pre>';
print_r($array);
echo '</pre>';
}
function array_empty($mixed) {
if (is_array($mixed)) {
foreach ($mixed as $value) {
if (!array_empty($value)) {
return false;
}
}
}
elseif (!empty($mixed)) {
return false;
}
return true;
}
add_action('admin_print_styles', 'style_like_a_boss');
register_sidebar(array(
'id' => 'jobsbar',
'name' => 'Jobs Sidebar',
'description' => __( 'Sidebar for the jobs board page.' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
));
function style_like_a_boss(){
echo '<link rel="stylesheet" href="'.get_bloginfo('stylesheet_directory').'/boss/admin.css" type="text/css" media="screen">';
}
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
}
register_nav_menus(array('Serious Menu'));
function wake_up_call(){
if($_REQUEST['wake_up']['email']){
$name = $_REQUEST['wake_up']['name'];
$headers = "From: ".$_REQUEST['wake_up']['email'];
$message = "
Hey, ".$name." has sent you a wakeup message from the depths of onedayoneapp.com. Reply to this email to get back to them.
".$_REQUEST['wake_up']['message']."
";
$sent = mail(
'narang.rohan@gmail.com',
'New message from '.$name,
$message,
$headers
);
if($sent){
boss_popup_message('Thanks for sending your message! We\'ll get back to you soon.');
}
}
}
function do_the_contact_form(){
//pr($_REQUEST);
$contact_type = $_REQUEST['contact_type'];
//$fields = explode(', ', $fields);
if($contact_type == 'app'){
echo $_REQUEST['contact_vars']['category'];
$post = array(
'post_author' => 3, //The user ID number of the author.
'post_content' => '<h2>App Category: '.$_REQUEST['contact_vars']['category'].'<h2>'.$_REQUEST['contact_vars']['contact_message'],
'post_name' => sanitize_title($_REQUEST['contact_vars']['app_name']), // The name (slug) for your post
'post_status' => 'pending', //Set the status of the new post.
'post_title' => $_REQUEST['contact_vars']['app_name'], //The title of your post.
'post_type' => $_REQUEST['contact_vars']['app_type'],
);
$type = $_REQUEST['contact_vars']['category'];
wp_set_post_terms($post, $_REQUEST['contact_vars']['category'], $_REQUEST['contact_vars']['app_type'].'-app-category',false);
$success = wp_insert_post($post);
$admin_email = 'narang.rohan@gmail.com';
if($success){
add_post_meta($success, 'price-of-app', $_REQUEST['contact_vars']['price']);
add_post_meta($success, 'app-developer', $_REQUEST['contact_vars']['developer_name']);
add_post_meta($success, 'app-developer-link', $_REQUEST['contact_vars']['developer_link']);
add_post_meta($success, 'appstore-link', $_REQUEST['contact_vars']['app_store_link']);
$message = '
Hey Dude!
'.$_REQUEST['contact_vars']['your_name'].' has submitted an iPad app to the website, so you should go check it out. It\'s currently in pending mode, so awaiting your confirmation and upload of screenshots. You should get to it.
'.get_edit_post_link($success).'
Here\'s a lowdown though:
Name: '.$_REQUEST['contact_vars']['app_name'].'
Developer: '.$_REQUEST['contact_vars']['developer_name'].
$_REQUEST['contact_vars']['developer_link'].'
Description: '.$_REQUEST['contact_vars']['contact_message'];
$headers = "From: ".$_REQUEST['contact_vars']['your_email'];
$mail_sent = mail(
$admin_email,
"There has been a new ipad app submission at onedayoneapp.com",
$message,
$headers
);
if($mail_sent){
boss_popup_message('Thanks for the App! We will review it, and let you know the outcome!');
}
}
} elseif($contact_type == 'message') {
$message = '
Reply to this email to reply to their message.
'.$_REQUEST['contact_vars']['contact_message'];
$headers = "From: ".$_REQUEST['contact_vars']['your_email'];
$mail_sent = mail(
$admin_email,
$_REQUEST['contact_vars']['your_name']." has sent you a message from onedayoneapp.com",
$message,
$headers
);
if($mail_sent){
boss_popup_message('Thanks for enquiring. We\'ll get back to you soon.');
}
}
}
function boss_popup_message($message){
?>
<div class="popup-wrapper">
<style type="text/css">
.popup-message{
}
</style>
<script type="text/javascript">
jQuery(function(){
var w1 = jQuery(window).width();
var w2 = jQuery('.popup-message').width();
var h1 = jQuery(window).height();
var h2 = jQuery('.popup-message').height();
var mathL = w1 / 2 - w2 / 2 - 30;
var mathT = h1 / 2 - h2 / 2 - 30;
jQuery('.popup-message').css({top: mathT, left: mathL, display: 'block'})
.hide()
.delay(1000)
.fadeIn(500)
.delay(4000)
.fadeOut(500);
});
</script>
<div class="popup-message">
<p><?php echo $message; ?></p>
</div>
</div>
<?php
}
$post_types = array('ipad-app', 'iphone-app', 'mac-app');
$registered_images = array(
'Screenshot #1',
'Screenshot #2',
'Screenshot #3',
'Screenshot #4',
'Screenshot #5',
'Screenshot #6',
'Screenshot #7',
);
if(class_exists('MultiPostThumbnails')){
foreach($registered_images as $name) :
foreach($post_types as $type) :
new MultiPostThumbnails(
array(
'label' => $name,
'id' => sanitize_title($name),
'post_type' => $type
)
);
endforeach;
endforeach;
}
function add_tags_to_post_types(){
$post_types = array('ipad-app', 'iphone-app', 'mac-app');
foreach($post_types as $type){
$args = array(
'label' => ucwords(str_replace('-', ' ', $type)).' Tags',
'show_tagcloud' => true,
'rewrite' => 'slug',
);
register_taxonomy($type.'-tags', $type, $args);
}
}
function is_singular_app(){
if(is_singular('ipad-app') || is_singular('iphone-app') || is_singular('mac-app')){
return true;
} else {
return false;
}
}
function is_app_home(){
if(is_page(array('ipad-apps', 'iphone-apps', 'mac-apps', 'iPad', 'iPhone', 'Mac'))){
return true;
} else {
return false;
}
}
function them_archives(){
$obj = get_queried_object();
//pr($obj);
$tax = $obj->taxonomy;
$device = explode('-', $tax);
$device = $device[0];
echo '<div id="header-archives-inner">';
global $wpdb;
$year_prev = null;
$months = $wpdb->get_results( "SELECT DISTINCT MONTH( post_date ) AS month ,
YEAR( post_date ) AS year,
COUNT( id ) as post_count FROM $wpdb->posts
WHERE post_status = 'publish' and post_date <= now( )
and post_type = '$device-app'
GROUP BY month , year
ORDER BY post_date DESC");
foreach($months as $month) :
$year_current = $month->year;
if ($year_current != $year_prev){
if ($year_prev != null){?>
</ul>
</div>
<?php } ?>
<div class="yor">
<h3><?php echo $month->year; ?></h3>
<ul class="archive-list">
<?php } ?>
<li>
<?php //pr($month); ?>
<a href="<?php bloginfo('url') ?>/<?php echo $device; ?>-app/<?php echo $month->year; ?>/<?php echo date("m", mktime(0, 0, 0, $month->month, 1, $month->year)) ?>">
<span class="archive-month"><?php echo date("F", mktime(0, 0, 0, $month->month, 1, $month->year)) ?></span>
<span class="archive-count"></span>
</a>
</li>
<?php $year_prev = $year_current;
endforeach; ?>
</div>
<?php }