PluginProbe
Property Hive / 1.4.5
Property Hive v1.4.5
2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 All 261 releases
propertyhive / includes / admin / post-types / class-ph-admin-cpt-enquiry.php

class-ph-admin-cpt-enquiry.php in Property Hive 1.4.5, at includes/admin/post-types/class-ph-admin-cpt-enquiry.php

201 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin functions for the enquiry post type
4 *
5 * @author PropertyHive
6 * @category Admin
7 * @package PropertyHive/Admin/Post Types
8 * @version 1.0.0
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly
13 }
14
15 if ( ! class_exists( 'PH_Admin_CPT' ) ) {
16 include( 'class-ph-admin-cpt.php' );
17 }
18
19 if ( ! class_exists( 'PH_Admin_CPT_Enquiry' ) ) :
20
21 /**
22 * PH_Admin_CPT_Enquiry Class
23 */
24 class PH_Admin_CPT_Enquiry extends PH_Admin_CPT {
25
26 /**
27 * Constructor
28 */
29 public function __construct() {
30 $this->type = 'enquiry';
31
32 // Post title fields
33 add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
34
35 // Featured image text
36 //add_filter( 'gettext', array( $this, 'featured_image_gettext' ) );
37 //add_filter( 'media_view_strings', array( $this, 'media_view_strings' ), 10, 2 );
38
39 // Visibility option
40 //add_action( 'post_submitbox_misc_actions', array( $this, 'property_data_visibility' ) );
41
42 // Before data updates
43 add_action( 'pre_post_update', array( $this, 'pre_post_update' ) );
44 add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ) );
45
46 // Admin Columns
47 add_filter( 'manage_edit-enquiry_columns', array( $this, 'edit_columns' ) );
48 add_action( 'manage_enquiry_posts_custom_column', array( $this, 'custom_columns' ), 2 );
49
50 // Bulk / quick edit
51 add_filter( 'bulk_actions-edit-enquiry', array( $this, 'remove_bulk_actions') );
52
53 // Call PH_Admin_CPT constructor
54 parent::__construct();
55 }
56
57 /**
58 * Check if we're editing or adding a is_editing_enquiry
59 * @return boolean
60 */
61 private function is_editing_enquiry() {
62 if ( ! empty( $_GET['post_type'] ) && 'is_editing_enquiry' == $_GET['post_type'] ) {
63 return true;
64 }
65 if ( ! empty( $_GET['post'] ) && 'is_editing_enquiry' == get_post_type( $_GET['post'] ) ) {
66 return true;
67 }
68 if ( ! empty( $_REQUEST['post_id'] ) && 'is_editing_enquiry' == get_post_type( $_REQUEST['post_id'] ) ) {
69 return true;
70 }
71 return false;
72 }
73
74 /**
75 * Change title boxes in admin.
76 * @param string $text
77 * @param object $post
78 * @return string
79 */
80 public function enter_title_here( $text, $post ) {
81 if ( is_admin() && $post->post_type == 'enquiry' ) {
82 return __( 'Enter Enquiry Subject', 'propertyhive' );
83 }
84
85 return $text;
86 }
87
88 /**
89 * Some functions, like the term recount, require the visibility to be set prior. Lets save that here.
90 *
91 * @param int $post_id
92 */
93 public function pre_post_update( $post_id ) {
94
95 }
96
97 /**
98 * Forces certain product data based on the product's type, e.g. grouped products cannot have a parent.
99 *
100 * @param array $data
101 * @return array
102 */
103 public function wp_insert_post_data( $data ) {
104
105
106 return $data;
107 }
108
109 /**
110 * Change the columns shown in admin.
111 */
112 public function edit_columns( $existing_columns ) {
113
114 if ( empty( $existing_columns ) && ! is_array( $existing_columns ) ) {
115 $existing_columns = array();
116 }
117
118 unset( $existing_columns['title'], $existing_columns['comments'] );
119
120 $columns = array();
121 $columns['cb'] = '<input type="checkbox" />';
122
123 $columns['subject'] = __( 'Subject', 'propertyhive' );
124
125 $columns['status'] = __( 'Status', 'propertyhive' );
126
127 $columns['source'] = __( 'Source', 'propertyhive' );
128
129 $columns['negotiator'] = __( 'Negotiator', 'propertyhive' );
130
131 $columns['office'] = __( 'Office', 'propertyhive' );
132
133 return array_merge( $columns, $existing_columns );
134 }
135
136 /**
137 * Define our custom columns shown in admin.
138 * @param string $column
139 */
140 public function custom_columns( $column ) {
141 global $post, $propertyhive, $the_enquiry;
142
143 if ( empty( $the_enquiry ) || $the_enquiry->ID != $post->ID )
144 {
145 $the_enquiry = new PH_Enquiry( $post->ID );
146 }
147
148 switch ( $column ) {
149 case 'subject' :
150 $edit_link = get_edit_post_link( $post->ID );
151 $title = _draft_or_post_title();
152
153 echo '<strong><a class="row-title" href="' . esc_url( $edit_link ) .'">' . $title.'</a></strong>';
154
155 break;
156 case 'status' :
157 echo $the_enquiry->status;
158 break;
159 case 'source' :
160 echo $the_enquiry->source;
161 break;
162 case 'negotiator' :
163 if ($the_enquiry->_negotiator_id == '' || $the_enquiry->_negotiator_id == 0)
164 {
165 echo '<em>-- ' . __( 'Unassigned', 'propertyhive' ) . ' --</em>';
166 }
167 else
168 {
169 $userdata = get_userdata( $the_enquiry->_negotiator_id );
170 if ( $userdata !== FALSE )
171 {
172 echo $userdata->display_name;
173 }
174 else
175 {
176 echo '<em>Unknown user</em>';
177 }
178 }
179 break;
180 case 'office' :
181 echo get_the_title( $the_enquiry->_office_id );
182 break;
183 default :
184 break;
185 }
186 }
187
188 /**
189 * Remove bulk edit option
190 * @param array $actions
191 */
192 public function remove_bulk_actions( $actions ) {
193 unset( $actions['edit'] );
194 return $actions;
195 }
196
197 }
198
199 endif;
200
201 return new PH_Admin_CPT_Enquiry();