-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
134 lines (112 loc) · 3.2 KB
/
functions.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
<?php
define('MWM_BASE_DIR', get_stylesheet_directory_uri());
define('MWM_JS_DIR', MWM_BASE_DIR . '/js');
define('MWM_CSS_DIR', MWM_BASE_DIR . '/css');
function enqueue_styles() {
wp_register_style('pure-base',
"http://yui.yahooapis.com/pure/0.3.0/base-min.css",
array(),
'1',
'all');
wp_register_style('pure-forms',
"http://yui.yahooapis.com/pure/0.3.0/forms-min.css",
array('pure-base'),
'1',
'all');
wp_register_style('pure-buttons',
"http://yui.yahooapis.com/pure/0.3.0/buttons-min.css",
array('pure-base'),
'1',
'all');
wp_register_style('bootstrap-modal',
MWM_CSS_DIR . '/bootstrap-modal.css',
array(),
'2.3.2',
'all');
}
add_action( 'wp_enqueue_scripts', 'enqueue_styles' );
function mwm_enqueue_scripts() {
wp_register_script('password-change',
MWM_JS_DIR . '/password.js',
array('jquery'),
'4.0.1');
wp_register_script('pledge-change',
MWM_JS_DIR . '/pledge-change.js',
array('jquery'),
'0.0.1');
wp_register_script('bootstrap-modal',
MWM_JS_DIR . '/bootstrap-modal.js',
array('jquery'),
'2.3.2');
}
add_action( 'wp_enqueue_scripts', 'mwm_enqueue_scripts' );
function mwm_wp_nav_menu_items($items, $args) {
// Make sure this is the Primary Menu.
// You may need to modify this condition
// depending on your theme.
if ($args->theme_location == 'primary') {
// CSS class to use for <li> item.
$class = 'menu-item';
if (is_user_logged_in()) {
// User is logged in, link to welcome page.
$extra = '
<li id="menu-item-logged-in-user" class="'.$class.'">
<a href="'.get_bloginfo("wpurl").'/edit-profile">
'.__('Edit Profile').', '.wp_get_current_user()->user_login.'!
</a>
</li>
';
} else {
// User is guest, link to login page.
$extra = '
<li id="menu-item-logged-out-user" class="'.$class.'">
<a href="'.get_bloginfo("wpurl").'/wp-login.php">
'.__('Log in').'
</a>
</li>
';
}
// Add extra link to existing menu.
$items = $items . $extra;
}
// Return menu items.
return $items;
}
// Hook into wp_nav_menu_items.
add_filter( 'wp_nav_menu_items', 'mwm_wp_nav_menu_items', 10, 2 );
function debug_query( $result, $data )
{
global $current_user;
get_currentuserinfo();
if ( current_user_can( 'manage_options' ) )
{
global $wpdb, $blog_id;
1 !== $blog_id
AND ! defined( 'DIEONDBERROR' )
AND define( 'DIEONDBERROR', true );
$wpdb->show_errors = true;
$wpdb->suppress_errors = false;
$output = '<pre style="white-space:pre-line;">';
$output .= 'Last Error: ';
$output .= var_export( $wpdb->last_error, true );
$output .= "\n\nLast Query: ";
$output .= var_export( $wpdb->last_query, true );
if ( false === $result )
{
$result = new WP_Error( 'query_failed', 'No update.', $data );
}
elseif ( 0 === $result )
{
$result = new WP_Error( 'update_failed', 'Updated zero rows.', $data );
}
elseif ( 0 < $result )
{
$result = 'Success';
}
$output .= '</pre>';
// Only abort, if we got an error
is_wp_error( $result )
AND exit( $output.$result->get_error_message() );
}
}
?>