PLEASE Note: We reserve the right to edit or delete your paid article placement if it violates our user agreement. There are no refunds.';
$data['post_type']='page';
$data['post_status']='publish';
$data['comment_status']='closed';
$data['ping_status']='closed';
wp_insert_post($data);
}
if ( ( $_POST['qixit_settings_previous_cost_to_be_author'] != $options['cost_to_be_author'] ) ||
( is_array($qixit_settings) && array_key_exists('qixit_admin_product_for_registration',$qixit_settings)
&& ($qixit_settings['qixit_admin_product_for_registration'] == '') ) ||
( is_array($qixit_settings) && !array_key_exists('qixit_admin_product_for_registration',$qixit_settings) )
)
{
$success=qixit_product_for_author_registration($options['cost_to_be_author'], get_option('blogname'));
if ( !($success) )
{
$options['cost_to_be_author']=$_POST['qixit_settings_previous_cost_to_be_author'];
}
else
{
$qixit_settings = get_option('qixit_settings');
if ( array_key_exists('qixit_admin_product_for_registration',$qixit_settings) )
{
$options['qixit_admin_product_for_registration'] = $qixit_settings['qixit_admin_product_for_registration'];
}
if ( array_key_exists('qixit_admin_product_for_author_post_publish',$qixit_settings) )
{
$options['qixit_admin_product_for_author_post_publish'] = $qixit_settings['qixit_admin_product_for_author_post_publish'];
}
update_option('qixit_settings',$options);
}
}
}
else
{
$options['cost_to_be_author']=$_POST['qixit_settings_previous_cost_to_be_author'];
}
}
}
//cost_to_publish_post_by_author
$number='';$number=explode('.',$options['cost_to_publish_post_by_author']);
if ( !is_numeric($options['cost_to_publish_post_by_author']) || (float)$options['cost_to_publish_post_by_author'] < 0 || ((isset($number[1]) && strlen($number[1])>2)) )
{
$error_msg[]="Guest Authors may publish an article for a price should have non-negative numeric value only.";
}
else
{
$r_set = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->terms." WHERE name='".addslashes(QIXIT_AUTHOR_TAG)."'"));
$slug=preg_replace( "/[^A-Za-z]/", "", QIXIT_AUTHOR_TAG);
$r_set_slug = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->terms." WHERE slug='".$slug."'"));
if ( count($r_set) <= 0 && count($r_set_slug) <= 0 )
{
$inserted = $wpdb->insert( $wpdb->terms, array(
'name' => QIXIT_AUTHOR_TAG,
'slug' => $slug
));
if ( $inserted )
{
$term_id=mysql_insert_id();
}
}
else
{
$term_id=$r_set[0]->term_id;
}
$r_set = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->term_taxonomy." WHERE term_id ='".$term_id."'"));
if ( count($r_set) <= 0 && $term_id )
{
$wpdb->insert( $wpdb->term_taxonomy, array(
'term_id' => $term_id,
'taxonomy'=>'post_tag',
'description'=>'',
'count' => '0'
));
}
if ( $options['cost_to_publish_post_by_author'] > 0 && $_POST['qixit_settings_previous_cost_to_publish_post_by_author']!=$options['cost_to_publish_post_by_author'] ||
( is_array($qixit_settings) && array_key_exists('qixit_admin_product_for_author_post_publish',$qixit_settings)
&& ($qixit_settings['qixit_admin_product_for_author_post_publish'] == '') ) ||
( is_array($qixit_settings) && !array_key_exists('qixit_admin_product_for_author_post_publish',$qixit_settings) )
)
{
if ( empty($error_msg) )
{
$success=qixit_product_for_author_post_publish($options['cost_to_publish_post_by_author'], get_option('blogname'));
if ( !($success) )
{
$options['cost_to_publish_post_by_author']=$_POST['qixit_settings_previous_cost_to_publish_post_by_author'];
}
else
{
$qixit_settings = get_option('qixit_settings');
if ( array_key_exists('qixit_admin_product_for_registration',$qixit_settings) )
{
$options['qixit_admin_product_for_registration'] = $qixit_settings['qixit_admin_product_for_registration'];
}
if ( array_key_exists('qixit_admin_product_for_author_post_publish',$qixit_settings) )
{
$options['qixit_admin_product_for_author_post_publish'] = $qixit_settings['qixit_admin_product_for_author_post_publish'];
}
update_option('qixit_settings',$options);
}
}
else
{
$options['cost_to_publish_post_by_author']=$_POST['qixit_settings_previous_cost_to_publish_post_by_author'];
}
}
}
if ( $options['cost_to_publish_post_by_author'] == '' )
{
$options['cost_to_publish_post_by_author'] = '0';
}
// post_cost_of_author
if ( $options['post_cost_of_author'] == '' )
{
$options['post_cost_of_author']='0';
}
$number='';$number=explode('.',$options['post_cost_of_author']);
if ( !is_numeric($options['post_cost_of_author']) || (float)$options['post_cost_of_author'] < 0 || ((isset($number[1]) && strlen($number[1])>2)) )
{
$error_msg[]="Enable premium content settings for Authors, with a default price should have non-negative numeric value only.";
}
// percent_to_author
if ( $options['percent_to_author'] == '' )
{
$options['percent_to_author']=QIXIT_DEFAUL_PERCENT_TO_AUTHOR;
}
if ( !is_numeric($options['percent_to_author']) || (float)$options['percent_to_author'] < 0 )
{
$error_msg[]="Author’s percent share amount should have non-negative numeric value only.";
}
elseif ( is_numeric($options['percent_to_author']) && ( (float)$options['percent_to_author'] < 0 || (float)$options['percent_to_author'] > 100 ))
{
$error_msg[]="Author percent share should be between 0 and 100";
}
//
//===========================================================================================================================================
//==================================== END REPEATED CODE Below code is also in qixit_admin_options_for_authors_settings() If any change here
//==================================== cost_to_be_author, cost_to_publish_post_by_author, post_cost_of_author, percent_to_author
//===========================================================================================================================================
}
//view_any_time_cookie_exp
if ( !is_numeric($options['view_any_time_cookie_exp']) || (int)$options['view_any_time_cookie_exp'] < 0 )
{
$error_msg[]="Pay once view anytime cookie expiry time should have non-negative integer value only.";
}
elseif ( is_numeric($options['view_any_time_cookie_exp']) && ereg("[.]",$options['view_any_time_cookie_exp']) )
{
$error_msg[]="Pay once view anytime cookie expiry time should have non-negative integer value only.";
}
if ( is_numeric($options['view_any_time_cookie_exp']) && !ereg("[.]",$options['view_any_time_cookie_exp']) )
{
$options['view_any_time_cookie_exp']=60*60*24*$options['view_any_time_cookie_exp'];
}
else
{
$options['view_any_time_cookie_exp']=60*60*24*30;
}
if ( $options['view_any_time_cookie_exp'] == '' || $options['view_any_time_cookie_exp'] <= 0 )
{
$options['view_any_time_cookie_exp']=60*60*24*30;
}
if ( empty( $error_msg ) && $invalid_password==false )
{
$qixit_settings = get_option('qixit_settings');
$all_settings = array();
$all_settings['qixit_id'] = $options['qixit_id'];
$all_settings['qixit_password'] = $options['qixit_password'];
$all_settings['cost'] = $options['cost'];
$all_settings['paid_comments_price'] = $options['paid_comments_price'];
$all_settings['paid_comments'] = "0";
$all_settings['e_guest_authors'] = $options['e_guest_authors'];
$all_settings['paid_comments_only'] = $options['paid_comments_only'];
if ( array_key_exists('paid_comments', $options) )
{
$all_settings['paid_comments'] = $options['paid_comments'];
}
$all_settings['characters'] = $options['characters'];
$all_settings['cost_to_be_author'] = $options['cost_to_be_author'];
$all_settings['cost_to_publish_post_by_author'] = $options['cost_to_publish_post_by_author'];
$all_settings['post_cost_of_author'] = $options['post_cost_of_author'];
$all_settings['percent_to_author'] = $options['percent_to_author'];
$all_settings['view_any_time_cookie_exp'] = $options['view_any_time_cookie_exp'];
$all_settings['terms_of_service'] = $options['terms_of_service'];
$all_settings['premium_bg_color'] = $options['premium_bg_color'];
$all_settings['premium_heading_bg_color'] = $options['premium_heading_bg_color'];
$all_settings['widget_name'] = $options['widget_name'];
if ( array_key_exists('qixit_admin_product_for_registration',$qixit_settings) )
{
$all_settings['qixit_admin_product_for_registration'] = $qixit_settings['qixit_admin_product_for_registration'];
}
if ( array_key_exists('qixit_admin_product_for_author_post_publish',$qixit_settings) )
{
$all_settings['qixit_admin_product_for_author_post_publish'] = $qixit_settings['qixit_admin_product_for_author_post_publish'];
}
// now update all options
update_option('qixit_settings',$all_settings);
$op_table = $wpdb->prefix."options";
$auth_regi = $options['e_guest_authors'];
$sql = "update `$op_table` set `option_value` = $auth_regi where `option_name` = 'users_can_register' ";
$rows_affected = $wpdb->query( $sql );
$success='Settings saved.';
}
}
else
{
$options = get_option('qixit_settings');
}
require_once QIXIT_PLUGIN_DIR . '/wp-qixit-admin-settings-form.php';
}
// qixit settings for author
function qixit_settings_for_author()
{
global $wpdb;
$author_info = qixit_get_current_author_settings();
if ( isset($_POST) && (!empty($_POST)) )
{
$error_msg = array();
$author_settings = $_POST['qixit_author_settings'];
// Validate account settings
if ( trim($author_settings['qixit_id']) == '' )
{
$error_msg[]="Qixit ID cannot be blank.";
}
else
{
$author_settings['qixit_id']=trim($author_settings['qixit_id']);
}
if ( empty( $error_msg ) )
{
$current_user = wp_get_current_user();
if ( !$author_info )
{
$wpdb->insert( $wpdb->prefix.QIXIT_AUTHOR_SETTINGS, array(
'wp_user_id' => $current_user->ID,
'qixit_id' => $author_settings['qixit_id'],
'date_created' => date('Y-m-d H:i:s')));
}
else
{
$wpdb->update( $wpdb->prefix.QIXIT_AUTHOR_SETTINGS,
array('qixit_id' => $author_settings['qixit_id'],
'date_updated' => date('Y-m-d H:i:s')),
array('wp_user_id' => $current_user->ID));
}
// get updated information
$author_info = qixit_get_current_author_settings();
$success='Settings saved.';
}
}
?>
has_cap( "administrator" ) )
{
add_options_page(__('QixIT Micropay','qixit'), __('QixIT Micropay','qixit'), 'manage_options', 'qixit_settings_for_admin', 'qixit_settings_for_admin');
add_submenu_page('qixit_cross_ref_page',__('Ad hoc Link Create','qixit'), __('Ad hoc Link Add','qixit'), 'publish_posts', 'qixit_ad_hoc_create', 'qixit_ad_hoc_create');
add_submenu_page('qixit_cross_ref_page',__('Ad hoc Link List','qixit'), __('Ad hoc Link List','qixit'), 'publish_posts', 'qixit_ad_hoc_list', 'qixit_ad_hoc_list');
add_submenu_page('qixit_cross_ref_page',__('QixIT Micropay','qixit'), __('QixIT Micropay','qixit'), 'publish_posts', 'qixit_settings_for_admin', 'qixit_settings_for_admin');
}
else // for other roles
{
add_users_page(__('QixIT Micropay','qixit'), __('QixIT Micropay','qixit'), 'qixit_settings_for_author', 'qixit_settings_for_author', 'qixit_settings_for_author');
}
add_submenu_page('',__('Qixit Warning','qixit'), __('Qixit Warning','qixit'), 'publish_posts', 'qixit_post_product_delete_warning', 'qixit_post_product_delete_warning');
}
}
/**
* this is for only sub menu page. can can't be called
*/
add_action('admin_init', 'qixit_unwanted_sesssion_rid');
function qixit_unwanted_sesssion_rid()
{
@session_start();
if (isset($_SESSION['qixit_widget_error']))
{
unset($_SESSION['qixit_script_error_msg']);
}
if (isset($_SESSION['qixit_widget_success']))
{
unset($_SESSION['qixit_widget_success']);
}
unset($_SESSION['qixit_widget_error']);
unset($_SESSION['qixit_widget_submitted_options']);
}
add_action('admin_init', 'qixit_post_product_deleted_redirect');
function qixit_post_product_deleted_redirect()
{
@session_start();
//to redirect contorl after deleting single post. wordpress redirect to http_refer page and http_reffer is qixit_post_product_delete_warning so to ignore qixit_warning page we redirect control to from where delete action was performed.
if ( isset($_GET['deleted']) && $_GET['deleted'] ==' 1' && isset($_SESSION['delete_deny_url']) )
{
$delete_deny_url=$_SESSION['delete_deny_url'];
unset($_SESSION['delete_deny_url']);
wp_redirect($delete_deny_url);
die(" ");
}
}
add_action('admin_init', 'qixit_export_sales_report');
function qixit_export_sales_report()
{
if ( isset($_GET['export']) && $_GET['export']=='csv' )
{
$where='';
if ( isset($_GET['f']) && $_GET['f'] == 'ar' )
{
$where = " WHERE payment_for='author_registration' ";
}
if ( isset($_GET['f']) && $_GET['f'] == 'ap' )
{
$where = " WHERE payment_for='add_post' ";
}
if ( isset($_GET['f']) && $_GET['f'] == 'vadhoc' )
{
$where = " WHERE payment_for='view_ad_hoc' ";
}
if ( isset($_GET['f']) && $_GET['f'] == 'vp' )
{
$where = " WHERE payment_for='view_post' ";
}
if ( isset($_GET['f']) && $_GET['f'] == 'c' )
{
$where = " WHERE payment_for='comments' ";
}
$data_array = qixit_sales_history_data('fetch',$where);
$headings[] = __('Paid For','qixit');
$headings[] = __('Amount Paid','qixit');
$headings[] = __('Date','qixit');
$headings[] = __('Buyer’s Qixit User ID','qixit');
$headings[] = __('Qixit Transaction ID','qixit');
$headings[] = __('Product Title','qixit');
$headings[] = __('Amount Sharing','qixit');
$headings[] = __('Author’s percent share','qixit');
$headings[] = __('Author','qixit');
exportcsv_from_array($data_array,$headings);
}
}
/**
* called from admin_menu it is hidden page
*/
function qixit_post_product_delete_warning()
{
@session_start();
$delete_url=$_SESSION['delete_url'];
$delete_deny_url=$_SESSION['delete_deny_url'];
unset($_SESSION['delete_url']);
//unset($_SESSION['delete_deny_url']); moved into qixit_admin_init
?>
2)) )
{
$error_msg[]="Cost should have non-negative numeric value with only two digit after decimal.";
}
// Pitch Url
if ( $_POST['_qixit_pitch_url'] == '' || !qixit_is_valid_url($_POST['_qixit_pitch_url']) )
{
$error_msg[]="Pitch url should have correct url string.";
}
// Delivery Url
if ( $_POST['_qixit_delivery_url'] == '' || !qixit_is_valid_url($_POST['_qixit_delivery_url']) )
{
$error_msg[]="Delivery url should have correct url string.";
}
if ( empty($error_msg) )
{
$returned_qixit_product_id='';
//CODE TO WRITE POST
if ( !(isset($_POST['ID'])) )
{
$post_id = write_post();
qixit_product_add_or_update($post_id);
}
else
{
wp_update_post($_POST);
$post_id = $_POST['ID'];
}
$_GET['edit_post_id'] = $post_id;
update_post_meta( $post_id, '_qixit_cost', $post_meta->_qixit_cost);
update_post_meta( $post_id, '_qixit_pitch_url', $post_meta->_qixit_pitch_url);
update_post_meta( $post_id, '_qixit_delivery_url', $post_meta->_qixit_delivery_url );
update_post_meta( $post_id, '_qixit_ad_hoc_link_type', $post_meta->_qixit_ad_hoc_link_type );
$qixit_ad_hoc_product = new QixitAdHocProduct($post_id);
if ( !(isset($_POST['ID'])) )
{
if (qixit_ad_hoc_product_add())
{
$success = 'Ad hoc link created successfully.';
$post['ID'] = $post_id;
$post['post_status'] = 'publish';
wp_update_post( $post );
}
else
{
$success = 'Ad hoc link created successfully but due to qixit error it has draft status.';
}
}
elseif ( ($_POST['_qixit_cost'] != $_POST['pre_qixit_cost']) || ($_POST['post_title'] != $_POST['pre_post_title']))
{
qixit_ad_hoc_product_update();
$success = 'Ad hoc link updated.';
}
else
{
$success = 'Ad hoc link updated.';
}
}
}
else
{
$post_status = 'draft';
}
if ( isset($_GET['edit_post_id']) )
{
//post
$post = get_post( $_GET['edit_post_id'] );
$post_title = $post->post_title;
$post_status = $post->post_status;
//meta
$post_meta = qixit_get_post_meta( $_GET['edit_post_id'] );
}
?>
}
/**
* this is for only sub menu page. can can't be called
*/
function qixit_ad_hoc_list()
{
global $wpdb,$current_user,$wp_locale,$qixit_ad_hoc_product;
$qixit_no_record_found = true;
if ( isset($_GET['delete_post_id']) )
{
if ( isset($_GET['confirm']) )
{
qixit_delete_qixit_product($_GET['delete_post_id']);
wp_delete_post( $_GET['delete_post_id'], true);
}
else
{
?>
post_status=='publish' )
{
$data['ID'] = $post->ID;
$data['post_status'] = 'draft';
wp_update_post($data);
}
else
{
$data['ID'] = $post->ID;
$data['post_type'] = 'post';
$data['post_status'] = 'publish';
$qixit_ad_hoc_product = new QixitAdHocProduct($post->ID);
$qixit_settings = get_option('qixit_settings');
$_POST['post_type'] = 'post';
if ( $qixit_ad_hoc_product->get_qixit_PID() == '' )
{
if ( qixit_ad_hoc_product_add() )
{
$post_data['ID'] = $qixit_ad_hoc_product->get_post_id();
$post_data['post_status'] = 'publish';
wp_update_post( $post_data );
}
}
else
{
$post_data['ID'] = $qixit_ad_hoc_product->get_post_id();
$post_data['post_status'] = 'publish';
wp_update_post( $post_data );
}
}
}
$qixit_products_post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM " . $wpdb->prefix.QIXIT_AD_HOC_PRODUCTS . "
WHERE qixit_PID IS NOT NULL OR qixit_PID IS NULL".qixit_date_filter_condition()." ") );
if (!isset($_GET['delete_post_id']) || isset($_GET['confirm']))
{
if ( count( $qixit_products_post_ids ) > 0 )
{
qixit_date_filter_drop_down(QIXIT_AD_HOC_PRODUCTS,'qixit_ad_hoc_list');
?>
get_results( $wpdb->prepare(" SELECT * FROM " . $wpdb->prefix.QIXIT_PAYMENT_DETAILS . " as pd
LEFT JOIN " . $wpdb->prefix.QIXIT_PRODUCTS . " as qp ON pd.product_id=qp.product_id
order by date_purchased desc limit 0,5") );
if ( count($sales_history_set) > 0 )
{
?>
$sales_history )
{
if ( $sales_history->type == 'A' && $sales_history->payment_for == 'view_ad_hoc')
{
$sales_ad_hoc_history = $wpdb->get_row( $wpdb->prepare(" SELECT * FROM " . $wpdb->prefix.QIXIT_PAYMENT_DETAILS . " as pd
LEFT JOIN " . $wpdb->prefix.QIXIT_AD_HOC_PRODUCTS . " as a ON pd.product_id=a.product_id
WHERE a.qixit_PID='".$sales_history->qixit_PID."'") );
}
if ( $sales_history->payment_for == 'view_ad_hoc' )
{ $post = get_post($sales_ad_hoc_history->post_id);
$owner = new WP_User( $post->post_author );
if ( !$current_user->has_cap( "administrator" ) )
{
if ( $current_user->ID != $post->post_author )
continue;
}
$qixit_no_record_found = false;
?>
';
echo __('Provided Vendor ID or Password invalid. You must upgrade your Qixit ID to a vendor account at','qixit');
echo " www.Qixit.com/products.";
echo '
';
}
unset($_SESSION['qixit_script_error_msg']);
}
}
function qixit_post_product_add()
{
global $wpdb, $qixit_product;
$qixit_settings = get_option('qixit_settings');
$post = get_post( $qixit_product->get_post_id() );
if (is_null($post))
{
return;
}
$post_id = $post->ID;
if ( $_POST['qixit_post_type'] == QIXIT_PREMIUM_PAY_ONCE_VIEW_ANYTIME || $_POST['qixit_post_type'] == QIXIT_PREMIUM_PAY_PER_VIEW )
{
if ( $_POST['qixit_post_cost'] <= 0 )
{
qixit_set_old_status_post($post->ID);
$_SESSION['qixit_script_error_msg'] = "Post Cost should be greater than zero OR the content should be 'Regular'.";
return;
}
$post_owner = new WP_User( $post->post_author );
$qixit_product_object = new ProductAdd();
$qixit_product_object->set_vend( $qixit_settings['qixit_id'] );
$password = base64_decode( $qixit_settings['qixit_password'] );
$qixit_product_object->set_vendpw( $password );
if ( $post_owner->has_cap( "administrator" ) )
{
$qixit_product_object->set_aff( $qixit_settings['qixit_id'] );
$qixit_product_object->set_affpct( QIXIT_AFFPCT );
}
else
{
$author_info = qixit_get_author_settings( $post_owner->ID );
$qixit_product_object->set_aff( $author_info->qixit_id );
$qixit_product_object->set_affpct( $qixit_settings['percent_to_author'] );
}
$desc = trim($_POST['post_title'])!=''?$_POST['post_title']:$post->ID;
$qixit_product_object->set_desc( $desc );
$qixit_product_object->set_cost( $_POST['qixit_post_cost'] );
$qixit_product_object->set_purl( get_option('siteurl') );
if ($_POST['qixit_post_type'] == QIXIT_PREMIUM_PAY_ONCE_VIEW_ANYTIME )
{
$qixit_product_object->set_perm('Y');
}
elseif ( $_POST['qixit_post_type'] == QIXIT_PREMIUM_PAY_PER_VIEW )
{
$qixit_product_object->set_perm('N');
}
$qixit_product_object->set_siteurl(get_option('siteurl'));
$qixit_product_object->set_permalink(get_permalink($post->ID));
$qixit_product_object->set_rmsg('Thanks+for+reading+' . get_option('siteurl') . '.Here\'s+the+link+if+you+want+to+see+' . $qixit_product_object->get_desc() .'+again..');
$qixit_product_object->set_durl(QIXIT_PLUGIN_URL.'/wp-qixit-redirect.php?post_id='. $post->ID);
$qixit_product_object->set_echo('qixit_id=(userid)');
$url=$qixit_product_object->construct_product_url();
if ( is_array($url) )
{
qixit_set_old_status_post($post->ID);
$_SESSION['qixit_script_error_msg'] = $url['error_message'];
return;
}
$html=@file_get_contents($url);
$matches = explode("|", $html);
if ( is_array($matches) )
{
$PID = trim(substr(strip_tags(nl2br($matches[3])),16));
if ( $PID != '' && (strtolower(trim(strip_tags(nl2br($matches[1])))) == 'success') )
{
$data = array( 'post_qixit_PID' => $PID,
'qixit_post_type' => $_POST['qixit_post_type'],
'premium_post_cost' => $_POST['qixit_post_cost'] );
$qixit_product = qixit_update_qixit_product( $qixit_product->get_post_id(), $data);
// everything looks good, so lets return
return;
}
//looks like we encountered an error
qixit_set_old_status_post($post->ID);
$_SESSION['qixit_script_error_msg'] = qixit_get_qixit_system_error($matches);
return;
}
else
{
qixit_set_old_status_post($post->ID);
$_SESSION['qixit_script_error_msg']='There was an error in connecting to the Qixit system.';
}
}
}
function qixit_comment_product_add()
{
global $wpdb, $qixit_product;
$qixit_settings = get_option( 'qixit_settings' );
// add a comments QIXIT product only if paid_comments is set
if ( $qixit_settings['paid_comments'] == 1 && (isset($_POST['qixit_comment_cost']) && $_POST['qixit_comment_cost'] > 0) )
{
$post = get_post( $qixit_product->get_post_id() );
if (is_null($post))
{
return;
}
$post_id = $post->ID;
$qixit_comment_product_object = new ProductAdd();
$qixit_comment_product_object->set_vend( $qixit_settings['qixit_id'] );
$password = base64_decode( $qixit_settings['qixit_password'] );
$qixit_comment_product_object->set_vendpw( $password );
$post_owner = new WP_User( $post->post_author );
if ( !$post_owner->has_cap( "administrator" ))
{
$author_info = qixit_get_author_settings( $post_owner->ID );
$qixit_comment_product_object->set_aff( $author_info->qixit_id );
$qixit_comment_product_object->set_affpct( $qixit_settings['percent_to_author'] );
}
else
{
$qixit_comment_product_object->set_aff( $qixit_settings['qixit_id'] );
$qixit_comment_product_object->set_affpct( QIXIT_AFFPCT );
}
$desc = trim($_POST['post_title'])!=''?$_POST['post_title']:$post_id;
$qixit_comment_product_object->set_desc('Comments+on+'.$desc);
$qixit_comment_product_object->set_cost($_POST['qixit_comment_cost']);
$qixit_comment_product_object->set_purl(get_option('siteurl'));
$qixit_comment_product_object->set_rmsg('Thanks+for+reading+' . get_option('siteurl') . '.++Your+comment+was+posted+at+' . get_permalink($_POST['post_ID']) . '.');
$qixit_comment_product_object->set_perm('Y');
$qixit_comment_product_object->set_siteurl(get_option('siteurl'));
$qixit_comment_product_object->set_permalink(get_permalink($post_id));
$qixit_comment_product_object->set_durl(QIXIT_PLUGIN_URL.'/wp-qixit-redirect.php?post_id='.$post_id.'&action=premium_comment');
$qixit_comment_product_object->set_echo('qixit_id=(userid)');
$url = $qixit_comment_product_object->construct_product_url();
if ( is_array($url) )
{
$_SESSION['qixit_script_error_msg'] = $url['error_message'];
return;
}
$html=@file_get_contents($url);
$matches = explode("|", $html);
if ( is_array($matches) )
{
$PID = trim(substr(strip_tags(nl2br($matches[3])),16));
if ( $PID != '' && (strtolower(trim(strip_tags(nl2br($matches[1]))))=='success') )
{
$data = array( 'comments_qixit_PID' => $PID,
'premium_comments_cost' => $_POST['qixit_comment_cost']);
$qixit_product = qixit_update_qixit_product( $qixit_product->get_post_id(), $data);
// everything looks good, so lets return
return;
}
// looks like we encountered an error
$_SESSION['qixit_script_error_msg'] = qixit_get_qixit_system_error($matches);
return;
}
else
{
$_SESSION['qixit_script_error_msg']='There was an error in connecting to the Qixit system.';
}
}
}
function qixit_post_product_update()
{
global $wpdb, $qixit_product;
@session_start();
$qixit_settings = get_option('qixit_settings');
$post = get_post($qixit_product->get_post_id());
$post_id = $post->ID;
if ( $_POST['qixit_post_type'] == QIXIT_PREMIUM_PAY_ONCE_VIEW_ANYTIME || $_POST['qixit_post_type'] == QIXIT_PREMIUM_PAY_PER_VIEW )
{
if ( $_POST['qixit_post_cost'] <= 0 )
{
qixit_set_old_status_post($post->ID);
$_SESSION['qixit_script_error_msg'] = "Post Cost should be greater than zero OR the content should be 'Regular'.";
return;
}
$post_owner = new WP_User( $post->post_author );
$qixit_product_object=new ProductAdd();
$qixit_product_object->set_vend($qixit_settings['qixit_id']);
$password = base64_decode($qixit_settings['qixit_password']);
$qixit_product_object->set_vendpw($password);
if ( $post_owner->has_cap( "administrator" ) )
{
$qixit_product_object->set_aff($qixit_settings['qixit_id']);
$qixit_product_object->set_affpct(QIXIT_AFFPCT);
}
else
{
$author_info = qixit_get_author_settings($post_owner->ID);
$qixit_product_object->set_aff($author_info->qixit_id);
$qixit_product_object->set_affpct($qixit_settings['percent_to_author']);
}
$desc = trim($_POST['post_title'])!=''?$_POST['post_title']: $qixit_product->get_post_id();
$qixit_product_object->set_desc($desc);
$qixit_product_object->set_cost($_POST['qixit_post_cost']);
$qixit_product_object->set_purl(get_option('siteurl'));
$qixit_product_object->set_rmsg('Thanks+for+reading+' . get_option('siteurl') . '.Here\'s+the+link+if+you+want+to+see+' . $qixit_product_object->get_desc() .'+again..');
if ( $_POST['qixit_post_type'] == QIXIT_PREMIUM_PAY_ONCE_VIEW_ANYTIME )
{
$qixit_product_object->set_perm('Y');
}
elseif ( $_POST['qixit_post_type'] == QIXIT_PREMIUM_PAY_PER_VIEW )
{
$qixit_product_object->set_perm('N');
}
$qixit_product_object->set_siteurl(get_option('siteurl'));
$qixit_product_object->set_permalink(get_permalink($qixit_product->get_post_id()));
$qixit_product_object->set_durl(QIXIT_PLUGIN_URL.'/wp-qixit-redirect.php?post_id='. $qixit_product->get_post_id());
$qixit_product_object->set_echo('qixit_id=(userid)');
$qixit_product_object->set_qixit_pid($qixit_product->get_post_qixit_PID());
$url = $qixit_product_object->construct_product_url();
if ( is_array($url) )
{
qixit_set_old_status_post($post->ID);
$_SESSION['qixit_script_error_msg']=$url['error_message'];
return;
}
$html=@file_get_contents($url);
$matches = explode("|", $html);
if ( is_array($matches) )
{
$result=trim(strip_tags(nl2br($matches[2])));
if ( stristr($result,'Updated') )
{
// everything looks good
return true;
}
else
{
if ( trim($result)!='' )
{
qixit_set_old_status_post($post->ID);
$_SESSION['qixit_script_error_msg']=$result;
return;
}
qixit_set_old_status_post($post->ID);
$_SESSION['qixit_script_error_msg']='There was an error in connecting to the Qixit system.';
return;
}
}
}
}
function qixit_comment_product_update()
{
@session_start();
global $wpdb, $qixit_product;
$post = get_post( $qixit_product->get_post_id() );
$post_owner = new WP_User( $post->post_author );
$post_id = $post->ID;
$qixit_settings = get_option('qixit_settings');
if ( $qixit_settings['paid_comments'] == 1 )
{
if ( $_POST['qixit_comment_cost'] <= 0 )
{
$_SESSION['qixit_script_error_msg'] = "Comment Cost should be greater than zero";
return;
}
$qixit_comment_product_object = new ProductAdd();
$qixit_comment_product_object->set_vend($qixit_settings['qixit_id']);
$password = base64_decode($qixit_settings['qixit_password']);
$qixit_comment_product_object->set_vendpw($password);
$desc=trim($_POST['post_title'])!=''?$_POST['post_title']: $qixit_product->get_post_id();
$qixit_comment_product_object->set_desc('Comments+on+'.$desc);
$qixit_comment_product_object->set_cost($_POST['qixit_comment_cost']);
if ( !$post_owner->has_cap( "administrator" ))
{
$author_info = qixit_get_author_settings( $post_owner->ID );
$qixit_comment_product_object->set_aff( $author_info->qixit_id );
$qixit_comment_product_object->set_affpct( $qixit_settings['percent_to_author'] );
}
else
{
$qixit_comment_product_object->set_aff($qixit_settings['qixit_id']);
$qixit_comment_product_object->set_affpct(QIXIT_AFFPCT);
}
$site_url=get_option('siteurl');
$qixit_comment_product_object->set_purl($site_url);
$qixit_comment_product_object->set_rmsg('Thanks+for+reading+' . get_option('siteurl') . '.++Your+comment+was+posted+at+' . get_permalink( $qixit_product->get_post_id() ) . '.');
$qixit_comment_product_object->set_perm('Y');
$qixit_comment_product_object->set_siteurl(get_option('siteurl'));
$qixit_comment_product_object->set_permalink(get_permalink( $qixit_product->get_post_id() ));
$qixit_comment_product_object->set_durl(QIXIT_PLUGIN_URL.'/wp-qixit-redirect.php?post_id='.$qixit_product->get_post_id().'&action=premium_comment');
$qixit_comment_product_object->set_echo('qixit_id=(userid)');
$qixit_comment_product_object->set_qixit_pid($qixit_product->get_comments_qixit_PID());
$url = $qixit_comment_product_object->construct_product_url();
if ( is_array($url) )
{
$_SESSION['qixit_script_error_msg']=$url['error_message'];
return;
}
$html=@file_get_contents($url);
$matches = explode("|", $html);
if ( is_array($matches) )
{
$result=trim(strip_tags(nl2br($matches[2])));
if ( stristr($result,'Updated') )
{
// everything looks good
return;
}
else
{
if ( trim($result) != '' )
{
$_SESSION['qixit_script_error_msg'] = $result;
return;
}
$_SESSION['qixit_script_error_msg'] = 'There was an error in connecting to the Qixit system.';
return;
}
}
}
}
function qixit_ad_hoc_product_add()
{
@session_start();
global $wpdb, $qixit_ad_hoc_product;
if ( !isset($_POST['qixit_product_type']) )
{
$_POST['qixit_product_type'] = 'A';
}
if ( isset($_POST['_qixit_cost']) && $_POST['_qixit_cost'] <= 0 )
{
$_SESSION['qixit_script_error_msg'] = "Ad hoc Cost should be greater than zero.";
return;
}
$qixit_settings = get_option('qixit_settings');
$post = get_post( $qixit_ad_hoc_product->get_post_id() );
if ($post != null)
{
$post_id = $post->ID;
$post_owner = new WP_User( $post->post_author );
$qixit_product_object = new ProductAdd();
$qixit_product_object->set_vend( $qixit_settings['qixit_id'] );
$password = base64_decode( $qixit_settings['qixit_password'] );
$qixit_product_object->set_vendpw( $password );
if ( $post_owner->has_cap( "administrator" ) )
{
$qixit_product_object->set_aff( $qixit_settings['qixit_id'] );
$qixit_product_object->set_affpct( QIXIT_AFFPCT );
}
if (!isset($_POST['post_title']))
{
$desc = trim($post->post_title)!=''?$post->post_title:$post->ID;
}
else
{
$desc = trim($_POST['post_title'])!=''?$_POST['post_title']:$post_id;
}
$qixit_product_object->set_desc( $desc );
if (!isset($_POST['_qixit_cost']))
{
$qixit_cost = $qixit_ad_hoc_product->get_cost();
}
else
{
$qixit_cost = $_POST['_qixit_cost'];
}
$qixit_product_object->set_cost( $qixit_cost );
$qixit_product_object->set_purl( get_option('siteurl') );
if ($_POST['_qixit_ad_hoc_link_type'] == QIXIT_PREMIUM_PAY_ONCE_VIEW_ANYTIME )
{
$qixit_product_object->set_perm('Y');
}
elseif ( $_POST['_qixit_ad_hoc_link_type'] == QIXIT_PREMIUM_PAY_PER_VIEW )
{
$qixit_product_object->set_perm('N');
}
$qixit_product_object->set_siteurl(get_option('siteurl'));
$qixit_product_object->set_permalink(get_permalink($post_id));
$qixit_product_object->set_rmsg('Thanks+for+reading+' . get_option('siteurl') . '.Here\'s+the+link+if+you+want+to+see+' . $qixit_product_object->get_desc() .'+again..');
$qixit_product_object->set_durl(QIXIT_PLUGIN_URL.'/wp-qixit-redirect.php?post_id='. $post_id);
$qixit_product_object->set_echo('qixit_id=(userid)');
$url=$qixit_product_object->construct_product_url();
if ( is_array($url) )
{
qixit_set_old_status_post($post_id);
$_SESSION['qixit_script_error_msg'] = $url['error_message'];
return;
}
$html=@file_get_contents($url);
$matches = explode("|", $html);
if ( is_array($matches) )
{
$PID = trim(substr(strip_tags(nl2br($matches[3])),16));
if ( $PID != '' && (strtolower(trim(strip_tags(nl2br($matches[1])))) == 'success') )
{
$data = array( 'qixit_PID' => $PID,
'cost' => $qixit_cost );
$qixit_ad_hoc_product = qixit_update_qixit_product( $qixit_ad_hoc_product->get_post_id(), $data);
// everything looks good, so lets return
return true;
}
$_SESSION['qixit_script_error_msg'] = qixit_get_qixit_system_error($matches);
return;
}
else
{
$_SESSION['qixit_script_error_msg']='There was an error in connecting to the Qixit system.';
}
}
}
function qixit_ad_hoc_product_update()
{
global $wpdb, $qixit_ad_hoc_product;
@session_start();
$qixit_settings = get_option('qixit_settings');
if ( !isset($_POST['qixit_product_type']) )
{
$_POST['qixit_product_type'] = 'A';
}
if ( $_POST['_qixit_cost'] <= 0 )
{
$_SESSION['qixit_script_error_msg'] = "Ad hoc Cost should be greater than zero.";
return;
}
if ($qixit_ad_hoc_product->get_qixit_PID()=='')
{
if (qixit_ad_hoc_product_add())
{
$post['ID'] = $qixit_ad_hoc_product->get_post_id();
$post['post_status'] = 'publish';
wp_update_post( $post );
return ;
}
}
$post = get_post( $qixit_ad_hoc_product->get_post_id() );
$post_id = $post->ID;
$post_owner = new WP_User( $post->post_author );
$qixit_product_object=new ProductAdd();
$qixit_product_object->set_vend($qixit_settings['qixit_id']);
$password = base64_decode($qixit_settings['qixit_password']);
$qixit_product_object->set_vendpw($password);
if ( $post_owner->has_cap( "administrator" ) )
{
$qixit_product_object->set_aff($qixit_settings['qixit_id']);
$qixit_product_object->set_affpct(QIXIT_AFFPCT);
}
else
{
/*
$author_info = qixit_get_author_settings($post_owner->ID);
$qixit_product_object->set_aff($author_info->qixit_id);
$qixit_product_object->set_affpct($qixit_settings['percent_to_author']);
*/
}
$desc = trim($_POST['post_title'])!=''?$_POST['post_title']: $qixit_ad_hoc_product->get_post_id();
$qixit_product_object->set_desc($desc);
$qixit_product_object->set_cost($_POST['_qixit_cost']);
$qixit_product_object->set_purl(get_option('siteurl'));
$qixit_product_object->set_rmsg('Thanks+for+reading+' . get_option('siteurl') . '.Here\'s+the+link+if+you+want+to+see+' . $qixit_product_object->get_desc() .'+again..');
if ($_POST['_qixit_ad_hoc_link_type'] == QIXIT_PREMIUM_PAY_ONCE_VIEW_ANYTIME )
{
$qixit_product_object->set_perm('Y');
}
elseif ( $_POST['_qixit_ad_hoc_link_type'] == QIXIT_PREMIUM_PAY_PER_VIEW )
{
$qixit_product_object->set_perm('N');
}
$qixit_product_object->set_siteurl(get_option('siteurl'));
$qixit_product_object->set_permalink(get_permalink($qixit_ad_hoc_product->get_post_id()));
$qixit_product_object->set_durl(QIXIT_PLUGIN_URL.'/wp-qixit-redirect.php?post_id='. $qixit_ad_hoc_product->get_post_id());
$qixit_product_object->set_echo('qixit_id=(userid)');
$qixit_product_object->set_qixit_pid($qixit_ad_hoc_product->get_qixit_PID());
$url = $qixit_product_object->construct_product_url();
if ( is_array($url) )
{
qixit_set_old_status_post($post_id);
$_SESSION['qixit_script_error_msg']=$url['error_message'];
return;
}
$html=@file_get_contents($url);
$matches = explode("|", $html);
if ( is_array($matches) )
{
$result=trim(strip_tags(nl2br($matches[2])));
if ( stristr($result,'Updated') )
{
// everything looks good
$data = array( 'cost' => $_POST['_qixit_cost'] );
$qixit_ad_hoc_product = qixit_update_qixit_product( $qixit_ad_hoc_product->get_post_id(), $data );
return true;
}
else
{
if ( trim($result)!='' )
{
qixit_set_old_status_post($post_id);
$_SESSION['qixit_script_error_msg']=$result;
return;
}
qixit_set_old_status_post($post_id);
$_SESSION['qixit_script_error_msg']='There was an error in connecting to the Qixit system.';
return;
}
}
}
/**
* Set OLD_STATUS in session
*/
add_action('transition_post_status','qixit_transition_post_status','',3);
function qixit_transition_post_status($new_status, $old_status, $post)
{
global $qixit_post_old_status;
if ( $old_status != 'inherit' && $old_status != 'new' && $new_status != $old_status )
{
$qixit_post_old_status = $old_status;
}
}
function qixit_product_add_or_update( $post_id )
{
global $wpdb, $current_user, $qixit_product;
$post = get_post($post_id);
if ($post->post_parent == 0)
{
$qixit_post_id = $post_id;
}
else
{
$qixit_post_id = $post->post_parent;
}
$qixit_settings = get_option('qixit_settings');
$qixit_product = new QixitProduct($qixit_post_id);
$qixit_ad_ho_product = new QixitAdHocProduct($qixit_post_id);
$qixit_post_cost = (isset($_POST['qixit_post_cost'])) ? $_POST['qixit_post_cost'] : $qixit_settings['cost'];
$qixit_comment_cost = (isset($_POST['qixit_comment_cost'])) ? $_POST['qixit_comment_cost'] : $qixit_settings['paid_comments_price'];
// looks like we do not have a qixit product yet in our db, so lets insert one
if ( $qixit_product->get_product_id() == '' && $qixit_ad_ho_product->get_product_id() == '' )
{
if (isset($_POST['qixit_product_type']) && trim($_POST['qixit_product_type'])=='A')
{
$data = array(
'post_id' => $qixit_post_id,
'cost' => $_POST['_qixit_cost']
);
$qixit_ad_hoc_product = qixit_add_qixit_product($post, $data);
}
else
{
$data = array(
'post_id' => $qixit_post_id,
'qixit_post_type' => $_POST['qixit_post_type'],
'premium_post_cost' => $qixit_post_cost,
'premium_comments_cost' => $qixit_comment_cost
);
$qixit_product = qixit_add_qixit_product($post, $data);
}
}
else // update
{
if (isset($_POST['qixit_product_type']) && trim($_POST['qixit_product_type'])=='A')
{
//this data will be update in qixit_ad_hoc_product_update after updation on qixit.com
}
else
{
$has_post_product_changed = false;
$has_comments_product_changed = false;
$old_post = get_post( $qixit_post_id );
$data = array(
'qixit_post_type' => $_POST['qixit_post_type'],
'premium_post_cost' => $qixit_post_cost,
'premium_comments_cost' => $qixit_comment_cost);
if ( $qixit_product->get_premium_comments_cost() != $qixit_comment_cost ||
$old_post->post_title != $_POST['post_title'] )
{
$has_comments_product_changed = true;
}
if ( $qixit_product->get_qixit_post_type() != $_POST['qixit_post_type'] ||
$qixit_product->get_premium_post_cost() != $qixit_post_cost ||
$old_post->post_title != $_POST['post_title'] )
{
$has_post_product_changed = true;
}
$qixit_product->set_has_post_product_changed( $has_post_product_changed );
$qixit_product->set_has_comments_product_changed( $has_comments_product_changed );
qixit_update_qixit_product( $qixit_product->get_post_id(), $data );
}
}
}
add_action('save_post','qixit_save_post');
function qixit_save_post($post_id)
{
if ( current_user_can( 'publish_posts' ) && QIXIT_USEABLE && isset($_POST['post_type']) && $_POST['post_type'] == 'post')
{
global $current_user;
$post=get_post($post_id);
$qixit_settings = get_option('qixit_settings');
//if ($post->post_status != 'auto-draft')
if ($post->post_status != 'auto-draft' && isset($_POST['action']) && $_POST['action'] != 'autosave' )
{
if ( isset($_POST['action']) && ( $_POST['action'] == 'post-quickpress-save' || $_POST['action'] == 'post-quickpress-publish' ) ) //quickpress = Quickpress
{
$_POST['qixit_post_type'] = QIXIT_REG;
if ( !$current_user->has_cap( "administrator" ) )
{
$_POST['qixit_post_cost'] = $qixit_settings['post_cost_of_author'];
}
else
{
$_POST['qixit_post_cost'] = $qixit_settings['cost'];
}
$_POST['qixit_comment_cost'] = $qixit_settings['paid_comments_price'];
}
if ( isset($_POST['action']) && $_POST['action'] == 'inline-save' ) //inline-save = quick edit
{
$qixit_product = new QixitProduct($_POST['ID']);
$_POST['qixit_post_type'] = $qixit_product->get_qixit_post_type();
$_POST['qixit_post_cost'] = $qixit_product->get_premium_post_cost();
$_POST['qixit_comment_cost'] = $qixit_product->get_premium_comments_cost();
}
if ( (!isset($_GET['action'])) || (isset($_GET['action']) && $_GET['action'] != 'restore') )
{
qixit_product_add_or_update($post_id);
}
}
}
}
add_action('publish_post','qixit_publish_post');
function qixit_publish_post($post_id)
{
if ( current_user_can( 'publish_posts' ) && QIXIT_USEABLE && (isset($_REQUEST['post_type']) && $_REQUEST['post_type']=='post') )
{
@session_start();
global $wpdb, $current_user, $qixit_product;
$post = get_post($post_id);
if ($post->post_parent == 0)
{
$qixit_post_id = $post_id;
}
else
{
$qixit_post_id = $post->post_parent;
}
$qixit_settings = get_option('qixit_settings');
if ( !$qixit_product )
{
$qixit_product = new QixitProduct($qixit_post_id);
}
$qixit_ad_hoc_product_durl = get_post_meta( $qixit_post_id, '_qixit_delivery_url' );
if ( !empty($qixit_ad_hoc_product_durl) )
{
return;
}
// author post publish
if ( !$current_user->has_cap( "administrator" ) && !$current_user->has_cap( "editor" ) && (float)$qixit_settings['cost_to_publish_post_by_author'] > 0 )
{
if ((float)$qixit_settings['percent_to_author'] < 0)
{
if ( isset($_POST['action']) && ( $_POST['action'] == 'post-quickpress-save' || $_POST['action'] == 'post-quickpress-publish' ) ) //quickpress = Quickpress
{
$_SESSION['qixit_script_error_msg'] = "Author percent is not set. Contact the administrator.";
qixit_set_save_draft_post($post_id);
qixit_show_script_error_msg();
$_POST['action'] = 'post-quickpress-save';
}
else
{
qixit_set_old_status_post($post_id);
$_SESSION['qixit_script_error_msg'] = "Author percent is not set. Contact the administrator.";
return;
}
}
else
{
$qixit_post_cost = ($_POST['qixit_post_cost']) ? $_POST['qixit_post_cost'] : $qixit_settings['post_cost_of_author'];
if ( $qixit_settings['paid_comments'] == 1)
{
$qixit_comment_cost = ($_POST['qixit_comment_cost']) ? $_POST['qixit_comment_cost'] : $qixit_settings['paid_comments_price'];
}
$qixit_PID_for_author_post_publish = $qixit_settings['qixit_admin_product_for_author_post_publish'];
$qixit_payment_details = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix.QIXIT_PAYMENT_DETAILS . "
WHERE product_id='".$qixit_product->get_product_id()."' and qixit_PID = '$qixit_PID_for_author_post_publish'"));
// we know that this is the first time the post is being published
if ( !$qixit_payment_details )
{
$data = array( 'post_id' => $qixit_post_id,
'qixit_post_type' => $_POST['qixit_post_type'],
'premium_post_cost' => $qixit_post_cost,
'premium_comments_cost' => $qixit_comment_cost);
$qixit_product = new QixitProduct($qixit_post_id);
if ( !$qixit_product )
{
$qixit_product = qixit_add_qixit_product($post, $data);
}
else
{
$qixit_product = qixit_update_qixit_product( $qixit_post_id, $data);
}
$_SESSION['QIXIT_AUTHOR_PUBLISHING_POST']['post_title'] = $_POST['post_title'];
$_SESSION['QIXIT_AUTHOR_PUBLISHING_POST']['post_ID'] = $_POST['post_ID'];
$_SESSION['QIXIT_AUTHOR_PUBLISHING_POST']['qixit_post_type'] = $_POST['qixit_post_type'];
qixit_set_old_status_post($post_id);
// comments product
if ( !is_null($qixit_product) && $qixit_product->get_comments_qixit_PID() == '')
{
// add comment product to QIXIT system
qixit_comment_product_add();
}
else if ( !is_null($qixit_product) && $qixit_product->get_has_comments_product_changed() )
{
qixit_comment_product_update();
}
if ( isset($_POST['action']) && ( $_POST['action'] == 'post-quickpress-save' || $_POST['action'] == 'post-quickpress-publish' ) ) //quickpress = Quickpress
{
?>
get_post_qixit_PID() == '' )
{
//add post product to QIXIT system
qixit_post_product_add();
}
// comments product add
if ( $qixit_product->get_comments_qixit_PID() == '')
{
// add comment product to QIXIT system
qixit_comment_product_add();
}
}
}
}
}
else
{
// post product add
if ( $qixit_product->get_post_qixit_PID() == '' )
{
//add post product to QIXIT system
qixit_post_product_add();
}
// comments product add
if ( $qixit_product->get_comments_qixit_PID() == '')
{
// add comment product to QIXIT system
qixit_comment_product_add();
}
}
// post product update
if ( $qixit_product->get_has_post_product_changed() )
{
qixit_post_product_update();
}
// comments product update
if ( $qixit_product->get_has_comments_product_changed() )
{
qixit_comment_product_update();
}
if ( isset($_POST['action']) && ( $_POST['action'] == 'post-quickpress-save' || $_POST['action'] == 'post-quickpress-publish' ) ) //quickpress = Quickpress
{
qixit_show_script_error_msg();
}
}
}
if ( qixit_admin_settings_found() === true )
{
add_action('admin_menu', 'qixit_add_box');
}
function qixit_add_box()
{
if ( current_user_can( 'publish_posts' ) && QIXIT_USEABLE)
{
add_meta_box(
'qixit_box', // id of the
we'll add
__('Qixit','qixit'), //title
'qixit_add_content_in_the_box', // callback function that will echo the box content
'post', // where to add the box: on "post", "page", or "link" page
'side',
'high'
);
}
}
function qixit_add_content_in_the_box()
{
if ( isset($_GET['post']) && $_GET['post'] != '' )
{
$self_url=admin_url('post.php'.'?post='.$_GET['post'].'&action=edit');
}
else
{
$self_url=admin_url('post-new.php');
}
global $current_user;
$qixit_settings = get_option('qixit_settings');
if (isset($_GET['post']))
{
$qixit_product = new QixitProduct($_GET['post']);
}
else
{
$qixit_product = new QixitProduct();
}
?>