__('Ads'), 'singular_name' => __('Ad'), 'add_new' => __('Add New'), 'add_new_item' => __('Add New Ad'), 'edit_item' => __('Edit Ad'), 'new_item' => __('New Ad'), 'view_item' => __('View Ad'), 'search_items' => __('Search Ads'), 'not_found' => __('No Ads found'), 'not_found_in_trash' => __('No Ads found in Trash'), 'parent_item_colon' => '', 'menu_name' => __('Ads'), ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => false, 'rewrite' => true, 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','author') ); register_post_type('adherder_ad',$args); } function adherder_store_logged_in() { if(!is_user_logged_in()) { return true; // always track users that are not logged in } $options = get_option('adherder_options'); return $options['track_logged_in']; // only track logged in users when the option says so } function adherder_store_impression($id) { if (adherder_store_logged_in()) { if(get_post_custom_keys($id)&&in_array('adherder_impressions',get_post_custom_keys($id))){ $adherder_impressions = get_post_meta($id,'adherder_impressions',true); } if (!isset($adherder_impressions)){ $adherder_impressions = 0; } $adherder_impressions++; update_post_meta($id, 'adherder_impressions', $adherder_impressions); adherder_database_track($id, 'impression'); } } function adherder_store_click($id) { if (adherder_store_logged_in()) { if(get_post_custom_keys($id)&&in_array('adherder_clicks',get_post_custom_keys($id))){ $adherder_clicks = get_post_meta($id,'adherder_clicks',true); } if (!isset($adherder_clicks)){ $adherder_clicks = 0; } $adherder_clicks++; update_post_meta($id, 'adherder_clicks', $adherder_clicks); adherder_database_track($id, 'click'); } } function adherder_get_impressions($id) { if(get_post_custom_keys($id)&&in_array('adherder_impressions',get_post_custom_keys($id))){ return get_post_meta($id,'adherder_impressions',true); } else { return 0; } } function adherder_get_clicks($id) { if(get_post_custom_keys($id)&&in_array('adherder_clicks',get_post_custom_keys($id))){ return get_post_meta($id,'adherder_clicks',true); } else { return 0; } } ?>