Visual Picker for ACF Flexible Content. * Handles the "check for updates" AJAX action and the uninstall-data setting. */ class Settings_Page { private static ?self $instance = null; public static function init(): void { if ( null === self::$instance ) { self::$instance = new self(); } } /** Option that controls whether all data is wiped on uninstall. */ const OPTION_DELETE_DATA = 'aibs_fcp_for_acf_delete_data_on_uninstall'; /** * Buy Me a Coffee page for the plugin author. * Keep this in sync with the `Donate link:` header in readme.txt. */ const SUPPORT_URL = 'https://buymeacoffee.com/gmnuriddin'; private function __construct() { add_action( 'admin_init', [ $this, 'register_settings' ] ); add_action( 'admin_menu', [ $this, 'register_menu' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); add_action( 'wp_ajax_aibs_fcp_for_acf_check_update', [ $this, 'ajax_check_update' ] ); add_filter( 'plugin_action_links_' . plugin_basename( AIBS_FCP_FOR_ACF_PLUGIN_FILE ), [ $this, 'action_links' ] ); } /** * Registers the uninstall-data option with the WordPress Settings API so * options.php handles saving, nonce verification, and the redirect for free. */ public function register_settings(): void { register_setting( 'aibs_fcp_for_acf_plugin_settings', self::OPTION_DELETE_DATA, [ 'type' => 'boolean', 'sanitize_callback' => [ __CLASS__, 'sanitize_delete_data_flag' ], 'default' => '0', ] ); } /** * Sanitizes the "delete data on uninstall" checkbox to a strict '1' or '0' * string. Used as the register_setting() sanitize_callback. * * @param mixed $value Raw submitted value. * @return string '1' when checked, otherwise '0'. */ public static function sanitize_delete_data_flag( $value ): string { return ! empty( $value ) ? '1' : '0'; } public function action_links( array $links ): array { $settings = sprintf( '%s', esc_url( admin_url( 'options-general.php?page=aibs-fcp-for-acf-plugin' ) ), esc_html__( 'Settings', 'aibs-flexible-content-picker-for-acf' ) ); array_unshift( $links, $settings ); return $links; } public function register_menu(): void { add_options_page( __( 'Visual Picker for ACF Flexible Content', 'aibs-flexible-content-picker-for-acf' ), __( 'Visual Picker for ACF Flexible Content', 'aibs-flexible-content-picker-for-acf' ), 'manage_options', 'aibs-fcp-for-acf-plugin', [ $this, 'render_page' ] ); } public function enqueue( string $hook ): void { if ( 'settings_page_aibs-fcp-for-acf-plugin' !== $hook ) { return; } wp_enqueue_style( 'aibs-fcp-for-acf-plugin-settings', AIBS_FCP_FOR_ACF_PLUGIN_URL . 'assets/css/settings.css', [], AIBS_FCP_FOR_ACF_PLUGIN_VERSION ); wp_enqueue_script( 'aibs-fcp-for-acf-plugin-settings', AIBS_FCP_FOR_ACF_PLUGIN_URL . 'assets/js/settings.js', [ 'jquery' ], AIBS_FCP_FOR_ACF_PLUGIN_VERSION, true ); wp_localize_script( 'aibs-fcp-for-acf-plugin-settings', 'FcpForAcfSettings', [ 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'aibs_fcp_for_acf_admin' ), 'i18n' => [ 'checking' => __( 'Checking…', 'aibs-flexible-content-picker-for-acf' ), 'request_failed' => __( 'Request failed. Please try again.', 'aibs-flexible-content-picker-for-acf' ), ], ] ); } public function render_page(): void { if ( ! current_user_can( 'manage_options' ) ) { return; } ?>
' . esc_html( AIBS_FCP_FOR_ACF_PLUGIN_VERSION ) . '' ); ?>
[ 'href' => [] ] ] ), 'gmnuriddin2020@gmail.com' ); ?>