justdev/lomnio-api-connector
Composer 安装命令:
composer require justdev/lomnio-api-connector
包简介
Connects WordPress with the Lomnio API.
README 文档
README
WordPress plugin for syncing Lomnio data into local database tables and reading it from theme code.
Installation
Recommended project install:
composer require justdev/lomnio-api-connector
When the plugin is installed from the project Composer file, Composer installs the plugin into wp-content/plugins/lomnio-api-connector through composer/installers. Plugin dependencies are installed by the root project.
Keep woocommerce/action-scheduler in root vendor, not in wp-content/plugins/action-scheduler. Add this exception before the generic type:wordpress-plugin installer path in the root project:
"installer-paths": { "vendor/woocommerce/action-scheduler/": [ "woocommerce/action-scheduler" ], "wp-content/plugins/{$name}/": [ "type:wordpress-plugin" ] }
Local plugin development install:
cd wp-content/plugins/lomnio-api-connector
composer install
composer dump-autoload --no-dev
Activate the plugin in WordPress admin:
/wp-admin/plugins.php
Admin Pages
Endpoint management page:
/wp-admin/admin.php?page=lomnio-api-endpoints
This page allows admins to:
- enable or disable endpoints;
- set sync frequency;
- configure which
WP_ENVvalues may send Leads; - run all syncs manually;
- run Project, Units, or Floors sync separately;
- check Status, Message, and Fetched / Used At.
Hidden API token settings page:
/wp-admin/admin.php?page=lomnio-api-connector
The page is available only to users with manage_options. The API token is stored encrypted in wp_options.
You can paste either a raw token or the full header:
Authorization: Bearer YOUR_API_TOKEN
After saving a valid token, the plugin queues immediate Project, Units, and Floors sync when the endpoints are active.
Sync
The plugin uses Action Scheduler.
Project action hook:
lomnio_api_connector_sync_project
Units action hook:
lomnio_api_connector_sync_units
Floors action hook:
lomnio_api_connector_sync_floors
Default schedules:
- Project: once per day;
- Units: every 10 minutes.
- Floors: every 10 minutes.
Available schedules include 5 minutes, 10 minutes, 30 minutes, hourly, twice daily, and daily.
Leads
Leads are sent through:
/v1/leads
The endpoint is managed on the endpoint management page. If Leads is inactive, calls to the sender return a skipped result and do not send, note, or log anything.
Allowed environments are controlled per endpoint. By default, only production sends real API requests. If the current WP_ENV is not allowed, the payload is recorded locally instead of being sent. The All environments option allows real sending from every environment.
Use the global class when you do not want to import a namespace:
$result = \LomnioLeads::send( array( 'name' => sanitize_text_field( $_POST['input_10'] ?? '' ), 'email' => sanitize_email( $_POST['input_3'] ?? '' ), 'phone' => sanitize_text_field( $_POST['input_4'] ?? '' ), 'message' => sanitize_textarea_field( $_POST['input_5'] ?? '' ), ), array( 'source' => 'Contact form', 'entry_id' => isset( $entry['id'] ) ? (int) $entry['id'] : 0, ) );
When GFAPI exists and entry_id is passed, the plugin writes the request result to the Gravity Forms entry notes. For other forms, the plugin writes to:
wp-content/uploads/lomnio_leads_log.txt
The sender returns either a result array or WP_Error.
Stored Data
Project data is stored in:
{$wpdb->prefix}lomnio_project
The table stores ProjectResource without the API data wrapper.
Units data is stored in:
{$wpdb->prefix}lomnio_units
Units sync uses one detailed list request:
/v1/units?per_page=-1&detailed=true
The plugin does not call:
/v1/units/{unit}
Each unit row stores the full UnitDetailResource in payload_json, plus separate columns for filtering and sorting: project_id, identifiers, status, type, layout, orientation, building, floor, phase, areas, pricing, floor plan, and bundle fields.
Legacy unit columns such as list_payload_json, detail_payload_json, list_hash, and detail_hash are not used. If lomnio_units was created by an older plugin version, recreate or migrate the table before running the current sync.
Floors data is stored in:
{$wpdb->prefix}lomnio_floors
Floors sync uses:
/v1/floors
Each floor row stores the full FloorResource in payload_json, plus separate columns for filtering and sorting: project_id, id, name, number, sort_order, building, availability, unit counts, facade_map_id, and floor_plan_url.
Local table relations:
lomnio_project.project_id = lomnio_units.project_id
lomnio_project.project_id = lomnio_floors.project_id
lomnio_floors.floor_id = lomnio_units.floor_id
These are indexed local relation columns, not database-level foreign key constraints.
Theme Usage
Use global Lomnio classes in theme code. Do not instantiate repository classes directly unless you need low-level plugin internals.
Project as object:
$section['project'] = \LomnioProject::get();
Project as array:
$project = \LomnioProject::to_array();
Project ID:
$project_id = \LomnioProject::id();
Units list:
$section['units'] = \LomnioUnits::get();
Units with filters:
$section['units'] = \LomnioUnits::get( array( 'status' => 'available', 'floor' => 2, ) );
Single unit by ID:
$section['unit'] = \LomnioUnits::find( 51 );
Single unit by code:
$section['unit'] = \LomnioUnits::find_by_code( 'A101' );
Units by floor:
$section['units'] = \LomnioUnits::by_floor( 10 );
Floors list:
$section['floors'] = \LomnioFloors::get();
Floors with filters:
$section['floors'] = \LomnioFloors::get( array( 'building_id' => 1, 'availability' => 'available', ) );
Single floor by ID:
$section['floor'] = \LomnioFloors::find( 10 );
Single floor by number:
$section['floor'] = \LomnioFloors::find_by_number( 2 );
Floors by project:
$section['floors'] = \LomnioFloors::by_project( 51 );
Available Unit Filters
\LomnioUnits::get() supports these filters:
idproject_idunit_idcodestatusstatus_codestatus_labelstatus_colorstatus_is_systemtypelayout_typeorientationfloorfloor_numberfloor_idfloor_namebuilding_idbuilding_namephase_idphase_nameroom_countareaarea_floorarea_grossarea_buildingarea_landprice_without_vatprice_with_vatdiscount_without_vatdiscount_with_vatdiscounted_price_without_vatdiscounted_price_with_vatprice_per_sqmvat_ratepricing_hiddenpricing_display_textfloor_plan_urlbundle_idbundle_name
Filter values can be scalar values or arrays:
$units = \LomnioUnits::get( array( 'status' => array( 'available', 'reserved' ), 'floor' => array( 1, 2, 3 ), ) );
Available Floor Filters
\LomnioFloors::get() supports these filters:
idproject_idfloor_idnamenumberfloor_numbersort_orderbuilding_idbuilding_nameavailabilitystatusunits_countavailable_units_countfacade_map_idfloor_plan_url
Filter values can be scalar values or arrays:
$floors = \LomnioFloors::get( array( 'building_id' => array( 1, 2 ), 'availability' => array( 'available', 'unavailable' ), ) );
Direct Authorization Header
If plugin code needs the configured authorization header:
$headers = \LomnioApiConnector\Plugin::instance() ->secret_storage() ->get_authorization_headers();
The result is either a headers array or WP_Error.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-06-23