Plugin Directory

Changeset 2999820


Ignore:
Timestamp:
11/22/2023 02:03:45 AM (2 years ago)
Author:
vistawp
Message:

Update to version 1.3.0 from GitHub

Location:
vistawp
Files:
10 added
18 edited
1 copied

Legend:

Unmodified
Added
Removed
  • vistawp/tags/1.3.0/css/admin.css

    r2949654 r2999820  
    104104}
    105105
     106#vistawp-banner{
     107display: grid;
     108grid-template-columns: 40px auto;
     109}
    106110
    107111
     112.vsta-text-error {
     113    color: #d63638;
     114    font-weight: bold;
     115}
    108116
     117.vsta-text-success {
     118    color: #00a32a;
     119    font-weight: bold;
     120}
     121
  • vistawp/tags/1.3.0/css/slideshow.css

    r2949654 r2999820  
     1* {
     2  box-sizing: border-box;
     3}
     4
    15.vista-grid-img {
    26  max-width: 100%;
     
    812}
    913
    10 
    1114.vista-grid-img:hover {
    1215  -ms-transform: scale(1.05); /* IE 9 */
     
    1417  transform: scale(1.05);
    1518}
     19
    1620/* Main CSS */
    1721.grid-wrapper > div {
     
    2024  align-items: center;
    2125}
     26
    2227.grid-wrapper > div > img {
    2328  width: 100%;
     
    3641  overflow: hidden;
    3742}
     43
    3844.grid-wrapper .wide {
    3945  grid-column: span 2;
    4046}
     47
    4148.grid-wrapper .tall {
    4249  grid-row: span 2;
    4350}
     51
    4452.grid-wrapper .big {
    4553  grid-column: span 2;
     
    8997    width:90%;
    9098  }
     99
    91100  .close{
    92101    top:25px;
     
    97106    top:50%;
    98107  }
    99 
    100 
    101 }
    102 
     108}
    103109
    104110.close:hover,
     
    110116
    111117/* Next & previous buttons */
    112 .vista-grid-prev,
    113 .vista-grid-next {
     118div .slideshow-container .vista-grid-prev,
     119div .slideshow-container .vista-grid-next {
    114120  cursor: pointer;
    115121  position: absolute;
     
    118124  padding: 16px;
    119125  margin-top: -50px;
    120   color: white;
     126  color: #fff;
    121127  font-weight: bold;
    122128  font-size: 20px;
    123129  transition: 0.6s ease;
    124   border-radius: 0 3px 3px 0;
    125130  user-select: none;
    126131  -webkit-user-select: none;
    127132  background-color: rgba(0, 0, 0, 0.8);
     133}
     134
     135div .slideshow-container .vista-grid-prev {
     136  border-radius: 0 3px 3px 0;
     137}
     138
     139div .slideshow-container .vista-grid-next {
     140  border-radius: 3px 0px 0px 3px;
    128141}
    129142
     
    140153}
    141154
    142 .mySlides {
     155.vista-slide-item {
    143156  display: none;
    144157}
     
    165178}
    166179
    167 
    168 .vista-scroller-photobanner:hover img{
    169 
    170 }
    171 
    172 * {
    173   box-sizing: border-box;
    174 }
    175 
    176 
     180.vista-scroller-photobanner:hover img{}
    177181
    178182.zoom {
     
    190194
    191195.zoom-main {
    192 
    193196  transition: transform .2s; /* Animation */
    194197}
     
    198201  transform: scale(1.1); /* (150% zoom - Note: if the zoom is too large, it will go outside of the viewport) */
    199202}
    200 
    201203
    202204/* Next & previous buttons */
     
    230232/* Slideshow container */
    231233.slideshow-container {
    232   max-width: 1000px;
     234  max-width: 100%;
     235  height: 100%;
    233236  position: relative;
     237  overflow: hidden;
    234238  margin: auto;
    235239  font-family: Verdana, sans-serif;
    236   margin: 0;
    237240}
    238241
    239242.slideshow-container * {box-sizing: border-box}
    240243.slideshow-container .otherSlides {display: none}
    241 .slideshow-container img {vertical-align: middle; max-height: 600px; width: auto;}
    242 
     244.slideshow-container img {
     245  vertical-align: middle;
     246  height: auto;
     247  width: 100%;
     248}
    243249
    244250/* Fading animation */
     
    265271}
    266272
    267 
    268273.grid-container {
    269274  padding: 10px;
     
    283288}
    284289
     290.thumbnails-carousel {
     291  height:150px !important;
     292  width:16.6%;
     293  display: inline-block;
     294  object-fit: cover;
     295}
     296
     297.slides-masonry {
     298  width:100%;
     299}
     300
     301#vista-grid-load-btn {
     302  width:100%;
     303}
     304
     305/* slide count element */
     306#vista-slide-number {
     307  top: 50px;
     308  z-index: 1;
     309  position: relative;
     310  float: right;
     311  padding: 8px;
     312  width: 40px;
     313  background:#000;
     314  color:#fff;
     315  text-align:center;
     316  margin-top: -50px;
     317  font-size: 9px;
     318  border-radius: 0px 0px 0px 3px;
     319  opacity: 0.6;
     320}
  • vistawp/tags/1.3.0/includes/listings/single-listing.php

    r2964274 r2999820  
    8383   */
    8484  protected function price_sqft_field(?int $price, ?int $sqft): void {
    85     if(
    86       isset( $price ) && !empty( $price ) &&
    87       isset( $sqft ) && !empty( $sqft )
    88     ) {
     85    if (!empty($price) && !empty($sqft)) {
    8986      try {
    90         $this->try_process_field( 'sqftPrice', $price / $sqft );
     87        $this->try_process_field('sqftPrice', $price / $sqft);
    9188
    9289      } catch(\Exception $e) {
    93         $this->try_process_field( 'sqftPrice', parent::ERROR );
    94 
     90        $this->try_process_field('sqftPrice', parent::ERROR);
    9591      }
    9692    } else {
     
    366362    if (is_null($value)) {
    367363      $this->try_process_field('photos', NULL);
     364
    368365      return;
    369366    }
    370367
    371     // Initialize an empty string to hold the HTML for the slideshow
    372     $photos = "";
    373 
    374     // Create a container for the slideshow
    375     $photos .= "<div class='slideshow-container'>";
    376 
    377     // Initialize a counter to keep track of the index of the current photo being displayed
    378     $slider_count = 0;
    379 
    380     // Loop through the array of photos and add <img> elements to the slideshow container
     368    // set slideshow
     369    $slideshow = '';
     370
     371    // Loops through the slideshow and adds `<img>` elements to the `$fields` array
    381372    foreach ($value as $photo) {
    382     // If this is the first photo in the array, give it a special CSS class to display it larger
    383       if ($slider_count == 0){
    384         $photos .= "<div class='mySlides fade' style='display:block;'>" . "<img class='vista-listing-photo zoom-main' src='$photo' style='display:block;' alt='Property photo'> " . "</div>";
    385       } else {
    386         // For all other photos, use a different CSS class
    387         $photos .= "<div class='mySlides fade otherSlides'>" . "<img class='vista-listing-photo' src='$photo' alt='Property photo'> " . "</div>";
     373      $other_slide = '';
     374      if (empty($slideshow)) {
     375        $other_slide = 'otherSlides';
    388376      }
    389       $slider_count++; // Increment the counter
    390     }
    391 
    392     // Close the slideshow container
    393     $photos .= "</div>";
    394 
    395     // Initialize another counter to keep track of the index of the current photo in the thumbnail banner
    396     $slider_count = 0;
    397 
    398     // Create a container for the thumbnail banner
    399     $photos .= "<div id='vista-scroller-container'><div class='vista-scroller-photobanner'>";
    400 
    401     // Loop through the array of photos again to create the thumbnail banner
    402     foreach ($value as $photo) {
    403       // Create an <img> element for each photo, with a click handler that will display the corresponding slide in the main slideshow
    404      
    405       $photos .= "<img class='zoom'  src='$photo' style='height:150px; width:16.6%;display: inline-block;object-fit: cover;' onclick='currentSlide($slider_count+1)' alt='The Woods'>";
    406 
    407       $slider_count++; // Increment the counter
    408     }
    409 
    410     // Close the thumbnail banner container and add previous/next buttons
    411     $photos .= "</div><a class='prev' onclick=" . "vista_scroller('left')" . ">&#10094;</a>" . "<a class='next' onclick='vista_scroller()'>&#10095;</a>" . "</div>";
    412 
    413     // Pass the HTML for the slideshow to a function that will process it and insert it into the page
    414     $this->try_process_field('photos', $photos);
    415 
    416     // Create a modal container for the slideshow
    417     $masonry = '<div id="myModal" class="modal">
    418     <span class="close cursor" onclick="closeModal()">&times;</span>
    419     <div class="modal-content">';
    420 
    421     // Loop through the array of photos again to create the slideshow inside the modal
    422     foreach ($value as $photo) {
    423      // Create an <img> element for each photo to be displayed in the modal slideshow
    424      $masonry .= "<div class='mySlides'>
    425       <img src='$photo' style='width:100%'></div>";
    426     } 
    427 
    428     // Close the modal container and add previous/next buttons
    429     $masonry .= '<a class="vista-grid-prev" onclick="plusSlides(-1)">&#10094;</a>
    430       <a class="vista-grid-next" onclick="plusSlides(1)">&#10095;</a></div></div>';
    431 
    432     // Create a grid of images with randomly assigned sizes
    433     $masonry .= '<div class="grid-wrapper">';
    434     $sizes = array("", "tall", "wide", "big", "", "tall", "wide");
    435     $masonryCount = 0 ;
    436 
    437     foreach ($value as $photo) {
    438       $random = array_rand($sizes, 2);
    439       $randomSize = $sizes[$random[0]];
    440       $masonry .= "<div class='$randomSize'>
    441             <img onclick='openModal();currentSlide($masonryCount+1)' class='vista-grid-img' src='$photo' /></div>";
    442       $masonryCount++;
    443     }
    444 
    445     $masonry .= '</div><div><button id="vista-grid-load-btn" onclick="vistaGridLoadMore()"style="width:100%" >Load More</button></div>';
    446 
    447     // Try to process the 'photos-masonry' field with the generated HTML
    448     $this->try_process_field('photos-masonry', $masonry);
    449   }
     377
     378      $slideshow .= "<div class='vista-slide-item fade {$other_slide}'><img class='vista-listing-photo' src='". esc_url($photo) ."' alt='Property photo'></div>";
     379    }
     380
     381    // Create a container for the slideshow and add previous/next buttons
     382    $slideshow_container = <<<EOD
     383<div id='vista-slide-number'></div>
     384<div class='slideshow-container'>
     385   %s
     386  <a class='vista-grid-prev' onclick='plusSlides(-1)'>&#10094;</a>
     387  <a class='vista-grid-next' onclick='plusSlides(1)'>&#10095;</a>
     388</div>
     389EOD;
     390
     391    $this->try_process_field(
     392      'photos',
     393      sprintf(
     394        $slideshow_container,
     395        $slideshow
     396      )
     397    );
     398  }
     399
    450400  /**
    451401   * Process the virtualTourUrl field into an unstyled <a> element with class vista-tour-button
     
    461411      $this->try_process_field('virtualTourUrl', "No virtual tour available");
    462412  }
    463 
    464413}
    465 
    466 
    467 
    468 
    469  ?>
  • vistawp/tags/1.3.0/includes/options/options-display.php

    r2949654 r2999820  
    88
    99/**
    10  * Adds options pages and defines their display HTML
    11  */
     10* Adds options pages and defines their display HTML
     11*/
    1212class Options_Display {
     13  /**
     14  * Option name for the listings page type.
     15  *
     16  * This constant holds the option name for the listings page type,
     17  * which is used to store and retrieve the page ID associated with
     18  * the 'listings' type of page.
     19  *
     20  * @var string
     21  */
     22  public const LISTINGS_OPTION = Generate_Pages::OPTION_PREFIX . 'listings';
     23 
     24  /**
     25  * Option name for the individual listings page type.
     26  *
     27  * This constant holds the option name for the individual listings
     28  * page type, which is used to store and retrieve the page ID associated
     29  * with the 'individual' type of page.
     30  *
     31  * @var string
     32  */
     33  public const INDIVIDUAL_OPTION = Generate_Pages::OPTION_PREFIX . 'individual';
     34 
     35  /**
     36  * Option name for the openhouse page type.
     37  *
     38  * This constant holds the option name for the openhouse page type,
     39  * which is used to store and retrieve the page ID associated with
     40  * the 'openhouse' type of page.
     41  *
     42  * @var string
     43  */
     44  public const OPENHOUSE_OPTION = Generate_Pages::OPTION_PREFIX . 'openhouse';
     45 
     46  /**
     47  * Singleton instance of this class
     48  * @var Options_Display
     49  */
     50  private static ?Options_Display $instance = NULL;
    1351
    1452  /**
    15    * Singleton instance of this class
    16    * @var Options_Display
     53   * The slug that should be used for the main page
     54   * when the View menu header is selected.
     55   * This slug should only be used for an Options_Page.
     56   *
     57   * @var string
    1758   */
    18   private static ?Options_Display $instance = NULL;
    19 
    20  /**
    21   * The options_page with this slug will be the default
    22   * selected page when the Vista menu header is selected.
    23   * This slug must only be used for one Options_Page
     59  public const MAIN_PAGE_SLUG = 'vista_main';
     60 
     61  /**
     62  * Default capability required to interact with vista settings
     63  * Individual pages may use this or set their own role requirement
    2464  * @var string
    2565  */
    26   public const DEFAULT_PAGE_SLUG = 'vista_default';
    27 
     66  public const VISTA_CAPABILITY = 'manage_options';
     67 
    2868  /**
    29    * Default capability required to interact with vista settings
    30    * Individual pages may use this or set their own role requirement
    31    * @var string
    32    */
    33   public const VISTA_CAPABILITY = 'manage_options';
    34 
     69  * This will be a file path to the icon for the
     70  * vista menu item
     71  * @var string
     72  */
     73  private string $icon_url;
     74 
    3575  /**
    36    * This will be a file path to the icon for the
    37    * vista menu item
    38    * @var string
    39    */
    40   private string $icon_url;
    41 
    42  /**
    4376  * Array of Options_Page objects that have been registered
    4477  * with register_settings_page
     
    4679  */
    4780  private array $pages;
    48 
    49  /**
     81 
     82  /**
    5083  * Retrieve the single instance of this class
    5184  * @return Options_Display
     
    5588      self::$instance = new self();
    5689    }
    57 
     90   
    5891    return self::$instance;
    5992  }
    60 
    61  /**
     93 
     94  /**
    6295  * Protected to enforce singleton pattern
    6396  */
    6497  protected function __construct() {
    6598    add_action('admin_menu', array($this, 'init_settings'));
    66 
    6799    $this->icon_url = \vista_plugin_url("/img/dashboard_logo.png");
    68 
    69 
     100   
    70101    // Styles for admin dashboard
    71102    V\Main::get_instance()->register_style('vsta_admin', \vista_plugin_url("/css/admin.css"));
    72 
    73103    if (\is_admin()) {
    74104      V\Main::get_instance()->enqueue_style('vsta_admin');
    75105    }
    76 
    77106  }
    78 
    79  /**
     107 
     108  /**
    80109  * Registers a settings page, to be included under the Vista menu header.
    81   * If the slug is 'vista_default', this will be the default selected page
     110  * If the slug is 'vista_main', this will be the default selected page
    82111  * @param Options_Page $page  Class representing the page
    83112  */
     
    85114    $this->pages[] = $page;
    86115  }
    87 
    88  /**
     116 
     117  /**
    89118  * Initializes the settings page and all subpages
    90119  * These are registered by other classes and this is called when admin_menu
     
    95124      "Vista",
    96125      self::VISTA_CAPABILITY,
    97       self::DEFAULT_PAGE_SLUG,
    98       array($this, 'default_page'),
     126      self::MAIN_PAGE_SLUG,
     127      array(
     128        $this,
     129        'main_page'
     130      ),
    99131      $this->icon_url,
    100132      8,
    101133    );
     134   
     135    // This bug only occurs in very specific circumstances,
     136    // so this check is rarely necessary, but it's here just in case
     137    if (empty($this->pages)) {
     138      return;
     139    }
    102140
    103141    foreach($this->pages as $page) {
    104142      \add_submenu_page(
    105         self::DEFAULT_PAGE_SLUG,
     143        self::MAIN_PAGE_SLUG,
    106144        $page->page_title(),
    107145        $page->menu_title(),
     
    113151    }
    114152  }
     153 
     154  /**
     155  * Creates the three default pages
     156  * and displays a banner indicating success or failure
     157  */
     158  private function create_pages(): void {
     159    $listings_page = new Generate_Pages();
     160    $allPagesCreated = true;
     161   
     162    // Try to create pages
     163    if (isset($_POST['generate_pages'])) {
     164      $allPagesCreated &= $listings_page->auto_create_page(Options_Display::LISTINGS_OPTION, 'Listings');
     165      $allPagesCreated &= $listings_page->auto_create_page(Options_Display::INDIVIDUAL_OPTION, 'Individual Listing');
     166      // $allPagesCreated &= $listings_page->auto_create_page(Options_Display::OPENHOUSE_OPTION, 'Openhouses');
     167     
     168      if ($allPagesCreated) {
     169        $notification = Notifications_Banner::create('success','Success All Pages Created');
     170        $notification->display_notification();
     171      } else {
     172        $notification = Notifications_Banner::create('error','Error Some Pages Failed to Create');
     173        $notification->display_notification();
     174      }
     175    }
     176  }
     177 
     178  /**
     179  * Outputs text for the default Vista admin page
     180  * This should be overridden by registering a function
     181  * with slug set to MAIN_PAGE_SLUG
     182  */
     183  public function main_page(): void {
     184    $this->create_pages();
    115185
    116   /**
    117    * Outputs text for the default Vista admin page
    118    * This should be overridden by registering a function
    119    * with slug set to DEFAULT_PAGE_SLUG
    120    */
    121   public function default_page(): void {
    122     ?>
    123     <div>
    124       <h2>Welcome to VistaWP!</h2>
     186    ob_start();
     187      \vista_get_template(
     188        'pages/main_page.php',
     189        array(
     190          'listings' => get_option(Options_Display::LISTINGS_OPTION),
     191          'individual' => get_option(Options_Display::INDIVIDUAL_OPTION),
     192        ),
     193      );
    125194
    126       <h3>Getting Started</h3>
    127    
    128       <p> Watch this short intro video to understand how the plugin works.</p>
    129 
    130       <iframe width="560" height="315" src="https://www.youtube.com/embed/5r2DZiB2yXU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
    131       <br>
    132 
    133       <p>We’ve made getting started with VistaWP simple. Find simple instructions and ready-made templates at https://vistawp.com/get-started.</p>
    134    
    135       <h3>Getting Help</h3>
    136      
    137       <p> For more detailed documentation and tutorials, visit https://vistawp.com/support.</p>
    138    
    139       <p>Need extra help? Reach out with questions, or to schedule a 1-on-1 live work session with someone from the VistaWP team. You can email us directly at [email protected].</p>
    140    
    141       <h3>License</h3>
    142    
    143       <p>If you don’t have a valid VistaWP license key entered below, VistaWP will show dummy data. After submitting your MLS/IDX setup request with VistaWP support, enter your VistaWP license on the VistaWP license page.</p>
    144 
    145       <br>
    146       <h3>Integrating Your MLS/IDX Feed</h3>
    147 
    148       <p> The VistaWP team will need to set up your MLS/IDX feed for you. Once you have access to your MLS database, submit the MLS/IDX Setup Request form in the VistaWP support panel. Our team will set up your feed and VistaWP will start showing listings from your MLS instead of dummy data. It can take our team 24-72 hours to set up your feed.</p>
    149     </div>
    150     <?php
     195    echo ob_get_clean();
    151196  }
    152 
    153197}
    154 
    155 
    156 ?>
  • vistawp/tags/1.3.0/includes/options/options-page.php

    r2924340 r2999820  
    6969  /**
    7070   * Get the slug for this page.
    71    * If the slug is Options_Display::DEFAULT_PAGE_SLUG, this page will be selected
     71   * If the slug is Options_Display::MAIN_PAGE_SLUG, this page will be selected
    7272   * by default when a user clicks the vista menu header
    7373   * Every slug must be unique
  • vistawp/tags/1.3.0/includes/options/welcome-header.php

    r2961844 r2999820  
    6666      <div>
    6767        <h3>Thanks for activating VistaWP</h3>
    68         <p>Head to the <a href="/wp-admin/admin.php?page=vista_default">settings page</a> to get started</p>
     68        <p>Head to the <a href="/wp-admin/admin.php?page=vista_main">settings page</a> to get started</p>
    6969      </div>
    7070    </div>
  • vistawp/tags/1.3.0/js/slideshow.js

    r2949654 r2999820  
    3030}
    3131
    32 var slideIndex = 1;
     32var vista_slide_index = 1;
    3333
    3434/**
     
    3737 */
    3838function plusSlides(n) {
    39   showSlides(slideIndex += n);
     39  showSlides(vista_slide_index += n);
    4040}
    4141
     
    4545 */
    4646function currentSlide(n) {
    47   showSlides(slideIndex = n);
     47  showSlides(vista_slide_index = n);
    4848}
    4949
     
    5353 */
    5454function showSlides(n) {
    55   var i;
    56   var slides = document.getElementsByClassName("mySlides");
     55  var slides = document.getElementsByClassName('vista-slide-item');
     56  var slide_number = document.getElementById('vista-slide-number');
     57  var size = slides.length;
    5758
    58   if (n > slides.length) {
    59     slideIndex = 1;
     59  if (n > size) {
     60    vista_slide_index = 1;
    6061  }
     62 
    6163  if (n < 1) {
    62     slideIndex = slides.length;
     64    vista_slide_index = size;
    6365  }
    64   for (i = 0; i < slides.length; i++) {
     66
     67  for (let i = 0; i < size; i++) {
    6568    slides[i].style.display = "none";
    6669  }
    67   slides[slideIndex - 1].style.display = "block";
     70  slides[vista_slide_index - 1].style.display = "block";
     71
     72  slide_number.innerHTML = "<span>" + vista_slide_index + "/" + size + "</span>";
    6873}
    6974
  • vistawp/tags/1.3.0/readme.txt

    r2990365 r2999820  
    44Tags: IDX, MLS, idx search, Real Estate Search, IDX plugin, RETS, real-estate 
    55Requires at least: 4.7 
    6 Tested up to: 6.3 
    7 Stable tag: 1.2.4 
    8 Requires PHP: 7.0 
     6Tested up to: 6.4 
     7Stable tag: 1.3.0 
     8Requires PHP: 7.4.1 
    99License: GPLv2 or later 
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html 
  • vistawp/tags/1.3.0/vista.php

    r2990365 r2999820  
    33* Plugin Name: VistaWP
    44* Description: Retrieves and displays real estate listings
    5 * Version: 1.2.4
     5* Version: 1.3.0
    66* Author: VistaWP
    77* Author URI: https://vistawp.com/
     
    183183      require_once "includes/openhouses/multiple-openhouse-display.php";
    184184    }
     185
    185186    // Welcome Header file
    186187    if ( !class_exists("\\VSTA\\Options\\Welcome_Header") ) {
     
    188189    }
    189190
     191    // Notifications Banenr File
     192    if ( !class_exists("\\VSTA\\Options\\Notifications_Banner") ) {
     193      require_once "includes/options/notifications-banner.php";
     194    }
     195
     196        // Welcome Header file
     197    if ( !class_exists("\\VSTA\\Options\\Notifications_Banner") ) {
     198      require_once "includes/options/notifications-banner.php";
     199    }
     200
    190201    // Abstract class for forms
    191202    if ( !class_exists("\\VSTA\\Forms\\Form") ) {
    192203      require_once 'includes/forms/form.php';
    193204    }
    194     // Class for Vistawp Advanced form
     205    // Class for Advanced form
    195206    if ( !class_exists("\\VSTA\\Forms\\Advanced") ) {
    196207      require_once 'includes/forms/advanced.php';
    197208    }
    198     // Class for Vistawp basic form
     209    // Class for basic form
    199210    if ( !class_exists("\\VSTA\\Forms\\Basic") ) {
    200211      require_once 'includes/forms/basic.php';
    201212    }
    202     // Class for Vistawp q form
     213    // Class for search form
    203214    if ( !class_exists("\\VSTA\\Forms\\Search") ) {
    204215      require_once 'includes/forms/search.php';
     216    }
     217    // Class for auto-generated pages
     218    if ( !class_exists("\\VSTA\\Options\\Generate_Pages") ) {
     219      require_once 'includes/options/page-generator.php';
    205220    }
    206221
     
    329344
    330345// Init hooks
    331 add_action('plugins_loaded', '\VSTA\Vista_init', 12);
    332 function Vista_init() {
     346add_action('plugins_loaded', '\VSTA\vista_init', 12);
     347function vista_init() {
    333348  // This is a bugfix for wp_redirect not firing properly inside this plugin,
    334349  // probably because the redirect gets canceled when things are added to the output buffer.
     
    336351  ob_start();
    337352
    338   // Init plugin
    339   \VSTA\Main::get_instance();
     353  // Init plugin with failsafe block for initialization errors
     354  try {
     355    \VSTA\Main::get_instance();
     356  } catch (\Exception $e) {
     357    $GLOBALS['vista_error_message'] = $e->getMessage();
     358    \add_action('admin_notices', '\VSTA\vista_fallback_error', 11);
     359    \add_action('wp_loaded', '\VSTA\deactivate_vista', 12);
     360  }
    340361 
    341362  // This is a courtesy to other developers,
     
    344365}
    345366
    346 ?>
     367/**
     368 * Deactivates the plugin- used in case of fatal error.
     369 * Must be called after the plugins_loaded hook
     370 */
     371function deactivate_vista(): void {
     372  // Sometimes the file with this function isn't included, so include it
     373  require_once ABSPATH . 'wp-admin/includes/plugin.php';
     374  \deactivate_plugins(plugin_basename(__FILE__));
     375}
     376
     377/**
     378 * Display an admin error with customizable message.
     379 * This should only be used in the event that the plugin
     380 * encounters a fatal error.
     381 * Otherwise, the Notifications_Banner class should be used.
     382 * The message is retrieved from the global vista_error_message variable.
     383 */
     384function vista_fallback_error(): void {
     385 ?>
     386 <div class="error notice">
     387    <p>
     388      The VistaWP plugin has encountered a fatal error and self-deactivated.
     389      Error message: <?php echo $GLOBALS['vista_error_message']; ?>
     390    </p>
     391 </div>
     392 <?php
     393}
  • vistawp/trunk/css/admin.css

    r2949654 r2999820  
    104104}
    105105
     106#vistawp-banner{
     107display: grid;
     108grid-template-columns: 40px auto;
     109}
    106110
    107111
     112.vsta-text-error {
     113    color: #d63638;
     114    font-weight: bold;
     115}
    108116
     117.vsta-text-success {
     118    color: #00a32a;
     119    font-weight: bold;
     120}
     121
  • vistawp/trunk/css/slideshow.css

    r2949654 r2999820  
     1* {
     2  box-sizing: border-box;
     3}
     4
    15.vista-grid-img {
    26  max-width: 100%;
     
    812}
    913
    10 
    1114.vista-grid-img:hover {
    1215  -ms-transform: scale(1.05); /* IE 9 */
     
    1417  transform: scale(1.05);
    1518}
     19
    1620/* Main CSS */
    1721.grid-wrapper > div {
     
    2024  align-items: center;
    2125}
     26
    2227.grid-wrapper > div > img {
    2328  width: 100%;
     
    3641  overflow: hidden;
    3742}
     43
    3844.grid-wrapper .wide {
    3945  grid-column: span 2;
    4046}
     47
    4148.grid-wrapper .tall {
    4249  grid-row: span 2;
    4350}
     51
    4452.grid-wrapper .big {
    4553  grid-column: span 2;
     
    8997    width:90%;
    9098  }
     99
    91100  .close{
    92101    top:25px;
     
    97106    top:50%;
    98107  }
    99 
    100 
    101 }
    102 
     108}
    103109
    104110.close:hover,
     
    110116
    111117/* Next & previous buttons */
    112 .vista-grid-prev,
    113 .vista-grid-next {
     118div .slideshow-container .vista-grid-prev,
     119div .slideshow-container .vista-grid-next {
    114120  cursor: pointer;
    115121  position: absolute;
     
    118124  padding: 16px;
    119125  margin-top: -50px;
    120   color: white;
     126  color: #fff;
    121127  font-weight: bold;
    122128  font-size: 20px;
    123129  transition: 0.6s ease;
    124   border-radius: 0 3px 3px 0;
    125130  user-select: none;
    126131  -webkit-user-select: none;
    127132  background-color: rgba(0, 0, 0, 0.8);
     133}
     134
     135div .slideshow-container .vista-grid-prev {
     136  border-radius: 0 3px 3px 0;
     137}
     138
     139div .slideshow-container .vista-grid-next {
     140  border-radius: 3px 0px 0px 3px;
    128141}
    129142
     
    140153}
    141154
    142 .mySlides {
     155.vista-slide-item {
    143156  display: none;
    144157}
     
    165178}
    166179
    167 
    168 .vista-scroller-photobanner:hover img{
    169 
    170 }
    171 
    172 * {
    173   box-sizing: border-box;
    174 }
    175 
    176 
     180.vista-scroller-photobanner:hover img{}
    177181
    178182.zoom {
     
    190194
    191195.zoom-main {
    192 
    193196  transition: transform .2s; /* Animation */
    194197}
     
    198201  transform: scale(1.1); /* (150% zoom - Note: if the zoom is too large, it will go outside of the viewport) */
    199202}
    200 
    201203
    202204/* Next & previous buttons */
     
    230232/* Slideshow container */
    231233.slideshow-container {
    232   max-width: 1000px;
     234  max-width: 100%;
     235  height: 100%;
    233236  position: relative;
     237  overflow: hidden;
    234238  margin: auto;
    235239  font-family: Verdana, sans-serif;
    236   margin: 0;
    237240}
    238241
    239242.slideshow-container * {box-sizing: border-box}
    240243.slideshow-container .otherSlides {display: none}
    241 .slideshow-container img {vertical-align: middle; max-height: 600px; width: auto;}
    242 
     244.slideshow-container img {
     245  vertical-align: middle;
     246  height: auto;
     247  width: 100%;
     248}
    243249
    244250/* Fading animation */
     
    265271}
    266272
    267 
    268273.grid-container {
    269274  padding: 10px;
     
    283288}
    284289
     290.thumbnails-carousel {
     291  height:150px !important;
     292  width:16.6%;
     293  display: inline-block;
     294  object-fit: cover;
     295}
     296
     297.slides-masonry {
     298  width:100%;
     299}
     300
     301#vista-grid-load-btn {
     302  width:100%;
     303}
     304
     305/* slide count element */
     306#vista-slide-number {
     307  top: 50px;
     308  z-index: 1;
     309  position: relative;
     310  float: right;
     311  padding: 8px;
     312  width: 40px;
     313  background:#000;
     314  color:#fff;
     315  text-align:center;
     316  margin-top: -50px;
     317  font-size: 9px;
     318  border-radius: 0px 0px 0px 3px;
     319  opacity: 0.6;
     320}
  • vistawp/trunk/includes/listings/single-listing.php

    r2964274 r2999820  
    8383   */
    8484  protected function price_sqft_field(?int $price, ?int $sqft): void {
    85     if(
    86       isset( $price ) && !empty( $price ) &&
    87       isset( $sqft ) && !empty( $sqft )
    88     ) {
     85    if (!empty($price) && !empty($sqft)) {
    8986      try {
    90         $this->try_process_field( 'sqftPrice', $price / $sqft );
     87        $this->try_process_field('sqftPrice', $price / $sqft);
    9188
    9289      } catch(\Exception $e) {
    93         $this->try_process_field( 'sqftPrice', parent::ERROR );
    94 
     90        $this->try_process_field('sqftPrice', parent::ERROR);
    9591      }
    9692    } else {
     
    366362    if (is_null($value)) {
    367363      $this->try_process_field('photos', NULL);
     364
    368365      return;
    369366    }
    370367
    371     // Initialize an empty string to hold the HTML for the slideshow
    372     $photos = "";
    373 
    374     // Create a container for the slideshow
    375     $photos .= "<div class='slideshow-container'>";
    376 
    377     // Initialize a counter to keep track of the index of the current photo being displayed
    378     $slider_count = 0;
    379 
    380     // Loop through the array of photos and add <img> elements to the slideshow container
     368    // set slideshow
     369    $slideshow = '';
     370
     371    // Loops through the slideshow and adds `<img>` elements to the `$fields` array
    381372    foreach ($value as $photo) {
    382     // If this is the first photo in the array, give it a special CSS class to display it larger
    383       if ($slider_count == 0){
    384         $photos .= "<div class='mySlides fade' style='display:block;'>" . "<img class='vista-listing-photo zoom-main' src='$photo' style='display:block;' alt='Property photo'> " . "</div>";
    385       } else {
    386         // For all other photos, use a different CSS class
    387         $photos .= "<div class='mySlides fade otherSlides'>" . "<img class='vista-listing-photo' src='$photo' alt='Property photo'> " . "</div>";
     373      $other_slide = '';
     374      if (empty($slideshow)) {
     375        $other_slide = 'otherSlides';
    388376      }
    389       $slider_count++; // Increment the counter
    390     }
    391 
    392     // Close the slideshow container
    393     $photos .= "</div>";
    394 
    395     // Initialize another counter to keep track of the index of the current photo in the thumbnail banner
    396     $slider_count = 0;
    397 
    398     // Create a container for the thumbnail banner
    399     $photos .= "<div id='vista-scroller-container'><div class='vista-scroller-photobanner'>";
    400 
    401     // Loop through the array of photos again to create the thumbnail banner
    402     foreach ($value as $photo) {
    403       // Create an <img> element for each photo, with a click handler that will display the corresponding slide in the main slideshow
    404      
    405       $photos .= "<img class='zoom'  src='$photo' style='height:150px; width:16.6%;display: inline-block;object-fit: cover;' onclick='currentSlide($slider_count+1)' alt='The Woods'>";
    406 
    407       $slider_count++; // Increment the counter
    408     }
    409 
    410     // Close the thumbnail banner container and add previous/next buttons
    411     $photos .= "</div><a class='prev' onclick=" . "vista_scroller('left')" . ">&#10094;</a>" . "<a class='next' onclick='vista_scroller()'>&#10095;</a>" . "</div>";
    412 
    413     // Pass the HTML for the slideshow to a function that will process it and insert it into the page
    414     $this->try_process_field('photos', $photos);
    415 
    416     // Create a modal container for the slideshow
    417     $masonry = '<div id="myModal" class="modal">
    418     <span class="close cursor" onclick="closeModal()">&times;</span>
    419     <div class="modal-content">';
    420 
    421     // Loop through the array of photos again to create the slideshow inside the modal
    422     foreach ($value as $photo) {
    423      // Create an <img> element for each photo to be displayed in the modal slideshow
    424      $masonry .= "<div class='mySlides'>
    425       <img src='$photo' style='width:100%'></div>";
    426     } 
    427 
    428     // Close the modal container and add previous/next buttons
    429     $masonry .= '<a class="vista-grid-prev" onclick="plusSlides(-1)">&#10094;</a>
    430       <a class="vista-grid-next" onclick="plusSlides(1)">&#10095;</a></div></div>';
    431 
    432     // Create a grid of images with randomly assigned sizes
    433     $masonry .= '<div class="grid-wrapper">';
    434     $sizes = array("", "tall", "wide", "big", "", "tall", "wide");
    435     $masonryCount = 0 ;
    436 
    437     foreach ($value as $photo) {
    438       $random = array_rand($sizes, 2);
    439       $randomSize = $sizes[$random[0]];
    440       $masonry .= "<div class='$randomSize'>
    441             <img onclick='openModal();currentSlide($masonryCount+1)' class='vista-grid-img' src='$photo' /></div>";
    442       $masonryCount++;
    443     }
    444 
    445     $masonry .= '</div><div><button id="vista-grid-load-btn" onclick="vistaGridLoadMore()"style="width:100%" >Load More</button></div>';
    446 
    447     // Try to process the 'photos-masonry' field with the generated HTML
    448     $this->try_process_field('photos-masonry', $masonry);
    449   }
     377
     378      $slideshow .= "<div class='vista-slide-item fade {$other_slide}'><img class='vista-listing-photo' src='". esc_url($photo) ."' alt='Property photo'></div>";
     379    }
     380
     381    // Create a container for the slideshow and add previous/next buttons
     382    $slideshow_container = <<<EOD
     383<div id='vista-slide-number'></div>
     384<div class='slideshow-container'>
     385   %s
     386  <a class='vista-grid-prev' onclick='plusSlides(-1)'>&#10094;</a>
     387  <a class='vista-grid-next' onclick='plusSlides(1)'>&#10095;</a>
     388</div>
     389EOD;
     390
     391    $this->try_process_field(
     392      'photos',
     393      sprintf(
     394        $slideshow_container,
     395        $slideshow
     396      )
     397    );
     398  }
     399
    450400  /**
    451401   * Process the virtualTourUrl field into an unstyled <a> element with class vista-tour-button
     
    461411      $this->try_process_field('virtualTourUrl', "No virtual tour available");
    462412  }
    463 
    464413}
    465 
    466 
    467 
    468 
    469  ?>
  • vistawp/trunk/includes/options/options-display.php

    r2949654 r2999820  
    88
    99/**
    10  * Adds options pages and defines their display HTML
    11  */
     10* Adds options pages and defines their display HTML
     11*/
    1212class Options_Display {
     13  /**
     14  * Option name for the listings page type.
     15  *
     16  * This constant holds the option name for the listings page type,
     17  * which is used to store and retrieve the page ID associated with
     18  * the 'listings' type of page.
     19  *
     20  * @var string
     21  */
     22  public const LISTINGS_OPTION = Generate_Pages::OPTION_PREFIX . 'listings';
     23 
     24  /**
     25  * Option name for the individual listings page type.
     26  *
     27  * This constant holds the option name for the individual listings
     28  * page type, which is used to store and retrieve the page ID associated
     29  * with the 'individual' type of page.
     30  *
     31  * @var string
     32  */
     33  public const INDIVIDUAL_OPTION = Generate_Pages::OPTION_PREFIX . 'individual';
     34 
     35  /**
     36  * Option name for the openhouse page type.
     37  *
     38  * This constant holds the option name for the openhouse page type,
     39  * which is used to store and retrieve the page ID associated with
     40  * the 'openhouse' type of page.
     41  *
     42  * @var string
     43  */
     44  public const OPENHOUSE_OPTION = Generate_Pages::OPTION_PREFIX . 'openhouse';
     45 
     46  /**
     47  * Singleton instance of this class
     48  * @var Options_Display
     49  */
     50  private static ?Options_Display $instance = NULL;
    1351
    1452  /**
    15    * Singleton instance of this class
    16    * @var Options_Display
     53   * The slug that should be used for the main page
     54   * when the View menu header is selected.
     55   * This slug should only be used for an Options_Page.
     56   *
     57   * @var string
    1758   */
    18   private static ?Options_Display $instance = NULL;
    19 
    20  /**
    21   * The options_page with this slug will be the default
    22   * selected page when the Vista menu header is selected.
    23   * This slug must only be used for one Options_Page
     59  public const MAIN_PAGE_SLUG = 'vista_main';
     60 
     61  /**
     62  * Default capability required to interact with vista settings
     63  * Individual pages may use this or set their own role requirement
    2464  * @var string
    2565  */
    26   public const DEFAULT_PAGE_SLUG = 'vista_default';
    27 
     66  public const VISTA_CAPABILITY = 'manage_options';
     67 
    2868  /**
    29    * Default capability required to interact with vista settings
    30    * Individual pages may use this or set their own role requirement
    31    * @var string
    32    */
    33   public const VISTA_CAPABILITY = 'manage_options';
    34 
     69  * This will be a file path to the icon for the
     70  * vista menu item
     71  * @var string
     72  */
     73  private string $icon_url;
     74 
    3575  /**
    36    * This will be a file path to the icon for the
    37    * vista menu item
    38    * @var string
    39    */
    40   private string $icon_url;
    41 
    42  /**
    4376  * Array of Options_Page objects that have been registered
    4477  * with register_settings_page
     
    4679  */
    4780  private array $pages;
    48 
    49  /**
     81 
     82  /**
    5083  * Retrieve the single instance of this class
    5184  * @return Options_Display
     
    5588      self::$instance = new self();
    5689    }
    57 
     90   
    5891    return self::$instance;
    5992  }
    60 
    61  /**
     93 
     94  /**
    6295  * Protected to enforce singleton pattern
    6396  */
    6497  protected function __construct() {
    6598    add_action('admin_menu', array($this, 'init_settings'));
    66 
    6799    $this->icon_url = \vista_plugin_url("/img/dashboard_logo.png");
    68 
    69 
     100   
    70101    // Styles for admin dashboard
    71102    V\Main::get_instance()->register_style('vsta_admin', \vista_plugin_url("/css/admin.css"));
    72 
    73103    if (\is_admin()) {
    74104      V\Main::get_instance()->enqueue_style('vsta_admin');
    75105    }
    76 
    77106  }
    78 
    79  /**
     107 
     108  /**
    80109  * Registers a settings page, to be included under the Vista menu header.
    81   * If the slug is 'vista_default', this will be the default selected page
     110  * If the slug is 'vista_main', this will be the default selected page
    82111  * @param Options_Page $page  Class representing the page
    83112  */
     
    85114    $this->pages[] = $page;
    86115  }
    87 
    88  /**
     116 
     117  /**
    89118  * Initializes the settings page and all subpages
    90119  * These are registered by other classes and this is called when admin_menu
     
    95124      "Vista",
    96125      self::VISTA_CAPABILITY,
    97       self::DEFAULT_PAGE_SLUG,
    98       array($this, 'default_page'),
     126      self::MAIN_PAGE_SLUG,
     127      array(
     128        $this,
     129        'main_page'
     130      ),
    99131      $this->icon_url,
    100132      8,
    101133    );
     134   
     135    // This bug only occurs in very specific circumstances,
     136    // so this check is rarely necessary, but it's here just in case
     137    if (empty($this->pages)) {
     138      return;
     139    }
    102140
    103141    foreach($this->pages as $page) {
    104142      \add_submenu_page(
    105         self::DEFAULT_PAGE_SLUG,
     143        self::MAIN_PAGE_SLUG,
    106144        $page->page_title(),
    107145        $page->menu_title(),
     
    113151    }
    114152  }
     153 
     154  /**
     155  * Creates the three default pages
     156  * and displays a banner indicating success or failure
     157  */
     158  private function create_pages(): void {
     159    $listings_page = new Generate_Pages();
     160    $allPagesCreated = true;
     161   
     162    // Try to create pages
     163    if (isset($_POST['generate_pages'])) {
     164      $allPagesCreated &= $listings_page->auto_create_page(Options_Display::LISTINGS_OPTION, 'Listings');
     165      $allPagesCreated &= $listings_page->auto_create_page(Options_Display::INDIVIDUAL_OPTION, 'Individual Listing');
     166      // $allPagesCreated &= $listings_page->auto_create_page(Options_Display::OPENHOUSE_OPTION, 'Openhouses');
     167     
     168      if ($allPagesCreated) {
     169        $notification = Notifications_Banner::create('success','Success All Pages Created');
     170        $notification->display_notification();
     171      } else {
     172        $notification = Notifications_Banner::create('error','Error Some Pages Failed to Create');
     173        $notification->display_notification();
     174      }
     175    }
     176  }
     177 
     178  /**
     179  * Outputs text for the default Vista admin page
     180  * This should be overridden by registering a function
     181  * with slug set to MAIN_PAGE_SLUG
     182  */
     183  public function main_page(): void {
     184    $this->create_pages();
    115185
    116   /**
    117    * Outputs text for the default Vista admin page
    118    * This should be overridden by registering a function
    119    * with slug set to DEFAULT_PAGE_SLUG
    120    */
    121   public function default_page(): void {
    122     ?>
    123     <div>
    124       <h2>Welcome to VistaWP!</h2>
     186    ob_start();
     187      \vista_get_template(
     188        'pages/main_page.php',
     189        array(
     190          'listings' => get_option(Options_Display::LISTINGS_OPTION),
     191          'individual' => get_option(Options_Display::INDIVIDUAL_OPTION),
     192        ),
     193      );
    125194
    126       <h3>Getting Started</h3>
    127    
    128       <p> Watch this short intro video to understand how the plugin works.</p>
    129 
    130       <iframe width="560" height="315" src="https://www.youtube.com/embed/5r2DZiB2yXU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
    131       <br>
    132 
    133       <p>We’ve made getting started with VistaWP simple. Find simple instructions and ready-made templates at https://vistawp.com/get-started.</p>
    134    
    135       <h3>Getting Help</h3>
    136      
    137       <p> For more detailed documentation and tutorials, visit https://vistawp.com/support.</p>
    138    
    139       <p>Need extra help? Reach out with questions, or to schedule a 1-on-1 live work session with someone from the VistaWP team. You can email us directly at [email protected].</p>
    140    
    141       <h3>License</h3>
    142    
    143       <p>If you don’t have a valid VistaWP license key entered below, VistaWP will show dummy data. After submitting your MLS/IDX setup request with VistaWP support, enter your VistaWP license on the VistaWP license page.</p>
    144 
    145       <br>
    146       <h3>Integrating Your MLS/IDX Feed</h3>
    147 
    148       <p> The VistaWP team will need to set up your MLS/IDX feed for you. Once you have access to your MLS database, submit the MLS/IDX Setup Request form in the VistaWP support panel. Our team will set up your feed and VistaWP will start showing listings from your MLS instead of dummy data. It can take our team 24-72 hours to set up your feed.</p>
    149     </div>
    150     <?php
     195    echo ob_get_clean();
    151196  }
    152 
    153197}
    154 
    155 
    156 ?>
  • vistawp/trunk/includes/options/options-page.php

    r2924340 r2999820  
    6969  /**
    7070   * Get the slug for this page.
    71    * If the slug is Options_Display::DEFAULT_PAGE_SLUG, this page will be selected
     71   * If the slug is Options_Display::MAIN_PAGE_SLUG, this page will be selected
    7272   * by default when a user clicks the vista menu header
    7373   * Every slug must be unique
  • vistawp/trunk/includes/options/welcome-header.php

    r2961844 r2999820  
    6666      <div>
    6767        <h3>Thanks for activating VistaWP</h3>
    68         <p>Head to the <a href="/wp-admin/admin.php?page=vista_default">settings page</a> to get started</p>
     68        <p>Head to the <a href="/wp-admin/admin.php?page=vista_main">settings page</a> to get started</p>
    6969      </div>
    7070    </div>
  • vistawp/trunk/js/slideshow.js

    r2949654 r2999820  
    3030}
    3131
    32 var slideIndex = 1;
     32var vista_slide_index = 1;
    3333
    3434/**
     
    3737 */
    3838function plusSlides(n) {
    39   showSlides(slideIndex += n);
     39  showSlides(vista_slide_index += n);
    4040}
    4141
     
    4545 */
    4646function currentSlide(n) {
    47   showSlides(slideIndex = n);
     47  showSlides(vista_slide_index = n);
    4848}
    4949
     
    5353 */
    5454function showSlides(n) {
    55   var i;
    56   var slides = document.getElementsByClassName("mySlides");
     55  var slides = document.getElementsByClassName('vista-slide-item');
     56  var slide_number = document.getElementById('vista-slide-number');
     57  var size = slides.length;
    5758
    58   if (n > slides.length) {
    59     slideIndex = 1;
     59  if (n > size) {
     60    vista_slide_index = 1;
    6061  }
     62 
    6163  if (n < 1) {
    62     slideIndex = slides.length;
     64    vista_slide_index = size;
    6365  }
    64   for (i = 0; i < slides.length; i++) {
     66
     67  for (let i = 0; i < size; i++) {
    6568    slides[i].style.display = "none";
    6669  }
    67   slides[slideIndex - 1].style.display = "block";
     70  slides[vista_slide_index - 1].style.display = "block";
     71
     72  slide_number.innerHTML = "<span>" + vista_slide_index + "/" + size + "</span>";
    6873}
    6974
  • vistawp/trunk/readme.txt

    r2990365 r2999820  
    44Tags: IDX, MLS, idx search, Real Estate Search, IDX plugin, RETS, real-estate 
    55Requires at least: 4.7 
    6 Tested up to: 6.3 
    7 Stable tag: 1.2.4 
    8 Requires PHP: 7.0 
     6Tested up to: 6.4 
     7Stable tag: 1.3.0 
     8Requires PHP: 7.4.1 
    99License: GPLv2 or later 
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html 
  • vistawp/trunk/vista.php

    r2990365 r2999820  
    33* Plugin Name: VistaWP
    44* Description: Retrieves and displays real estate listings
    5 * Version: 1.2.4
     5* Version: 1.3.0
    66* Author: VistaWP
    77* Author URI: https://vistawp.com/
     
    183183      require_once "includes/openhouses/multiple-openhouse-display.php";
    184184    }
     185
    185186    // Welcome Header file
    186187    if ( !class_exists("\\VSTA\\Options\\Welcome_Header") ) {
     
    188189    }
    189190
     191    // Notifications Banenr File
     192    if ( !class_exists("\\VSTA\\Options\\Notifications_Banner") ) {
     193      require_once "includes/options/notifications-banner.php";
     194    }
     195
     196        // Welcome Header file
     197    if ( !class_exists("\\VSTA\\Options\\Notifications_Banner") ) {
     198      require_once "includes/options/notifications-banner.php";
     199    }
     200
    190201    // Abstract class for forms
    191202    if ( !class_exists("\\VSTA\\Forms\\Form") ) {
    192203      require_once 'includes/forms/form.php';
    193204    }
    194     // Class for Vistawp Advanced form
     205    // Class for Advanced form
    195206    if ( !class_exists("\\VSTA\\Forms\\Advanced") ) {
    196207      require_once 'includes/forms/advanced.php';
    197208    }
    198     // Class for Vistawp basic form
     209    // Class for basic form
    199210    if ( !class_exists("\\VSTA\\Forms\\Basic") ) {
    200211      require_once 'includes/forms/basic.php';
    201212    }
    202     // Class for Vistawp q form
     213    // Class for search form
    203214    if ( !class_exists("\\VSTA\\Forms\\Search") ) {
    204215      require_once 'includes/forms/search.php';
     216    }
     217    // Class for auto-generated pages
     218    if ( !class_exists("\\VSTA\\Options\\Generate_Pages") ) {
     219      require_once 'includes/options/page-generator.php';
    205220    }
    206221
     
    329344
    330345// Init hooks
    331 add_action('plugins_loaded', '\VSTA\Vista_init', 12);
    332 function Vista_init() {
     346add_action('plugins_loaded', '\VSTA\vista_init', 12);
     347function vista_init() {
    333348  // This is a bugfix for wp_redirect not firing properly inside this plugin,
    334349  // probably because the redirect gets canceled when things are added to the output buffer.
     
    336351  ob_start();
    337352
    338   // Init plugin
    339   \VSTA\Main::get_instance();
     353  // Init plugin with failsafe block for initialization errors
     354  try {
     355    \VSTA\Main::get_instance();
     356  } catch (\Exception $e) {
     357    $GLOBALS['vista_error_message'] = $e->getMessage();
     358    \add_action('admin_notices', '\VSTA\vista_fallback_error', 11);
     359    \add_action('wp_loaded', '\VSTA\deactivate_vista', 12);
     360  }
    340361 
    341362  // This is a courtesy to other developers,
     
    344365}
    345366
    346 ?>
     367/**
     368 * Deactivates the plugin- used in case of fatal error.
     369 * Must be called after the plugins_loaded hook
     370 */
     371function deactivate_vista(): void {
     372  // Sometimes the file with this function isn't included, so include it
     373  require_once ABSPATH . 'wp-admin/includes/plugin.php';
     374  \deactivate_plugins(plugin_basename(__FILE__));
     375}
     376
     377/**
     378 * Display an admin error with customizable message.
     379 * This should only be used in the event that the plugin
     380 * encounters a fatal error.
     381 * Otherwise, the Notifications_Banner class should be used.
     382 * The message is retrieved from the global vista_error_message variable.
     383 */
     384function vista_fallback_error(): void {
     385 ?>
     386 <div class="error notice">
     387    <p>
     388      The VistaWP plugin has encountered a fatal error and self-deactivated.
     389      Error message: <?php echo $GLOBALS['vista_error_message']; ?>
     390    </p>
     391 </div>
     392 <?php
     393}
Note: See TracChangeset for help on using the changeset viewer.