Advertisement
bananamariap

ts-listings.php

Aug 11th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.65 KB | None | 0 0
  1. <?php
  2. // Register Custom Post Type
  3. function ts_listings() {
  4.  
  5. $labels = array(
  6. 'name' => _x( 'Listings', '', 'ts' ),
  7. 'singular_name' => _x( 'Listing', '', 'ts' ),
  8. 'menu_name' => __( 'Listings', 'ts' ),
  9. 'name_admin_bar' => __( 'Listing', 'ts' ),
  10. 'archives' => __( 'Item Archives', 'ts' ),
  11. 'parent_item_colon' => __( 'Parent Listing:', 'ts' ),
  12. 'all_items' => __( 'All Listings', 'ts' ),
  13. 'add_new_item' => __( 'Add New Listing', 'ts' ),
  14. 'add_new' => __( 'Add New', 'ts' ),
  15. 'new_item' => __( 'New Listing', 'ts' ),
  16. 'edit_item' => __( 'Edit Listing', 'ts' ),
  17. 'update_item' => __( 'Update Listing', 'ts' ),
  18. 'view_item' => __( 'View Listing', 'ts' ),
  19. 'search_items' => __( 'Search Listing', 'ts' ),
  20. 'not_found' => __( 'Not found', 'ts' ),
  21. 'not_found_in_trash' => __( 'Not found in Trash', 'ts' ),
  22. 'featured_image' => __( 'Featured Image', 'ts' ),
  23. 'set_featured_image' => __( 'Set featured image', 'ts' ),
  24. 'remove_featured_image' => __( 'Remove featured image', 'ts' ),
  25. 'use_featured_image' => __( 'Use as featured image', 'ts' ),
  26. 'insert_into_item' => __( 'Insert into Listing', 'ts' ),
  27. 'uploaded_to_this_item' => __( 'Uploaded to this Listing', 'ts' ),
  28. 'items_list' => __( 'Listings list', 'ts' ),
  29. 'items_list_navigation' => __( 'Listings list navigation', 'ts' ),
  30. 'filter_items_list' => __( 'Filter Listings list', 'ts' ),
  31. );
  32. $rewrite = array(
  33. 'slug' => 'listings',
  34. 'with_front' => true,
  35. 'pages' => true,
  36. 'feeds' => true,
  37. );
  38. $args = array(
  39. 'label' => __( 'Listing', 'ts' ),
  40. 'labels' => $labels,
  41. 'supports' => array(),
  42. 'hierarchical' => false,
  43. 'public' => true,
  44. 'show_ui' => true,
  45. 'show_in_menu' => true,
  46. 'menu_position' => 5,
  47. 'show_in_admin_bar' => true,
  48. 'show_in_nav_menus' => true,
  49. 'can_export' => true,
  50. 'has_archive' => true,
  51. 'exclude_from_search' => false,
  52. 'publicly_queryable' => true,
  53. 'capability_type' => 'page',
  54. 'rewrite' => $rewrite
  55. );
  56. register_post_type( 'ts-listings', $args );
  57.  
  58. }
  59.  
  60. add_action( 'init', 'ts_listings', 0 );
  61.  
  62. // Register Custom Taxonomy
  63. function ts_listing_type() {
  64.  
  65. $labels = array(
  66. 'name' => _x( 'Types', 'Taxonomy General Name', 'ts' ),
  67. 'singular_name' => _x( 'Type', 'Taxonomy Singular Name', 'ts' ),
  68. 'menu_name' => __( 'Type', 'ts' ),
  69. 'all_items' => __( 'All Types', 'ts' ),
  70. 'parent_item' => __( 'Parent Type', 'ts' ),
  71. 'parent_item_colon' => __( 'Parent Type:', 'ts' ),
  72. 'new_item_name' => __( 'New Type Name', 'ts' ),
  73. 'add_new_item' => __( 'Add New Type', 'ts' ),
  74. 'edit_item' => __( 'Edit Type', 'ts' ),
  75. 'update_item' => __( 'Update Type', 'ts' ),
  76. 'view_item' => __( 'View Type', 'ts' ),
  77. 'separate_items_with_commas' => __( 'Separate items with commas', 'ts' ),
  78. 'add_or_remove_items' => __( 'Add or remove items', 'ts' ),
  79. 'choose_from_most_used' => __( 'Choose from the most used', 'ts' ),
  80. 'popular_items' => __( 'Popular Types', 'ts' ),
  81. 'search_items' => __( 'Search Items', 'ts' ),
  82. 'not_found' => __( 'Not Found', 'ts' ),
  83. 'no_terms' => __( 'No items', 'ts' ),
  84. 'items_list' => __( 'Items list', 'ts' ),
  85. 'items_list_navigation' => __( 'Items list navigation', 'ts' ),
  86. );
  87. $rewrite = array(
  88. 'slug' => 'listing-types',
  89. 'with_front' => true,
  90. 'hierarchical' => false,
  91. );
  92. $args = array(
  93. 'labels' => $labels,
  94. 'hierarchical' => false,
  95. 'public' => true,
  96. 'show_ui' => true,
  97. 'show_admin_column' => true,
  98. 'show_in_nav_menus' => true,
  99. 'show_tagcloud' => true,
  100. 'rewrite' => $rewrite,
  101. );
  102. register_taxonomy( 'ts-listing-type', array( 'ts-listings' ), $args );
  103.  
  104. }
  105. add_action( 'init', 'ts_listing_type', 0 );
  106.  
  107. add_filter( 'rwmb_meta_boxes', 'ts_listings_register_meta_boxes' );
  108.  
  109. function ts_listings_register_meta_boxes($meta_boxes)
  110. {
  111. global $prefix;
  112.  
  113. $meta_boxes[] = array(
  114. 'title' => __( "Details", 'no-translate' ),
  115. 'pages' => array( 'ts-listings' ),
  116. 'fields' => array(
  117. array(
  118. 'id' => "{$prefix}listing_featured",
  119. 'type' => 'checkbox',
  120. 'name' => __( 'Featured', 'no-translate' ),
  121. ),
  122. array(
  123. 'id' => "{$prefix}listing_sold",
  124. 'type' => 'checkbox',
  125. 'name' => __( 'Sold', 'no-translate' ),
  126. ),
  127. array(
  128. 'id' => "{$prefix}listing_sale_pending",
  129. 'type' => 'checkbox',
  130. 'name' => __( 'Sale Pending', 'no-translate' ),
  131. ),
  132. array(
  133. 'id' => "{$prefix}listing_reduced_price",
  134. 'type' => 'checkbox',
  135. 'name' => __( 'Price Reduced', 'no-translate' ),
  136. ),
  137. array(
  138. 'id' => "{$prefix}mls_no_maine",
  139. 'type' => 'text',
  140. 'name' => __( 'Maine MLS #', 'no-translate' ),
  141. ),
  142. array(
  143. 'id' => "{$prefix}mls_no_nh",
  144. 'type' => 'text',
  145. 'name' => __( 'New Hampshire MLS #', 'no-translate' ),
  146. ),
  147. array(
  148. 'id' => "{$prefix}listing_num",
  149. 'type' => 'text',
  150. 'name' => __( 'MLS Code:', 'no-translate' ),
  151. ),
  152. array(
  153. 'id' => "{$prefix}listing_address",
  154. 'type' => 'textarea',
  155. 'name' => __( 'Address', 'no-translate' ),
  156. ),
  157. // array(
  158. // 'id' => "{$prefix}listing_city",
  159. // 'type' => 'text',
  160. // 'name' => __( 'City', 'no-translate' ),
  161. // ),
  162. // array(
  163. // 'id' => "{$prefix}listing_state",
  164. // 'type' => 'text',
  165. // 'name' => __( 'State', 'no-translate' ),
  166. // ),
  167. // array(
  168. // 'id' => "{$prefix}listing_zip",
  169. // 'type' => 'text',
  170. // 'name' => __( 'Zip', 'no-translate' ),
  171. // ),
  172. array(
  173. 'id' => "{$prefix}listing_price",
  174. 'type' => 'text',
  175. 'name' => __( 'Price ($)', 'no-translate' ),
  176. ),
  177. array(
  178. 'id' => "{$prefix}listing_images",
  179. 'type' => 'image_advanced',
  180. 'name' => __( 'Images', 'no-translate' ),
  181. ),
  182. array(
  183. 'id' => "{$prefix}listing_the_realtors",
  184. 'type' => 'group',
  185. 'clone' => true,
  186. 'fields' => array(
  187. array(
  188. 'id' => "email",
  189. 'type' => 'email',
  190. 'name' => __( 'Email', 'no-translate' ),
  191. ),
  192. ),
  193. 'name' => __( 'Realtors', 'no-translate' ),
  194. ),
  195. array(
  196. 'id' => "{$prefix}listing_coordinates",
  197. 'type' => 'text',
  198. 'name' => __( 'Map', 'no-translate' ),
  199. ),
  200. )
  201. );
  202.  
  203. return $meta_boxes;
  204. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement