ID , 'location_rotation' , true);
$location_price = get_post_meta($post->ID , 'location_price' ,true);
$location_enforce = get_post_meta($post->ID , 'location_enforce' ,true);
$location_width = get_post_meta($post->ID , 'location_width' ,true);
$location_height = get_post_meta($post->ID , 'location_height' ,true);
?>
Width
px
Height
px
Enforce unchecked)', 'ADVERT_TEXTDOMAIN' ); ?>
ID , 'location_imagead' ,true));
?>
ID , 'location_videoad' ,true));
$location_duration = get_post_meta($post->ID , 'location_duration' ,true);
?>
ID , 'location_textad' ,true));
$location_characters1 = get_post_meta($post->ID , 'location_characters1' ,true);
$location_characters2 = get_post_meta($post->ID , 'location_characters2' ,true);
$location_textad_html1 = htmlspecialchars_decode(get_post_meta($post->ID , 'location_textad_html1' ,true));
$location_textad_html2 = htmlspecialchars_decode(get_post_meta($post->ID , 'location_textad_html2' ,true));
?>
'', // Unused. Messages start at index 1.
1 => __( 'Location updated.' , 'ADVERT_TEXTDOMAIN' ) ,
6 => __( 'Location published.' , 'ADVERT_TEXTDOMAIN' ),
8 => __( 'Location submitted.' , 'ADVERT_TEXTDOMAIN' ),
9 => sprintf( __( 'Location scheduled for: %1$s.' , 'ADVERT_TEXTDOMAIN'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ) ),
10 => __( 'Location draft updated.', 'ADVERT_TEXTDOMAIN' )
);
return $messages;
}
//save post meta data
function location_save_meta($post_id){
if ('advert-location' != get_post_type() || !current_user_can('publish_adverts'))
return;
if(!isset($_POST['location_meta_box_nonce']) || !wp_verify_nonce($_POST['location_meta_box_nonce'], 'location_meta_box'))
return;
//justincase
if (defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE)
return;
if(isset($_POST['location_width'])){
update_post_meta( $post_id, 'location_width' , intval($_POST['location_width']) );
}
if(isset($_POST['location_height'])){
update_post_meta( $post_id, 'location_height' , intval($_POST['location_height']) );
}
if(isset($_POST['location_enforce'])){
update_post_meta( $post_id, 'location_enforce' , intval($_POST['location_enforce']) );
}
else{
update_post_meta( $post_id, 'location_enforce' , 0 );
}
if(isset($_POST['location_price']) && is_numeric($_POST['location_price']) ){
update_post_meta( $post_id, 'location_price' , number_format($_POST['location_price'], 2) );
}
$location_rotation_array = array('random','priority');
if(isset($_POST['location_rotation']) && in_array($_POST['location_rotation'], $location_rotation_array)){
update_post_meta( $post_id, 'location_rotation' , $_POST['location_rotation'] );
}
if(isset($_POST['location_imagead'])){
update_post_meta( $post_id, 'location_imagead' , intval($_POST['location_imagead']) );
}
else{
update_post_meta( $post_id, 'location_imagead' , 0 );
}
if(isset($_POST['location_videoad'])){
update_post_meta( $post_id, 'location_videoad' , intval($_POST['location_videoad']) );
}
else{
update_post_meta( $post_id, 'location_videoad' , 0 );
}
if(is_numeric($_POST['location_duration']) || empty($_POST['location_duration'])){
update_post_meta( $post_id, 'location_duration' , intval($_POST['location_duration']) );
}
if(isset($_POST['location_textad'])){
update_post_meta( $post_id, 'location_textad' , intval($_POST['location_textad']) );
}
else{
update_post_meta( $post_id, 'location_textad' , 0 );
}
if($_POST['location_characters1'] || empty($_POST['location_characters1'])){
update_post_meta( $post_id, 'location_characters1' , intval($_POST['location_characters1']) );
}
if($_POST['location_characters2'] || empty($_POST['location_characters2'])){
update_post_meta( $post_id, 'location_characters2' , intval($_POST['location_characters2']) );
}
update_post_meta( $post_id, 'location_textad_html1' , wp_kses_post(htmlspecialchars($_POST['location_textad_html1'])) );
update_post_meta( $post_id, 'location_textad_html2' , wp_kses_post(htmlspecialchars($_POST['location_textad_html2'])) );
}//save stuff
//add and change columns for advertisers
function custom_location_columns($columns) {
unset(
$columns['title'],
$columns['date']
);
$new_columns = array(
'title' => __('Title', 'ADVERT_TEXTDOMAIN'),
'lid' => __('LID', 'ADVERT_TEXTDOMAIN'),
'price' => __( 'Price', 'ADVERT_TEXTDOMAIN' ),
'rotation' => __( 'Rotation', 'ADVERT_TEXTDOMAIN' ),
'shortcode' => __( 'Shortcode', 'ADVERT_TEXTDOMAIN' ),
);
return array_merge($columns, $new_columns);
}
function custom_location_column( $column, $post_id ) {
switch ( $column ) {
case 'title' :
break;
case 'lid' :
echo $post_id;
break;
case 'price' :
$location_value = get_post_meta( $post_id , 'location_price' , true );
if(!empty($location_value)){echo number_format($location_value, 2);}
break;
case 'rotation' :
if( get_post_meta( $post_id , 'location_rotation' , true ) === 'random' ){
_e( 'Random', 'ADVERT_TEXTDOMAIN' );
}
else{
_e( 'Priority', 'ADVERT_TEXTDOMAIN' );
}
break;
case 'shortcode':
echo '[advert_location location_id="'.$post_id.'"]';
break;
}
}
function location_sortable_columns( $sortable_columns ) {
$sortable_columns['lid'] = 'lid';
$sortable_columns['rotation'] = 'rotation';
$sortable_columns['price'] = 'price';
return $sortable_columns;
}