id ) { return; } if ( empty( $_GET['settings-updated'] ) ) { return; } $variant = sanitize_key( wp_unslash( $_GET['settings-updated'] ) ); $message = ( 'reset' === $variant ) ? __( 'Settings reset to defaults.', 'advanced-form-integration' ) : __( 'Settings saved.', 'advanced-form-integration' ); printf( '
%s
' . esc_html__( 'Advanced Form Integration sends form submissions from popular WordPress form plugins to dozens of CRMs, email-marketing tools, and webhooks — without writing any code.', 'advanced-form-integration' ) . '
' . '' . sprintf( /* translators: %s: link to documentation */ wp_kses( __( 'For setup walkthroughs, supported platforms, and troubleshooting tips, visit the Knowledge Base.', 'advanced-form-integration' ), array( 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array() ) ) ), esc_url( $kb_url ) ) . '
', ) ); $screen->set_help_sidebar( '' . esc_html__( 'For more information:', 'advanced-form-integration' ) . '
' . '' . esc_html__( 'Knowledge Base', 'advanced-form-integration' ) . '
' . '' . esc_html__( 'Get Help (in-plugin)', 'advanced-form-integration' ) . '
' ); } /** * Persist screen-meta value for the log list table's per-page setting. */ public function adfoin_log_table_set_option( $status, $option, $value ) { if ( 'adfoin_log_per_page' == $option ) return $value; return $status; } /** * Persist the integrations-list per-page screen option (legacy * filter name; pre-5.4.2 cores). */ public function adfoin_integrations_set_option( $status, $option, $value ) { if ( 'adfoin_integrations_per_page' === $option ) { return (int) $value; } return $status; } /** * Per-option filter (WP 5.4.2+). $status here is the raw incoming * value, not a bool, so we just clamp + return. */ public function adfoin_integrations_set_option_v2( $value ) { return (int) $value; } /** * Register the admin menu. * * @return void */ public function admin_menu() { global $submenu; $hook1 = add_menu_page( esc_html__( 'Advanced Form Integration', 'advanced-form-integration' ), esc_html__( 'AFI', 'advanced-form-integration' ), 'manage_options', 'advanced-form-integration', array( $this, 'adfoin_routing' ), 'data:image/svg+xml;base64,' . base64_encode( '' ) ); add_submenu_page( 'advanced-form-integration', esc_html__( 'Advanced Form Integration', 'advanced-form-integration' ), esc_html__( 'Integrations', 'advanced-form-integration' ), 'manage_options', 'advanced-form-integration', array( $this, 'adfoin_routing' ) ); $hook2 = add_submenu_page( 'advanced-form-integration', esc_html__( 'Integrations', 'advanced-form-integration' ), esc_html__( 'Add New', 'advanced-form-integration' ), 'manage_options', 'advanced-form-integration-new', array( $this, 'adfoin_new_integration' ) ); $hook3 = add_submenu_page( 'advanced-form-integration', esc_html__( 'Settings', 'advanced-form-integration' ), esc_html__( 'Settings', 'advanced-form-integration'), 'manage_options', 'advanced-form-integration-settings', array( $this,'adfoin_settings') ); $hook4 = add_submenu_page( 'advanced-form-integration', esc_html__( 'Log', 'advanced-form-integration' ), esc_html__( 'Log', 'advanced-form-integration'), 'manage_options', 'advanced-form-integration-log', array( $this,'adfoin_log') ); $hook5 = add_submenu_page( 'advanced-form-integration', esc_html__( 'Export / Import', 'advanced-form-integration' ), esc_html__( 'Export / Import', 'advanced-form-integration'), 'manage_options', 'advanced-form-integration-import-export', array( $this,'adfoin_import_export' ) ); add_submenu_page( 'advanced-form-integration', esc_html__( 'Get Help', 'advanced-form-integration' ), esc_html__( 'Get Help', 'advanced-form-integration'), 'manage_options', 'advanced-form-integration-help', array( $this,'adfoin_get_help') ); add_action( 'admin_head-' . $hook1, array( $this, 'enqueue_assets' ) ); add_action( 'admin_head-' . $hook2, array( $this, 'enqueue_assets' ) ); add_action( 'admin_head-' . $hook3, array( $this, 'enqueue_assets' ) ); add_action( 'admin_head-' . $hook4, array( $this, 'enqueue_assets' ) ); add_action( 'admin_head-' . $hook5, array( $this, 'enqueue_assets' ) ); // Add screen options for log page add_action( "load-$hook4", array( $this, 'adfoin_log_screen_options' ) ); // Add screen options for the integrations list page (top-level // hook). Suppressed for the edit/duplicate flows since those // aren't list views — only the action=list default needs it. add_action( "load-$hook1", array( $this, 'adfoin_integrations_screen_options' ) ); } /** * Add screen options for log list table */ public function adfoin_log_screen_options() { if ( isset( $_GET['action'] ) && 'view' == $_GET['action'] ) { return; } $option = 'per_page'; $args = array( 'label' => esc_html__( 'Logs per page', 'advanced-form-integration' ), 'default' => 20, 'option' => 'adfoin_log_per_page' ); add_screen_option( $option, $args ); } /** * Screen Options tab for the integrations list page. WP renders * the tab automatically once the option is registered; users can * change per-page count and column visibility from there. The * value is read in Advanced_Form_Integration_List_Table::prepare_items * via $this->get_items_per_page(). * * Skipped on edit/duplicate sub-actions so the tab doesn't show * an irrelevant "per page" knob next to the form. */ public function adfoin_integrations_screen_options() { $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; if ( '' !== $action && 'list' !== $action ) { return; } add_screen_option( 'per_page', array( 'label' => esc_html__( 'Integrations per page', 'advanced-form-integration' ), 'default' => 20, 'option' => 'adfoin_integrations_per_page', ) ); } public function enqueue_assets() { wp_enqueue_script( 'adfoin-vuejs' ); // Determine current page context $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; // Shared Vue components (registered globally before the app boots) wp_enqueue_script( 'adfoin-searchable-select', ADVANCED_FORM_INTEGRATION_ASSETS . '/js/components/searchable-select.js', array( 'adfoin-vuejs' ), ADVANCED_FORM_INTEGRATION_VERSION, true ); // Always load core utilities wp_enqueue_script( 'adfoin-core', ADVANCED_FORM_INTEGRATION_ASSETS . '/js/core.js', array( 'adfoin-vuejs', 'adfoin-searchable-select' ), ADVANCED_FORM_INTEGRATION_VERSION, true ); // Load triggers and actions only on new/edit integration pages $needs_integration_scripts = ( $page === 'advanced-form-integration-new' || ( $page === 'advanced-form-integration' && $action === 'edit' ) ); if ( $needs_integration_scripts ) { // Version-stamp the editor scripts with their file mtime so an // updated triggers.js/app.js busts the browser cache automatically, // without waiting for a plugin version bump. $triggers_path = ADVANCED_FORM_INTEGRATION_PATH . '/assets/js/triggers.js'; $app_path = ADVANCED_FORM_INTEGRATION_PATH . '/assets/js/app.js'; $triggers_ver = ADVANCED_FORM_INTEGRATION_VERSION . '.' . ( file_exists( $triggers_path ) ? filemtime( $triggers_path ) : '0' ); $app_ver = ADVANCED_FORM_INTEGRATION_VERSION . '.' . ( file_exists( $app_path ) ? filemtime( $app_path ) : '0' ); // Load trigger components (always needed for new/edit) wp_enqueue_script( 'adfoin-triggers', ADVANCED_FORM_INTEGRATION_ASSETS . '/js/triggers.js', array( 'adfoin-core' ), $triggers_ver, true ); // Load Vue app initialization (handles lazy loading of action components) wp_enqueue_script( 'adfoin-app', ADVANCED_FORM_INTEGRATION_ASSETS . '/js/app.js', array( 'adfoin-triggers' ), $app_ver, true ); // Action components are now loaded one platform at a time from // platforms/%s