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  772  773  774  775  776  777  778  779  780  781  782  783  784  785  786  787  788  789  790  791  792  793  794  795  796  797  798  799  800  801  802  803  804  805  806  807  808  809  810  811  812  813  814  815  816  817  818  819  820  821  822  823  824  825  826  827  828  829  830  831  832  833  834  835  836  837  838  839  840  841  842  843  844  845  846  847  848  849  850  851  852  853  854  855  856  857  858  859  860  861  862  863  864  865  866  867  868  869  870  871  872  873  874  875  876  877  878  879  880  881  882  883  884  885  886  887  888  889  890  891  892  893  894  895  896  897  898  899  900  901  902  903  904  905  906  907  908  909  910  911  912  913  914  915  916  917  918  919  920  921  922  923  924  925  926  927  928  929  930  931  932  933  934  935  936  937  938  939  940  941  942  943  944  945  946  947  948  949  950  951  952  953  954  955  956  957  958  959  960  961  962  963  964  965  966  967  968  969  970  971  972  973  974  975  976  977  978  979  980  981  982  983  984  985  986  987  988  989  990  991  992  993  994  995  996  997  998  999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 
<?php
namespace hji\ResponsiveIDX\controllers;

use \hji\membership\Membership;
use \hji\ResponsiveIDX\models\IdxSearchModel;
use \hji\ResponsiveIDX\ResponsiveIDX;
use \hji\ResponsiveIDX\utils\ArrayFormat;
use \hji\common\utils\Cookies;


class Settings extends BaseController
{
    // Settings object instance

    private static $instance;

    private $plugin_options_key = 'hjpl_options'; //hj Responsive IDX

    // Settings sections keys
    // http://theme.fm/2011/10/how-to-create-tabs-with-the-settings-api-in-wordpress-2590/

    static $general_settings_key        = 'hjpl_general_settings';
    static $property_ads_settings_key   = 'hjpl_property_ads_settings';
    static $offices_agents_settings_key = 'hjpl_offices_agents_settings';
    static $color_settings_key          = 'hjpl_color_settings';
    static $contact_info_settings_key   = 'hjpl_contact_info_settings';

    // Array of all loaded settings.

    private $loadedSettings = null;

    static $valid_license_keys = 'hjpl_valid_license_keys';

    static $mls_metadata = 'hjpl_mls_metadata';

    static $registration_settings_key = 'hjpl_registration_settings';

    // Default General Settings

    private $default_general_settings = array(
        'listings_slug'          => 'featured-listings',
        'grid_size'              => '4',
        'grid_rows'              => '5', // number of rows in a grid
        'results_per_page'       => '20',// non-rendered field: = grid_size * grid_rows
        'button_1'               => 'Request More Info',
        'button_2'               => 'Schedule a Showing',
        'button_listing_details' => 'View Property Details',
        'button_search'          => 'Search Now',
        'button_ad_call2action'  => 'View More Photos',
        'form_1'                 => false,
        'form_2'                 => false,
    );

    // Default Color Settings

    static $default_color_settings = array(
        'button-bg-light'   => '0088cc',
        'button-bg-dark'    => '0044cc',
        'button-text-color' => 'ffffff',
        'zebra-bg-light'    => 'ffffff',
        'zebra-bg-dark'     => 'f7f7f7'
    );

    private $default_registration_settings = array(
        'on'                  => false,
        'required'            => false,
        'trigger_listings'    => 3,
    );


    public function __construct()
    {
        parent::__construct();

        $this->default_general_settings['leads_email'] = get_option('admin_email');
        $this->loadSettings();

        add_filter('query_vars', array($this, 'addQueryVars'));

        if (is_admin())
        {
            add_action('admin_menu', array(&$this, 'add_menu'));
            add_action('admin_init', array(&$this, 'register_general_settings'));
            add_action('admin_init', array(&$this, 'register_property_ads_settings'));
            add_action('admin_init', array(&$this, 'register_offices_agents_settings'));
            add_action('admin_init', array(&$this, 'register_color_settings'));
            add_action('admin_init', array(&$this, 'register_contact_info_settings'));
            add_action('admin_init', array(&$this, 'register_registration_settings'));

            add_action('admin_notices', array(&$this, 'admin_notices_action'));

            add_action('wp_ajax__findAgents', array(&$this, '_findAgents'));
            add_action('wp_ajax__findOffices', array(&$this, '_findOffices'));
            add_action('wp_ajax__getAgents', array(&$this, '_getAgents'));
            add_action('wp_ajax__updateAgents', array(&$this, '_updateAgents'));
            add_action('wp_ajax__getOffices', array(&$this, '_getOffices'));
            add_action('wp_ajax__updateOffices', array(&$this, '_updateOffices'));
        }
    }


    static function getInstance()
    {
        if (!self::$instance)
        {
            self::$instance = new Settings();
        }

        return self::$instance;
    }


    function refreshRewriteRules()
    {
        $this->addRewriteRules();
        flush_rewrite_rules();
    }


    /**
     * Adds IDX-related variables to WP_Query object
     *
     * @param $queryVars
     * @return array
     */
    function addQueryVars($queryVars)
    {
        $queryVars[] = 'idx-action';
        $queryVars[] = 'idx-PropertyTypes';
        $queryVars[] = 'idx-Cities';
        $queryVars[] = 'idx-BedsMin';
        $queryVars[] = 'idx-BathsMin';
        $queryVars[] = 'idx-PriceMin';
        $queryVars[] = 'idx-PriceMax';
        $queryVars[] = 'idx-MlsNumber';
        $queryVars[] = 'idx-AddressSlug';
        $queryVars[] = 'idx-print';
        $queryVars[] = 'idx-MlsID';

        return $queryVars;
    }


    static function getRewriteRulesPatterns()
    {
        $opt = get_option(self::$general_settings_key);

        // /([^/]*)/mls-([a-zA-Z0-9\-]{5,})-([a-zA-Z0-9_\-]*)/?$

        return array(
            'listing-print' => array(
                'pattern'  => home_url($opt['listings_slug']) .'/{market}/mls-{listingId}-{address}/print/',
//                'rule'     => $opt['listings_slug'] . "/([^/]*)/mls-(.+)-([^/]*)/print/?$",
                'rule'     => $opt['listings_slug'] . '/([^/]*)/mls-([a-zA-Z0-9\-]{5,})-([a-zA-Z0-9_\-]*)/print/?$',
                'rewrite'  => 'index.php?idx-action=details&idx-MlsID=$matches[1]&idx-MlsNumber=$matches[2]&idx-AddressSlug=$matches[3]&idx-print=1'
            ),

            'listing-full' => array(
                'pattern'  => home_url($opt['listings_slug']) .'/{market}/mls-{listingId}-{address}',
//                'rule'     => $opt['listings_slug'] . "/([^/]*)/mls-(.+)-([^/]*)/?$",
                'rule'     => $opt['listings_slug'] . '/([^/]*)/mls-([a-zA-Z0-9\-]{5,})(?=-([a-zA-Z0-9\_]*))[^/]/?',
                'rewrite'  => 'index.php?idx-action=details&idx-MlsID=$matches[1]&idx-MlsNumber=$matches[2]&idx-AddressSlug=$matches[3]'
            ),

            'listing-short' => array(
                'pattern'  => home_url($opt['listings_slug']) .'/{market}/mls-{listingId}/',
//                'rule'     => $opt['listings_slug'] . '/([^/]*)/mls-(.+)/?$',
                'rule'     => $opt['listings_slug'] . '/([^/]*)/mls-([a-zA-Z0-9\-]{5,})/?$',
                'rewrite'  => 'index.php?idx-action=details&idx-MlsID=$matches[1]&idx-MlsNumber=$matches[2]'
            ),
        );
    }


    static function getRewriteRulePattern($item, $type)
    {
        $patterns = self::getRewriteRulesPatterns();

        if (isset($patterns[$item][$type]))
        {
            return $patterns[$item][$type];
        }
    }


    /**
     * Registers custom rewrite rules
     */
    function addRewriteRules()
    {
        // Listing Details Print View

        add_rewrite_rule(
            $this->getRewriteRulePattern('listing-print', 'rule'),
            $this->getRewriteRulePattern('listing-print', 'rewrite'),
            'top');

        // Listing Details View - Long URL /{market}/{listing_id}-{address}

        add_rewrite_rule(
            $this->getRewriteRulePattern('listing-full', 'rule'),
            $this->getRewriteRulePattern('listing-full', 'rewrite'),
            'top');

        // Listing Details View - Sort URL /{market}/{listing_id}
        // IMPORTANT: this rule has to be last in the sequence of rIDX rules

        add_rewrite_rule(
            $this->getRewriteRulePattern('listing-short', 'rule'),
            $this->getRewriteRulePattern('listing-short', 'rewrite'),
            'top');
    }


    /**
     * Displays all messages registered to 'your-settings-error-slug'
     */
    function admin_notices_action()
    {
        settings_errors(self::$general_settings_key);
    }


    function loadSettings()
    {
        $this->general_settings = (array)get_option(self::$general_settings_key);

        //Merge with defaults
        $this->general_settings = array_merge($this->default_general_settings, $this->general_settings);
        $this->loadedSettings[self::$general_settings_key] = $this->general_settings;

        $this->color_settings   = self::get_colors();
        $this->loadedSettings[self::$color_settings_key] = $this->color_settings;

        $this->contact_info_settings = get_option(self::$contact_info_settings_key);
        $this->loadedSettings[self::$contact_info_settings_key] = $this->contact_info_settings;

        $this->registration_settings = (array)get_option(self::$registration_settings_key);
        $this->registration_settings = array_merge($this->default_registration_settings, $this->registration_settings);
        $this->loadedSettings[self::$registration_settings_key] = $this->registration_settings;

        $this->offices_agents = get_option(self::$offices_agents_settings_key);
        $this->loadedSettings[self::$offices_agents_settings_key] = $this->offices_agents;
    }


    /**
     * Returns setting value
     *
     * @param $optionName
     * @return mixed
     */
    function getOption($optionName)
    {
        foreach($this->loadedSettings as $settings)
        {
            if (isset($settings[$optionName]))
            {
                return $settings[$optionName];
            }
        }
    }


    function getSearchPageSlug()
    {
        if ($pageId = $this->getOption('search_results_page_id'))
        {
            $post_data = get_post($pageId, ARRAY_A);
            return $post_data['post_name'];
        }
    }


    function add_menu()
    {
        //$page = add_options_page('Responsive IDX', 'Responsive IDX', 'manage_options', $this->plugin_options_key, array(&$this,'plugin_options_page'));
        $page = add_menu_page(
            'Responsive IDX',
            'Responsive IDX',
            'manage_options',
            $this->plugin_options_key,
            array($this, 'plugin_options_page'),
            Membership::$url . '/resources/images/admin-menu.png'
        );
        add_action('admin_print_scripts-' . $page, array($this, 'loadScripts'));
    }


    function plugin_options_page()
    {
        if (!current_user_can('manage_options'))
        {
            wp_die(__('You do not have sufficient permissions to access this page.'));
        }

        $tab = isset($_GET['tab']) ? $_GET['tab'] : self::$general_settings_key;

        echo '<div class="wrap">';
        if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == true)
        {
            echo '<div id="message" class="updated"><p>' . _('Settings saved.') . '</p></div>';
        }

        //Init API if General Options were saved

        if (isset($_REQUEST['settings-updated']) && $tab == self::$general_settings_key)
        {
            IdxApp::getInstance()->AuthenticateIDXAPI(true);

            // Refresh rewrite rules since we alter slugs

            $this->refreshRewriteRules();
        }

        //display enter license key message if none exist
        //Important to have API INIT before checking for valid licenses (see code above).

        if (!$this->membership->isLicensed())
        {
            printf('<div class="error"><p>Please provide a <a href="%s">valid license key</a>, otherwise Responsive IDX will not function correctly.</p></div>', admin_url('admin.php?page=hji-membership'));

        }

        $this->plugin_options_tabs();

        echo '<form method="post" action="options.php">';
        wp_nonce_field('update-options');
        settings_fields($tab);
        if (!Membership::getInstance()->isLicensed())
        {
            echo '<p>Please make sure your license is valid and current.</p>';
        }
        else
        {
            do_settings_sections($tab);
            submit_button();
        }

        echo '</form>';

        echo '</div>';
    }


    function plugin_options_tabs()
    {
        $current_tab = isset($_GET['tab']) ? $_GET['tab'] : self::$general_settings_key;

        echo '<div id="icon-options-general" class="icon32"><br></div>';
        echo '<h1>Responsive IDX by Home Junction&reg;</h1>';

        //screen_icon();
        echo '<h2 class="nav-tab-wrapper">';
        foreach ($this->plugin_settings_tabs as $tab_key => $tab_caption)
        {
            $active = $current_tab == $tab_key ? 'nav-tab-active' : '';
            echo '<a class="nav-tab ' . $active . '" href="?page=' . $this->plugin_options_key . '&tab=' . $tab_key . '">' . $tab_caption . '</a>';
        }
        echo '</h2>';
    }


    function general_settings_validate($input)
    {
        if (!isset($input['button_1']) || $input['button_1'] == null)
        {
            $input['button_1'] = $this->default_general_settings['button_1'];
        }

        if (!isset($input['button_2']) || $input['button_2'] == null)
        {
            $input['button_2'] = $this->default_general_settings['button_2'];
        }

        if (!isset($input['button_listing_details']) || $input['button_listing_details'] == null)
        {
            $input['button_listing_details'] = $this->default_general_settings['button_listing_details'];
        }

        if (!isset($input['button_ad_call2action']) || $input['button_ad_call2action'] == null)
            $input['button_ad_call2action'] = $this->default_general_settings['button_ad_call2action'];

        if (!isset($input['leads_email']) || $input['leads_email'] == null)
            $input['leads_email'] = $this->default_general_settings['leads_email'];

        if (isset($input['grid_size']) && isset($input['grid_rows']))
        {
            $input['results_per_page'] = (int)$input['grid_size'] * (int)$input['grid_rows'];
        }
        else
        {
            $input['results_per_page'] = $this->default_general_settings['results_per_page'];
        }

        // Reset search results view cookies, otherwise old setting will be in use.
        // Keep the require() here, don't load it outside of the class,
        // since this path does not exist in earlier version of Membership

        Cookies::deleteCookie('idx-results-viewas');

        return $input;
    }


    //TODO: Remove when the following story is resolved:
    // https://www.pivotaltracker.com/story/show/73315916
    static function get_valid_license_keys()
    {
        return Membership::getInstance()->customerModel->license->licenseKey;
    }


    static function get_mls_ids()
    {
        _deprecated_function( __FUNCTION__, '3.0', 'Membership::getMarkets()' );

        $markets =  Membership::getInstance()->getMarkets();

        return $markets;
    }


    /**
     * Registers General Settings
     *
     * @return void [type] [description]
     */
    function register_general_settings()
    {
        $this->plugin_settings_tabs[self::$general_settings_key] = 'General';

        register_setting(
            self::$general_settings_key,
            self::$general_settings_key,
            array($this,'general_settings_validate'));

        add_settings_section(
            'section_general',
            'General Plugin Settings',
            array($this, 'section_general'),
            self::$general_settings_key);

        wp_enqueue_script('jquery');
        wp_enqueue_script('jquery-ui-core');
        wp_enqueue_script('jquery-ui-widget');
        wp_enqueue_script('jquery-ui-dialog');
        wp_enqueue_style('wp-jquery-ui-dialog');
    }


    /**
     * General Settings Tab Content
     *
     * @return void [type] [description]
     */
    function section_general()
    {
        echo '<table class="form-table"><tbody>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Listings Slug</label></th>';
        echo '<td><input type="text" name="' . self::$general_settings_key . '[listings_slug]" value="' . esc_attr($this->general_settings['listings_slug']) . '" class="regular-text" /></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Search Results Page</label></th>';
        $pages_args = array(
            'echo'              => 0,
            'name'              => self::$general_settings_key . '[search_results_page_id]',
            'selected'          => isset($this->general_settings['search_results_page_id']) ? $this->general_settings['search_results_page_id'] : null,
            'show_option_none'  => 'Select Page',
            'option_none_value' => '',
        );
        echo '<td>' . wp_dropdown_pages($pages_args) . '</td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Search Results Layout</label></th>';
        echo '<td>';
        echo '<select id="grid_size" name="' . self::$general_settings_key . '[grid_size]">'
            .'<option value="2"' . selected($this->general_settings['grid_size'], '2', false) . '>2 in a row</option>'
            .'<option value="3"' . selected($this->general_settings['grid_size'], '3', false) . '>3 in a row</option>'
            .'<option value="4"' . selected($this->general_settings['grid_size'], '4', false) . '>4 in a row</option>'
            .'</select>';

        echo '<select id="grid_rows" name="' . self::$general_settings_key . '[grid_rows]">'
            .'<option value="1"' . selected($this->general_settings['grid_rows'], '1', false) . '>1 rows in a grid</option>'
            .'<option value="2"' . selected($this->general_settings['grid_rows'], '2', false) . '>2 rows in a grid</option>'
            .'<option value="3"' . selected($this->general_settings['grid_rows'], '3', false) . '>3 rows in a grid</option>'
            .'<option value="4"' . selected($this->general_settings['grid_rows'], '4', false) . '>4 rows in a grid</option>'
            .'<option value="5"' . selected($this->general_settings['grid_rows'], '5', false) . '>5 rows in a grid</option>'
            .'<option value="6"' . selected($this->general_settings['grid_rows'], '6', false) . '>6 rows in a grid</option>'
            .'<option value="7"' . selected($this->general_settings['grid_rows'], '7', false) . '>7 rows in a grid</option>'
            .'<option value="8"' . selected($this->general_settings['grid_rows'], '8', false) . '>8 rows in a grid</option>'
            .'<option value="9"' . selected($this->general_settings['grid_rows'], '9', false) . '>9 rows in a grid</option>'
            .'<option value="10"' . selected($this->general_settings['grid_rows'], '10', false) . '>10 rows in a grid</option>'
            .'</select>';

        echo '<p id="grid-layout-description" class="description"></p>';

        echo '</td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Leads Email Address</label></th>';
        echo '<td><input type="text" name="' . self::$general_settings_key . '[leads_email]" value="' . esc_attr($this->general_settings['leads_email']) . '" class="regular-text" /><p class="description">All generated leads/contacts will be sent to this email address.</p></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Sticky Search Widget</label></th>';
        echo '<td><input type="checkbox" name="' . self::$general_settings_key . '[sticky_search]" value="1" ' . checked(@$this->general_settings['sticky_search'], true, false) . ' /><p class="description">Search widget at the top of search results will stick to the top of the page, when page is scrolled down.</p></td>';
        echo '</tr>';

        echo '</tbody></table>';

        //echo $this->_offices_agents();

        echo '<h3>Custom Forms</h3>';
        echo '<p class="description">Default built-in forms will be used if no custom forms provided.</p>';
        echo '<table class="form-table"><tbody>';
        echo '<tr valign="top">';
        echo '<th scope="row"><label>Form 1 / Listing Inquiry</label></th>';
        echo '<td><input type="text" name="' . self::$general_settings_key . '[form_1]" value="' . esc_attr($this->general_settings['form_1']) . '" class="regular-text" /><span class="description">Form shortcode or absolute URL.</span></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Form 2 / Schedule a Showing</label></th>';
        echo '<td><input type="text" name="' . self::$general_settings_key . '[form_2]" value="' . esc_attr($this->general_settings['form_2']) . '" class="regular-text" /><span class="description">Form shortcode or absolute URL.</span></td>';
        echo '</tr>';

        echo '</tbody></table>';

        echo '<h3>Call to Action Buttons</h3>';

        echo '<table class="form-table"><tbody>';
        echo '<tr valign="top">';
        echo '<th scope="row"><label>Form 1 Button / Listing Inquiry</label></th>';

        echo '<td><input type="text" name="' . self::$general_settings_key . '[button_1]" value="' . esc_attr($this->general_settings['button_1']) . '" class="regular-text" /></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Form 2 Button / Schedule a Showing</label></th>';
        echo '<td><input type="text" name="' . self::$general_settings_key . '[button_2]" value="' . esc_attr($this->general_settings['button_2']) . '" class="regular-text" /></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Listing Details Button</label></th>';
        echo '<td><input type="text" name="' . self::$general_settings_key . '[button_listing_details]" value="' . esc_attr($this->general_settings['button_listing_details']) . '" class="regular-text" /><p class="description">Displayed under each listing on search results pages.</p></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>IDX Search Button</label></th>';
        echo '<td><input type="text" name="' . self::$general_settings_key . '[button_search]" value="' . esc_attr($this->general_settings['button_search']) . '" class="regular-text" /><p class="description">Displayed within search widgets.</p></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Inside Ads Call to Action Link</label></th>';
        echo '<td><input type="text" name="' . self::$general_settings_key . '[button_ad_call2action]" value="' . esc_attr($this->general_settings['button_ad_call2action']) . '" class="regular-text" /><p class="description">Displayed within property ads linking to property details pages.</p></td>';
        echo '</tr>';

        echo '</tbody></table>';

        ?>
        <script>
        (function($)
        {
            $(document).ready(function()
            {
                var gridLayout =
                {
                    ui: {
                        gridSize:       $('#grid_size'),
                        gridRows:       $('#grid_rows'),
                        description:    $('#grid-layout-description')
                    },

                    init: function()
                    {
                        var that = this;

                        this.calculate();

                        this.ui.gridSize.on('change', function()
                        {
                            that.calculate();
                        });

                        this.ui.gridRows.on('change', function()
                        {
                            that.calculate();
                        });
                    },

                    calculate: function()
                    {
                        var result = '';

                        if (this.ui.gridSize.val() && this.ui.gridRows.val())
                        {
                            result = 'Grid: ' + this.ui.gridSize.val() + ' x ' + this.ui.gridRows.val() +
                                ' = ' +  this.ui.gridSize.val() * this.ui.gridRows.val() + ' results per page.';
                        }

                        this.ui.description.html(result);
                    }
                };

                gridLayout.init();
            });

        })(jQuery);
        </script>

        <?php

    }


    /**
     * Offices/Agents IDs Sub-section for General Section.
     */
    function section_offices_agents()
    {
        if (!$this->membership->isLicensed())
            return;
        ?>
        <style tyle="text/css">
            /* Don't display the default submit button */
            .submit {
                display: none;
            }

            .ajax_loader {
                display: block;
                width: 31px;
                height: 31px;
                background: transparent url( <?php echo ResponsiveIDX::$images . '/ajax-loader.gif';?> ) no-repeat;
                position: relative;
                margin-top: -51px;
                top: -45px;
                left: 12em;
            }

            .ajax_loader.office {
                top: -5px;
            }

            input[disabled="disabled"],
            select[disabled="disabled"] {
                background: #eee;
            }
        </style>
        <script>

        (function($)
        {
            var add_agents = new Array,
                del_agents = new Array,
                all_agents = new Array,
                add_offices = new Array,
                del_offices = new Array,
                all_offices = new Array,
                agents =[],
                offices = [],
                license_key = null;

            var dialog_type = 'office'; // default

            var data =
            {
                agents:  [],
                offices: []
            };

            var ui = {};

            var oa =
            {
                init: function()
                {
                    ui = {
                        mls:            $('#mls'),
                        agentName:      $('#agent_name'),
                        agentId:        $('#agent_id'),
                        agentIds:       $('#agent_ids'),
                        officeName:     $('#agent_name'),
                        officeId:       $('#office_id'),
                        officeIds:      $('#office_ids'),
                        saveBtn:        $('#save_office_agents'),
                        addBtn:         $('.add_id'),
                        delBtn:         $('.delete_id')
                    };

                    oa.reloadAll();

                    //if license key is changed - reload everything
                    ui.mls.change(function()
                    {
                        oa.reloadAll();
                    });

                    //if agent name and id fields filled out
                    //then make Add button available
                    ui.agentName.keyup(function()
                    {
                        oa.buttonsOnOff('agent');
                    });

                    ui.agentId.keyup(function()
                    {
                        oa.buttonsOnOff('agent');
                    });

                    ui.agentIds.change(function()
                    {
                        oa.buttonsOnOff('agent');
                    });

                    ui.officeName.keyup(function()
                    {
                        oa.buttonsOnOff('office');
                    });

                    ui.officeId.keyup(function()
                    {
                        oa.buttonsOnOff('office');
                    });

                    ui.officeIds.change(function()
                    {
                        oa.buttonsOnOff('office');
                    });

                    ui.saveBtn.click(function()
                    {
                        oa.save();
                    });

                    ui.delBtn.click(function()
                    {
                        var type = $(this).attr('rel');
                        var confirmation = confirm("Are you sure you want to delete this " + type + "?");

                        if (false == confirmation)
                        {
                            return;
                        }

                        var del_id = jQuery('#' + type + '_ids').val();

                        if (typeof( del_id ) == 'undefined'
                            || del_id == null || del_id.length == -1)
                        {
                            return;
                        }

                        oa.deleteItem(del_id, type);

                        if (!ui.officeIds.find("option:selected").length)
                        {
                            oa.buttonsOnOff('office');
                            oa.buttonsOnOff('agent');
                        }
                    });

                    oa.setupDialog();
                },

                getData: function(type)
                {
                    if (typeof type != 'undefined')
                    {
                        return data[type+'s'];
                    }

                    return data;
                },

                setData: function(type, value)
                {
                    if (type === false && typeof value != 'undefined')
                    {
                        data = (value.length > 0) ? value : [];
                    }
                    else
                    {
                        data[type+'s'] = (value.length > 0) ? value : [];
                    }
                },

                getIds: function (type)
                {
                    var method = '_getAgents';

                    if (type == 'office')
                        method = '_getOffices';

                    if (typeof ui.mls != 'undefined')
                    {
                        mls = ui.mls.val();
                    }

                    jQuery.post(ajaxurl,
                        {
                            action: method,
                            mls: mls
                        },
                        function (response)
                        {
                            if (response instanceof Array)
                            {
                                oa.setData(type, response);
                                oa.updateSelectionListView(type, oa.getData(type));
                            }
                            else
                            {
                                oa.setData(type, []);
                                oa.updateSelectionListView(type, oa.getData(type));
                            }
                            oa.spinner(type, false);
                        },
                        "json"
                    );
                },

                reloadAll: function()
                {
                    this.spinner('office', true);
                    this.spinner('agent', true);
                    this.getIds('office');
                    this.getIds('agent');
                },

                deleteItem: function(del_id, type)
                {
                    var items = this.getData(type);

                    for (i in items)
                    {
                        if (typeof items[i].id != 'undefined'
                            && items[i].id == del_id)
                        {
                            items.splice(i, 1);
                            this.setData(type, items);
                        }
                    }

                    this.save();
                },

                buttonsOnOff: function(type)
                {
                    if (ui[type + 'Ids'].find('option:selected').length > 0)
                    {
                        console.log('selected');
                        $('#delete_' + type + '_id').removeAttr('disabled');
                    }
                    else
                    {
                        console.log('NOT selected');
                        $('#delete_' + type + '_id').attr('disabled', 'disabled');
                    }
                },

                spinner: function(type, on)
                {
                    if (on)
                    {
                        if (jQuery('.ajax_loader.' + type).length > 0)
                            return false;

                        if ('search_results' == type) {
                            jQuery('#' + type).after('<div class="ajax_loader ' + type + '"></div>');
                            jQuery('.ajax_loader.' + type).css({'position': 'relative', 'margin-top': '-150px', 'left': '48%'});
                            return false;
                        }

                        //console.log('ajax loader on: ' + '#' + type + '_ids');
                        jQuery('#' + type + '_ids').after('<div class="ajax_loader ' + type + '"></div>');
                        jQuery('#' + type + '_ids').attr('disabled', 'disabled');
                        jQuery('#' + type + '_id').attr('disabled', 'disabled');
                        jQuery('#' + type + '_name').attr('disabled', 'disabled');
                    }
                    else
                    {
                        //console.log('ajax loader off');
                        jQuery('#' + type + '_ids').removeAttr('disabled', 'disabled');
                        jQuery('#' + type + '_id').removeAttr('disabled', 'disabled');
                        jQuery('#' + type + '_name').removeAttr('disabled', 'disabled');
                        jQuery('.ajax_loader.' + type).remove();
                    }
                },

                updateSelectionListView: function (type, ids)
                {
                    var options = '';

                    for (i in ids)
                    {
                        options += '<option value="' + ids[i].id + '">' + ids[i].label + ' - ' + ids[i].id + '</option>';
                    }

                    $('#' + type + '_ids').html(options);
                },

                save: function()
                {
                    this._save('office');
                    this._save('agent');
                },

                _save: function(type)
                {
                    var method = '_updateAgents';

                    if (type == 'office')
                    {
                        method = '_updateOffices';
                    }


                    //console.log('AJAX: saving agents');
                    this.spinner(type, true);

                    jQuery.post(ajaxurl,
                        {
                            action: method,
                            mls: mls,
                            data: this.getData()
                        },
                        function (response)
                        {
                            //console.log('AJAX: add id ' + response);
                            if (response == true)
                            {
                                // Get updated data from the system
                                // and update Views
                                oa.getIds(type);
                            }

                            ui.officeIds.find('option').prop('selected', false);
                            ui.agentIds.find('option').prop('selected', false);
                            oa.buttonsOnOff(type);
                            oa.updateSelectionListView(type, oa.getData(type));
                            oa.spinner(type, false);
                        },
                        "json"
                    );
                },

                addItemToList: function (id, name, type)
                {                     var new_id = id;
                    var new_id = id;
                    var new_name = name;
                    var items = this.getData(type);

                    //clear the entry fields
                    jQuery('#' + type + '_id').val('');
                    jQuery('#' + type + '_name').val('');

                    if (new_id.length > 0 && new_name.length > 0)
                    {
                        if (items.length > 0)
                        {
                            //check if new id already exists in the list
                            for (i in items) {
                                if (items[i].id == new_id) {
                                    alert('This ' + type + ' ID already exists.');
                                    return;
                                }
                            }
                        }

                        var new_record = {
                            id: new_id,
                            label: new_name
                        };

                        items.push(new_record);
                        this.setData(type, items);

                        this.updateSelectionListView(type, this.getData(type));
                        this.save();

                        alert(type.charAt(0).toUpperCase() + type.slice(1) + ' ' + new_name + ' has been added to the list.');

                    }

                    return false;
                },

                lookupItem: function(type)
                {
                    dialog_type = jQuery('[name="search_type"]:checked').val();

                    //if at least 3 characters - perform a search

                    if (jQuery('#search_item').val().length >= 3)
                    {
                        this.spinner('search_results', true);
                        var method = '_findOffices';
                        var type = dialog_type + 's';

                        if (dialog_type == 'agent')
                            var method = '_findAgents';

                        jQuery.post(ajaxurl,
                            {
                                action: method,
                                market: mls,
                                name: jQuery('#search_item').val()
                            },
                            function (response)
                            {
                                if (typeof response[type] != 'undefined'
                                    && response[type] != null
                                    && response[type].length > 0)
                                {
                                    var options = '';
                                    var results = response[type];
                                    for (i in results)
                                    {
                                        var id = results[i]["id"];
                                        var name = results[i]["name"];
                                        options += '<li id="id_' + id + '">';
                                        options += '<input type="hidden" class="id" value="' + id + '" />';
                                        options += '<input type="hidden" class="name" value="' + name + '" />';
                                        options += '<span class="item-title">' + name + '</span>';
                                        options += '<span class="item-info">' + id + '</span>';
                                        options += '</li>';
                                    }
                                    var content = '<ul>' + options + '</ul>';
                                    oa.spinner('search_results', false);
                                }
                                else if (response.total === 0)
                                {
                                    oa.spinner('search_results', false);
                                    alert('No matches were found.');
                                }
                                else
                                {
                                    if (response.code != 'undefined')
                                    {
                                        var error = 'Something went wrong. API returned code %code%. Please contact Home Junction support.';

                                        if (response.message.length > 0)
                                        {
                                            error = 'API Error (%code%): ' + response.message;
                                        }

                                        error = error.replace('%code%', response.code);

                                        content = '<p style="color: red">' + error + '</p>';
                                        oa.spinner('search_results', false);
                                    }

                                }

                                jQuery('#search_results').html(content);
                                oa.spinner('search_results', false);
                            },
                            "json"
                        );
                    }
                },

                setupDialog: function()
                {
                    jQuery('#agent_office_dialog').dialog({
                        dialogClass: 'wp-dialog',
                        modal: true,
                        autoOpen: false,
                        closeOnEscape: true,
                        minWidth: 530,
                        height: 530,
                        title: 'Lookup: Agent/Office',
                        buttons: [
                            {
                                text: "Insert",
                                click: function () {
                                    var _id = jQuery('#search_results li.selected .id').val();
                                    var _name = jQuery('#search_results li.selected .name').val();
                                    oa.addItemToList(_id, _name, dialog_type);
                                    //jQuery( this ).dialog( "close" );
                                }
                            },
                            {
                                text: "Close",
                                click: function () {
                                    jQuery('#search_results').html('');
                                    jQuery('#search_item').val('');
                                    jQuery(this).dialog("close");
                                }
                            }
                        ],
                        open: function (event, ui) {
                            jQuery('[name="search_type"]').prop('checked', false);
                            jQuery('#agent_office_dialog .type_' + dialog_type).prop('checked', true);
                        }
                    });

                    // Reset search results selection action

                    jQuery(document).on('click', '#search_results li', function()
                    {
                        jQuery('#search_results li').removeClass('selected');
                        jQuery(this).addClass('selected');
                    });

                    jQuery('[name="search_type"]').change(function()
                    {
                        dialog_type = jQuery('[name="search_type"]:checked').val();
                        jQuery('#search_results').html('');
                        jQuery('#search_item').val('');
                    });

                    jQuery('.add_id').click(function()
                    {
                        dialog_type = jQuery(this).attr('rel');
                        jQuery('#agent_office_dialog').dialog('open');
                    });



                    //search field listener
                    var thread = null;

                    jQuery('#search_item').keyup(function()
                    {
                        clearTimeout(thread);
                        $this = jQuery(this);
                        thread = setTimeout(function()
                        {
                            oa.lookupItem($this.val());
                        }, 300);

                    });
                }

            }

            $(document).ready(function()
            {
                oa.init();
            });


            function _ajax_loader_center_css(selector) {
                var css = {'position': 'relative', 'top': '-' + (w - alw) / 2 + 'px', 'left': (h - alh) / 2 + 'px'};
                return css;
            }

        })(jQuery);

        </script>

        <style tyle="text/css">
            #agent_office_dialog {
                padding: 10px;
            }

            #search_results {
                width: 500px;
                height: 300px;
                border: 1px solid #dfdfdf;
                background-color: white;
                border-radius: 3px;
                overflow-y: scroll;
            }

            #search_results ul {
                list-style: none;
                margin: 0;
            }

            #search_results .item-title {
                display: inline-block;
                width: 80%;
            }

            #search_results .item-info {
                text-transform: uppercase;
                color: #666;
                font-size: 11px;
                position: absolute;
                right: 5px;
                top: 4px;
                bottom: 0;
            }

            #search_results li {
                cursor: pointer;
            }

            #search_results li {
                clear: both;
                margin-bottom: 0;
                border-bottom: 1px solid #f1f1f1;
                color: #333;
                padding: 4px 6px;
                cursor: pointer;
                position: relative;
            }

            #search_results li:nth-child(even) {
                background-color: #fcfcfc;
            }

            #search_results li:hover {
                background: #eaf2fa;
                color: #151515;
            }

            #search_results li.selected {
                background-color: #ddd;
                color: #333;
            }

            #search_results li.selected .item-title {
                font-weight: bold;
            }
        </style>
        <?php
        //If multiple license keys exist, then display them
        //in a selection list, otherwise - not.
        $mls_ids = Membership::getInstance()->getMarkets();

        if (!empty($mls_ids))
        {
            $options = '';
            foreach ($mls_ids as $key => $mls)
            {
                $options .= '<option value="' . $mls . '">' . strtoupper($mls) . '</option>';
            }
            echo '<table class="form-table"><tbody>';
            echo '<tr valign="top">';
            echo '<th scope="row"><label>MLS</label></th>';
            echo '<td><select id="mls">' . $options . '</select></td>';
            echo '</tr>';
            echo '</tbody></table>';
            echo '<br />';
            echo '<br />';
        }

        ?>

        <div id="agent_office_dialog">
            <p><label>Lookup Type</label></p>

            <p>Office <input class="type_office" type="radio" name="search_type" value="office"/>&nbsp;&nbsp;&nbsp;Agent
                <input class="type_agent" type="radio" name="search_type" value="agent"/></p>

            <p>Enter Office/Agent name: <input id="search_item" type="text"/> <em>(enter at least 3 characters)</em>
            </p>

            <div id="search_results">
            </div>
        </div>
        <?php
        echo '<p class="description">Office and Agent IDs associated with your license key.</p>';
        echo '<table class="form-table"><tbody>';


        echo '<tr valign="top">';
        echo '<th scope="row"><label>Offices</label></th>';
        echo '<td><select id="office_ids" size="10" style="width: 25em; height: 7em">';
        echo '</select><br />';
        echo '<input type="button" value="Add" id="add_office_id" rel="office" class="add_id button-secondary" />&nbsp;';
        echo '<input type="button" value="Delete" id="delete_office_id" rel="office" action="delete" class="delete_id button-secondary" disabled="disabled"/>';
        echo '</td>';
        echo '</tr>';


        echo '<tr valign="top">';
        echo '<th scope="row"><label>Agents</label></th>';
        echo '<td><select id="agent_ids" size="10" style="width: 25em; height: 14em">';
        echo '</select><br />';
        echo '<input type="button" value="Add" id="add_agent_id" rel="agent" class="add_id button-secondary" />&nbsp;';
        echo '<input type="button" value="Delete" id="delete_agent_id" rel="agent" action="delete" class="delete_id button-secondary" disabled="disabled"/>';
        echo '</td>';
        echo '</tr>';

        echo '</tbody></table>';
        echo '<p><input type="button" id="save_office_agents" class="button-primary" value="Save Changes" /></p>';

    }


    static function _getAgents()
    {
        if (isset($_POST['mls']))
        {
            $params['mls'] = esc_attr($_POST['mls']);
        }
        else
        {
            $membership = Membership::getInstance();
            $params['mls'] = array_shift($membership->customerModel->markets);
        }

        $opt = get_option(self::$offices_agents_settings_key);
        $opt = ArrayFormat::stripslashes($opt);

        if (isset($opt[$params['mls']]['agents']))
        {
            die(json_encode($opt[$params['mls']]['agents']));
        }

        die(-1);
    }


    /**
     * Ajax function
     */
    static function _findAgents()
    {
        if (isset($_POST['market']))
        {
            $params['market'] = esc_attr($_POST['market']);
        }
        else
        {
            $membership = Membership::getInstance();
            $params['mls'] = array_shift($membership->customerModel->markets);
        }

        $params['name'] = isset($_POST['name']) ? $_POST['name'] : die($_POST['name']);

        $idxSearchModel = IdxApp::getInstance()->idxSearchModel;

        $ids = $idxSearchModel->searchAgents($params);

        if ($error = $idxSearchModel->getError())
        {
            if (isset($error->error['code']) && $error->error['code'] != null)
            {
                die(json_encode($error->error));
            }
        }

        die(json_encode($ids));
    }


    /**
     * Ajax function
     */
    static function _findOffices()
    {
        if (isset($_POST['market']))
        {
            $params['market'] = esc_attr($_POST['market']);
        }
        else
        {
            //get first one on the list

            $membership = Membership::getInstance();
            $params['mls'] = array_shift($membership->customerModel->markets);
        }

        $params['name'] = isset($_POST['name']) ? $_POST['name'] : die($_POST['name']);

        $ids = IdxApp::getInstance()->idxSearchModel->searchOffices($params);

        die(json_encode($ids));
    }


    /**
     * Ajax function
     */
    static function _updateAgents()
    {
        if (isset($_POST['mls']))
        {
            $market = esc_attr($_POST['mls']);
            $opt = get_option(self::$offices_agents_settings_key);

            $data = (isset($_POST['data'])) ? $_POST['data'] : null;
            $opt[$market] = $data;

            $opt = ArrayFormat::stripslashes($opt);

            if (update_option(self::$offices_agents_settings_key, $opt))
            {
                die(true);
            }
        }

        die(-1);
    }


    static function _getOffices()
    {
        if (isset($_POST['mls']))
        {
            $params['mls'] = esc_attr($_POST['mls']);
        }
        else
        {
            $membership = Membership::getInstance();
            $params['mls'] = array_shift($membership->customerModel->markets);
        }

        $opt = ArrayFormat::stripslashes(get_option(self::$offices_agents_settings_key));

        if (isset($opt[$params['mls']]['offices']))
        {
            die(json_encode($opt[$params['mls']]['offices']));
        }

        die(-1);
    }


    /**
     * Ajax function
     */
    static function _updateOffices()
    {
        if (isset($_POST['mls']))
        {
            $market = esc_attr($_POST['mls']);
            $opt = ArrayFormat::stripslashes(get_option(self::$offices_agents_settings_key));

            $data = (isset($_POST['data'])) ? $_POST['data'] : null;
            $opt[$market] = $data;

            $opt = ArrayFormat::stripslashes($opt);

            if (update_option(self::$offices_agents_settings_key, $opt))
            {
                die(true);
            }
        }

        die(-1);
    }


    /**
     * Registers Property Ads settings
     *
     * @return void [type] [description]
     */
    function register_property_ads_settings()
    {
        $this->plugin_settings_tabs[self::$property_ads_settings_key] = 'Property Ads';
        register_setting(self::$property_ads_settings_key, self::$property_ads_settings_key);

        add_settings_section('section_property_ads', 'Property HTML Ads', array(
                                                                               &$this, 'section_property_ads'
                                                                          ), self::$property_ads_settings_key);
    }


    /**
     * Register Offices/Agents settings
     *
     * @return void [type] [description]
     */
    function register_offices_agents_settings()
    {
        $this->plugin_settings_tabs[self::$offices_agents_settings_key] = 'Offices/Agents';
        register_setting(self::$offices_agents_settings_key, self::$offices_agents_settings_key);

        add_settings_section('section_offices_agents', 'Offices and Agents', array(
                                                                                  &$this, 'section_offices_agents'
                                                                             ), self::$offices_agents_settings_key);
    }


    function register_color_settings()
    {
        $this->plugin_settings_tabs[self::$color_settings_key] = 'Colors';
        register_setting(self::$color_settings_key, self::$color_settings_key);

        add_settings_section('section_color', '', array(
                                                       &$this, 'section_color'
                                                  ), self::$color_settings_key, array(
                                                                                     &$this,
                                                                                     'color_settings_validate'
                                                                                ));
    }


    function register_contact_info_settings()
    {
        $this->plugin_settings_tabs[self::$contact_info_settings_key] = 'Contact Info';
        register_setting(self::$contact_info_settings_key, self::$contact_info_settings_key);

        add_settings_section('section_contact_info', '', array(
                                                              &$this, 'section_contact_info'
                                                         ), self::$contact_info_settings_key);
    }


    function register_registration_settings()
    {
        $this->plugin_settings_tabs[self::$registration_settings_key] = 'User Registration';
        register_setting(self::$registration_settings_key, self::$registration_settings_key);

        add_settings_section('section_registration', '', array(
                                                              &$this, 'section_registration'
                                                         ), self::$registration_settings_key);
    }


    function loadScripts()
    {
        wp_enqueue_script('jquery');
        wp_enqueue_script('jquery-ui-dialog');
        wp_enqueue_style('wp-jquery-ui-dialog');

        //load color-picker for colors tab
        if (isset($_GET['tab']) && self::$color_settings_key == $_GET['tab'])
        {
            wp_enqueue_script('thickbox');
            wp_enqueue_style('thickbox');
            wp_enqueue_script('media-upload');
            wp_enqueue_script('wptuts-upload');
            wp_enqueue_script('iris');
        }
    }


    /**
     * HTML Property Ads Tab Content
     *
     * @return void [type] [description]
     */
    function section_property_ads()
    {
        //TODO: PARAMETERS HAVE TO BE PREPARED IN ONE CENTRAL PLACE
        //otherwise can't set link URI correctly

        $markets = $this->membership->customerModel->markets;

        if (isset($_GET['market']))
        {
            $params['market'] = $_GET['market'];
        }
        else if (!empty($markets))
        {
            // Grab first licensed market
            foreach ($markets as $k => $v)
            {
                $params['market'] = $k;
                break;
            }
        }

        if (isset($_GET['listingId']) && !empty($_GET['listingId']))
        {
            $params['id'] = trim($_GET['listingId']);
        }

        if (isset($_GET['agentId']) && !empty($_GET['agentId']))
        {
            $params['agentId'] = trim($_GET['agentId']);
        }

        if (isset($_GET['officeId']) && !empty($_GET['officeId']))
        {
            $params['officeId'] = trim($_GET['officeId']);
        }

        $params['action'] = 'GetPromotedListings';

        $idxSearchModel = new IdxSearchModel();
        $idxSearchModel->SetSearchParams($params);

        // Start preparing the VIEW

        $notices = new \hji\common\models\Notices();


        if (!Membership::getInstance()->isLicensed())
        {
            $message = sprintf('Please make sure your <a href="%s">License Key</a> is valid. For help, contact customer support at %s or %s.</p>', admin_url('admin.php?page=hji-membership'), Membership::SUPPORT_EMAIL, Membership::SUPPORT_PHONE);
            $notices->addNotice($message, 2);
            $vars = array(
                'error' => $notices
            );
        }
        else
        {
            $searchResultsViewModel = new \hji\ResponsiveIDX\models\SearchResultsViewModel($idxSearchModel, $this->view);

            $this->view = $searchResultsViewModel->getPropertyAdsView();

            $this->view->set('idxApp', IdxApp::getInstance());
            $this->view->set(
                'call2action',
                (isset($this->general_settings['button_ad_call2action']))
                        ? $this->general_settings['button_ad_call2action']
                        : 'View More Photos');
            $this->view->set('offices_agents', $this->offices_agents);
        }

        echo $this->view->render('admin-property-ads');

        ?>
        <script>
            jQuery(document).ready(function () {
                jQuery('[id^="snippet_"]').dialog({
                    dialogClass: 'wp-dialog',
                    modal: true,
                    autoOpen: false,
                    closeOnEscape: true,
                    minWidth: 740,
                    title: 'Property Ad HTML Code'
                });
                jQuery('.get_html').click(function () {
                    var id = jQuery(this).attr('rel');
                    jQuery('#' + id).dialog('open');
                    //click to copy
                    jQuery('#' + id + ' textarea').live('click', function () {
                        jQuery(this).blur();
                        jQuery(this).focus();
                        jQuery(this).select();
                        return false;
                    });
                    return false;
                });

                //Submit filter form when Office is selected
                //this will update a corresponding selection list of agents for this office.
                jQuery('select#market').on('change', function ()
                {
                    // Get market value

                    var market = jQuery(this).val();

                    // Clear all previous selections in the form

                    jQuery(this).parent('form')[0].reset();
                    // For some reason reset doesn't clear values that have "select" attribute rendered.
                    jQuery(this).parent('form').find('select').each(
                        function(){
                            jQuery(this).val('');
                        }
                    );

                    // Set market value

                    jQuery(this).val(market);

                    // Submit form

                    jQuery('#filter-ads').trigger('click');
                });

            });
        </script>
        <style>
            p.submit {
                display: none;
            }
        </style>
    <?php

    }


    static function get_colors()
    {
        $color_settings = (array)get_option(self::$color_settings_key);
        $color_settings = array_merge(self::$default_color_settings, $color_settings);

        return $color_settings;
    }


    function section_color()
    {
        ?>
        <script>
            jQuery(document).ready(
                function ()
                {
                    function customColors()
                    {
                        if (jQuery('.custom-colors').is(':checked'))
                        {
                            jQuery('input.color').removeAttr('disabled');
                        }
                        else
                        {
                            jQuery('input.color').attr({'disabled' : 'disabled'})
                        }
                    }

                    customColors();

                    jQuery('.custom-colors').click(
                        function()
                        {
                            customColors();
                        }
                    )

                    jQuery('input.color').iris({
                        palettes: ['#f7f7f7', '#eaeaea', '#08c', '#04c']
                                               });
                    jQuery(document).click(function (e) {
                        if (!jQuery(e.target).is("input.color, .iris-picker, .iris-picker-inner")) {
                            jQuery('input.color').iris('hide');
                        }
                    });
                    jQuery('input.color').click(function (event) {
                        jQuery('input.color').iris('hide');
                        jQuery(this).iris('show');
                        return false;
                    });

                    jQuery('#upload_gmap_marker_button').click(function () {
                        formfield = jQuery('#upload_gmap_marker').attr('name');
                        tb_show('Upload New GMap Marker', 'media-upload.php?type=image&TB_iframe=true&post_id=0', false);
                        return false;
                    });


                    window.send_to_editor = function (html) {
                        var imgurl = jQuery('img', html).attr('src');
                        jQuery('#upload_gmap_marker').val(imgurl);
                        tb_remove();
                    }
            });
        </script>
        <?php
        echo '<h3>Button Colors</h3>';

        echo '<table class="form-table ridx-color-settings"><tbody>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Custom Colors</label></th>';
        echo '<td>';
        echo '<input class="custom-colors" type="checkbox" name="' . self::$color_settings_key . '[colors-on]" value="1" ' . checked(@$this->color_settings['colors-on'], true, false) . '/>';
        echo '</td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Light Gradient</label></th>';
        echo '<td>';
        echo '<input type="text" class="regular-text color" name="' . self::$color_settings_key . '[button-bg-light]" value="' . $this->color_settings['button-bg-light'] . '"/>';
        echo '</td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Dark Gradient</label></th>';
        echo '<td>';
        echo '<input type="text" class="regular-text color" name="' . self::$color_settings_key . '[button-bg-dark]" value="' . $this->color_settings['button-bg-dark'] . '"/>';
        echo '</td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Text Color</label></th>';
        echo '<td>';
        echo '<input type="text" class="regular-text color" name="' . self::$color_settings_key . '[button-text-color]" value="' . $this->color_settings['button-text-color'] . '"/>';
        echo '</td>';
        echo '</tr>';

        echo '</tbody></table>';

        echo '<h3>Zebra (odd/even) Rows</h3>';

        echo '<table class="form-table"><tbody>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Light Background</label></th>';
        echo '<td>';
        echo '<input type="text" class="regular-text color" name="' . self::$color_settings_key . '[zebra-bg-light]" value="' . $this->color_settings['zebra-bg-light'] . '"/>';
        echo '</td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Dark Background</label></th>';
        echo '<td>';
        echo '<input type="text" class="regular-text color" name="' . self::$color_settings_key . '[zebra-bg-dark]" value="' . $this->color_settings['zebra-bg-dark'] . '"/>';
        echo '</td>';
        echo '</tr>';

        echo '</tbody></table>';


        echo '<h3>Custom Map Marker</h3>';

        echo '<table class="form-table"><tbody>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Current Marker</label></th>';
        echo '<td>';
        $marker = ResponsiveIDX::$url . '/resources/images/marker.png';
        if (isset($this->color_settings['gmap-marker']) && !empty($this->color_settings['gmap-marker']))
            $marker = $this->color_settings['gmap-marker'];

        echo '<div id="current-icon"><img src="' . $marker . '"/></div>';
        echo '</td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>GMap Marker</label></th>';
        echo '<td>';
        echo '<label for="upload_gmap_marker">
                    <input id="upload_gmap_marker" type="text" size="36" name="' . self::$color_settings_key . '[gmap-marker]" value="' . @$this->color_settings['gmap-marker'] . '" />
                    <input id="upload_gmap_marker_button" type="button" value="Upload Marker Image" />
                    <br />Upload your custom Google Map Marker image.
                </label>';
        echo '</td>';
        echo '</tr>';

        echo '</tbody></table>';

    }


    function color_settings_validate($input)
    {
        if (isset($input['gmap-marker']))
            $input['gmap-marker'] = strip_tags(stripslashes($input['gmap-marker']));

        return $input;
    }


    function section_contact_info()
    {
        //pre-process field values, since they are empty by default
        $company_name   = (isset($this->contact_info_settings['company_name'])) ? esc_attr($this->contact_info_settings['company_name']) : '';
        $street_address = (isset($this->contact_info_settings['street_address'])) ? esc_attr($this->contact_info_settings['street_address']) : '';
        $city           = (isset($this->contact_info_settings['city'])) ? esc_attr($this->contact_info_settings['city']) : '';
        $state_province = (isset($this->contact_info_settings['state_province'])) ? esc_attr($this->contact_info_settings['state_province']) : '';
        $postal_code    = (isset($this->contact_info_settings['postal_code'])) ? esc_attr($this->contact_info_settings['postal_code']) : '';
        $contact_person = (isset($this->contact_info_settings['contact_person'])) ? esc_attr($this->contact_info_settings['contact_person']) : '';
        $email          = (isset($this->contact_info_settings['email'])) ? esc_attr($this->contact_info_settings['email']) : '';
        $phone1         = (isset($this->contact_info_settings['phone1'])) ? esc_attr($this->contact_info_settings['phone1']) : '';
        $phone2         = (isset($this->contact_info_settings['phone2'])) ? esc_attr($this->contact_info_settings['phone2']) : '';
        $fax            = (isset($this->contact_info_settings['fax'])) ? esc_attr($this->contact_info_settings['fax']) : '';

        echo '<h3>Contact Information</h3>';

        echo '<p class="description">This information will be used on property search results and listing details pages, partially or in full.</p>';

        echo '<table class="form-table"><tbody>';
        echo '<tr valign="top">';
        echo '<th scope="row"><label>Company Name</label></th>';
        echo '<td><input type="text" name="' . self::$contact_info_settings_key . '[company_name]" value="' . $company_name . '" class="regular-text" />';
        echo '</td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Street Address</label></th>';
        echo '<td><input type="text" name="' . self::$contact_info_settings_key . '[street_address]" value="' . $street_address . '" class="regular-text" /></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>City</label></th>';
        echo '<td><input type="text" name="' . self::$contact_info_settings_key . '[city]" value="' . $city . '" class="regular-text" /></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>State/Province</label></th>';
        echo '<td><input type="text" name="' . self::$contact_info_settings_key . '[state_province]" value="' . $state_province . '" class="regular-text" /></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Postal Code</label></th>';
        echo '<td><input type="text" name="' . self::$contact_info_settings_key . '[postal_code]" value="' . $postal_code . '" class="regular-text" /></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Contact Person</label></th>';
        echo '<td><input type="text" name="' . self::$contact_info_settings_key . '[contact_person]" value="' . $contact_person . '" class="regular-text" /></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Email</label></th>';
        echo '<td><input type="text" name="' . self::$contact_info_settings_key . '[email]" value="' . $email . '" class="regular-text" /></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Phone 1</label></th>';
        echo '<td><input type="text" name="' . self::$contact_info_settings_key . '[phone1]" value="' . $phone1 . '" class="regular-text" /></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Phone 2</label></th>';
        echo '<td><input type="text" name="' . self::$contact_info_settings_key . '[phone2]" value="' . $phone2 . '" class="regular-text" /></td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Fax</label></th>';
        echo '<td><input type="text" name="' . self::$contact_info_settings_key . '[fax]" value="' . $fax . '" class="regular-text" /></td>';
        echo '</tr>';

        echo '</tbody></table>';
    }


    function section_registration()
    {
        $on   = (isset($this->registration_settings['on'])) ? esc_attr($this->registration_settings['on']) : false;
        $confirmation   = (isset($this->registration_settings['confirmation'])) ? esc_attr($this->registration_settings['confirmation']) : false;
        $required   = (isset($this->registration_settings['required'])) ? esc_attr($this->registration_settings['required']) : false;
        $trigger_listings   = (isset($this->registration_settings['trigger_listings'])) ? esc_attr($this->registration_settings['trigger_listings']) : false;

        echo '<h3>User Registration</h3>';

        echo '<table class="form-table"><tbody>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>User Registration Prompt</label></th>';
        echo '<td><input type="checkbox" name="' . self::$registration_settings_key . '[on]" value="1"' . checked(1, $on, false) . ' /> <span class="description">Registration dialog will appear when a user visits a listing details page.</span>';
        echo '</td>';
        echo '</tr>';

        if (class_exists('\\hji\\users\\Users'))
        {
            echo '<tr valign="top">';
            echo '<th scope="row"><label>Ask Users to Confirm Registration</label></th>';
            echo '<td><input type="checkbox" name="' . self::$registration_settings_key . '[confirmation]" value="1"' . checked(1, $confirmation, false) . ' /> <span class="description">A confirmation link will be emailed to the user upon registration. Confirmed accounts can be viewed in the <a href="' . admin_url('admin.php?page=hji-users') . '">User Management</a> section.</span>';
            echo '</td>';
            echo '</tr>';
        }

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Require User Registration</label></th>';
        echo '<td><input type="checkbox" name="' . self::$registration_settings_key . '[required]" value="1"' . checked(1, $required, false) . ' /> <span class="description">Users must register before they can view listing details.</span>';
        echo '</td>';
        echo '</tr>';

        echo '<tr valign="top">';
        echo '<th scope="row"><label>Prompt Registration After</label></th>';
        echo '<td><select name="' . self::$registration_settings_key . '[trigger_listings]">';

        for ($i=0; $i<=10; $i++)
        {
            $verbiage = ($i == 1) ? 'Listing Viewed' : 'Listings Viewed';

            echo '<option value="' . $i . '" ' . selected($i, $trigger_listings) . '>' . $i . ' ' . $verbiage . '</option>';
        }
        echo '</select>';

        echo '<br /><span class="description">Users will be prompted to register after viewing the specified number of listings.</span>';
        echo '</td>';
        echo '</tr>';

        // User account templates is hjiUsers plugin is installed

        if (class_exists('\\hji\\users\\Users'))
        {
            $templates = get_page_templates();

            echo '<tr valign="top">';
            echo '<th scope="row"><label>User Account Template</label></th>';
            echo '<td>';

            echo '<select name="' . self::$registration_settings_key . '[user_account_template]">';
            echo '<option value="">Default</option>';
            foreach($templates as $template_name => $template_filename)
            {
                $selected = selected(@$this->registration_settings['user_account_template'], $template_filename, false);
                echo '<option value="' . $template_filename . '"' . $selected . '>' . $template_name . '</option>';
            }
            echo '</select>';

            echo '</td>';
            echo '</tr>';
        }

        echo '</tbody></table>';
    }
} 
HJI WP Membership Code Reference API documentation generated by ApiGen