ID, 'adsbenedict_url', true ); echo ''; echo ''; } function adsbenedict_expiration_callback( $post ) { wp_nonce_field( 'adsbenedict_expiration_callback', 'adsbenedict_expiration_callback_nonce' ); $offset = get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; $expiration = time()+YEAR_IN_SECONDS+$offset; if ( !!get_post_meta( $post->ID, 'adsbenedict_expiration') ) { $expiration = get_post_meta( $post->ID, 'adsbenedict_expiration', true ); } $month=date('n', $expiration ); $year=date('Y',$expiration ); $day=date('j',$expiration ); $hour=date('G',$expiration ); $minute=date('i',$expiration ); $second=date('s', $expiration ); echo ''; echo ''; ?> , @ : name; $zone=$zone[0]->name; $title="$advertiser in $zone"; wp_update_post( array( 'ID' => $post_id, 'post_title' => $title ) ); } add_action( 'save_post', 'adsbenedict_save_ad_url', 1); } add_action( 'save_post' , 'adsbenedict_save_ad_url', 1); function adsbenedict_init() { wp_enqueue_script( plugin_dir_path( __FILE__ ) . 'include/adsbenedict.js'); wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_style('jquery-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css'); register_post_type( 'adsbenedict', array( 'labels' => array( 'name' => __( 'Ads Benedict', 'adsbenedict' ), 'singular_name' => __( 'Ad', 'adsbenedict' ), 'all_items' => __( 'Ads', 'adsbenedict' ), 'new_item' => __( 'New ad', 'adsbenedict' ), 'add_new' => __( 'Add New', 'adsbenedict' ), 'add_new_item' => __( 'Add New ad', 'adsbenedict' ), 'edit_item' => __( 'Edit ad', 'adsbenedict' ), 'view_item' => __( 'View ad', 'adsbenedict' ), 'search_items' => __( 'Search ads', 'adsbenedict' ), 'not_found' => __( 'No ads found', 'adsbenedict' ), 'not_found_in_trash' => __( 'No ads found in trash', 'adsbenedict' ), 'parent_item_colon' => __( 'Parent adsbenedict', 'adsbenedict' ), 'menu_name' => __( 'Ads Benedict', 'adsbenedict' ), ), 'public' => false, 'hierarchical' => false, 'show_ui' => true, 'show_in_nav_menus' => true, 'supports' => array( 'thumbnail', 'link' , 'zone', 'advertisers'), 'has_archive' => false, 'rewrite' => true, 'query_var' => true, 'menu_icon' => 'dashicons-megaphone', ) ); } add_action( 'init', 'adsbenedict_init' ); function adsbenedict_updated_messages( $messages ) { global $post; $permalink = get_permalink( $post ); $messages['adsbenedict'] = array( 0 => '', // Unused. Messages start at index 1. 1 => sprintf( __('Adsbenedict updated. View adsbenedict', 'adsbenedict'), esc_url( $permalink ) ), 2 => __('Custom field updated.', 'adsbenedict'), 3 => __('Custom field deleted.', 'adsbenedict'), 4 => __('Adsbenedict updated.', 'adsbenedict'), /* translators: %s: date and time of the revision */ 5 => isset($_GET['revision']) ? sprintf( __('Adsbenedict restored to revision from %s', 'adsbenedict'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 6 => sprintf( __('Adsbenedict published. View adsbenedict', 'adsbenedict'), esc_url( $permalink ) ), 7 => __('Adsbenedict saved.', 'adsbenedict'), 8 => sprintf( __('Adsbenedict submitted. Preview adsbenedict', 'adsbenedict'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), 9 => sprintf( __('Adsbenedict scheduled for: %1$s. Preview adsbenedict', 'adsbenedict'), // translators: Publish box date format, see http://php.net/date date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ), 10 => sprintf( __('Adsbenedict draft updated. Preview adsbenedict', 'adsbenedict'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), ); return $messages; } add_filter( 'post_updated_messages', 'adsbenedict_updated_messages' ); add_filter('manage_adsbenedict_posts_columns', 'adsbenedict_show_thumb'); function adsbenedict_show_thumb($columns) { $columns['ab_thumb'] = 'Thumb'; $columns['ab_size'] = 'Ad Size'; $columns['ab_expiration'] = 'Expiration'; return $columns; } add_filter('manage_posts_custom_column', 'adsbenedict_show_thumb_display'); function adsbenedict_show_thumb_display($name) { add_image_size( 'ab_admin_thumb', 320, 320, false ); global $post; switch($name) { case 'ab_thumb': echo ''; echo the_post_thumbnail( 'ab_admin_thumb' ); echo ''; break; case 'ab_size': $tn_id = get_post_thumbnail_id( $post->ID ); $img = wp_get_attachment_image_src( $tn_id, 'full' ); $width = $img[1]; $height = $img[2]; echo "$width X $height"; break; case 'ab_expiration': if ( !!get_post_meta( $post->ID, 'adsbenedict_expiration') ) { $expiration = get_post_meta( $post->ID, 'adsbenedict_expiration', true ); if ($expiration"; } echo date('l jS \of F Y h:i A',$expiration); if ($expiration"; } } else { echo "expiration not set yet"; } } } add_action('admin_head', 'ab_column_width'); function ab_column_width() { echo ''; }