API Documentation
Table of Contents
Namespaces
Constants
- JPKCOM_ACFREFERENCES_BASENAME = \plugin_basename(__FILE__)
- JPKCOM_ACFREFERENCES_PLUGIN_PATH = \plugin_dir_path(__FILE__)
- JPKCOM_ACFREFERENCES_PLUGIN_URL = \plugin_dir_url(__FILE__)
- JPKCOM_ACFREFERENCES_VERSION = '1.0.4'
Functions
- jpkcom_acf_references_disable_archive_field() : void
- Render disable archive checkbox field
- jpkcom_acf_references_redirect_url_field() : void
- Render archive redirect URL field
- jpkcom_acf_references_shortcodes_page() : void
- Render Shortcodes admin page
- jpkcom_acf_references_options_page() : void
- Render Options admin page
- jpkcom_acf_references_breadcrumb() : void
- Output Bootstrap 5 breadcrumb navigation
- jpkcom_render_acf_fields() : void
- Renders all ACF fields of a post with Bootstrap 5 markup and smart icons
- acf_get_field_label() : string
- Get ACF field label by field key or field name
- jpkcom_get_acf_field_label() : string
- Get ACF field label with enhanced search capabilities
- jpkcom_human_readable_relative_date() : string
- Convert timestamp to human-readable relative date string
- jpkcom_acf_references_media_size() : void
- Register custom image sizes for reference posts
- jpkcom_acf_references_image_sizes_to_selector() : array<string|int, string>
- Add custom image sizes to media library size selector
- jpkcom_acf_references_pagination() : void
- Output Bootstrap 5 pagination navigation
- jpkcom_acf_references_locate_template() : string|false
- jpkcom_acf_references_locate_template() : string|false
- Locate template file with override support
- jpkcom_acf_references_template_include() : string
- Template loader for singular and archive templates
- jpkcom_acf_references_get_template_part() : void
- Load partial templates with full override support
- jpkcom_acfreferences_textdomain() : void
- Load plugin text domain for translations
- jpkcom_acfreferences_locate_file() : string|null
- Locate file with override support
Constants
JPKCOM_ACFREFERENCES_BASENAME
public
mixed
JPKCOM_ACFREFERENCES_BASENAME
= \plugin_basename(__FILE__)
JPKCOM_ACFREFERENCES_PLUGIN_PATH
public
mixed
JPKCOM_ACFREFERENCES_PLUGIN_PATH
= \plugin_dir_path(__FILE__)
JPKCOM_ACFREFERENCES_PLUGIN_URL
public
mixed
JPKCOM_ACFREFERENCES_PLUGIN_URL
= \plugin_dir_url(__FILE__)
JPKCOM_ACFREFERENCES_VERSION
public
mixed
JPKCOM_ACFREFERENCES_VERSION
= '1.0.4'
Functions
jpkcom_acf_references_disable_archive_field()
Render disable archive checkbox field
jpkcom_acf_references_disable_archive_field() : void
Tags
jpkcom_acf_references_redirect_url_field()
Render archive redirect URL field
jpkcom_acf_references_redirect_url_field() : void
Tags
jpkcom_acf_references_shortcodes_page()
Render Shortcodes admin page
jpkcom_acf_references_shortcodes_page() : void
Tags
jpkcom_acf_references_options_page()
Render Options admin page
jpkcom_acf_references_options_page() : void
Tags
jpkcom_acf_references_breadcrumb()
Output Bootstrap 5 breadcrumb navigation
jpkcom_acf_references_breadcrumb() : void
Generates breadcrumb navigation for:
- Single reference posts (Home > References > Reference Title)
- Reference archive (Home > References)
- Other pages (Home > Page Title)
Includes proper ARIA labels and semantic HTML5 markup.
Tags
Return values
void —Outputs HTML directly.
jpkcom_render_acf_fields()
Renders all ACF fields of a post with Bootstrap 5 markup and smart icons
jpkcom_render_acf_fields([string $post_type = '' ]) : void
Automatically detects field types and renders them with appropriate styling:
- Images: Responsive with rounded corners
- WYSIWYG/Textarea: Light background container
- Relationships/Post Objects: Linked post titles
- True/False: Badge indicators
- Repeater: Responsive tables
- Groups: Nested definition lists
Parameters
- $post_type : string = ''
-
Optional. Post type for field group query. Default empty (uses current post type).
Tags
acf_get_field_label()
Get ACF field label by field key or field name
acf_get_field_label(string $field_key_or_name) : string
Attempts to retrieve the field label from ACF. If not found, returns a formatted fallback based on the field name/key.
Parameters
- $field_key_or_name : string
-
Field key (e.g., 'field_abc123') or field name (e.g., 'job_title').
Tags
Return values
string —Field label or formatted fallback string.
jpkcom_get_acf_field_label()
Get ACF field label with enhanced search capabilities
jpkcom_get_acf_field_label(string $field_name_or_key[, string $post_type = '' ]) : string
Searches for field labels in this order:
- Direct field key lookup (if starts with 'field_')
- Search through field groups by post type
- Search through sub_fields (repeater/group fields)
- Fallback to formatted field name
Parameters
- $field_name_or_key : string
-
Field name (e.g., 'job_title') or field key (e.g., 'field_abc123').
- $post_type : string = ''
-
Optional. Post type for context-specific field group search. Default empty.
Tags
Return values
string —Field label or formatted fallback string.
jpkcom_human_readable_relative_date()
Convert timestamp to human-readable relative date string
jpkcom_human_readable_relative_date(int $timestamp) : string
Converts Unix timestamps into relative date strings like:
- "Published today"
- "Published yesterday"
- "Published 3 days ago"
- "Published 2 weeks ago"
- "Published 5 months ago"
- "Published 2 years ago"
All strings are translatable via the 'jpkcom-acf-references' text domain.
Parameters
- $timestamp : int
-
Unix timestamp to convert.
Tags
Return values
string —Translated relative date string.
jpkcom_acf_references_media_size()
Register custom image sizes for reference posts
jpkcom_acf_references_media_size() : void
Registers six image sizes:
- jpkcom-acf-reference-16x9: 576x324px (16:9, hard crop)
- jpkcom-acf-reference-logo: 512x512px (square, hard crop)
- jpkcom-acf-reference-header: 992x558px (16:9, hard crop)
- jpkcom-acf-reference-card-overlay: 800x600px (4:3, hard crop)
- jpkcom-acf-reference-gallery-thumb: 200x200px (square, hard crop)
- jpkcom-acf-reference-gallery-modal: 1400px width (proportional, no crop)
Tags
jpkcom_acf_references_image_sizes_to_selector()
Add custom image sizes to media library size selector
jpkcom_acf_references_image_sizes_to_selector(array<string|int, string> $sizes) : array<string|int, string>
Makes custom image sizes available in the WordPress media library dropdown when inserting images into posts.
Parameters
- $sizes : array<string|int, string>
-
Existing image size options.
Tags
Return values
array<string|int, string> —Modified array with custom sizes added.
jpkcom_acf_references_pagination()
Output Bootstrap 5 pagination navigation
jpkcom_acf_references_pagination([string|int $pages = '' ][, int $range = 2 ]) : void
Generates numbered pagination with first/last and prev/next controls. Includes proper ARIA labels and accessible markup.
Features:
- First/Last page links (« »)
- Previous/Next page links (‹ ›)
- Numbered page links with range control
- Active page indicator
- Disabled state for unavailable actions
Parameters
- $pages : string|int = ''
-
Optional. Total number of pages. Default empty (auto-detect from query).
- $range : int = 2
-
Optional. Number of page links to show on either side of current page. Default 2.
Tags
Return values
void —Outputs HTML directly.
jpkcom_acf_references_locate_template()
jpkcom_acf_references_locate_template(string $template_name) : string|false
Parameters
- $template_name : string
Return values
string|falsejpkcom_acf_references_locate_template()
Locate template file with override support
jpkcom_acf_references_locate_template(string $template_name) : string|false
Searches for template files in this priority order:
- Child Theme: /wp-content/themes/your-child-theme/jpkcom-acf-references/
- Parent Theme: /wp-content/themes/your-theme/jpkcom-acf-references/
- MU plugin override: /wp-content/mu-plugins/jpkcom-acf-references-overrides/templates/
- Plugin itself: /wp-content/plugins/jpkcom-acf-references/templates/ (or debug-templates/ if WP_DEBUG)
Parameters
- $template_name : string
-
Template filename (e.g., 'single-reference.php' or 'partials/reference/customer.php').
Tags
Return values
string|false —Full path to template file if found, false otherwise.
jpkcom_acf_references_template_include()
Template loader for singular and archive templates
jpkcom_acf_references_template_include(string $template) : string
Intercepts WordPress template_include filter and loads custom templates for reference, reference_customer, and reference_location post types (single and archive views).
Parameters
- $template : string
-
Default template path from WordPress.
Tags
Return values
string —Template path to use (plugin template or default).
jpkcom_acf_references_get_template_part()
Load partial templates with full override support
jpkcom_acf_references_get_template_part(string $slug[, string $name = '' ][, array<string|int, mixed> $args = [] ]) : void
Similar to WordPress get_template_part() but uses the plugin's template hierarchy system. Useful for loading reusable template partials.
Example usage: jpkcom_acf_references_get_template_part('partials/reference/customer'); jpkcom_acf_references_get_template_part('partials/reference/customer', 'detailed'); jpkcom_acf_references_get_template_part('partials/reference/modal', '', ['data' => $data]);
Parameters
- $slug : string
-
Template slug (e.g., 'partials/reference/customer').
- $name : string = ''
-
Optional. Template name/variation (e.g., 'alternative'). Default empty.
- $args : array<string|int, mixed> = []
-
Optional. Array of variables to pass to the template. Default empty.
Tags
jpkcom_acfreferences_textdomain()
Load plugin text domain for translations
jpkcom_acfreferences_textdomain() : void
Loads translation files from the /languages directory.
Tags
jpkcom_acfreferences_locate_file()
Locate file with override support
jpkcom_acfreferences_locate_file(string $filename) : string|null
Searches for a file in multiple locations with priority:
- Child theme
- Parent theme
- MU plugin overrides
- Plugin includes directory
Parameters
- $filename : string
-
The filename to locate (without path).
Tags
Return values
string|null —Full path to the file if found, null otherwise.