';
if ( $post->post_status == 'trash' ) {
echo '
' . __( 'Restore' ) . ' | ';
echo "
" . __( 'Delete Permanently' ) . "";
?>
post_status == 'publish' ) {
echo '
Spam';
echo ' | ';
echo '
';
echo '' . __( 'Trash' ) . '';
?>
post_status == 'spam' ) {
echo '
Not Spam';
echo ' | ';
echo "
" . __( 'Delete Permanently' ) . "";
?>
$field ) {
# need to dig deeper on select field options
if ( preg_match( "|^(.*)\-select$|", $field_id ) ) {
foreach ( (array) $field['options'] as $opt_i => $opt ) {
$contact_form_fields[$field_id]['options'][$opt_i] = html_entity_decode( $opt );
}
}
$contact_form_fields[$field_id]['label'] = html_entity_decode( $contact_form_fields[$field_id]['label'] );
$contact_form_fields[$field_id]['label'] = wp_kses( $contact_form_fields[$field_id]['label'], array() );
}
$out = array( 'fields' => $contact_form_fields, 'to' => $grunion_form->to, 'subject' => $grunion_form->subject );
die( json_encode( $out ) );
}
}
die( '' );
}
die( -1 );
}
add_action( 'wp_ajax_grunion_shortcode', 'grunion_ajax_shortcode' );
add_action( 'wp_ajax_grunion_shortcode_to_json', 'grunion_ajax_shortcode_to_json' );
// process row-action spam/not spam clicks
add_action( 'wp_ajax_grunion_ajax_spam', 'grunion_ajax_spam' );
function grunion_ajax_spam() {
global $wpdb;
if ( empty( $_POST['make_it'] ) )
return;
$post_id = (int) $_POST['post_id'];
check_ajax_referer( 'grunion-post-status-' . $post_id );
if ( !current_user_can("edit_page", $post_id) )
wp_die( __( 'You are not allowed to manage this item.' ) );
require_once dirname( __FILE__ ) . '/grunion-contact-form.php';
$current_menu = '';
if ( preg_match( '|post_type=feedback|', $_POST['sub_menu'] ) ) {
if ( preg_match( '|post_status=spam|', $_POST['sub_menu'] ) )
$current_menu = 'spam';
else if ( preg_match( '|post_status=trash|', $_POST['sub_menu'] ) )
$current_menu = 'trash';
else
$current_menu = 'messages';
}
$post = get_post( $post_id );
$post_type_object = get_post_type_object( $post->post_type );
$akismet_values = get_post_meta( $post_id, '_feedback_akismet_values', TRUE );
if ( $_POST['make_it'] == 'spam' ) {
$post->post_status = 'spam';
$status = wp_insert_post( $post );
wp_transition_post_status( 'spam', 'publish', $post );
do_action( 'contact_form_akismet', 'spam', $akismet_values );
} elseif ( $_POST['make_it'] == 'ham' ) {
$post->post_status = 'publish';
$status = wp_insert_post( $post );
wp_transition_post_status( 'publish', 'spam', $post );
do_action( 'contact_form_akismet', 'spam', $akismet_values );
// resend the original email
$email = get_post_meta( $post_id, '_feedback_email', TRUE );
wp_mail( $email['to'], $email['subject'], $email['message'], $email['headers'] );
} elseif( $_POST['make_it'] == 'publish' ) {
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
wp_die( __('You are not allowed to move this item out of the Trash.') );
if ( ! wp_untrash_post($post_id) )
wp_die( __('Error in restoring from Trash.') );
} elseif( $_POST['make_it'] == 'trash' ) {
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
wp_die( __('You are not allowed to move this item to the Trash.') );
if ( ! wp_trash_post($post_id) )
wp_die( __('Error in moving to Trash.') );
}
$sql = "
SELECT post_status,
COUNT( * ) AS post_count
FROM `{$wpdb->posts}`
WHERE post_type = 'feedback'
GROUP BY post_status
";
$status_count = (array) $wpdb->get_results( $sql, ARRAY_A );
$status = array();
$status_html = '';
foreach ( $status_count as $i => $row ) {
$status[$row['post_status']] = $row['post_count'];
}
if ( isset( $status['publish'] ) ) {
$status_html .= '
';
$status_html .= '(' . number_format( $status['publish'] ) . ')';
$status_html .= ' |';
}
if ( isset( $status['trash'] ) ) {
$status_html .= '
';
$status_html .= '(' . number_format( $status['trash'] ) . ')';
$status_html .= '';
if ( isset( $status['spam'] ) )
$status_html .= ' |';
$status_html .= '';
}
if ( isset( $status['spam'] ) ) {
$status_html .= '
';
$status_html .= '(' . number_format( $status['spam'] ) . ')';
$status_html .= '';
}
echo $status_html;
exit;
}