0){
advert_add_dashboard_user_widget( 'advert_user_dashboard2', __( 'AdCredits', 'ADVERT_TEXTDOMAIN' ), 'advert_user_dashboard_meta_box2' );
advert_add_dashboard_user_widget( 'advert_user_dashboard3', __( 'Transaction History', 'ADVERT_TEXTDOMAIN' ), 'advert_user_dashboard_meta_box3' );
}
do_action( 'do_meta_boxes', $currentScreen->id, 'normal', '' );
do_action( 'do_meta_boxes', $currentScreen->id, 'side', '' );
echo '
'. __( 'Show on screen', 'ADVERT_TEXTDOMAIN' ) .'
';
meta_box_prefs($currentScreen);
if ( $howmany > 0 ){
// 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner
if ( isset( $_GET['welcome'] ) ) {
$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
update_user_meta( get_current_user_id(), 'show_advert_welcome_panel', $welcome_checked );
}
else {
$welcome_checked = get_user_meta( get_current_user_id(), 'show_advert_welcome_panel', true );
}
echo '\n";
}
echo '';
}
function advert_user_dashboard_meta_box1(){
global $advert_options;
global $howmany;
global $post_id;
global $user_id;
?>
' . __( 'AdCredits Available', 'ADVERT_TEXTDOMAIN') . '';
$company_credits = get_post_meta($post_id, 'company_credits', true);
if(empty($company_credits)){
echo '0
';
}
else{
echo ''.number_format_i18n( $company_credits, 2).'
';
}
if(has_action('advert_payment_type')){
if(has_action('advert_lightbox')){
do_action('advert_lightbox');
}
echo '';
echo '' . __( 'Add more AdCredits', 'ADVERT_TEXTDOMAIN') . '
';
echo '';
do_action('advert_payment_type');
echo '
';
}
}
}
function advert_user_dashboard_meta_box3(){
global $howmany;
global $post_id;
global $user_id;
?>
|
|
|
|
removed > 0){
echo '| '.number_format_i18n( str_replace("-", "", $transaction->removed), 2 ).' | '. __( 'Removed', 'ADVERT_TEXTDOMAIN') .' | '. esc_html($transaction->reason) .' | '. date_i18n( __( 'm/j/Y - G:i:s' ), strtotime($transaction->time) ) .' |
';
}
else{
echo '| '.number_format_i18n( str_replace("-", "", $transaction->added), 2 ).' | '. __( 'Added', 'ADVERT_TEXTDOMAIN') .' | '. esc_html($transaction->reason) .' | '. date_i18n( __( 'm/j/Y - G:i:s' ), strtotime($transaction->time) ) .' |
';
}
}
}
?>
View More';
}
function advert_add_dashboard_user_widget($widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null) {
$screen = get_current_screen();
$side_widgets = array('advert_user_dashboard3');
$location = 'normal';
if (in_array($widget_id, $side_widgets))
$location = 'side';
$priority = 'core';
if ('dashboard_browser_nag' === $widget_id)
$priority = 'high';
add_meta_box($widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args);
}
function add_new_advertiser(){
global $advert_options;
global $howmany;
global $post_id;
global $user_id;
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'post'){
if ( !is_user_logged_in() || ! wp_verify_nonce( $_POST['user_advertiser'], 'add_advertiser' ) ){
print 'Woah, whats really going on...?';
return;
}
$user_id = $_POST['user_id'];
$current_user_id = $user_id;
$post_title = sanitize_text_field( $_POST['advertiser_name'] );
$email = sanitize_email( $_POST['advertiser_email'] );
$phone = sanitize_text_field( $_POST['advertiser_phone'] );
if ( $user_id != $current_user_id )
return;
global $notice_array;
global $notice_num;
$notice_array = array();
if (empty($post_title)) $notice_array[] = __( 'Please add your Company name or Title.', 'ADVERT_TEXTDOMAIN');
if (empty($email)) $notice_array[] = __( 'Please add an email address.', 'ADVERT_TEXTDOMAIN');
if (!is_email($email)) $notice_array[] = __( 'Please use a different email address.', 'ADVERT_TEXTDOMAIN');
if (empty($phone)) $notice_array[] = __( 'Please add a telephone number.', 'ADVERT_TEXTDOMAIN');
if (count($notice_array) > 0){
$notice_num = 0;
add_action('advert-notices', 'advert_notices');
return;
}
if ( $howmany === 0 && empty($post_id) ){
// Create post object
$add_advert = array(
'post_title' => $post_title,
'post_status' => 'pending',
'post_author' => $user_id,
'post_type' => 'advert-advertiser',
);
// Insert the post into the database
$post_id = wp_insert_post( $add_advert );
$notice_array[] = __( 'Your information has been submitted for approval.', 'ADVERT_TEXTDOMAIN');
$notice_num = 1;
add_action('advert-notices', 'advert_notices');
}
else{
if(!empty($post_id)){
$update_advert = array(
'ID' => $post_id,
'post_title' => $post_title,
);
wp_update_post( $update_advert );
if(!empty($post_id) && $howmany === 0){$notice_array[] = __( 'Your information has been updated and waiting approval.', 'ADVERT_TEXTDOMAIN');}
else{$notice_array[] = __( 'Your information has been updated.', 'ADVERT_TEXTDOMAIN');}
$notice_num = 1;
add_action('advert-notices', 'advert_notices');
}
}
if(!empty($post_id)){
update_post_meta($post_id, 'advertiser_company', $post_title);
update_post_meta($post_id, 'advertiser_email', $email);
update_post_meta($post_id, 'advertiser_telephone', $phone);
update_user_meta( $user_id, 'advert_advertiser_company_id'.get_current_blog_id(), $post_id);
}
}
}
/** Create the User Dashboard */
function do_advert_user_dashboard(){
$currentScreen = get_current_screen();
global $advert_options;
global $howmany;
global $post_id;
global $user_id;
$columns = absint( $currentScreen->get_columns() );
$columns_css = '';
if ( $columns ) {
$columns_css = " columns-$columns";
}
wp_enqueue_style('dashboard');
wp_enqueue_script( 'dashboard' );
echo '';
echo '
a
';
echo '
'. __( 'Dashboard', 'ADVERT_TEXTDOMAIN' ) .'
';
echo '
';
//display notices
do_action('advert-notices');
//check if advertiser is published
if ( $howmany > 0 ){
//welcome
$classes = 'welcome-panel';
//get options
$option = intval(get_user_meta( get_current_user_id(), 'show_advert_welcome_panel', true ));
if($option != 1 && $option != 0){
$option = 1;
}
$user_analysis = 0;
if(array_key_exists('advert_allow_analysis_users', $advert_options)){
$user_analysis = intval($advert_options['advert_allow_analysis_users']);
}
// 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner
//$hide = 0 == $option || ( 2 == $option && wp_get_current_user()->user_email != get_option( 'admin_email' ) );
$hide = 0 == $option;
if ( $hide )
$classes .= ' hidden';
?>
';
echo '
';
echo '
';
echo '';
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
}