';
}
/************************************************************************************/
/* AWTW Styling CSS */
/************************************************************************************/
/**
* Admin panel CSS
*
* @version 1.0
* @since AWTW 1.0
* @author Ritesh Sanap
*
* @return string
*/
function awtw_table_style() { ?>
*
* @return none
*/
function awtw_ajax() {
$action = $_POST['actions'];
$id = $_POST['id'];
switch ($action) {
case 'mark_spam':
// send as Spam
Awtw_Akismet::submit($id, 'spam');
break;
case 'mark_approve':
// send as a HAM
Awtw_Akismet::submit($id, 'ham');
break;
case 'mark_pending':
// Mark as pending
Awtw_DB::statusUpdate($id, 0);
break;
case 'delete':
// Function for delete
Awtw_DB::delete($id);
break;
}
}
/************************************************************************************/
/* Handle request sent by AJAX from front end */
/************************************************************************************/
function awtw_ajax_front() {
global $wpdb;
$tablename = $wpdb->prefix. 'awtw_plugin';
/**
* When nonce is verified, store all the data in the database and
* then Send it to Akismet to check whether it is spam or not.
*/
if( wp_verify_nonce($_POST['awtw-feedback-nonce']) ) {
$feedback = $_POST['awtw-feedback-msg'];
$source_url = $_SERVER['HTTP_REFERER'];
$ip_address = $_SERVER["REMOTE_ADDR"];
$user_agent = $_SERVER["HTTP_USER_AGENT"];
if(!empty($feedback)) {
/**
* Insert all the data into the database.
*/
$rows_affected = $wpdb->insert( $tablename, array(
'ip_address' => $ip_address,
'source_url' => $source_url,
'agent' => $user_agent,
'created_at' => current_time('mysql'),
'status' => 0,
'feedback' => stripslashes_deep($feedback),
) );
$result = Awtw_Akismet::check($wpdb->insert_id); // Check if it is SPAM !
echo $result;
//return true;
die();
} // End if !empty()
return false;
} // End if WP_verify_nonce()
}
/**
* Add AJAX action for front end AJAX script
*/
add_action( 'wp_ajax_awtw_ajax_front', 'awtw_ajax_front' );
add_action( 'wp_ajax_nopriv_awtw_ajax_front', 'awtw_ajax_front' );
/************************************************************************************/
/* Load Files */
/************************************************************************************/
// Load all SQL queries
require_once('awtw-sql.php');
//Load Admin Table to display feedback
require_once('awtw-table.php');
// Load Akismet
require_once('awtw-akismet.php');
/************************************************************************************/
/* THE END. Thank you for everything */
/************************************************************************************/
?>