css
1 year ago
img
1 year ago
js
1 year ago
partials
1 year ago
class-eqw-advance.php
1 year ago
class-eqw-cart.php
1 year ago
class-eqw-email.php
1 year ago
class-eqw-enquiry.php
1 year ago
class-eqw-form-control.php
1 year ago
class-eqw-menu.php
1 year ago
class-eqw-option.php
1 year ago
class-eqw-product-options.php
1 year ago
class-pisol-enquiry-quotation-woocommerce-admin.php
1 year ago
index.php
1 year ago
plugins.php
1 year ago
class-eqw-enquiry.php
133 lines
| 1 | <?php |
| 2 | |
| 3 | class Pi_Eqw_Enquiry{ |
| 4 | |
| 5 | public $plugin_name; |
| 6 | public $version; |
| 7 | public $menu; |
| 8 | public $enquiry_type; |
| 9 | |
| 10 | function __construct($plugin_name , $version){ |
| 11 | $this->plugin_name = $plugin_name; |
| 12 | $this->version = $version; |
| 13 | |
| 14 | $this->enquiry_type = 'pisol_enquiry'; |
| 15 | |
| 16 | add_action( 'init', array($this, 'create_enquiry_type') ); |
| 17 | add_action( 'init', array($this, 'remove_post_type_title') ); |
| 18 | |
| 19 | add_action( 'add_meta_boxes', array($this,'user_detail') ); |
| 20 | |
| 21 | add_filter( 'manage_edit-pisol_enquiry_columns', array($this,'columnsToList') ) ; |
| 22 | |
| 23 | add_action( 'manage_pisol_enquiry_posts_custom_column', array($this,'columnsContent'), 10, 2 ); |
| 24 | } |
| 25 | |
| 26 | function create_enquiry_type() { |
| 27 | register_post_type( $this->enquiry_type, |
| 28 | array( |
| 29 | 'labels' => array( |
| 30 | 'name' => __( 'Enquiries' ), |
| 31 | 'singular_name' => __( 'Enquiry' ), |
| 32 | 'add_new_item' =>__('Enquiry') |
| 33 | ), |
| 34 | 'public' => false, |
| 35 | 'exclude_from_search' => true, |
| 36 | 'publicaly_queryable' => false, |
| 37 | 'show_ui'=>true, |
| 38 | 'rewrite'=>false, |
| 39 | 'show_in_nav_menus' => false, |
| 40 | 'query_var' => false, |
| 41 | 'has_archive' => false, |
| 42 | 'supports'=>array('title'), |
| 43 | 'menu_icon'=>plugins_url( 'enquiry-quotation-for-woocommerce/admin/img/pi.svg' ), |
| 44 | /** this hides add post option */ |
| 45 | 'capability_type' => 'post', |
| 46 | 'capabilities' => array( |
| 47 | 'create_posts' => 'do_not_allow' |
| 48 | ), |
| 49 | 'map_meta_cap' => true, |
| 50 | ) |
| 51 | ); |
| 52 | } |
| 53 | |
| 54 | function remove_post_type_title() { |
| 55 | remove_post_type_support( 'pisol_enquiry', 'title' ); |
| 56 | remove_post_type_support( 'pisol_enquiry', 'slugdiv' ); |
| 57 | } |
| 58 | |
| 59 | function user_detail(){ |
| 60 | add_meta_box( |
| 61 | 'pisol_enquiry_detail', |
| 62 | __( 'Enquiry Detail'), |
| 63 | array($this,'enquiry_detail'), |
| 64 | $this->enquiry_type |
| 65 | ); |
| 66 | } |
| 67 | |
| 68 | function enquiry_detail($enquiry){ |
| 69 | include_once('partials/enquiry_detail.php'); |
| 70 | } |
| 71 | |
| 72 | function variation_detail($variation_detail){ |
| 73 | $attributes_group = explode(',', $variation_detail); |
| 74 | if(is_array($attributes_group) && count($attributes_group) > 0){ |
| 75 | foreach($attributes_group as $attribute){ |
| 76 | if($attribute != ""){ |
| 77 | $pair = explode('|',$attribute); |
| 78 | echo isset($pair[0]) ? '<strong>'.esc_html($pair[0]).'</strong> : ' : ""; |
| 79 | echo isset($pair[1]) ? '<span>'.esc_html($pair[0]).'</span><br>' : ""; |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | function columnsToList( $columns ) { |
| 86 | |
| 87 | $columns = array( |
| 88 | 'cb' => '<input type="checkbox" />', |
| 89 | 'id' => __( 'Enq no.', 'pisol-enquiry-quotation-woocommerce' ), |
| 90 | 'title' => __( 'Name', 'pisol-enquiry-quotation-woocommerce' ), |
| 91 | 'pi_email' => __( 'Email', 'pisol-enquiry-quotation-woocommerce' ), |
| 92 | 'pi_phone' => __( 'Phone', 'pisol-enquiry-quotation-woocommerce' ), |
| 93 | 'pi_subject' => __( 'Subject', 'pisol-enquiry-quotation-woocommerce' ), |
| 94 | 'pi_message' => __( 'Message', 'pisol-enquiry-quotation-woocommerce' ), |
| 95 | 'date' => __( 'Date', 'pisol-enquiry-quotation-woocommerce' ) |
| 96 | ); |
| 97 | |
| 98 | return $columns; |
| 99 | } |
| 100 | |
| 101 | function columnsContent( $column, $post_id ) { |
| 102 | global $post; |
| 103 | |
| 104 | switch( $column ) { |
| 105 | case 'id' : |
| 106 | echo '#'.esc_html( $post_id ); |
| 107 | break; |
| 108 | |
| 109 | case 'pi_email' : |
| 110 | $pi_email = get_post_meta( $post_id, 'pi_email', true ); |
| 111 | echo esc_html($pi_email); |
| 112 | break; |
| 113 | |
| 114 | case 'pi_phone' : |
| 115 | $pi_phone = get_post_meta( $post_id, 'pi_phone', true ); |
| 116 | echo esc_html($pi_phone); |
| 117 | break; |
| 118 | |
| 119 | case 'pi_subject' : |
| 120 | $pi_subject = get_post_meta( $post_id, 'pi_subject', true ); |
| 121 | echo esc_html($pi_subject); |
| 122 | break; |
| 123 | |
| 124 | case 'pi_message' : |
| 125 | $pi_message = get_post_meta( $post_id, 'pi_message', true ); |
| 126 | echo esc_html($pi_message); |
| 127 | break; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | } |
| 132 | |
| 133 | new Pi_Eqw_Enquiry($this->plugin_name, $this->version); |