HJI WP Membership Code Reference
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hook Reference
  • Slipstream API Docs

Namespaces

  • hji
    • AgentRoster
      • controllers
      • models
      • utils
    • common
      • factories
      • interfaces
      • models
      • utils
    • construction
      • admin
        • controllers
        • models
      • core
      • front
        • controllers
      • interfaces
      • models
        • listings
        • subdivisions
      • views
    • geofarms
      • common
      • controllers
      • models
      • widgets
    • homevalue
      • controllers
      • core
        • abstracts
      • models
    • lifestylefinder
    • listingstoblog
      • controllers
    • membership
      • abstracts
      • controllers
      • entities
      • extension
        • abstracts
        • interfaces
      • factories
      • includes
      • interfaces
      • models
        • data
        • webservice
          • abstracts
          • actions
          • interfaces
      • observers
      • services
    • recentsales
      • controllers
      • tinymce
      • widgets
    • ResponsiveIDX
      • abstracts
      • adapters
      • controllers
      • core
        • abstracts
      • entities
      • models
      • services
      • tinymce
      • utils
      • widgets
    • schools
      • controllers
      • tinymce
      • widgets
    • users
      • abstracts
      • admin
        • controllers
        • models
      • controllers
      • core
        • abstracts
      • entities
      • models
      • utils
  • None
  • REL
    • controllers
    • Models
    • Taxonomies
    • Utils
      • Convert
    • widgets

Classes

  • hji\AgentRoster\AgentRoster
  • hji\AgentRoster\controllers\AgentRosterAdmin
  • hji\AgentRoster\controllers\Testimonials
  • hji\AgentRoster\models\TestimonialsModel
  • hji\AgentRoster\utils\ContactForm
  • hji\common\factories\mcePluginFactory
  • hji\common\factories\WidgetTrioFactory
  • hji\common\interfaces\AbstractSettingsModel
  • hji\common\interfaces\Shortcode
  • hji\common\interfaces\Widget
  • hji\common\interfaces\WidgetShortcode
  • hji\common\models\Alerts
  • hji\common\models\GForms
  • hji\common\models\JsVars
  • hji\common\models\mcePluginModel
  • hji\common\models\Notices
  • hji\common\models\PluginJsVars
  • hji\common\utils\APIClient
  • hji\common\utils\Cookies
  • hji\common\utils\GFHelper
  • hji\common\utils\HTTP
  • hji\common\utils\ipAddress
  • hji\common\utils\MetaBoxes
  • hji\common\utils\Modal
  • hji\common\utils\Paths
  • hji\common\utils\SiteInfo
  • hji\common\utils\String
  • hji\common\utils\Updater
  • hji\common\utils\Validator
  • hji\common\utils\View
  • hji\common\utils\Views
  • hji\common\utils\WPCache
  • hji\common\utils\WPHelper
  • hji\construction\admin\AdminController
  • hji\construction\admin\controllers\GeneralPageController
  • hji\construction\admin\models\GeneralPageModel
  • hji\construction\App
  • hji\construction\core\Component
  • hji\construction\core\Controller
  • hji\construction\core\DataModel
  • hji\construction\core\DataObjectPostView
  • hji\construction\core\Model
  • hji\construction\core\Paths
  • hji\construction\core\PostModel
  • hji\construction\core\WebService
  • hji\construction\core\Widget
  • hji\construction\front\controllers\ListingsController
  • hji\construction\front\controllers\SubdivisionsController
  • hji\construction\front\FrontController
  • hji\construction\models\Images
  • hji\construction\models\Labels
  • hji\construction\models\listings\ListingModel
  • hji\construction\models\listings\ListingsGetFilters
  • hji\construction\models\listings\ListingsModel
  • hji\construction\models\listings\ListingsSearchFilters
  • hji\construction\models\NCSearchWidget
  • hji\construction\models\NCSearchWidgetViewModel
  • hji\construction\models\Pagination
  • hji\construction\models\Settings
  • hji\construction\models\subdivisions\SubdivisionModel
  • hji\construction\models\subdivisions\SubdivisionsGetFilters
  • hji\construction\models\subdivisions\SubdivisionsGetOptions
  • hji\construction\models\subdivisions\SubdivisionsModel
  • hji\construction\models\subdivisions\SubdivisionsSearchFilters
  • hji\construction\models\subdivisions\SubdivisionsSearchOptions
  • hji\construction\NewConstruction
  • hji\construction\ServiceContainer
  • hji\construction\views\ListingsView
  • hji\construction\views\SubdivisionsView
  • hji\geofarms\common\ImageResize
  • hji\geofarms\common\RewriteRules
  • hji\geofarms\controllers\AreaCache
  • hji\geofarms\controllers\CMB
  • hji\geofarms\controllers\CPT
  • hji\geofarms\controllers\FrontEnd
  • hji\geofarms\controllers\Settings
  • hji\geofarms\controllers\Shortcodes
  • hji\geofarms\controllers\Slipstream
  • hji\geofarms\controllers\Taxonomy
  • hji\geofarms\controllers\TinyMCE
  • hji\geofarms\controllers\UpdateNeighborhoods
  • hji\geofarms\GeoFarms
  • hji\geofarms\models\CMB
  • hji\geofarms\models\CPT
  • hji\geofarms\models\Settings
  • hji\geofarms\models\Slipstream
  • hji\geofarms\models\Taxonomy
  • hji\geofarms\models\TinyMCE
  • hji\geofarms\widgets\Display
  • hji\geofarms\widgets\Map
  • hji\homevalue\controllers\HomeValueTinyMCE
  • hji\homevalue\controllers\HomeValueWidget
  • hji\homevalue\controllers\Settings
  • hji\homevalue\controllers\Shortcodes
  • hji\homevalue\core\abstracts\Component
  • hji\homevalue\core\Controller
  • hji\homevalue\core\Model
  • hji\homevalue\HomeValue
  • hji\homevalue\models\Settings
  • hji\lifestylefinder\LifestyleFinder
  • hji\listingstoblog\controllers\ImportListings
  • hji\listingstoblog\controllers\Settings
  • hji\listingstoblog\ListingsToBlog
  • hji\membership\abstracts\Component
  • hji\membership\abstracts\Controller
  • hji\membership\abstracts\Model
  • hji\membership\controllers\APIClient
  • hji\membership\controllers\CommonScripts
  • hji\membership\controllers\Dependency
  • hji\membership\controllers\DependencyResolver
  • hji\membership\controllers\Dispatcher
  • hji\membership\controllers\Downloads
  • hji\membership\controllers\GForms
  • hji\membership\controllers\ProductManager
  • hji\membership\controllers\ProductRegistrar
  • hji\membership\controllers\RegistryEntry
  • hji\membership\controllers\RequireJs
  • hji\membership\controllers\Settings
  • hji\membership\controllers\UpdateManager
  • hji\membership\entities\Event
  • hji\membership\entities\UserActionEvent
  • hji\membership\extension\abstracts\Component
  • hji\membership\factories\ProductFactory
  • hji\membership\includes\CustomerInfoSynchronizer
  • hji\membership\interfaces\Product
  • hji\membership\Membership
  • hji\membership\models\APIClientModel
  • hji\membership\models\Customer
  • hji\membership\models\data\Address
  • hji\membership\models\data\Image
  • hji\membership\models\data\Images
  • hji\membership\models\data\Paging
  • hji\membership\models\data\Sorting
  • hji\membership\models\DependencyEntity
  • hji\membership\models\DependencyModel
  • hji\membership\models\PluginEntity
  • hji\membership\models\ProductDependencies
  • hji\membership\models\Settings
  • hji\membership\models\ThemeEntity
  • hji\membership\models\UserActionLogger
  • hji\membership\models\UserSession
  • hji\membership\models\webservice\abstracts\QueryProperties
  • hji\membership\models\webservice\abstracts\WebService
  • hji\membership\models\webservice\abstracts\WebServiceFilters
  • hji\membership\models\webservice\actions\ActionsSearchFilters
  • hji\membership\models\webservice\actions\ActionsWebService
  • hji\membership\models\webservice\WebServiceOptions
  • hji\membership\models\WpCatalog
  • hji\membership\observers\EventDispatcher
  • hji\membership\observers\EventLogger
  • hji\membership\services\CPT_Router
  • hji\membership\services\DependencyInjector
  • hji\membership\services\DependencyInjectorInterface
  • hji\membership\services\Request
  • hji\membership\services\Route
  • hji\membership\services\Router
  • hji\membership\services\ServiceContainer
  • hji\membership\services\SocialGraph
  • hji\recentsales\controllers\Shortcodes
  • hji\recentsales\RecentSales
  • hji\recentsales\tinymce\RecentSales
  • hji\recentsales\widgets\RecentSales
  • hji\ResponsiveIDX\abstracts\FilterSchema
  • hji\ResponsiveIDX\adapters\IdxAdapter
  • hji\ResponsiveIDX\adapters\LegalAdapter
  • hji\ResponsiveIDX\adapters\ListingAdapter
  • hji\ResponsiveIDX\controllers\BaseController
  • hji\ResponsiveIDX\controllers\IdxApp
  • hji\ResponsiveIDX\controllers\Pagination
  • hji\ResponsiveIDX\controllers\RecentlyViewed
  • hji\ResponsiveIDX\controllers\RegistrationForm
  • hji\ResponsiveIDX\controllers\Settings
  • hji\ResponsiveIDX\controllers\Upgrader
  • hji\ResponsiveIDX\core\abstracts\Component
  • hji\ResponsiveIDX\core\Controller
  • hji\ResponsiveIDX\core\Model
  • hji\ResponsiveIDX\entities\ComplianceRule
  • hji\ResponsiveIDX\entities\ListingEntity
  • hji\ResponsiveIDX\models\ComplianceModel
  • hji\ResponsiveIDX\models\ComplianceViewModel
  • hji\ResponsiveIDX\models\FieldLabels
  • hji\ResponsiveIDX\models\HashMap
  • hji\ResponsiveIDX\models\IdxSearchModel
  • hji\ResponsiveIDX\models\MarketMetadata
  • hji\ResponsiveIDX\models\PaginationViewModel
  • hji\ResponsiveIDX\models\QuickSearchViewModel
  • hji\ResponsiveIDX\models\SearchFilters
  • hji\ResponsiveIDX\models\SearchParams
  • hji\ResponsiveIDX\models\SearchResultsViewModel
  • hji\ResponsiveIDX\models\ShortcodesModel
  • hji\ResponsiveIDX\models\SpatialMatchModel
  • hji\ResponsiveIDX\ResponsiveIDX
  • hji\ResponsiveIDX\services\ServiceContainer
  • hji\ResponsiveIDX\tinymce\FeaturedListings
  • hji\ResponsiveIDX\utils\ArrayFormat
  • hji\ResponsiveIDX\utils\PluginDependency
  • hji\ResponsiveIDX\utils\StringFormat
  • hji\ResponsiveIDX\utils\View
  • hji\ResponsiveIDX\widgets\FeaturedListings_TinyMCE
  • hji\ResponsiveIDX\widgets\FeaturedListings_Widget
  • hji\ResponsiveIDX\widgets\QuickSearch_Widget
  • hji\schools\controllers\Shortcodes
  • hji\schools\Schools
  • hji\schools\tinymce\Schools
  • hji\schools\widgets\Schools
  • hji\users\abstracts\AdminPageModel
  • hji\users\abstracts\UserAdminTable
  • hji\users\admin\AdminController
  • hji\users\admin\BaseController
  • hji\users\admin\controllers\ActionsPageController
  • hji\users\admin\controllers\UsersPageController
  • hji\users\admin\models\ActionsPageModel
  • hji\users\admin\models\UsersPageModel
  • hji\users\controllers\GravityForms
  • hji\users\controllers\GravityFormsAdmin
  • hji\users\controllers\RegistrationPrompter
  • hji\users\controllers\Settings
  • hji\users\controllers\SocialAuth
  • hji\users\controllers\User
  • hji\users\controllers\UserPanel
  • hji\users\core\abstracts\Component
  • hji\users\core\Controller
  • hji\users\core\Model
  • hji\users\entities\GFEntry
  • hji\users\entities\User
  • hji\users\entities\UserProfile
  • hji\users\models\ActionsSearchFilters
  • hji\users\models\ActionsWebServiceOptions
  • hji\users\models\FavoritesViewModel
  • hji\users\models\FrontEndNotices
  • hji\users\models\RegistrationNotificationViewModel
  • hji\users\models\Request
  • hji\users\models\Settings
  • hji\users\models\SettingsTab
  • hji\users\models\User
  • hji\users\models\UserActionsModel
  • hji\users\models\UserFactory
  • hji\users\models\UsersSearchModel
  • hji\users\Users
  • hji\users\utils\GravityFormsHelper
  • hji\users\utils\UserActionsTable
  • hji\users\utils\UserAuth
  • hji\users\utils\UserFavoritesTable
  • hji\users\utils\UserFormEntriesTable
  • hji\users\utils\UserListTable
  • hji\users\utils\UserSearchesTable
  • hji\users\utils\UserSessionsTable
  • REL\controllers\Admin
  • REL\controllers\FSBO
  • REL\controllers\PocketListings
  • REL\controllers\rIDXImport
  • REL\Models\ListingViewModel
  • REL\Models\rIDXImport
  • REL\Models\Upgrades
  • REL\RealEstateListings
  • REL\Taxonomies\CustomTaxonomies
  • REL\Utils\Convert\ListingConverter
  • REL\widgets\PocketListingsSearchWidget
  • REL\widgets\PocketListingsWidget
  • SM_API_Client

Interfaces

  • hji\construction\interfaces\IPost
  • hji\membership\extension\interfaces\ExtensionInterface
  • hji\membership\interfaces\CRUD
  • hji\membership\interfaces\Dispatchable
  • hji\membership\interfaces\EventDispatcherInterface
  • hji\membership\interfaces\Loggable
  • hji\membership\models\webservice\interfaces\IGettable
  • hji\membership\models\webservice\interfaces\ISearchable

Functions

  • __admin_redirect
  • get_pocket_listing
  • hji\membership\controllers\__inject_plugin_table
  • hji\membership\controllers\__inject_theme_table
  • hji_user_favorite_toggle
  • hjigf_display
  • hjigf_display_map
  • hjigf_get_community_feature
  • hjigf_get_post_thumbnail
  • hjigf_has_area_map
  • ridx_get_listing
  • ridx_is_results_page
  • ridx_is_single
  • ridx_is_single_print
  • table_hjpl_cache
  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 
<?php
namespace REL\controllers;

use \hji\membership\Membership;
use \REL\Models\ListingViewModel;
use \REL\Taxonomies\CustomTaxonomies;
use \hji\common\utils\MetaBoxes;

require_once(REL_CONTROLLERS . 'Admin.php');
require_once(Membership::$dir . '/common/utils/MetaBoxes.php');


class PocketListings
{
    private static $_instance;

    // Meta fields prefix

    const PREFIX = '_pl_';

    // Custom post type

    public $post_type = 'listing';
    const POST_TYPE = 'listing';

    // Custom post type slugs

    private $singular_slug  = 'listing';
    private $plural_slug    = 'listings';


    private function __construct()
    {
        MetaBoxes::add(self::getMetaboxSettings());
        $this->registerActions();
    }


    /**
     * @since 2.0.0
     * @return PocketListings
     */
    static function getInstance()
    {
        if (!(self::$_instance instanceof self))
        {
            self::$_instance = new self();
        }

        return self::$_instance;
    }


    /**
     * @since 2.0.0
     */
    function registerActions()
    {
        // Initialize custom post type

        add_action('init', array($this, 'create_post_type'));

        // Register custom taxonomies

        add_action('init', array($this, 'register_taxonomies'));

        // Adding front-end styles

        add_action('wp_print_styles', array($this, 'add_styles'));

        // Alter $wp_query to output listings in a way we want

        add_action('pre_get_posts', array($this, 'wp_query_listings'));


        // Template Redirection

        add_filter('template_include', array($this, 'use_template'));

        // Setting index to 100 assuming that all templates will be loaded by then.
        add_filter('template_include', array($this, 'pocket_listing_play_nice_with_default_template'), 100);
        add_filter('excerpt_more', array($this, 'set_pocket_listing_excerpt'), 100);

        // Property listing content output - using priority 7 to support embedded media,
        // because WP runs oEmbed with priority 8.

        add_filter('the_content', array($this, 'listing_output'), 7);
    }


    /**
     * Registering custom post types
     */
    function create_post_type()
    {
        // Check settings for custom url slugs

        $general_settings = Admin::getSettings();

        if (isset($general_settings['singular_slug']))
        {
            $this->singular_slug = $general_settings['singular_slug'];
        }

        if (isset($general_settings['plural_slug']))
        {
            $this->plural_slug = $general_settings['plural_slug'];
        }

        $singular = __('Listing', 'rel');
        $plural   = __('Listings', 'rel');

        $args = apply_filters('rel_post_type_args',
            array(
                'label'              => $singular,
                'labels'             => array(
                    'name'               => 'Pocket Listings',
                    'singular_name'      => $singular,
                    'add_new'            => _x('Add New Listing', 'rel'),
                    'all_items'          => sprintf(_x('All %s', 'rel'), $plural),
                    'add_new_item'       => sprintf(_x('Add New %s', 'rel'), $singular),
                    'edit_item'          => sprintf(__('Edit %s', 'rel'), $singular),
                    'new_item'           => sprintf(_x('New %s', 'rel'), $singular),
                    'view_item'          => sprintf(_x('View %s', 'rel'), $singular),
                    'search_items'       => sprintf(_x('Search %s', 'rel'), $plural),
                    'not_found'          => sprintf(_x('No %s found', 'rel'), $plural),
                    'not_fount_in_trash' => sprintf(_x('No %s found in Trash', 'rel'), $plural),
                ),
                'description'        => _x('Real estate property listings.', 'rel'),
                'public'             => true,
                'publicly_queryable' => true,
                'show_ui'            => true,
                'show_in_menu'       => true,
                'menu_position'      => 20,
                'menu_icon'          => Membership::$url . '/resources/images/admin-menu.png',
                'capability_type'    => 'post',
                'hierarchical'       => false,
                'supports'           => array(
                    'title', 'editor', 'thumbnail', 'page-attributes'
                ),
                'taxonomies'         => array_keys($this->taxonomy_args()),
                'has_archive'        => $this->plural_slug,
                'rewrite'            => array(
                    'slug' => $this->singular_slug, 'feeds' => true, 'with_front' => false
                ),
                'query_var'          => true,
                'can_export'         => true,
                'show_in_nav_menus'  => false,
            )
        );

        register_post_type($this->post_type, $args);
    }


    /**
     * Property listing taxonomy structure
     */
    function taxonomy_args()
    {
        // Taxonomy_code_name => Label

        $taxonomy_args = array(
            'mainfeatures'  => array(
                'singular' => __('Main Feature', 'rel'),
                'plural'   => __('Main Features', 'rel'),
            ),

            'features'      => array(
                'singular' => __('Feature', 'rel'),
                'plural'   => __('Additional Features', 'rel'),
            ),
            'listing-type'  => array(
                'singular' => __('Listing Type', 'rel'),
                'plural'   => __('Listing Types', 'rel'),
            ),
            'property-type' => array(
                'singular' => __('Property Type', 'rel'),
                'plural'   => __('Property Types', 'rel'),
            ),
            'city'          => array(
                'singular' => __('City', 'rel'),
                'plural'   => __('Cities', 'rel'),
            ),
            'neighborhood'  => array(
                'singular' => __('Neighborhood', 'rel'),
                'plural'   => __('Neighborhoods', 'rel')
            ),
        );

        $taxonomy_args = apply_filters('rel_taxonomy_args', $taxonomy_args);

        return $taxonomy_args;
    }


    static function getMetaboxSettings()
    {
        $address = array(
            'id'           => 'address',
            'title'        => __('Property Address', 'rel'),
            'object_types'        => array('listing'),
            'context'      => 'normal',
            'priority'     => 'high',
            'show_names'   => true,
            'fields'       => array(
                array(
                    'name'      => __('Street Address', 'rel'),
                    'id'        => self::PREFIX . 'street',
                    'type'      => 'text',
                ),
                array(
                    'name'      => __('Unit', 'rel'),
                    'id'        => self::PREFIX . 'unit',
                    'type'      => 'text',
                ),
                array(
                    'name'      => __('City', 'rel'),
                    'id'        => self::PREFIX . 'city',
                    'type'      => 'text',
                ),
                array(
                    'name'      => __('State', 'rel'),
                    'id'        => self::PREFIX . 'state',
                    'type'      => 'text',
                ),
                array(
                    'name'      => __('Zip', 'rel'),
                    'id'        => self::PREFIX . 'postalcode',
                    'type'      => 'text',
                )
            )
        );

        $listing_details = array(
            'id'           => 'listing_details',
            'title'        => __('Property Details', 'rel'),
            'object_types'        => array('listing'),
            'context'      => 'normal',
            'priority'     => 'high',
            'show_names'   => true,
            'fields' => array(
                array(
                    'name'      => __('MLS #', 'rel'),
                    'id'        => self::PREFIX . 'mls',
                    'type'      => 'text',
                ),
                array(
                    'name'      => __('Price', 'rel'),
                    'id'        => self::PREFIX . 'price',
                    'type'      => 'text_price',
                ),
                array(
                    'name'      => __('Beds', 'rel'),
                    'id'        => self::PREFIX . 'beds',
                    'type'      => 'text',
                ),
                array(
                    'name'      => __('Baths', 'rel'),
                    'id'        => self::PREFIX . 'baths',
                    'type'      => 'text',
                ),
                array(
                    'name'      => __('Size SqFt', 'rel'),
                    'id'        => self::PREFIX . 'sqft',
                    'type'      => 'text',
                ),
                array(
                    'name'      => __('Year Built', 'rel'),
                    'id'        => self::PREFIX . 'year',
                    'type'      => 'text',
                ),
                array(
                    'name'      => __('Taxes', 'rel'),
                    'id'        => self::PREFIX . 'taxes',
                    'type'      => 'text_price',
                ),
                array(
                    'name'      => __('Levels', 'rel'),
                    'id'        => self::PREFIX . 'levels',
                    'type'      => 'text',
                ),
                array(
                    'name'      => __('Parking', 'rel'),
                    'id'        => self::PREFIX . 'parking',
                    'type'      => 'text',
                ),
                array(
                    'name'      => __('HOA', 'rel'),
                    'id'        => self::PREFIX . 'hoa',
                    'type'      => 'text',
                )
            )
        );

        $photos     = array(
            'id'         => 'photos',
            'title'      => __('Property Photos', 'rel'),
            'object_types'        => array('listing'),
            'context'      => 'normal',
            'priority'     => 'high',
            'show_names'   => true,
            'fields'     => array(
                array(
                    'name'  => 'Images',
                    'desc'  => 'Upload and manage property photos',
                    'button' => 'Manage gallery',
                    'id'    => self::PREFIX . 'photos',
                    'type'  => 'pw_gallery',
                    'sanitization_cb' => 'pw_gallery_field_sanitise',
                ),
            )
        );

        $video_code = array(
            'id'         => 'video',
            'title'      => __('Property Video Tour', 'rel'),
            'object_types'        => array('listing'),
            'context'      => 'normal',
            'priority'     => 'high',
            'show_names'   => true,
            'fields'     => array(
                array(
                    'name' => __('Embedded Video Code', 'rel'),
                    'id'    => self::PREFIX . 'video_code',
                    'type'  => 'oembed',
                )
            )
        );

        $latlng = array(
            'id'     => 'latlng',
            'title'  => __('Latitude/Longitude', 'rel'),
            'object_types'        => array('listing'),
            'context'      => 'normal',
            'priority'     => 'high',
            'show_names'   => true,
            'fields' => array(
                array(
                    'id'         => self::PREFIX . 'lat',
                    'name'      => __('Latitude', 'rel'),
                    'type' => 'text_medium'
                ),
                array(
                    'id'         => self::PREFIX . 'lng',
                    'name'      => __('Longitude', 'rel'),
                    'type' => 'text_medium'
                )
            )
        );

        $maps = array(
            'id'           => 'maps',
            'title'        => __('Property Maps', 'rel'),
            'object_types'        => array('listing'),
            'context'      => 'normal',
            'priority'     => 'high',
            'show_names'   => true,
            'fields'       => array(
                array(
                    'id'         => self::PREFIX . 'gmap',
                    'name'      => __('Google Map', 'rel'),
                    'type' => 'checkbox',
                    'desc'  => __('Address fields are required for Google Map to function.', 'rel')
                ),
                array(
                    'id'         => self::PREFIX . 'birdseye',
                    'name'      => __('Bird\'s Eye View', 'rel'),
                    'type' => 'checkbox',
                    'desc'  => __('Latitude/Longitude are required for Bird\'s Eye View.', 'rel')
                )
            )
        );

        $plMetaBoxes = array(
            'address'           => $address,
            'listing_details'   => $listing_details,
            'photos'            => $photos,
            'video_code'        => $video_code,
            'latlng'            => $latlng,
            'maps'              => $maps
        );

        $return = apply_filters('hji_pocket_listings_metaboxes', $plMetaBoxes);
        return $return;
    }


    /**
     * Registering custom taxonomies
     */
    function register_taxonomies()
    {
        require_once(REL_UTILS . 'custom-taxonomies/CustomTaxonomies.php');

        $tax              = new CustomTaxonomies(self::POST_TYPE, self::taxonomy_args());
        $tax->register_taxonomies();

        $this->taxonomies = $tax->get_taxonomies();
    }


    /**
     * Load front-end styles
     */
    function add_styles()
    {
        wp_enqueue_style('rel_css', REL_STYLES . 'style.min.css');
    }


    /**
     * Altering wp_query before it gets executed
     *  - setting results per page value
     *
     * @param $query
     */
    function wp_query_listings($query)
    {
        // WP has a bug in pagination where it grabs
        // per page number of items ordered by date
        // this causes duplicate items spanned across multiple
        // pages if their post dare are the same.
        // So, we reorder by ID, since they are unique.
//        && $query->is_archive() && $query->is_tax()


        if (!is_admin() &&
            ($query->is_main_query() && ($query->get('post_type') == $this->post_type)) &&
            !$query->is_tax())
        {
            $general_settings = Admin::getSettings();

            $per_page = 24; //default

            if (isset($general_settings['per_page']) && $general_settings['per_page'] != null)
            {
                $per_page = $general_settings['per_page'];
            }

            $query->set('posts_per_page', $per_page);

            // Sort listings per user settings

            self::setQueryOrder($query);
        }

        else if (!is_admin() &&
            ($query->is_main_query() && $query->is_tax()))
        {
            $args       = array(
                'object_type' => array($this->post_type)
            );

            $taxonomies = get_taxonomies($args, 'names');

            $is_listing = false;
            $in_tax     = false;

            // Check if archive

            if ($query->is_archive())
            {
                // Is it listings archive?

                if ($query->get('post_type') == $this->post_type)
                {
                    $is_listing = true;
                }
                // Is it taxonomy archive?
                else if ($query->is_tax())
                {
                    // Get listing taxonomies and check if current request belongs to listing post type

                    $args       = array(
                        'object_type' => array($this->post_type)
                    );
                    $taxonomies = get_taxonomies($args, 'names');

                    if (count($query->query) > 0)
                    {
                        foreach ($query->query as $k => $v)
                        {
                            if (in_array($k, $taxonomies))
                            {
                                $in_tax = true;
                                break;
                            }
                        }
                    }
                }

                // Set query parameters

                if ($is_listing || $in_tax)
                {
                    $general_settings = Admin::getSettings();

                    $per_page = 24; //default

                    if (isset($general_settings['per_page']) && $general_settings['per_page'] != null)
                    {
                        $per_page = $general_settings['per_page'];
                    }

                    $query->set('posts_per_page', $per_page);

                    self::setQueryOrder($query);
                }

            }
        }

        return $query;
    }


    /**
     * @since 2.0.0
     * @param \WP_Query $query
     * @return \WP_Query
     */
    static function setQueryOrder(\WP_Query $query)
    {
        $args = self::getQueryOrderArgs();

        if (!empty($args))
        {
            foreach ($args as $k => $v)
            {
                $query->set($k, $v);
            }
        }

        return $query;
    }


    /**
     * @since 2.0.0
     * @return array
     */
    static function getQueryOrderArgs()
    {
        $args = array();
        $general_settings = Admin::getSettings();

        if (isset($general_settings['orderby']) && isset($general_settings['order']))
        {
            if (strpos($general_settings['orderby'], self::PREFIX) !== false)
            {
                $args['orderby']  = 'meta_value_num';
                $args['meta_key'] = self::PREFIX . 'price';
            }
            else
            {
                $args['orderby']  = $general_settings['orderby'];
            }

            $args['order']  = $general_settings['order'];
        }
        else
        {
            $args['order']    = 'DESC';
            $args['orderby']  = 'ID';
        }

        return $args;
    }


    /**
     * Renders templates based on the ones selected in general settings of the plugin
     */
    function use_template($template)
    {
        global $post;

        if (is_object($post) && $this->post_type == $post->post_type)
        {
            $general_settings = Admin::getSettings();

            $grid = (isset($general_settings['layout']) && !empty($general_settings['layout']))
                ? $general_settings['layout'] : null;

            $theme = wp_get_theme(); // Get current theme info

            if (is_archive())
            {
                if ((isset($general_settings['listings_template']) &&
                    !empty($general_settings['listings_template'])))
                {
                    $located = locate_template($general_settings['listings_template']);

                    if (!empty($located))
                    {
                        $template = $located;
                    }
                }
                // Check if current theme is Avenue, fallback onto the template inside the plugin's folder
                else if (stristr($theme->get('Name'), 'avenue'))
                {
                    $template = REL_PATH . 'templates/Avenue/archive-listing.php';
                }
            }
            else if (is_singular())
            {
                if ((isset($general_settings['listing_template']) &&
                    !empty($general_settings['listing_template'])))
                {
                    $located = locate_template($general_settings['listing_template']);

                    if (!empty($located))
                    {
                        $template = $located;
                    }
                }
            }
        }

        return $template;
    }


    /**
     * A Hack to make Pocket Listings play nice
     * with default theme templates.
     *
     * Possible issue that it solves:
     *
     * Default archive.php and single.php of any theme
     * can render post thumbnails by default. Since Pocket Listings
     * implements main listing photo as Featured Image of the post,
     * there is a risk of duplicate photo being rendered.
     *
     * This hack checks if default templates are used for listing post types
     * and if so, fires up filter that removes the_post_thumbnail() content.
     */

    function pocket_listing_play_nice_with_default_template($template)
    {
        global $post;

        if (!$post || $post->post_type !== 'listing')
            return $template;

        $fileName = basename($template);

        // Check if it's a default template
        if ($fileName == 'archive.php' || $fileName == 'single.php')
        {
            // A big chance that it calls get_post_thumbnail(),
            // which will cause to display duplicate photo for each listing snippet
            add_filter('post_thumbnail_html', array($this, 'remove_extra_thumbnail'));
        }

        return $template;
    }


    /**
     * Removes thumbnail html from listing post type
     *
     * @param $html
     * @return mixed
     */
    function remove_extra_thumbnail($html)
    {
        global $post;

        if ($post->post_type == $this->post_type)
        {
            return;
        }

        return $html;
    }


    /**
     * Another hack
     * Since by default Pocket Listings renders content via
     * the_content, we don't know if the template uses excerpts and
     * strips all html off. Fot hat case we do the following:
     *
     * 1. Hook into excerpt public function only on listing post types
     * 2. Set excerpt_more to 'pocket-listings'
     * 3. Hook into wp_trim_words and check if $more == 'pocket-listings'
     * 4. if 3 == true - return full html
     */

    function set_pocket_listing_excerpt($more)
    {
        global $post;

        if ($post->post_type !== $this->post_type)
            return $more;

        add_filter('wp_trim_words', array($this, 'dont_trim_excerpt'), 10, 4);

        return 'pocket-listing';
    }


    function dont_trim_excerpt($text, $num_words, $more, $original_text)
    {
        global $post;

        if ($post->post_type !== $this->post_type && $more != 'pocket-listings')
            return $text;

        return $original_text;
    }


    /**
     * Renders a single listing details page
     * implementation of the_content action hook
     *
     * @param $content existing page content
     * @return mixed|string|void
     */
    function listing_output($content)
    {
        global $post;

        if (is_admin() || $this->post_type !== $post->post_type)
        {
            return $content;
        }

        // Prepare listing object for the View

        $listing = $this->get_pocket_listing($post);

        ob_start();

        // Load View Template based on the currently requested page type

        if (is_archive())
        {
            include REL_VIEWS . 'archive-listing-view.phtml';
        }
        else
        {
            include REL_VIEWS . 'single-listing-view.phtml';
        }

        $output = ob_get_clean();

        return apply_filters('rel_listing_output', $output, $listing);
    }


    /**
     * Returns pocket listing object based on post object
     *
     * @param $post wp post object
     * @return \stdClass
     */
    function get_pocket_listing(\WP_Post $post)
    {
        require_once(REL_MODELS . 'ListingViewModel.php');

        $listing_view_model = new ListingViewModel($post);

        // Prepare listing object for the View

        return $listing_view_model->getListing();
    }
} 
HJI WP Membership Code Reference API documentation generated by ApiGen