<?php

/**
 * ACF (Advanced Custom Fields) Integration for WPSummarize
 * 
 * This file provides functions to retrieve and format ACF field content
 * for inclusion in AI summarization.
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
// Exit if accessed directly
/**
 * Check if ACF is active
 * 
 * @return bool
 */
function wpsummarize_is_acf_active() {
    return class_exists( 'ACF' ) || function_exists( 'get_field' );
}

/**
 * Settings callback for ACF integration enable/disable
 */
function wpsummarize_acf_enabled_callback() {
    global $wpsummarize_options;
    // Check if ACF is installed
    if ( !wpsummarize_is_acf_active() ) {
        echo '<p class="description" style="color: #999;">';
        echo esc_html__( 'Advanced Custom Fields plugin is not detected. Install and activate ACF to use this feature.', 'wpsummarize' );
        echo '</p>';
        return;
    }
    if ( wpsummarize_fs()->is_paying_or_trial() === false ) {
        echo '<a href="' . esc_url( wpsummarize_fs()->get_upgrade_url() ) . '">' . esc_html__( 'Upgrade to enable ACF support', 'wpsummarize' ) . '</a>';
    }
}

/**
 * Settings callback for ACF field selection
 */
function wpsummarize_acf_fields_callback() {
    global $wpsummarize_options;
    if ( !wpsummarize_is_acf_active() ) {
        echo '<p class="description" style="color: #999;">';
        echo esc_html__( 'Advanced Custom Fields plugin is not detected. Install and activate ACF to use this feature.', 'wpsummarize' );
        echo '</p>';
        return;
    }
    if ( wpsummarize_fs()->is_paying_or_trial() === false ) {
        echo '<a href="' . esc_url( wpsummarize_fs()->get_upgrade_url() ) . '">' . esc_html__( 'Upgrade to enable ACF support', 'wpsummarize' ) . '</a>';
    }
}
