public function ajax_generate_template() {
if ( ! isset( $_POST['is_background'] ) ) { check_ajax_referer( 'ftl_ajax_nonce', 'nonce' ); }
$object_id = intval( $_POST['object_id'] );
$object_type = sanitize_text_field( $_POST['object_type'] );
$use_custom = isset( $_POST['use_custom'] ) && intval( $_POST['use_custom'] ) === 1;
$auto_gen = isset( $_POST['auto_gen'] ) ? ( intval( $_POST['auto_gen'] ) === 1 ? '1' : '0' ) : '1';
$update_meta = function($k, $v) use ($object_id, $object_type) { $object_type === 'term' ? update_term_meta( $object_id, $k, $v ) : update_post_meta( $object_id, $k, $v ); };
if ( isset( $_POST['use_custom'] ) ) $update_meta( '_ftl_use_custom_settings', $use_custom ? '1' : '0' );
if ( isset( $_POST['auto_gen'] ) ) $update_meta( '_ftl_auto_generate', $auto_gen );
$get_meta = function($key) use ($object_id, $object_type) { return $object_type === 'term' ? get_term_meta( $object_id, $key, true ) : get_post_meta( $object_id, $key, true ); };
if ( ! isset( $_POST['use_custom'] ) ) $use_custom = $get_meta( '_ftl_use_custom_settings' ) === '1';
$url = $object_type === 'term' ? get_term_link( $object_id ) : get_permalink( $object_id );
$html = wp_remote_retrieve_body( wp_remote_get( add_query_arg( 'ftl_bypass', '1', $url ), array( 'timeout' => 30, 'sslverify' => false ) ) );
$global_quality = get_option('ftl_global_image_quality', '80');
$defer_js = get_option('ftl_global_defer_js', '');
$defer_css = get_option('ftl_global_defer_css', '');
if ( $use_custom ) {
if ( isset( $_POST['selected_css'] ) ) {
$update_meta( '_ftl_selected_assets', array( 'css' => (array) $_POST['selected_css'], 'js' => (array) $_POST['selected_js'], 'images' => (array) $_POST['selected_images'] ));
$sel_css = (array) $_POST['selected_css']; $sel_js = (array) $_POST['selected_js']; $sel_img = (array) $_POST['selected_images'];
} else {
$saved_assets = $get_meta( '_ftl_selected_assets' ) ?: array();
$sel_css = $saved_assets['css'] ?? array(); $sel_js = $saved_assets['js'] ?? array(); $sel_img = $saved_assets['images'] ?? array();
}
$options = array(
'auto_unify' => false,
'minify_html' => get_option('ftl_global_minify_html', '1') === '1',
'image_quality' => $global_quality,
'defer_js' => $defer_js,
'defer_css' => $defer_css,
'selected_css' => $sel_css,
'selected_js' => $sel_js,
'selected_images' => $sel_img,
);
} else {
$options = array(
'auto_unify' => true,
'minify_html' => get_option('ftl_global_minify_html', '1') === '1',
'unify_css' => get_option('ftl_global_unify_css', '1') === '1',
'unify_js' => get_option('ftl_global_unify_js', '1') === '1',
'optimize_images' => get_option('ftl_global_optimize_images', '1') === '1',
'image_quality' => $global_quality,
'defer_js' => $defer_js,
'defer_css' => $defer_css,
'exclude_scripts' => get_option('ftl_global_exclude_scripts', ''),
'exclude_styles' => get_option('ftl_global_exclude_styles', ''),
'exclude_images' => get_option('ftl_global_exclude_images', ''),
);
}
$cache = new FTL_Cache();
$cache->save_template( $object_id, $object_type, $html, $options );
wp_send_json_success();
}
Fatal error: Uncaught Error: Class "FTL_Admin" not found in /home/homologacentral/public_html/wp-content/plugins/headless-pwa-wp/wp-ftl-enhancer.php:24
Stack trace:
#0 /home/homologacentral/public_html/wp-content/plugins/headless-pwa-wp/wp-ftl-enhancer.php(28): run_wp_ftl_enhancer()
#1 /home/homologacentral/public_html/wp-settings.php(528): include_once('/home/homologac...')
#2 /home/homologacentral/public_html/wp-config.php(119): require_once('/home/homologac...')
#3 /home/homologacentral/public_html/wp-load.php(50): require_once('/home/homologac...')
#4 /home/homologacentral/public_html/wp-blog-header.php(13): require_once('/home/homologac...')
#5 /home/homologacentral/public_html/index.php(17): require('/home/homologac...')
#6 {main}
thrown in /home/homologacentral/public_html/wp-content/plugins/headless-pwa-wp/wp-ftl-enhancer.php on line 24