__('Ask Question', 'askquestion-plugin'), 'singular_name' => __('Ask Question', 'askquestion-plugin'), 'add_new' => __('New Ask Question', 'askquestion-plugin'), 'add_new_item' => __('Add new Ask Question', 'askquestion-plugin'), 'edit_item' => __('Edit Ask Question', 'askquestion-plugin'), 'new_item' => __('New Ask Question', 'askquestion-plugin'), 'view_item' => __('View Ask Question', 'askquestion-plugin'), 'search_items' => __('Search Ask Question s', 'askquestion-plugin'), 'not_found' => __('No Ask Question found', 'askquestion-plugin'), 'not_found_in_trash' => __('No Ask Question found in Trash', 'askquestion-plugin'), 'parent_item_colon' => '', ); $args = array( 'label' => __('Ask Question', 'askquestion-plugin'), 'labels' => $labels, 'public' => false, 'can_export' => true, 'show_ui' => true, 'menu_position' => 32, '_builtin' => false, 'capability_type' => 'post', 'menu_icon' => plugin_dir_url(__FILE__).'images/icon.png', 'hierarchical' => false, 'rewrite' => array( "slug" => "askquestion" ), 'supports'=> array('title', 'editor', 'comments'), 'show_in_nav_menus' => true ); register_post_type( 'askquestion', $args); } add_action( 'init', 'create_askquestion_postype' ); function create_askquestion_tags() { $labels = array( 'name' => __( 'Ask Tags' ), 'singular_name' => __( 'Ask Tag'), 'search_items' => __( 'Search Ask Tags' ), 'all_items' => __( 'All Ask Tags' ), 'parent_item' => __( 'Parent Ask Tag' ), 'parent_item_colon' => __( 'Parent Ask Tag:' ), 'edit_item' => __( 'Edit Ask Tag' ), 'update_item' => __( 'Update Ask Tag' ), 'add_new_item' => __( 'Add New Ask Tag' ), 'new_item_name' => __( 'New Ask Tag Name' ), 'menu_name' => __( 'Ask Tags' ), ); $args = array( 'hierarchical' => false, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'asktag' ), ); register_taxonomy( 'asktag', 'askquestion', $args ); } add_action('init', 'create_askquestion_tags'); function askquestion_title_placeholder( $title ){ $screen = get_current_screen(); if ( 'askquestion' == $screen->post_type ){ $title = __('your question here', 'askquestion-plugin'); } return $title; } add_filter( 'enter_title_here', 'askquestion_title_placeholder' ); function show_asks( ) { $isCaptcha = get_option('askquestion_setting_captcha'); if($isCaptcha) { require_once(dirname(__FILE__).'/captcha/captcha.php'); $publickey = get_option( 'askquestion_setting_captcha_publickey' ); $privatekey = get_option( 'askquestion_setting_captcha_privatekey' ); $resp = null; $error = null; } ob_start(); wp_enqueue_style( 'askquestion', plugins_url('askquestion.css',__FILE__) ); if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['post_type'] == 'askquestion' && $_POST['question'] != "") { if ($isCaptcha && $_POST["recaptcha_response_field"]) { $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp->is_valid) { $title = $_POST['question']; $post = array( 'post_title' => $title, 'post_status' => 'draft', 'post_type' => 'askquestion' ); $id = wp_insert_post($post); echo "
' . __('Get a key from https://www.google.com/recaptcha/admin/create', 'askquestion-plugin') . "
"; } function askquestion_captcha_puk_callback() { echo '' . __('Get a key from https://www.google.com/recaptcha/admin/create', 'askquestion-plugin') . "
"; } function askquestion_number_callback() { echo '' . __('How much askquestions you want to display on one page.', 'askquestion-plugin') . "
"; } add_action( 'admin_menu', 'add_user_menu_bubble' ); function add_user_menu_bubble() { global $menu; foreach ( $menu as $key => $value ) { if ( $menu[$key][2] == 'edit.php?post_type=askquestion' ) { $type = 'askquestion'; $args = array( 'post_type' => $type, 'post_status' => 'draft', 'posts_per_page' => -1); $my_query = query_posts( $args ); if(count($my_query) > 0) { $menu[$key][0] .= ' ' . count($my_query) . ' '; } wp_reset_query(); return; } } } function publish_askquestion_hook($id) { $customs = get_post_custom($id); if(isset($customs['askquestion_email'])) wp_mail( $customs['askquestion_email'], get_bloginfo('name').__(' - Ask Question - Answer Received', 'askquestion-plugin'), __('Your Ask Question has been Answered!', 'askquestion-plugin')); } add_action( 'publish_askquestion', 'publish_askquestion_hook' ); ?>