Диагностика Shared Forge Suite
Когда Field Forge активен, в админке WordPress доступна панель Forge Suite > Настройка и здоровье. Его AJAX действие только для чтения — forge_suite_health_check; оно требует manage_options и локализованный nonce forge_suite_health_check. Ответ возвращает диагностику для активных плагинов Forge, локальные лицензии, готовность виджета кредитов, API Avakode /health, постоянные ссылки и плагины источников миграции/интеграции, такие как ACF и ACF Pro. Он не импортирует данные ACF, не создает группы полей, не записывает значения полей, не вызывает AI конечные точки, не тратит кредиты и не изменяет состояние лицензии/Freemius.
Настройка вашей темы для работы с Field Forge
Field Forge хранит значения в пользовательских таблицах базы данных (wp_fieldforge_values), а не в wp_postmeta. Он предоставляет совместимый с ACF уровень функций, так что существующий код темы работает без изменений. Это означает, что вы можете использовать get_field(), the_field(), have_rows() и все другие знакомые функции — Field Forge регистрирует их автоматически, когда ACF не активен. Во время запросов активации ACF Field Forge передает управление ACF, чтобы ACF Pro можно было включить для миграции без фатальной ошибки повторного объявления PHP.
// functions.php -- ensure field functions are always available
if ( ! function_exists( 'get_field' ) ) {
// Field Forge (or ACF) is not active -- provide fallbacks
function get_field( $selector, $post_id = false ) {
return get_post_meta( $post_id ?: get_the_ID(), $selector, true );
}
}Эта схема гарантирует, что ваша тема никогда не сломается, даже если Field Forge деактивирован. Резервное чтение происходит из wp_postmeta, где стандартный WordPress хранит пользовательские поля.
// Check for Field Forge (not ACF)
if ( defined( 'FIELDFORGE_VERSION' ) ) {
// Field Forge-specific code here
$version = FIELDFORGE_VERSION; // e.g., '1.2.0'
}
// Check for Field Forge PRO features
if ( defined( 'FIELDFORGE_PRO' ) && FIELDFORGE_PRO ) {
// PRO-only code: repeaters, flexible content, options pages, etc.
}<?php
// single.php -- display custom fields on a post
$subtitle = get_field( 'subtitle' );
$hero_image = get_field( 'hero_image' ); // Returns array when return_format = 'array'
if ( $subtitle ) : ?>
<h2 class="entry-subtitle"><?php echo esc_html( $subtitle ); ?></h2>
<?php endif; ?>
<?php if ( $hero_image ) : ?>
<img src="<?php echo esc_url( $hero_image['url'] ); ?>"
alt="<?php echo esc_attr( $hero_image['alt'] ); ?>"
width="<?php echo esc_attr( $hero_image['width'] ); ?>"
height="<?php echo esc_attr( $hero_image['height'] ); ?>">
<?php endif; ?><p class="lead"><?php the_field( 'lead_text' ); ?></p><?php // archive.php or index.php
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<article class="post-card">
<?php $thumb = get_field( 'card_thumbnail' ); ?>
<?php if ( $thumb ) : ?>
<img src="<?php echo esc_url( $thumb['url'] ); ?>"
alt="<?php echo esc_attr( $thumb['alt'] ); ?>"
class="post-card__image">
<?php endif; ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><?php the_field( 'excerpt_text' ); ?></p>
</article>
<?php endwhile;
endif; ?><?php
/**
* Template Name: About Us
*/
get_header();
$team_photo = get_field( 'team_photo' );
$mission = get_field( 'mission_statement' );
$founded_year = get_field( 'founded_year' );
?>
<main class="about-page">
<section class="about-hero">
<?php if ( $team_photo ) : ?>
<img src="<?php echo esc_url( $team_photo['url'] ); ?>"
alt="<?php echo esc_attr( $team_photo['alt'] ); ?>">
<?php endif; ?>
<div class="about-hero__content">
<h1><?php the_title(); ?></h1>
<?php if ( $mission ) : ?>
<blockquote><?php echo esc_html( $mission ); ?></blockquote>
<?php endif; ?>
<?php if ( $founded_year ) : ?>
<p class="founded">Established <?php echo esc_html( $founded_year ); ?></p>
<?php endif; ?>
</div>
</section>
</main>
<?php get_footer(); ?>Декларация поддержки темы
Не требуется специальный вызов add_theme_support(). Field Forge автоматически активирует свой уровень совместимости, когда ACF не активен. Если ACF активен вместе с Field Forge, функции ACF имеют приоритет, и Field Forge действует только как бэкенд для хранения. Тот же защитный механизм применяется во время активации wp-admin и API плагинов WordPress, поэтому включение ACF Pro после того, как Field Forge уже активен, не приводит к повторному объявлению get_field().
Рекомендуемая структура темы
Организуйте файлы вашей темы для чистой интеграции Field Forge:
my-theme/
functions.php # Load field setup, register blocks
inc/
fieldforge-setup.php # Options pages, programmatic field groups
template-functions.php # Helper functions wrapping get_field()
template-parts/
content-*.php # Partial templates using fields
builder/ # Flexible content section templates
blocks/ # PHP block templates
fieldforge-json/ # Local JSON sync directory (PRO)<?php
// inc/template-functions.php
/**
* Get the hero image URL with a fallback.
*
* @param int|false $post_id Post ID or false for current post.
* @return string Image URL.
*/
function theme_get_hero_image( $post_id = false ) {
$image = get_field( 'hero_image', $post_id );
if ( $image && isset( $image['url'] ) ) {
return $image['url'];
}
return get_template_directory_uri() . '/assets/img/default-hero.jpg';
}
/**
* Render social links from options page.
*/
function theme_render_social_links() {
$platforms = [ 'facebook', 'twitter', 'instagram', 'linkedin', 'youtube' ];
echo '<div class="social-links">';
foreach ( $platforms as $platform ) {
$url = get_field( 'social_' . $platform, 'options' );
if ( $url ) {
printf(
'<a href="%s" class="social-link social-link--%s" target="_blank" rel="noopener">%s</a>',
esc_url( $url ),
esc_attr( $platform ),
esc_html( ucfirst( $platform ) )
);
}
}
echo '</div>';
}—