Advertisement
Guest User

Untitled

a guest
Jul 8th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.22 KB | None | 0 0
  1. <?php
  2.  
  3. class fire_island {
  4.  
  5. function __construct () {
  6.  
  7. $this->acf_required_fields = array('field_554add0107fe4', 'field_554adcf607fe3', 'field_554add9245c94', 'field_554ae220ba906', 'field_554ae2cfba907');
  8.  
  9. if(is_admin()) {
  10.  
  11. require_once (plugin_dir_path(__FILE__).'/include/Aidee-Optionz/options_class.php');
  12.  
  13. require_once (plugin_dir_path(__FILE__).'/include/Aidee-Formz/form_class.php');
  14.  
  15. require_once (plugin_dir_path(__FILE__).'include/Aidee-Optionz/options.php');
  16.  
  17. require_once(plugin_dir_path( __FILE__ ).'/include/Aidee-Upload-Class/basic_upload.php');
  18.  
  19. new uploader('upload_manager',
  20. array(
  21. 'upload_size_limit'=>'99999999999999',
  22. 'uploader_type'=>'upload',
  23. 'parent_class'=>'fire_island'
  24. ),
  25. array('xlsx'), array('application'));
  26.  
  27. }
  28.  
  29. add_action( 'wp_enqueue_scripts', array(&$this, 'enqueue_styles' ),15);
  30.  
  31. add_action( 'admin_enqueue_scripts', array(&$this, 'backend_enqueue_styles' ),15);
  32.  
  33. add_action('init', array(&$this, 'register_taxonomies'));
  34.  
  35. add_action ('init', array(&$this, 'register_post_types'));
  36.  
  37. add_action('admin_menu',array(&$this, 'cleanup_post_editor'));
  38.  
  39. // we're over-riding the parents property listing class with our own.
  40.  
  41. require_once( get_stylesheet_directory( __FILE__ ) . '/framework/admin/noo-property.php');
  42.  
  43. require_once( get_stylesheet_directory( __FILE__ ) . '/framework/admin/noo-agent.php');
  44.  
  45. require_once( plugin_dir_path( __FILE__ ) . '/framework/admin/meta-boxes/post-meta-boxes.php');
  46.  
  47. require_once( plugin_dir_path( __FILE__ ) . '/include/date_time.php');
  48.  
  49. add_action('add_meta_boxes', array(&$this, 'add_more_meta_boxes'));
  50.  
  51. add_action('add_meta_boxes', array(&$this, 'register_meta_boxes'), 1);
  52.  
  53. add_action( 'save_post', array(&$this, 'save_book_meta'), 10, 3 );
  54.  
  55. add_action('add_meta_boxes', array(&$this, 'register_quick_menu'), 1);
  56.  
  57. add_action( 'edit_form_after_title', array(&$this, 'cleanify_wp_editor' ));
  58.  
  59. add_action( 'edit_form_after_editor', array(&$this, 'cleanify_wp_editor_after' ));
  60.  
  61. add_filter( 'wp_mail_content_type', array(&$this, 'set_html_content_type'));
  62.  
  63. add_action('wp_ajax_event_calendar_change', array(&$this, 'update_side_bar_calendar'));
  64.  
  65. add_action('wp_ajax_nopriv_event_calendar_change', array(&$this, 'update_side_bar_calendar'));
  66.  
  67. add_action('wp_ajax_nopriv_xls_parser', array(&$this, 'xls_parser'));
  68.  
  69. add_action('wp_ajax_xls_parser', array(&$this, 'xls_parser'));
  70.  
  71. add_action('wp_ajax_show_cons_single_item', array(&$this, 'show_cons_single_item'));
  72.  
  73. add_action('wp_ajax_nopriv_show_cons_single_item', array(&$this, 'show_cons_single_item'));
  74.  
  75. add_filter( 'pre_get_posts', array(&$this, 'filter_pre_get_posts'));
  76.  
  77. add_filter('posts_where', array(&$this, 'no_privates'));
  78.  
  79. add_filter( 'wp_nav_menu_items', array(&$this, 'add_search_to_nav'));
  80.  
  81. /*
  82. $page = acf_add_options_page(array(
  83. 'page_title' => 'Fire Island Extra Options',
  84. 'menu_title' => 'Fire Island Command Center',
  85. 'menu_slug' => 'theme-general-settings',
  86. 'capability' => 'administrator',
  87. 'redirect' => false
  88. ));*/
  89.  
  90. add_shortcode('home_page_testimonials', array(&$this, 'home_page_testimonials'));
  91.  
  92. // adds lot # col sortable to post list.
  93.  
  94. add_filter('manage_edit-noo_property_columns', array(&$this, 'add_extra_column'));
  95.  
  96. add_action( 'manage_noo_property_posts_custom_column', array(&$this, 'add_column_content'), 10, 2 );
  97.  
  98. add_filter( 'manage_edit-noo_property_sortable_columns', array(&$this, 'resort_col' ));
  99.  
  100. add_action( 'pre_get_posts', array(&$this, 'resort_colums_filter' ));
  101.  
  102. // adds lot # col sortable to post list.
  103.  
  104. add_filter('manage_edit-noo_property_columns', array(&$this, 'add_post_status_extra_column'));
  105.  
  106. add_action( 'manage_noo_property_posts_custom_column', array(&$this, 'add_post_status_column_content'), 10, 2 );
  107.  
  108.  
  109. foreach ($this->acf_required_fields as $field ) {
  110.  
  111. add_filter("acf/load_field/key={$field}", array(&$this, 'my_acf_load_field'));
  112.  
  113. }
  114.  
  115. // these 6, yes count them 6 fucking filters/actions are ALL required to make our auto-emailer
  116. // work. We need to use the update_ hooks to store the updated data that we then use
  117. // to cross reference against our hidden data array to check if anythings change in the
  118. // wp_insert_post hook. Do not mess with these. Seriously, the kitten gets it if you do.
  119. //
  120. // This is the culmination of a 12 hour coding session, a lot of coffee and 1 step closer
  121. // to me going bald. FML.
  122.  
  123. if(is_admin() && $this->is_edit_page()) {
  124.  
  125.  
  126. add_action( 'wp_insert_post', array(&$this, 'auto_emailer_on_post_update'), 99999, 3 );
  127.  
  128. add_filter( "get_post_metadata", array(&$this, 'filter_get_post_meta'), true, 4);
  129.  
  130. add_action("update_post_metadata", array(&$this, 'filter_update_post_meta'), 10, 5);
  131.  
  132. add_action("update_post_meta", array(&$this, 'filter_update_post_meta'), 10, 5);
  133.  
  134. add_action("updated_postmeta", array(&$this, 'filter_update_post_meta'), 10, 5);
  135.  
  136. add_action("updated_post_meta", array(&$this, 'filter_update_post_meta'), 10, 5);
  137.  
  138. add_action('added_post_meta', array(&$this, 'filter_update_post_meta'), 10, 4 );
  139.  
  140. }
  141.  
  142. add_action( 'admin_menu', array(&$this, 'remove_default_metaboxes' ));
  143.  
  144. add_action( 'post_submitbox_misc_actions', array(&$this, 'show_modified_date' ));
  145.  
  146. require_once( get_stylesheet_directory( __FILE__ ) . '/include/acf-field-date-time-picker-master/acf-date_time_picker.php');
  147.  
  148. }
  149.  
  150. function show_modified_date() {
  151. if ( ! is_admin() )
  152. return;
  153.  
  154. global $post_ID;
  155. $post = get_post( $post_ID );
  156. ?>
  157. <div id="author" class="misc-pub-section" style="border-top-style:solid; border-top-width:1px; border-top-color:#EEEEEE; border-bottom-width:0px;">
  158. Last Modified:
  159. <?php the_modified_time('D M d Y g:i a');?>
  160. </div>
  161. <?php
  162. }
  163.  
  164.  
  165. function remove_default_metaboxes() {
  166. // Remove 'Keywords' (like tags) metabox
  167. remove_meta_box( 'tagsdiv-keyword', 'my-custom-post-type-slug', 'side' );
  168. // Remove 'Groups' (like categories) metabox
  169. remove_meta_box( 'groupdiv', 'my-custom-post-type-slug', 'side' );
  170. }
  171.  
  172. function cleanup_post_editor() {
  173.  
  174. foreach (array('noo_property','Testimonial','Event', 'concierge_service') as $post_type) {
  175.  
  176. remove_meta_box( 'authordiv',$post_type,'normal' );
  177. remove_meta_box( 'commentstatusdiv',$post_type,'normal' );
  178. remove_meta_box( 'commentsdiv',$post_type,'normal' );
  179. remove_meta_box( 'postcustom',$post_type,'normal' );
  180.  
  181. if($post_type!='concierge_service') remove_meta_box( 'postexcerpt',$post_type,'normal' );
  182.  
  183. remove_meta_box( 'revisionsdiv',$post_type,'normal' );
  184. remove_meta_box( 'slugdiv',$post_type,'normal' );
  185. remove_meta_box( 'tagsdiv-post_tag',$post_type,'normal' );
  186. remove_meta_box( 'pageparentdiv',$post_type,'normal' );
  187. remove_meta_box( 'trackbacksdiv',$post_type,'normal' );
  188. remove_meta_box('categorydiv', $post_type, 'normal');
  189.  
  190. }
  191.  
  192. }
  193.  
  194. function add_more_meta_boxes () { // hooks the noo featured image gallery to our post type for events
  195.  
  196. $helper = new NOO_Meta_Boxes_Helper($prefix, array('page' => 'event'));
  197.  
  198. $meta_box = array(
  199. 'id' => "{$prefix}_meta_box_gallery",
  200. 'title' => __('Gallery Settings', NOO_TEXT_DOMAIN),
  201. 'fields' => array(
  202. array(
  203. 'id' => "{$prefix}_gallery",
  204. // 'label' => __( 'Your Gallery', NOO_TEXT_DOMAIN ),
  205. 'type' => 'gallery',
  206. ),
  207. array(
  208. 'type' => 'divider',
  209. ),
  210. )
  211. );
  212.  
  213. $helper->add_meta_box($meta_box);
  214.  
  215. }
  216.  
  217. function list_all_sheets () {
  218.  
  219. global $wp_styles;
  220.  
  221. foreach ($wp_styles as $style) {
  222.  
  223. foreach ($style as $s) {
  224.  
  225. echo "<li>Source:$s->src</li>";
  226. echo "<li>Handle:$s->handle</li>";
  227.  
  228. }
  229. }
  230.  
  231. }
  232.  
  233. function register_post_types () {
  234.  
  235. include_once (get_stylesheet_directory(__FILE__) . '/include/register_post_types.php'); // Handles the vim section. Modifying vims, membership renewal etc.
  236.  
  237. new aidee_register_cpt('Testimonial');
  238.  
  239. new aidee_register_cpt('Event');
  240.  
  241. new aidee_register_cpt('Concierge Service');
  242.  
  243. }
  244.  
  245. function register_taxonomies () {
  246.  
  247. include_once (get_stylesheet_directory(__FILE__) . '/include/taxon_register.php'); // Handles the vim section. Modifying vims, membership renewal etc.
  248.  
  249. new taxonomy_register("market_availability", 'noo_property');
  250.  
  251. new taxonomy_register("property_features", 'noo_property');
  252.  
  253. }
  254.  
  255. function is_edit_page($new_edit = null){
  256.  
  257. global $pagenow;
  258.  
  259. if (!is_admin()) return false;
  260.  
  261. if($new_edit == "edit")
  262. return in_array( $pagenow, array( 'post.php', ) );
  263. elseif($new_edit == "new") //check for new post page
  264. return in_array( $pagenow, array( 'post-new.php' ) );
  265. else //check for either new or edit
  266. return in_array( $pagenow, array( 'post.php', 'post-new.php' ) );
  267.  
  268. }
  269.  
  270. function filter_get_post_meta ($metadata, $object_id, $meta_key, $single) {
  271.  
  272. // we use this function to build and hide an array of fields propogated on post load in the editor.
  273. // we will be using these in conjuction with the wp_insert_post hook above, and the updated_post
  274. global $post;
  275.  
  276. remove_filter( "get_post_metadata", array(&$this, 'filter_get_post_meta'), true, 4);
  277.  
  278. $current_meta = urlencode(serialize(get_post_meta($post->ID , $meta_key)));
  279.  
  280. add_filter( "get_post_metadata", array(&$this, 'filter_get_post_meta'), true, 4);
  281.  
  282. echo "<input type='hidden' class='hide_me_away' value='{$current_meta}' name='check_sum[$meta_key]'>";
  283.  
  284. }
  285.  
  286. function filter_update_post_meta ( $null, $object_id, $meta_key, $meta_value, $nah='') {
  287.  
  288. $this->changed_values[$meta_key] = $meta_value;
  289.  
  290. }
  291.  
  292. function resort_colums_filter( $query ) {
  293.  
  294. if( ! is_admin() )
  295. return;
  296.  
  297. $orderby = $query->get( 'orderby');
  298.  
  299. if( 'lot_nmb' == $orderby ) {
  300.  
  301. $query->set('meta_key','lot_nmb');
  302.  
  303. $query->set('orderby','meta_value_num');
  304.  
  305. }
  306.  
  307. }
  308.  
  309. function resort_col( $columns ) {
  310.  
  311. $columns['lot_nmb'] = 'lot_nmb';
  312.  
  313. return $columns;
  314. }
  315.  
  316. function add_post_status_column_content( $column_name, $post_id ) {
  317.  
  318. if ( 'lot_nmb' != $column_name )
  319. return;
  320.  
  321. $slices = get_post_meta($post_id, 'lot_nmb', true);
  322.  
  323. if($slices==0) {echo "Not Set";return;}
  324.  
  325. echo intval($slices);
  326.  
  327. }
  328.  
  329. function add_post_status_extra_column($columns) {
  330.  
  331. $columns['property_status'] = 'Property Status';
  332.  
  333. return $columns;
  334.  
  335. }
  336.  
  337. function add_column_content( $column_name, $post_id ) {
  338.  
  339. if ( 'property_status' != $column_name )
  340. return;
  341.  
  342. $terms = wp_get_post_terms($post_id, 'property_category');
  343.  
  344.  
  345. if($terms) foreach($terms as $term) {
  346.  
  347. echo $term->name." ";
  348.  
  349. }
  350.  
  351. }
  352.  
  353. function add_extra_column($columns) {
  354.  
  355. $columns['lot_nmb'] = 'Lot Number';
  356.  
  357. return $columns;
  358.  
  359. }
  360.  
  361.  
  362. function add_search_to_nav($menu) {
  363.  
  364. if (!is_user_logged_in()) {
  365.  
  366. return $menu;
  367.  
  368. } else {
  369.  
  370.  
  371. $profilelink = "<li class='nav_bar_search fa_awesome fa_awesome-search'></li>";
  372. $menu = $menu . $profilelink;
  373. return $menu;
  374.  
  375. }
  376.  
  377. }
  378.  
  379. function no_privates($where) { // hides/filters posts marked private from the front end.
  380.  
  381. if( is_admin() ) return $where;
  382.  
  383. global $wpdb;
  384.  
  385. return " $where AND {$wpdb->posts}.post_status != 'private' ";
  386.  
  387. }
  388.  
  389. function filter_pre_get_posts( $query ) { // changes PPP for concierge CPT
  390.  
  391. if(is_post_type_archive('concierge_service')) {
  392.  
  393. $query->set( 'posts_per_page',99 );
  394.  
  395. }
  396.  
  397. }
  398.  
  399.  
  400. function noo_social_icons($position = 'topbar', $direction = '') {
  401.  
  402. if ($position == 'topbar') {
  403. // Top Bar social
  404. } else {
  405. // Bottom Bar social
  406. }
  407.  
  408. $class = isset($direction) ? $direction : '';
  409. $html = array();
  410. $html[] = '<div class="noo-social social-icons ' . $class . '">';
  411.  
  412. $social_list = array(
  413. 'facebook' => __('Facebook', NOO_TEXT_DOMAIN) ,
  414. 'twitter' => __('Twitter', NOO_TEXT_DOMAIN) ,
  415. 'google' => __('Google+', NOO_TEXT_DOMAIN) ,
  416. 'pinterest' => __('Pinterest', NOO_TEXT_DOMAIN) ,
  417. 'linkedin' => __('LinkedIn', NOO_TEXT_DOMAIN) ,
  418. 'rss' => __('RSS', NOO_TEXT_DOMAIN) ,
  419. 'youtube' => __('YouTube', NOO_TEXT_DOMAIN) ,
  420. 'instagram' => __('Instagram', NOO_TEXT_DOMAIN) ,
  421. );
  422.  
  423. $social_html = array();
  424. foreach ($social_list as $key => $title) {
  425.  
  426. $social = noo_get_option("noo_social_{$key}", '');
  427.  
  428. if ($social) {
  429.  
  430. $social_html[] = '<a href="' . $social . '" title="' . $title . '" target="_blank">';
  431. $social_html[] = '<div class="nav_share fa_awesome fa_awesome-' . $key . '-square"></div>';
  432. $social_html[] = '</a>';
  433.  
  434. }
  435.  
  436. }
  437.  
  438. if(empty($social_html)) {
  439. $social_html[] = __('No Social Media Link',NOO_TEXT_DOMAIN);
  440. }
  441.  
  442. $html[] = implode($social_html, "\n");
  443. $html[] = '</div>';
  444.  
  445. echo implode($html, "\n");
  446. }
  447.  
  448. function render_menu_search_form () {
  449.  
  450. echo "<div id='menu_foldout_search' class='animoot menu_search_form_outter_wrapper minimized'>";
  451. NooProperty::advanced_map( false, '', true, '', false, $no_search_container,
  452. $source,!!$disable_search_form,$show_advanced_search_field, $map_height);
  453. echo "</div>";
  454.  
  455. }
  456.  
  457. function show_cons_single_item () {
  458.  
  459. if (is_numeric($_POST['post_id'])) {
  460.  
  461. $post = get_post($_POST['post_id'], ARRAY_A);
  462.  
  463. include_once (get_stylesheet_directory(__FILE__) . '/templates/concierge/single_item.php'); // Handles the vim section. Modifying vims, membership renewal etc.
  464.  
  465. } else {
  466.  
  467. $content.='Sorry, nothing found';
  468.  
  469. }
  470.  
  471. echo $content;
  472.  
  473. die;
  474.  
  475. }
  476. function update_side_bar_calendar() {
  477.  
  478. $the_date = (Aidee_date::validateDate($_POST['variables']['date'], 'Y-m-d') && $_POST['variables']['type']='date_change')
  479. ? $_POST['variables']['date']
  480. : "";
  481.  
  482. $what_date_are_we_showing = Aidee_date::flip_around_dates ($from_format = 'Y-m-d', $to_format = 'D M j', $the_date);
  483.  
  484. $query_args = array(
  485. 'post_type' => 'event',
  486. 'paged' => 0,
  487. 'posts_per_page' => -1,
  488. 'post_status' => 'publish',
  489. 'meta_key' => 'latest_date',
  490. 'orderby' => 'meta_value_num',
  491. 'meta_query' => array(
  492. 'relation' => 'AND',
  493. array(
  494.  
  495. 'key' => 'booked_dates',
  496. 'value' => $the_date,
  497. 'compare' => 'LIKE',
  498.  
  499. ),
  500.  
  501. ),
  502.  
  503. );
  504.  
  505.  
  506. $side_bar_posts = new WP_Query($query_args);
  507.  
  508. include(plugin_dir_path(__FILE__)."/templates/event/build_side_bar.php");
  509.  
  510. echo $string;
  511.  
  512. exit;
  513.  
  514. }
  515.  
  516. function get_all_attached_images ($post_id) {
  517.  
  518. $images = array();
  519.  
  520. foreach (get_attached_media( 'image', $post_id ) as $image) {
  521.  
  522. $get_image = wp_get_attachment_image_src( $image->ID, 'large' );
  523.  
  524. $images[] = array(
  525. 'url'=>$get_image[0],
  526. 'title'=>$image->post_title,
  527. 'caption'=>$image->post_excerpt
  528. );
  529.  
  530. }
  531.  
  532. return $images;
  533.  
  534. }
  535.  
  536. function get_featured_image ($post_id, $size='size') { //used to get first/featured post attached to post. If none found, we check for ANY attached picture. Failing that
  537. // we return a placeholder image.
  538.  
  539. $first_image = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), ($size) ? $size : 'large' );
  540.  
  541. if(!$first_image) {
  542.  
  543. foreach (get_attached_media( 'image',$post_id ) as $image) {
  544.  
  545. $get_image = wp_get_attachment_image_src( $image->ID, ($size) ? $size : 'large' );
  546.  
  547. $first_image[] = $get_image[0];
  548.  
  549. }
  550.  
  551. }
  552.  
  553. if (!$first_image)
  554. $first_image[0] = 'http://placehold.it/350x155';
  555.  
  556. return $first_image[0];
  557.  
  558. }
  559.  
  560. function home_page_testimonials() {
  561.  
  562. $posts = new wp_query( array('posts_per_page' => 3, 'post_type' => 'testimonial'));
  563.  
  564. if($posts->have_posts()) {
  565.  
  566. while($posts->have_posts()) {
  567.  
  568. $string = '';
  569.  
  570. $posts->the_post();
  571.  
  572. $post_content = apply_filters('the_content', get_post_field('post_content', $posts->id));
  573.  
  574. $img = $this->get_featured_image($posts->id);
  575.  
  576. $header = get_field('name_of_person', $posts->id);
  577.  
  578. $sub_header = get_field('small_quote', $posts->id);
  579.  
  580. $string.="<div class='testimonial-desc'>";
  581.  
  582. $string.=$post_content;
  583.  
  584. $string.="</div>";
  585.  
  586. $string.="<div class='our-customer-info col-md-4 col-md-offset-4'>";
  587.  
  588. $string.="<a class='col-sm-6' href='#'><img class='alignnone size-full wp-image-6501' src='{$img}' alt='customer' width='70' height='70' /></a>";
  589.  
  590. $string.="<div class='custom-desc col-sm-6'>";
  591.  
  592. $string.="<h4>{$header}</h4>";
  593.  
  594. $string.=$sub_header;
  595.  
  596. $string.="</div>";
  597.  
  598. $string.="</div>";
  599.  
  600. $content.=do_shortcode("[slide type='content']" . $string . "[/slide]");
  601.  
  602. }
  603.  
  604. return do_shortcode("[slider animation='slide' slider_time='3000' slider_speed='600' indicator_position='top' visibility='all' indicator='true' class=' testimonial-slide']".$content."[/slider]");
  605.  
  606. }
  607.  
  608. }
  609.  
  610. function set_html_content_type() {
  611.  
  612. return 'text/html';
  613.  
  614. }
  615.  
  616.  
  617. function send_email ($email='pcmagician@hotmail.com', $title = 'Test', $template='property_update_notice', $post=false) {
  618.  
  619. if(!$post) global $post;
  620.  
  621. $site_name = get_bloginfo('name');
  622.  
  623. $admin_email = get_bloginfo('admin_email');
  624.  
  625. $email = array();
  626.  
  627. $email = 'pcmagician@hotmail.com';
  628.  
  629. //$email[] = 'jessica@fireislandpines.com';
  630.  
  631. $email[] = 'justin_a_lindsay@hotmail.com';
  632.  
  633. $headers[] = "From: $site_name <$admin_email>";
  634.  
  635. //$headers[] = 'Cc: Jessica K <jessica@fireislandpines.com>;';
  636.  
  637. //$headers[] = 'Cc: Justin L <justin_a_lindsay@hotmail.com>;';
  638.  
  639. require_once( plugin_dir_path( __FILE__ ) . '/include/css-inline-class/CssToInlineStyles.php');
  640.  
  641. $css = file_get_contents(plugin_dir_path( __FILE__ ). 'c_assets/css/emailers.css'); // pulls in stylesheet and does its thing.
  642.  
  643. $message.= "<div class='email_body'>";
  644.  
  645. include_once(plugin_dir_path(__FILE__)."/templates/email/header.php");
  646.  
  647. if($template && file_exists(plugin_dir_path(__FILE__)."/templates/email/$template")) {
  648.  
  649. include_once(plugin_dir_path(__FILE__)."/templates/email/$template");
  650.  
  651. } else {
  652.  
  653. //$message.="no $template";
  654.  
  655.  
  656. }
  657.  
  658. ob_start();
  659.  
  660. $message.=ob_get_contents();
  661.  
  662. $message.= "</div>";
  663.  
  664. $emogrifier = new \Pelago\Emogrifier($message, $css);
  665.  
  666. $message = $emogrifier->emogrify();
  667.  
  668. echo($message);
  669.  
  670. wp_mail($email, $title, $message, $headers);
  671.  
  672.  
  673.  
  674. }
  675.  
  676. function searchArrayValueByKey(array $array, $search) {
  677.  
  678. foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($array)) as $key => $value) {
  679. if ($search === $key)
  680.  
  681. return $value;
  682.  
  683. }
  684.  
  685. return false;
  686.  
  687. }
  688.  
  689. function get_agent_email_list () {
  690.  
  691. $query_args = array(
  692.  
  693. 'post_type' => 'event',
  694. 'paged' => 0,
  695. 'posts_per_page' => -1,
  696.  
  697. );
  698.  
  699. $agents = new WP_Query($query_args);
  700.  
  701. if($agents->have_posts()) while($agents->have_posts()) {
  702.  
  703. $agents->the_post();
  704.  
  705. echo the_title();
  706.  
  707. }
  708.  
  709. die;
  710.  
  711. }
  712. function auto_emailer_on_post_update($post_id, $post, $updated) {
  713.  
  714.  
  715. global $post;
  716.  
  717. //$agent_email_list = $this->get_agent_email_list();
  718.  
  719. if(!$post->type == 'noo_property') return;
  720.  
  721. die;
  722.  
  723. $title = get_the_title($post->ID);
  724.  
  725. $user = wp_get_current_user();
  726.  
  727. $post_link = get_the_permalink($post->ID);
  728.  
  729. $name = $user->user_firstname . " " . $user->user_lastname;
  730.  
  731. $name = ($name) ? $name : $user->display_name;
  732.  
  733. foreach ($_POST['check_sum'] as $data=>$value){
  734.  
  735. if (!in_array($data,array('_thumbnail_id', '_edit_last'))) {
  736.  
  737. $conv_data = unserialize(urldecode($value));
  738.  
  739. $check_array[$data] = $conv_data[0] ;
  740.  
  741.  
  742. }
  743.  
  744. }
  745.  
  746. $result = array_diff($check_array, $this->changed_values);
  747.  
  748. if($result) {
  749.  
  750. $this->email_body.="<div class='main_message'>This email is to inform you that {$name} updated {$title}</div>";
  751.  
  752. $this->email_body.="<ul class='changes_list'>";
  753.  
  754. foreach ($result as $key=>$v) {
  755.  
  756. $this->email_body.="<li class='changes_made'>" . ucwords(str_replace(array('_'), array(' '), $key))."</li>";
  757.  
  758. }
  759.  
  760. $this->email_body.="</ul>";
  761.  
  762. $this->email_body.="<div class='main_message'>You can view this listing <a href='{$post_link}'>here</a></div>";
  763.  
  764. $this->send_email('pcmagician@hotmail.com', "{$title} has been updated by {$name}", 'property_update_notice.php');
  765.  
  766. }
  767.  
  768. }
  769.  
  770. function cleanify_wp_editor_after() {
  771.  
  772. global $post;
  773.  
  774. if($post->post_type=='noo_property' || $post->post_type=='event') {
  775.  
  776. echo "</div>";
  777.  
  778. }
  779.  
  780. }
  781.  
  782. function resort_meta_boxes ($custom_post_name='post') {
  783.  
  784. global $wp_meta_boxes;
  785.  
  786. $resorted = array(
  787. 'Rental Description'=>'0',
  788. 'Property Details'=>'1',
  789. 'Dates Booked'=>'2',
  790. 'Extra Property Info'=>'3',
  791. 'Property Media'=>'4',
  792. 'Contact Information'=>'5',
  793. 'Property Notes'=>'6',
  794. 'Place in Map'=>'7',
  795. );
  796.  
  797. foreach($wp_meta_boxes[$custom_post_name]['normal']['high'] as $k=>$v) {
  798.  
  799. if (key_exists($v['title'], $resorted)) {
  800.  
  801. $key = $resorted[$v['title']];
  802.  
  803. $array[$key] = $wp_meta_boxes[$custom_post_name]['normal']['high'][$k];
  804.  
  805. } else {
  806.  
  807. $after_array[$k] = $v;
  808.  
  809. }
  810.  
  811. }
  812.  
  813. ksort($array);
  814.  
  815. $wp_meta_boxes['noo_property']['normal']['high'] = array_merge($array, $after_array );
  816.  
  817. }
  818.  
  819. function sort_rental_pricing_keys ($prices){
  820.  
  821. $rent_order = array("Weekly"=>'0', 'Monthly'=>'1');
  822.  
  823. $shares_order = array("Quarter Share"=>'0', "Half Share"=>'1', "Full Season"=>'2', );
  824.  
  825. if(is_array($prices)) {
  826.  
  827. foreach($prices as $key=>$v) {
  828.  
  829. if(key_exists('share_type', $v)) { // Share handling
  830.  
  831. if(key_exists($v['share_type'], $shares_order)) {
  832.  
  833. $share_arrays[$shares_order[$v['share_type']]][] = $v;
  834.  
  835. }
  836.  
  837. }
  838.  
  839. if(key_exists('price_per', $v)) { // Share handling
  840.  
  841. if(key_exists($v['price_per'], $rent_order)) {
  842.  
  843. $share_arrays[$rent_order[$v['price_per']]][] = $v;
  844.  
  845. }
  846.  
  847. }
  848.  
  849. }
  850.  
  851. if (is_array($share_arrays)) ksort($share_arrays);
  852.  
  853. if(is_array($share_arrays)) $share_arrays = call_user_func_array('array_merge', $share_arrays);
  854.  
  855. return $share_arrays;
  856.  
  857. }
  858.  
  859. }
  860.  
  861. function cleanify_wp_editor() { // we're appending some things, and also changing the priority of a few things to achieve a nice
  862. // clean backend aesthetic.
  863.  
  864. global $post;
  865.  
  866. if($post->post_type=='noo_property') {
  867.  
  868. $post_type = NooProperty::check_prop_for_type($post->ID);
  869.  
  870. $class = ($post_type=='Both' || $post_type== 'Sale') ? '': "hide_post_editor";
  871.  
  872. echo "<div class='faux_post_editor_wrapper {$class}' id='main_post_editor'>";
  873.  
  874. echo '<h2 class="property_editor_first_editor">Sales Description</h2>';
  875.  
  876. $this->resort_meta_boxes('noo_property');
  877.  
  878. }
  879.  
  880. if($post->post_type=='event') {
  881.  
  882. echo "<div class='faux_post_editor_wrapper'>";
  883.  
  884. echo '<h2 class="property_editor_first_editor">Event Description</h2>';
  885.  
  886. }
  887.  
  888. }
  889.  
  890. function find_parent($array, $needle, $parent = null) {
  891.  
  892. foreach ($array as $key => $value) {
  893. if (is_array($value)) {
  894. $pass = $parent;
  895. if (is_string($key)) {
  896. $pass = $key;
  897. }
  898. $found = $this->find_parent($value, $needle, $pass);
  899. if ($found !== false) {
  900. return $found;
  901. }
  902. } else if ($key === 'id' && $value === $needle) {
  903. return $parent;
  904. }
  905. }
  906.  
  907. return false;
  908. }
  909.  
  910.  
  911. function show_template() {
  912. global $template;
  913. print_r($template);
  914. }
  915.  
  916. function add_quick_menu () {
  917.  
  918. echo "<div>";
  919.  
  920. echo "<li><a href='#titlediv'>Top</a></li>";
  921.  
  922. echo "<li><a href='#property_detail'>Property Details</a></li>";
  923.  
  924. echo "<li><a href='#property_video'>Media</a></li>";
  925.  
  926. echo "<li><a href='#acf-group_555035ed212aa'>Contact Info</a></li>";
  927.  
  928. echo "<li><a href='#acf-group_555035ed30e34'>Extra Info</a></li>";
  929.  
  930. echo "<li><a href='#acf-group_555035ed43e76'>Notes</a></li>";
  931.  
  932. echo "<li><a href='#datepicker'>Booking Dates</a></li>";
  933.  
  934. echo "<li><a href='#property_map'>Property Map</a></li>";
  935.  
  936. echo "</div>";
  937.  
  938.  
  939. }
  940.  
  941. function register_quick_menu () {
  942.  
  943. remove_filter( 'user_can_richedit' , array(&$this, 'remove_advanced_edit'));
  944.  
  945. add_meta_box( 'quick_menu', 'Quick Nav', array( $this, 'add_quick_menu' ), 'noo_property', 'normal', 'low');
  946.  
  947. }
  948.  
  949.  
  950. function my_acf_load_field($field) {
  951.  
  952. $field['required'] = true;
  953.  
  954. return $field;
  955.  
  956. }
  957.  
  958. function save_book_meta ($post_id) {
  959.  
  960. if($_POST['booked_dates']) $dates = explode(", ", $_POST['booked_dates']);
  961.  
  962. if(is_array($dates)) {
  963.  
  964. foreach ($dates as $date) {
  965.  
  966. if(Aidee_date::validateDate($date, 'Y-m-d')) {
  967.  
  968. $valid_dates[] = $date;
  969.  
  970. }
  971.  
  972. }
  973.  
  974. reset($valid_dates); // we're grabbing the first date and storing it separately for queries
  975.  
  976. $first_date = str_replace('-', '', $valid_dates[key($valid_dates)]);
  977.  
  978. end($valid_dates); // we're also grabbing the last date and storing it separately for queries
  979.  
  980. $last_date = str_replace('-', '', $valid_dates[key($valid_dates)]);
  981.  
  982. update_post_meta($post_id, 'booked_dates', $valid_dates);//$valid_dates);
  983.  
  984. update_post_meta($post_id, 'earliest_date', $first_date);
  985.  
  986. update_post_meta($post_id, 'latest_date', $last_date);
  987.  
  988. } else {
  989.  
  990. update_post_meta($post_id, 'booked_dates', null);
  991.  
  992. update_post_meta($post_id, 'earliest_date', null);
  993.  
  994. update_post_meta($post_id, 'latest_date', null);
  995.  
  996. }
  997.  
  998.  
  999.  
  1000. }
  1001.  
  1002. function register_meta_boxes () {
  1003.  
  1004. foreach (array('noo_property'=>'Dates Booked','Event'=>'Dates of Event') as $post_type=>$title) {
  1005. add_meta_box( 'datepicker', $title, array( $this, 'add_date_picker' ), $post_type, 'normal', 'high');
  1006. }
  1007.  
  1008. }
  1009.  
  1010. function add_date_picker ($post, $args) {
  1011.  
  1012.  
  1013. $meta_values = get_post_meta( $post->ID, 'booked_dates', true);
  1014.  
  1015. wp_localize_script('fi_back_end_scripts', 'data_obj', array('dates_booked'=>$meta_values));
  1016.  
  1017. if ($post->post_type == 'noo_property') {
  1018.  
  1019. echo "<span class='meta_helper'>";
  1020.  
  1021. echo "<p>To mark a date as booked, just click the date. Highlighted dates indicate they are booked. Clicking a date a second time";
  1022. echo "will remove the booking for that date.</p>";
  1023.  
  1024. echo "</span>";
  1025. }
  1026.  
  1027. if ($post->post_type == 'event') {
  1028.  
  1029. echo "<span class='meta_helper'>";
  1030.  
  1031. echo "<p>To setup dates an event is available, merely click on dates in the calendar to highlight them. If an event spans multiple dates,";
  1032. echo "then it will show up throughout dates in that range.</p>";
  1033.  
  1034. echo "<p>When a user is viewing the events on the front end, events marked with dates that are expired (Past the current date vs the dates";
  1035. echo "it's available), it will automaticall hide the event.</p>";
  1036.  
  1037. echo "</span>";
  1038.  
  1039. }
  1040.  
  1041. echo "<div id='datepicker'></div>";
  1042.  
  1043. echo "<input type='hidden' id='booked_dates' name='booked_dates'>";
  1044.  
  1045. }
  1046.  
  1047. function backend_enqueue_styles ($hook) { // teh backends
  1048.  
  1049. wp_enqueue_script('jquery-ui-core');
  1050.  
  1051. wp_register_style('back_end_css', get_stylesheet_directory_uri() . '/c_assets/css/back_end.css');
  1052.  
  1053. wp_register_style('emailer_style', get_stylesheet_directory_uri() . '/c_assets/css/emailers.css');
  1054.  
  1055. wp_enqueue_style('emailer_style');
  1056.  
  1057. wp_enqueue_style('back_end_css');
  1058.  
  1059. if($hook=='post.php') {
  1060.  
  1061. $this->date_picker();
  1062.  
  1063. wp_enqueue_script('date_picker_extension');
  1064.  
  1065. }
  1066.  
  1067. wp_register_script('fi_back_end_scripts', get_stylesheet_directory_uri() . '/c_assets/js/back_end.js', null, null, true);
  1068.  
  1069. wp_enqueue_script('fi_back_end_scripts');
  1070.  
  1071. }
  1072.  
  1073. function enqueue_styles ($hook) { // for front end
  1074.  
  1075. wp_dequeue_style( 'noo-main-style' );
  1076.  
  1077. wp_register_style('noo-main-style-child', get_stylesheet_directory_uri() . '/assets/css/noo.css');
  1078.  
  1079. wp_enqueue_style('noo-main-style-child');
  1080.  
  1081. wp_register_style('unified', get_stylesheet_directory_uri() . '/assets/css/unified.css');
  1082.  
  1083. wp_enqueue_style('unified');
  1084.  
  1085. wp_register_style('font-awesome2', get_stylesheet_directory_uri() . '/assets/font-awesome/css/font-awesome.css');
  1086.  
  1087. wp_enqueue_style('font-awesome2');
  1088.  
  1089. wp_register_script('equalizer', get_stylesheet_directory_uri() . '/c_assets/js/equalize.js', null, null, true);
  1090.  
  1091. wp_enqueue_script('equalizer');
  1092.  
  1093. wp_register_script('concierge', get_stylesheet_directory_uri() . '/c_assets/js/concierge.js', null, null, true);
  1094.  
  1095. wp_register_script('property_script', get_stylesheet_directory_uri() . '/c_assets/js/property_script.js', null, null, true);
  1096.  
  1097. wp_register_script('property_calendar', get_stylesheet_directory_uri() . '/c_assets/js/property_calendar.js', null, null, true);
  1098.  
  1099. $this->date_picker();
  1100.  
  1101. $this->magnificent();
  1102.  
  1103. $this->simple_slider();
  1104.  
  1105. $this->front_end_calendar_js_hook();
  1106.  
  1107. $this->jssor_slider();
  1108.  
  1109. }
  1110.  
  1111. function date_picker () {
  1112.  
  1113. wp_register_style('date_picker_css', get_stylesheet_directory_uri() . '/c_assets/css/jquery-date-picker.css');
  1114.  
  1115. wp_enqueue_style('date_picker_css');
  1116.  
  1117. wp_register_script('date_picker_extension', get_stylesheet_directory_uri() . '/c_assets/js/date-picker-extension.js', null, null, true);
  1118.  
  1119. }
  1120.  
  1121. function magnificent () {
  1122.  
  1123. wp_register_script('magnificent', get_stylesheet_directory_uri() . '/c_assets/magnificent/magnific-popup.js', null, null, true);
  1124.  
  1125. wp_register_script('magnificent_trigger', get_stylesheet_directory_uri() . '/c_assets/magnificent/trigger.js', null, null, true);
  1126.  
  1127. wp_enqueue_script('jQuery');
  1128.  
  1129. wp_enqueue_script('magnificent');
  1130.  
  1131. wp_enqueue_script('magnificent_trigger');
  1132.  
  1133. wp_register_style('magnificent_css', get_stylesheet_directory_uri() . '/c_assets/magnificent/magnific-popup.css');
  1134.  
  1135. wp_enqueue_style('magnificent_css');
  1136.  
  1137. }
  1138.  
  1139. function simple_slider () {
  1140.  
  1141. wp_register_script('simple_slider', get_stylesheet_directory_uri() . '/c_assets/js/simple_slide.js', null, null, true);
  1142.  
  1143. wp_register_style('simple_slider', get_stylesheet_directory_uri() . '/c_assets/css/simple_slide.css');
  1144.  
  1145. wp_enqueue_style('simple_slider');
  1146.  
  1147. }
  1148. function upload_manager ($uploaded_file) {
  1149.  
  1150. return wp_send_json(array('error'=>$uploaded_file['error'], 'results'=>$uploaded_file['message'], 'file_path'=>$uploaded_file['file']));
  1151.  
  1152. }
  1153.  
  1154. function merge_row_and_columns ($spread_sheet, $sheet_were_on, $row_were_on) {
  1155.  
  1156. $data_heads = $spread_sheet->rows($sheet_were_on)[0];
  1157.  
  1158. $data = $spread_sheet->rows($sheet_were_on)[$row_were_on];
  1159.  
  1160. foreach($data_heads as $k=>$v)
  1161. $array[str_replace(array(' ', '#', "$"), array('_','nmb', ''), $v)] = $data[$k];
  1162.  
  1163. return $array;
  1164.  
  1165. }
  1166.  
  1167. function get_row_and_colum_count ($spread_sheet, $sheet_were_on=1) {
  1168.  
  1169. $sheet_count = count($spread_sheet->sheetNames());
  1170.  
  1171. $columns_count = count($spread_sheet->rows($sheet_were_on));
  1172.  
  1173. return array('cols'=>$columns_count, 'sheets'=>$sheet_count);
  1174.  
  1175. }
  1176.  
  1177. function just_add_a_term($taxonomy, $term, $post_id) {
  1178.  
  1179. $term_id = term_exists( $term, $taxonomy);
  1180.  
  1181. if($term_id!=null) {
  1182. wp_set_post_terms( $post_id, $term_id, $taxonomy, true );
  1183. }
  1184.  
  1185. }
  1186.  
  1187. function create_imported_property_add_terms_compared($data_merged, $post_id, $array=array(), $taxonomy='', $compare_key) {
  1188.  
  1189. // checks to see if a specfic imported data array key is set again an array, and adds it to the term list if it is.
  1190.  
  1191. foreach($array as $k=>$v) {
  1192.  
  1193. if($data_merged[$compare_key]==$k) {
  1194.  
  1195. $term_id = term_exists( $v, $taxonomy);
  1196.  
  1197. if($term_id!=null) {
  1198.  
  1199. $term_id_array[] = $term_id['term_id'];
  1200.  
  1201. }
  1202.  
  1203. }
  1204.  
  1205. }
  1206.  
  1207. wp_set_post_terms( $post_id, $term_id_array, $taxonomy, FALSE );
  1208.  
  1209. }
  1210.  
  1211. function create_imported_property_add_terms($data_merged, $post_id, $array=array(), $taxonomy='') {
  1212.  
  1213. // This function just checks to see if the imported data is set within the array, and then sets the tax term if it does.
  1214. // useful for importing multiple taxonomies.
  1215.  
  1216. foreach($array as $k=>$v) {
  1217.  
  1218. if($data_merged[$k]!='') {
  1219.  
  1220. $term_id = term_exists( $v, $taxonomy);
  1221.  
  1222. if($term_id!=null) {
  1223.  
  1224. $term_id_array[] = $term_id['term_id'];
  1225.  
  1226. }
  1227.  
  1228. }
  1229.  
  1230. }
  1231.  
  1232. wp_set_post_terms( $post_id, $term_id_array, $taxonomy, FALSE );
  1233.  
  1234. }
  1235.  
  1236. function create_imported_property_create_data ($data_merged, $post_id, $title, $already_exists) {
  1237.  
  1238. /////////////////////////////////////// Tagging Features ///.//////////////////////////////////////////////////
  1239.  
  1240. $features_array = array('Fpl'=>'Fire Place (Gas)',
  1241. 'Pool'=>'Pool',
  1242. 'H/T'=>'Hot Tub',
  1243. 'A/C'=>'AC'
  1244. );
  1245.  
  1246. /////////////////////////////////////// Rental Information ///.//////////////////////////////////////////////////
  1247.  
  1248. if($data_merged['Rent_']!='' || $data_merged['Rent']!='') {
  1249.  
  1250. $old_pricing_info = get_field('field_55504b2c23183', $post_id); // contact_info
  1251.  
  1252. if(!$old_pricing_info) {
  1253.  
  1254. $old_pricing_info = array();
  1255.  
  1256. }
  1257.  
  1258. $old_pricing_info[] = array('price'=>($data_merged['Rent_']!='') ? $data_merged['Rent_'] : $data_merged['Rent'], // number_type
  1259. 'price_per'=>$data_merged['Term'] // number_number
  1260. );
  1261.  
  1262. update_field( 'field_55504b2c23183', $old_pricing_info, $post_id );
  1263.  
  1264. }
  1265.  
  1266. ///////////////////////////////// Contact Information section ///.//////////////////////////////////////////////////
  1267.  
  1268. $old_contact_info = get_field('field_554adcd507fe2', $post_id); // contact_info
  1269.  
  1270. if(!$old_contact_info)
  1271. $old_contact_info = array();
  1272.  
  1273. if($data_merged['Rent_'] || $data_merged['Rent']) {
  1274.  
  1275. $name = ($data_merged['Landlord']) ? explode(" ", $data_merged['Landlord']) : explode(" ", "None Entered") ;
  1276.  
  1277. } else {
  1278.  
  1279. $name = ($data_merged['Seller']) ? explode(" ", $data_merged['Seller']) : explode(" ", "None Entered") ;
  1280.  
  1281. }
  1282.  
  1283.  
  1284. $old_contact_info[] = array('field_554adcf607fe3' => $name[0], // first name
  1285. 'field_554add0107fe4' => $name[1],//last_name
  1286.  
  1287. 'field_554ae203ba905'=>array( // contact_numbers
  1288. array('number_type'=>'Phone', // number_type
  1289. 'number_number'=>($data_merged['Phone_nmb']) ? $data_merged['Phone_nmb'] : '000-000-0000' // number_number
  1290. )),
  1291.  
  1292. 'field_554add0707fe5'=> array( // email_address
  1293. array('email_addy'=>($data_merged['Email_']) ? $data_merged['Email_'] : "none@entered.com"
  1294. )), // email
  1295.  
  1296. 'field_55831cead156f' => ($data_merged['Listing_Price']!='') ? "Seller" : "Landlord",
  1297. );
  1298.  
  1299. /////////////////////////////////////// Address ///.//////////////////////////////////////////////////
  1300.  
  1301. update_field( 'field_554adcd507fe2', $old_contact_info, $post_id );
  1302.  
  1303. /////////////////////////////////////// Tagging ///.//////////////////////////////////////////////////
  1304.  
  1305. $status_array = array('OTM'=>'Off the Market', 'SOLD'=>'Sold');
  1306.  
  1307. $this->create_imported_property_add_terms($data_merged, $post_id, $features_array, 'property_features');
  1308.  
  1309. if($data_merged['Listing_Price'])
  1310. $this->just_add_a_term('property_category', 'Sale', $post_id);
  1311.  
  1312. if($data_merged['Rent_'] || $data_merged['Rent'])
  1313. $this->just_add_a_term('property_category', 'Rental', $post_id);
  1314.  
  1315. $this->create_imported_property_add_terms_compared($data_merged, $post_id, $status_array, 'market_availability', 'Status');
  1316.  
  1317. /////////////////////////////////////// Misc Data /////////////////////////////////////////////////////
  1318.  
  1319. $correlated_post_array = array('Listing_Price'=>'_price',
  1320. 'nmbBR'=>'_bedrooms',
  1321. 'nmbBTH'=>'_bathrooms',
  1322. 'Lot_Sz'=>'_area',
  1323. );
  1324.  
  1325. foreach($correlated_post_array as $key=>$value) {
  1326.  
  1327. if($key=='Listing_Price' && (!$data_merged['Listing_Price'])) continue; // because we dont want to override pricing
  1328.  
  1329. update_post_meta($post_id, $value, $data_merged[$key], true);
  1330.  
  1331. }
  1332.  
  1333. update_post_meta($post_id, '_address', $title, true);
  1334.  
  1335. $correlated_acf_array = array('Key_nmb'=>'field_554f041f53a00',
  1336. 'Pines_nmb'=>'field_55827f8769cb0',
  1337. 'Lot_nmb'=>'field_558271aa2e755',
  1338. 'Taxes'=>'field_55511f6faf880',
  1339. 'Keynmb'=>'field_554f041f53a00',
  1340. 'Notes'=>'agent_notes',
  1341. 'Walk'=>'walk');
  1342.  
  1343. foreach($correlated_acf_array as $key=>$value) {
  1344.  
  1345. if($value=='') continue; // so we dont overwrite values with blank data.
  1346.  
  1347. update_field( $value, $data_merged[$key], $post_id );
  1348.  
  1349. }
  1350.  
  1351. }
  1352.  
  1353. function create_imported_property ($data_merged, $title) {
  1354.  
  1355. remove_action( 'save_post_noo_property', array(&$this, 'auto_emailer_on_post_update'), 10, 3 ); // because yeah, we dont want to spam.
  1356.  
  1357. $already_exists = $this->wp_exist_post_by_title($title);
  1358.  
  1359. if($already_exists==null) {
  1360.  
  1361. $new_post = array(
  1362. 'post_title' => wp_strip_all_tags( $title ),
  1363. 'post_content' => 'Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem
  1364. Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum ',
  1365. 'post_status' => 'publish',
  1366. 'post_author' => 1,
  1367. 'post_type'=>'noo_property',
  1368. );
  1369.  
  1370. $post_id = wp_insert_post( $new_post );
  1371.  
  1372. $this->create_imported_property_create_data($data_merged, $post_id, $title, $already_exists);
  1373.  
  1374. return array('status'=>true, 'message'=>"{$title} Successfully Imported. ");
  1375.  
  1376. } else {
  1377.  
  1378. $post_id = $already_exists['ID'];
  1379.  
  1380. $this->create_imported_property_create_data($data_merged, $post_id, $title, $already_exists);
  1381.  
  1382. return array('status'=>false, 'message'=>"{$title} Already exists. Data appended instead. ");
  1383.  
  1384. }
  1385.  
  1386. }
  1387.  
  1388. function wp_exist_post_by_title($title_str) {
  1389.  
  1390. global $wpdb;
  1391.  
  1392. return $wpdb->get_row("SELECT ID FROM wp_posts WHERE post_type = 'noo_property' AND (post_title = '{$title_str}')", 'ARRAY_A');
  1393.  
  1394. }
  1395.  
  1396. function xls_parser ($sheet_were_on=1, $row_were_on=1) {
  1397.  
  1398. require_once (plugin_dir_path(__FILE__).'include/Excell_Parser/simplexlsx.class.php');
  1399.  
  1400. if (!file_exists($_POST['file_path'])) // checks to ensure we're parsing a file.
  1401. wp_send_json(array('results'=>$_POST['file_path'].'Not found, please try uploading a new file.'));
  1402.  
  1403. $sheet_were_on = (is_numeric($_POST['sheet_were_on'])) ? $_POST['sheet_were_on'] : $sheet_were_on;
  1404.  
  1405. $row_were_on = (is_numeric($_POST['row_were_on'])) ? $_POST['row_were_on'] : $row_were_on;
  1406.  
  1407. //if ($row_were_on>40) die;
  1408.  
  1409. $spread_sheet = new SimpleXLSX($_POST['file_path']);
  1410.  
  1411. $row_and_sheet_count = $this->get_row_and_colum_count($spread_sheet, $sheet_were_on);
  1412.  
  1413. $data_merged = $this->merge_row_and_columns($spread_sheet, $sheet_were_on, $row_were_on);
  1414.  
  1415. $results.="<h3 class='import_header'>Sheet Name: " . $spread_sheet->sheetNames()[$sheet_were_on] ."</h3>";
  1416.  
  1417. $results.="<li class='imported_row'><span class='field'>Sheet</span><span class='data'>{$sheet_were_on} of {$row_and_sheet_count['sheets']}</span></li> ";
  1418.  
  1419. $results.= "<li class='imported_row'><span class='field'>Row</span><span class='data'>{$row_were_on} of ".($row_and_sheet_count['cols']-1)."</span></li>";
  1420.  
  1421. foreach($data_merged as $k=>$v)
  1422. $results.="<li class='imported_row'><span class='field'>".str_replace(array('_','nmb', ''), array(' ', '#', "$"), $k)."</span> <span class='data'>$v</span></li>";
  1423.  
  1424. $title = ($data_merged['Lot_nmb']) ? $data_merged['Lot_nmb'] : "";
  1425.  
  1426. $title.= ($data_merged['Lot_nmb']) ? " " :"";
  1427.  
  1428. $title.= $data_merged['Walk'];
  1429.  
  1430. $title.= ($data_merged['Walk']) ? " Walk" : "";
  1431.  
  1432. $imported = $this->create_imported_property($data_merged, $title);
  1433.  
  1434. $results.= $imported['message'];
  1435.  
  1436. $done = false;
  1437.  
  1438. // do stuff here.
  1439.  
  1440. $row_were_on ++;
  1441.  
  1442. if ($row_were_on > $row_and_sheet_count['cols']) {
  1443.  
  1444. $sheet_were_on++;
  1445.  
  1446. $row_were_on = 1;
  1447.  
  1448. }
  1449.  
  1450. if ($sheet_were_on > $row_and_sheet_count['sheets']) {
  1451.  
  1452. $done = true;
  1453.  
  1454. }
  1455.  
  1456. wp_send_json(array('results'=>$results, 'sheet_were_on'=>$sheet_were_on, 'row_were_on'=>$row_were_on,'done'=>$done));
  1457.  
  1458. }
  1459.  
  1460. function jssor_slider ($hook='register') {
  1461.  
  1462. if($hook=='register') {
  1463.  
  1464. wp_register_script('jssor_1', get_stylesheet_directory_uri() . '/c_assets/jssor/js/jssor.js', null, null, true);
  1465.  
  1466. wp_register_script('jssor_2', get_stylesheet_directory_uri() . '/c_assets/jssor/js/jssor.slider.js', null, null, true);
  1467.  
  1468. wp_register_script('jssor_trigger', get_stylesheet_directory_uri() . '/c_assets/js/jssor-trigger.js', null, null, true);
  1469.  
  1470. wp_register_style('jssor-css', get_stylesheet_directory_uri() . '/c_assets/css/jssor.css');
  1471.  
  1472. }
  1473.  
  1474. if($hook=='queue') {
  1475.  
  1476. wp_enqueue_script('jssor_1');
  1477.  
  1478. wp_enqueue_script('jssor_2');
  1479.  
  1480. wp_enqueue_script('jssor_trigger');
  1481.  
  1482. wp_enqueue_style('jssor-css');
  1483.  
  1484. }
  1485.  
  1486. }
  1487.  
  1488. function front_end_calendar_js_hook () {
  1489.  
  1490. wp_register_style('front_end_event_calendar_style', get_stylesheet_directory_uri() . '/c_assets/fullcalendar/fullcalendar.min.css');
  1491.  
  1492. wp_register_script('front_end_event_calendar_moment', get_stylesheet_directory_uri() . '/c_assets/fullcalendar/lib/moment.min.js', null, null, true);
  1493.  
  1494. wp_register_script('front_end_event_calendar_base', get_stylesheet_directory_uri() . '/c_assets/fullcalendar/fullcalendar.js', null, null, true);
  1495.  
  1496. wp_register_script('front_end_event_calendar', get_stylesheet_directory_uri() . '/c_assets/js/event_calendar.js', null, null, true);
  1497.  
  1498. }
  1499.  
  1500. }
  1501.  
  1502.  
  1503.  
  1504. new fire_island();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement