javascript - Wordpress - Thumbs Up/Down plugin doesn't show on new ajax post -
i'm using wordpress , i'm newbie.
i have wordpress template has front-end entry maker. i'm newbie i'm sure using ajax update post list after publishing new post.
i have rating system (plugin) allows members up/down vote entries. problem is, up/down vote (including number) doesn't show on new published entry, after reloaded browser show. think it's ajax system, unfortunately i'm newbie on php , ajax, , think quite complicated problem.
what i've tried: finding method create up/down vote buttons, , think found it. , want call method in ajax system, have no idea.
here ajax create post codes i've found far:
/* * create post. */ static function new_post() { global $user_id; if ( empty( $_post['action'] ) || $_post['action'] != 'new_post' ) { die( '-1' ); } if ( !is_user_logged_in() ) { die( '<p>'.__( 'error: not logged in.', 'p2' ).'</p>' ); } if ( ! ( current_user_can( 'publish_posts' ) || (get_option( 'p2_allow_users_publish' ) && $user_id )) ) { die( '<p>'.__( 'error: not allowed post.', 'p2' ).'</p>' ); } check_ajax_referer( 'ajaxnonce', '_ajax_post' ); $user = wp_get_current_user(); $user_id = $user->id; $post_content = $_post['posttext']; $tags = trim( $_post['tags'] ); $title = $_post['post_title']; $post_type = isset( $_post['post_type'] ) ? $_post['post_type'] : 'post'; // strip placeholder text tags if ( __( 'tag it', 'p2' ) == $tags ) $tags = ''; // empty or placeholder text, create nice title based on content if ( empty( $title ) || __( 'post title', 'p2' ) == $title ) $post_title = p2_title_from_content( $post_content ); else $post_title = $title; $post_format = 'status'; $accepted_post_formats = apply_filters( 'p2_accepted_post_cats', p2_get_supported_post_formats() ); // keep 'p2_accepted_post_cats' filter compat (since p2 1.3.4) if ( in_array( $_post['post_format'], $accepted_post_formats ) ) $post_format = $_post['post_format']; // add quote citation content if exists if ( ! empty( $_post['post_citation'] ) && 'quote' == $post_format ) $post_content = '<p>' . $post_content . '</p><cite>' . $_post['post_citation'] . '</cite>'; $post_id = wp_insert_post( array( 'post_author' => $user_id, 'post_title' => $post_title, 'post_content' => $post_content, 'post_type' => 'post', 'tags_input' => $tags, 'post_status' => 'publish' ) ); if ( empty( $post_id ) ) echo '0'; set_post_format( $post_id, $post_format ); rating-system(); echo $post_id; } and rating system, contains lot of codes can't understand lot. maybe can check directly on link.
once again, i'm sorry if complicated (for self, maybe it's easier you). time reading question, , it's nice if want me. again :)
Comments
Post a Comment