forked from HacemosCodigo/base-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
executable file
·166 lines (104 loc) · 3.52 KB
/
Copy pathfunctions.php
File metadata and controls
executable file
·166 lines (104 loc) · 3.52 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
<?php
/*------------------------------------*\
#CONSTANTS
\*------------------------------------*/
/**
* Define paths to javascript, styles, theme and site.
**/
define( 'JSPATH', get_template_directory_uri() . '/js/' );
define( 'CSSPATH', get_template_directory_uri() . '/css/' );
define( 'THEMEPATH', get_template_directory_uri() . '/' );
define( 'SITEURL', site_url('/') );
/*------------------------------------*\
#INCLUDES
\*------------------------------------*/
require_once('inc/post-types.php');
require_once('inc/metaboxes.php');
require_once('inc/taxonomies.php');
require_once('inc/pages.php');
require_once('inc/users.php');
require_once('inc/functions-admin.php');
require_once('inc/functions-js-footer.php');
include 'inc/extra-metaboxes.php';
/*------------------------------------*\
#GENERAL FUNCTIONS
\*------------------------------------*/
/**
* Enqueue frontend scripts and styles
**/
add_action( 'wp_enqueue_scripts', function(){
// scripts
wp_enqueue_script( 'plugins', JSPATH.'plugins.js', array('jquery'), '1.0', true );
wp_enqueue_script( 'functions', JSPATH.'functions.js', array('plugins'), '1.0', true );
// localize scripts
wp_localize_script( 'functions', 'ajax_url', admin_url('admin-ajax.php') );
wp_localize_script( 'functions', 'site_url', site_url() );
wp_localize_script( 'functions', 'theme_url', THEMEPATH );
// styles
wp_enqueue_style( 'styles', get_stylesheet_uri() );
});
/**
* Add javascript to the footer of pages.
**/
add_action( 'wp_footer', 'footer_scripts', 21 );
/*------------------------------------*\
#HELPER FUNCTIONS
\*------------------------------------*/
/**
* Print the title tag based on what is being viewed.
* @return string
*/
function print_title(){
global $page, $paged;
wp_title( '|', true, 'right' );
bloginfo( 'name' );
// Add a page number if necessary
if ( $paged >= 2 || $page >= 2 ){
echo ' | ' . sprintf( __( 'Página %s' ), max( $paged, $page ) );
}
}// print_title
/*------------------------------------*\
#FORMAT FUNCTIONS
\*------------------------------------*/
/*------------------------------------*\
#SET/GET FUNCTIONS
\*------------------------------------*/
/*------------------------------------*\
#AJAX FUNCTIONS
\*------------------------------------*/
/**
* Send contact email to PMI.
*/
function send_email_contacto(){
$name = $_POST['name'];
$email = $_POST['email'];
$to_email = get_contact_email();
$msg = $_POST['message'];
$to = $to_email;
$subject = $name . ' te ha contactado a través de www.pmi.com.mx: ';
$headers = 'From: My Name <' . $to_email . '>' . "\r\n";
$message = '<html><body>';
$message .= '<h3>Datos de contacto</h3>';
$message .= '<p>Nombre: '.$name.'</p>';
$message .= '<p>Email: '. $email . '</p>';
if( $msg != '' ) $message .= '<p>Mensaje: '. $msg . '</p>';
$message .= '</body></html>';
add_filter('wp_mail_content_type',create_function('', 'return "text/html"; '));
$mail = wp_mail($to, $subject, $message, $headers );
if( ! $mail ) {
$message = array(
'error' => 1,
'message' => 'No se pudo enviar el correo.',
);
echo json_encode($message , JSON_FORCE_OBJECT);
exit;
}
$message = array(
'error' => 0,
'message' => 'Gracias por tu mensaje ' . $name . '. En breve nos pondremos en contacto contigo.',
);
echo json_encode($message , JSON_FORCE_OBJECT);
exit();
}// send_email_contacto
add_action("wp_ajax_send_email_contacto", "send_email_contacto");
add_action("wp_ajax_nopriv_send_email_contacto", "send_email_contacto");