__( 'The navigation engine has started (once per page load).', 'ajax-loading' ),
'wp_ajax_load_before' => __( 'A navigation is about to start. Cancelable: call event.preventDefault() to let the browser load the page normally.', 'ajax-loading' ),
'wp_ajax_load_start' => __( 'The page request has started.', 'ajax-loading' ),
'wp_ajax_load_before_replace' => __( 'The new page is ready to be swapped in. Cancelable (falls back to a normal page load).', 'ajax-loading' ),
'wp_ajax_load_replaced' => __( 'The new content is in place; its scripts are still running.', 'ajax-loading' ),
'wp_ajax_load_complete' => __( 'Everything is done. Fires exactly once per successful navigation; the best place to re-initialise your scripts.', 'ajax-loading' ),
'wp_ajax_load_error' => __( 'The navigation failed. event.detail.fallback tells whether a normal page load follows.', 'ajax-loading' ),
'wp_ajax_load_cancel' => __( 'The navigation was superseded by a newer one or prevented.', 'ajax-loading' ),
'wp_ajax_load_popstate' => __( 'A back or forward navigation is starting.', 'ajax-loading' ),
);
$ajxl_hooks = array(
'ajax_loading_enabled' => __( 'Filter (bool): turn AJAX navigation off for specific requests.', 'ajax-loading' ),
'ajax_loading_bypass' => __( 'Filter (bool): mark the current page as excluded; links to it load normally.', 'ajax-loading' ),
'ajax_loading_exclusions' => __( 'Filter (array): URL, selector and prefetch exclusion patterns sent to the browser.', 'ajax-loading' ),
'ajax_loading_exclude_selectors' => __( 'Filter (array): CSS selectors of links that must load normally.', 'ajax-loading' ),
'ajax_loading_content_selectors' => __( 'Filter (array): content area candidates for automatic detection.', 'ajax-loading' ),
'ajax_loading_head_selectors' => __( 'Filter (array): head elements kept in sync on navigation.', 'ajax-loading' ),
'ajax_loading_integrations' => __( 'Filter (array): integration registry shown on this tab.', 'ajax-loading' ),
'ajax_loading_frontend_config' => __( 'Filter (array): the complete configuration passed to the browser.', 'ajax-loading' ),
'ajax_loading_disable_core_speculative_loading' => __( 'Filter (bool): whether WordPress speculative loading is turned off while AJAX navigation is active.', 'ajax-loading' ),
'ajax_loading_settings_updated' => __( 'Action: settings were saved (old and new values).', 'ajax-loading' ),
);
$ajxl_snippets = array(
array(
'id' => 'events',
'title' => __( 'Run code after every navigation (JavaScript)', 'ajax-loading' ),
'code' => "document.addEventListener( 'wp_ajax_load_complete', function ( event ) {\n\t// event.detail.url, event.detail.title, event.detail.containers\n\tmyTheme.initSliders( event.detail.container );\n} );",
),
array(
'id' => 'legacy',
'title' => __( 'Version 1.x callback (still supported)', 'ajax-loading' ),
'code' => "wp_ajax_load_complete = function () {\n\t// Re-initialise your scripts here.\n};",
),
array(
'id' => 'jquery',
'title' => __( 'jQuery', 'ajax-loading' ),
'code' => "jQuery( document ).on( 'wp_ajax_load_complete', function ( event, detail ) {\n\tconsole.log( 'Navigated to', detail.url );\n} );",
),
array(
'id' => 'optout',
'title' => __( 'Make a link or an area load normally (HTML)', 'ajax-loading' ),
'code' => "Members\n\n",
),
array(
'id' => 'container',
'title' => __( 'Mark the content area for automatic detection (HTML)', 'ajax-loading' ),
'code' => '…',
),
array(
'id' => 'track',
'title' => __( 'Force a full reload when an asset changes (HTML)', 'ajax-loading' ),
'code' => '',
),
array(
'id' => 'api',
'title' => __( 'Navigate from your own code (JavaScript)', 'ajax-loading' ),
'code' => "if ( window.AjaxLoading && window.AjaxLoading.isEnabled() ) {\n\twindow.AjaxLoading.navigate( '/contact/' );\n} else {\n\twindow.location.assign( '/contact/' );\n}",
),
array(
'id' => 'php-enabled',
'title' => __( 'Turn AJAX navigation off on some pages (PHP)', 'ajax-loading' ),
'code' => "add_filter( 'ajax_loading_enabled', function ( \$enabled ) {\n\treturn is_page( 'landing' ) ? false : \$enabled;\n} );",
),
array(
'id' => 'php-exclusions',
'title' => __( 'Add exclusion patterns (PHP)', 'ajax-loading' ),
'code' => "add_filter( 'ajax_loading_exclusions', function ( \$exclusions ) {\n\t\$exclusions['urls'][] = '/members/*';\n\treturn \$exclusions;\n} );",
),
);
$admin->open_settings_form( $tab );
$admin->render_fields( $tab );
$admin->close_settings_form();
?>