-
Notifications
You must be signed in to change notification settings - Fork 1
/
post-publish.php
56 lines (42 loc) · 1.51 KB
/
post-publish.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
<?php
// YOU DON'T NEED TO EDIT THIS PAGE
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'post' ) {
if ( ! is_user_logged_in() )
auth_redirect();
if( !current_user_can( 'publish_posts' ) ) {
wp_redirect( get_bloginfo( 'url' ) . '/' );
exit;
}
check_admin_referer( 'new-post' ); // This executes the post form. Status = open by default
$abierto = get_option('bach_open');
$open = get_cat_id($abierto);
$user_id = $current_user->user_id;
$post_content = $_POST['posttext'];
$tags = $_POST['tags'];
$post_title = strip_tags($_POST['postTitle']);
$prioridad = $_POST['prioridad'];
$proyecto = $_POST['proyecto'];
$usuario = $_POST['usuario'];
$post_category = array($prioridad,$proyecto,$usuario,$open);
global $wpdb;
$proyecto_nombre = $wpdb->get_var("SELECT name FROM $wpdb->terms WHERE term_id = '$proyecto'");
$title = $post_title . ' ('. $proyecto_nombre . ')';
// if no category was selected, unset it & default will be used // Code for Bach 1.1
/* if ($post_category == '-1') {
unset($post_category);
} elseif ( isset($post_category) ) {
$post_category = array($post_category);
}
*/
$post_id = wp_insert_post( array( // Inserts the post with our options
'post_author' => $user_id,
'post_title' => $title,
'post_content' => $post_content,
'post_category' => $post_category,
'tags_input' => $tags,
'post_status' => 'publish'
) );
wp_redirect( get_bloginfo( 'url' ) . '/' );
exit;
}
?>