__( 'Dashboard', 'tibospeed' ), 'onbellek' => __( 'Cache', 'tibospeed' ), 'dosyalar' => __( 'CSS and JavaScript', 'tibospeed' ), 'medya' => __( 'Images and video', 'tibospeed' ), 'eklentiler' => __( 'WooCommerce and Elementor', 'tibospeed' ), 'veritabani' => __( 'Database', 'tibospeed' ), 'gelismis' => __( 'Advanced', 'tibospeed' ), ); $t = apply_filters( 'tibospeed_admin_tabs', $t ); if ( ! tibospeed_is_pro() ) { $t['pro'] = __( 'Pro', 'tibospeed' ); } return $t; } /** * Sekmelerin ayar anahtarları. * * @return array */ function tibospeed_tab_keys() { return apply_filters( 'tibospeed_tab_keys', array( 'onbellek' => array( 'cache', 'cache_hours', 'cache_mobile', 'preload', 'browser_cache' ), 'dosyalar' => array( 'html_minify', 'css_minify', 'js_defer', 'js_delay', 'delay_timeout', 'fonts_local', 'fonts_swap', 'preconnect', 'speculation', 'no_emoji', 'no_embeds', 'no_dashicons', 'block_css_split', 'head_clean', 'heartbeat' ), 'medya' => array( 'lazy', 'lazy_skip', 'img_dims', 'lcp', 'webp', 'webp_quality', 'yt_facade' ), 'eklentiler' => array( 'woo_fragments', 'woo_assets' ), 'veritabani' => array( 'revisions_keep', 'db_auto' ), 'gelismis' => array( 'ignore_params', 'exclude_urls', 'exclude_cookies', 'delay_exclude', 'defer_exclude' ), ) ); } add_action( 'admin_menu', function () { add_menu_page( 'TiboSpeed', 'TiboSpeed', 'manage_options', 'tibospeed', 'tibospeed_page', 'dashicons-performance', 81 ); } ); add_action( 'admin_enqueue_scripts', function ( $hook ) { if ( 'toplevel_page_tibospeed' !== $hook ) { return; } $v = function ( $f ) { return TIBOSPEED_VERSION . '.' . filemtime( TIBOSPEED_DIR . '/assets/' . $f ); }; wp_enqueue_style( 'tibospeed-ui', TIBOSPEED_URL . 'assets/ui.css', array(), $v( 'ui.css' ) ); wp_enqueue_style( 'tibospeed-admin', TIBOSPEED_URL . 'assets/admin.css', array( 'tibospeed-ui' ), $v( 'admin.css' ) ); wp_enqueue_script( 'tibospeed-admin', TIBOSPEED_URL . 'assets/admin.js', array( 'wp-i18n' ), $v( 'admin.js' ), true ); wp_set_script_translations( 'tibospeed-admin', 'tibospeed', TIBOSPEED_DIR . '/languages' ); wp_add_inline_script( 'tibospeed-admin', 'window.tibospeedAdmin=' . wp_json_encode( array( 'ajax' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'tibospeed_admin' ), ) , JSON_HEX_TAG | JSON_HEX_AMP ) . ';', 'before' ); } ); add_action( 'admin_post_tibospeed_save', function () { if ( ! current_user_can( 'manage_options' ) ) { wp_die( '', '', array( 'response' => 403 ) ); } check_admin_referer( 'tibospeed_save' ); $tab = isset( $_POST['tab'] ) ? sanitize_key( wp_unslash( $_POST['tab'] ) ) : 'onbellek'; $keys = tibospeed_tab_keys(); // Gelir gelmez temizlenir (satır sonları korunur); tibospeed_sanitize() ayrıca her alanı türüne göre doğrular. $in = isset( $_POST['tibospeed'] ) && is_array( $_POST['tibospeed'] ) ? map_deep( wp_unslash( $_POST['tibospeed'] ), 'sanitize_textarea_field' ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- map_deep() ile sanitize_textarea_field uygulanır. $old = tibospeed_settings(); $new = tibospeed_sanitize( $in, isset( $keys[ $tab ] ) ? $keys[ $tab ] : array() ); // Ayarlar profil değerlerinden ayrıldıysa "Özel". if ( $new !== $old && $old['profile'] !== 'ozel' ) { $prof = tibospeed_profile_settings( $old['profile'] ); foreach ( $prof as $k => $v ) { if ( 'profile' !== $k && isset( $new[ $k ] ) && (string) $new[ $k ] !== (string) $v ) { $new['profile'] = 'ozel'; break; } } } $new = apply_filters( 'tibospeed_before_save', $new, $in, $tab ); update_option( 'tibospeed_settings', $new ); tibospeed_settings( true ); do_action( 'tibospeed_saved', $tab, $in ); tibospeed_install(); tibospeed_purge_all(); tibospeed_preload_all(); wp_safe_redirect( admin_url( 'admin.php?page=tibospeed&tab=' . $tab . '&tibospeed_msg=saved' ) ); exit; } ); add_action( 'admin_post_tibospeed_profile', function () { if ( ! current_user_can( 'manage_options' ) ) { wp_die( '', '', array( 'response' => 403 ) ); } check_admin_referer( 'tibospeed_profile' ); $p = isset( $_GET['p'] ) ? sanitize_key( wp_unslash( $_GET['p'] ) ) : 'dengeli'; if ( isset( tibospeed_profiles()[ $p ] ) ) { // Profil yalnız hız ayarlarını değiştirir; hariç tutma listeleri korunur. $cur = tibospeed_settings(); $new = tibospeed_profile_settings( $p ); foreach ( tibospeed_tab_keys()['gelismis'] as $k ) { $new[ $k ] = $cur[ $k ]; } update_option( 'tibospeed_settings', apply_filters( 'tibospeed_before_save', $new, array(), 'profile' ) ); tibospeed_settings( true ); tibospeed_install(); tibospeed_purge_all(); tibospeed_preload_all(); } wp_safe_redirect( admin_url( 'admin.php?page=tibospeed&tibospeed_msg=profile' ) ); exit; } ); add_action( 'admin_post_tibospeed_repair', function () { if ( ! current_user_can( 'manage_options' ) ) { wp_die( '', '', array( 'response' => 403 ) ); } check_admin_referer( 'tibospeed_repair' ); tibospeed_install(); if ( ! empty( $_GET['force'] ) ) { tibospeed_write_dropin( true ); } wp_safe_redirect( admin_url( 'admin.php?page=tibospeed&tibospeed_msg=repaired' ) ); exit; } ); /* -------------------------------------------------------------------------- Alan yardımcıları */ /** * Aç/kapat. * * @param string $k Anahtar. * @param string $label Başlık. * @param string $desc Açıklama. * @param string $badge Rozet (ör. "Risk: düşük"). */ function tibospeed_f_toggle( $k, $label, $desc = '', $badge = '' ) { echo '
' . esc_html( $label ) . '' . ( $badge ? ' ' . esc_html( $badge ) . '' : '' ) . ( $desc ? '

' . esc_html( $desc ) . '

' : '' ) . '
'; } /** * Seçim. * * @param string $k Anahtar. * @param string $label Başlık. * @param array $opts Seçenekler değer => [ ad, açıklama ]. */ function tibospeed_f_choice( $k, $label, $opts ) { echo '
' . esc_html( $label ) . '
'; foreach ( $opts as $v => $o ) { echo ''; } echo '
'; } /** * Sayı. * * @param string $k Anahtar. * @param string $label Başlık. * @param string $unit Birim / açıklama. * @param int $min En az. * @param int $max En çok. */ function tibospeed_f_num( $k, $label, $unit, $min, $max ) { echo '
' . esc_html( $label ) . '
' . esc_html( $unit ) . '
'; } /** * Metin listesi. * * @param string $k Anahtar. * @param string $label Başlık. * @param string $desc Açıklama. */ function tibospeed_f_list( $k, $label, $desc ) { $v = str_replace( ', ', "\n", (string) tibospeed_get( $k ) ); echo '
' . esc_html( $label ) . '

' . esc_html( $desc ) . '

'; } /* -------------------------------------------------------------------------- Sayfa */ /** * Sayfa. */ function tibospeed_page() { $tabs = tibospeed_tabs(); $tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'panel'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ! isset( $tabs[ $tab ] ) ) { $tab = 'panel'; } $icons = tibospeed_tab_icons(); echo '

TiboSpeed

'; echo ''; echo '

' . esc_html( $tabs[ $tab ] ) . '

' . ( 'panel' !== $tab ? '' : '' ) . '' . esc_html__( 'Clear all cache', 'tibospeed' ) . '
'; $msgs = array( 'saved' => __( 'Saved. The cache was cleared and is being warmed again.', 'tibospeed' ), 'purged' => __( 'Cache cleared.', 'tibospeed' ), 'profile' => __( 'Profile applied. The cache is being warmed again.', 'tibospeed' ), 'repaired' => __( 'Setup refreshed.', 'tibospeed' ), 'elementor' => __( 'Elementor settings applied; Elementor CSS files will be regenerated.', 'tibospeed' ), ); $msg = isset( $_GET['tibospeed_msg'] ) ? sanitize_key( wp_unslash( $_GET['tibospeed_msg'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $msgs[ $msg ] ) ) { echo '
' . esc_html( $msgs[ $msg ] ) . '
'; } echo ''; $keys = tibospeed_tab_keys(); $form = isset( $keys[ $tab ] ) && $keys[ $tab ]; if ( $form ) { echo '
'; wp_nonce_field( 'tibospeed_save' ); echo ''; } $fn = 'tibospeed_tab_' . $tab; if ( function_exists( $fn ) ) { $fn(); } else { do_action( 'tibospeed_tab_' . $tab ); } if ( $form ) { echo '
' . esc_html__( 'Saving clears the cache and warms it again.', 'tibospeed' ) . '
'; } echo '
'; } /** * Menü simgeleri (24×24 SVG yolları). * * @return array */ function tibospeed_tab_icons() { return array( 'panel' => 'M3 13h8V3H3zm10 8h8V11h-8zM3 21h8v-6H3zm10-18v6h8V3z', 'onbellek' => 'M4 7c0-2 4-3 8-3s8 1 8 3-4 3-8 3-8-1-8-3zm0 0v10c0 2 4 3 8 3s8-1 8-3V7M4 12c0 2 4 3 8 3s8-1 8-3', 'dosyalar' => 'M8 8l-5 4 5 4m8-8l5 4-5 4M14 4l-4 16', 'medya' => 'M4 5h16v14H4zm0 11l5-5 4 4 3-3 4 4M15 9.5a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0z', 'eklentiler' => 'M9 3v4M15 3v4M7 7h10v4a5 5 0 01-10 0zM12 16v5', 'veritabani' => 'M4 6c0-1.7 3.6-3 8-3s8 1.3 8 3-3.6 3-8 3-8-1.3-8-3zm0 0v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6', 'gelismis' => 'M12 15a3 3 0 100-6 3 3 0 000 6zm7.4-3a7.4 7.4 0 00-.1-1.3l2-1.6-2-3.4-2.4 1a7.5 7.5 0 00-2.2-1.3L14.4 3h-4l-.4 2.4a7.5 7.5 0 00-2.2 1.3l-2.4-1-2 3.4 2 1.6a7.4 7.4 0 000 2.6l-2 1.6 2 3.4 2.4-1a7.5 7.5 0 002.2 1.3l.4 2.4h4l.4-2.4a7.5 7.5 0 002.2-1.3l2.4 1 2-3.4-2-1.6c.1-.4.1-.9.1-1.3z', 'pro' => 'M12 2l2.9 6.9L22 9.7l-5.5 4.8L18.2 22 12 18.3 5.8 22l1.7-7.5L2 9.7l7.1-.8z', ); } /** * Kart başlığı. * * @param string $t Başlık. * @param string $d Açıklama. */ function tibospeed_card( $t, $d = '' ) { echo '

' . esc_html( $t ) . '

' . ( $d ? '

' . esc_html( $d ) . '

' : '' ); } /** * Panel: hızlı işlemler, ölçüm, profil ve yalnız sorunlar. */ function tibospeed_tab_panel() { $st = tibospeed_cache_stats(); $prof = tibospeed_get( 'profile' ); $stack = tibospeed_stack(); $q = get_option( 'tibospeed_preload', array() ); $w = tibospeed_webp_stats(); $dbc = tibospeed_db_counts(); $junk = array_sum( array_map( 'intval', $dbc ) ); $wleft = max( 0, (int) $w[0] - (int) $w[1] ); echo '
'; echo '
' . esc_html( number_format_i18n( $st[0] ) ) . '' . esc_html__( 'cached pages', 'tibospeed' ) . '
'; echo '
' . esc_html( size_format( $st[1], 1 ) ? size_format( $st[1], 1 ) : '0 B' ) . '' . esc_html__( 'cache size', 'tibospeed' ) . '
'; echo '
' . esc_html( number_format_i18n( is_array( $q ) ? count( $q ) : 0 ) ) . '' . esc_html__( 'in the warm-up queue', 'tibospeed' ) . '
'; echo '
' . esc_html( $w[0] ? round( 100 * $w[1] / $w[0] ) : 0 ) . '%' . esc_html__( 'images converted to WebP', 'tibospeed' ) . '
'; echo '
'; // Tek tıkla yapılacak işler. echo '
'; echo '
' . esc_html__( 'Warm the cache', 'tibospeed' ) . '' . esc_html__( 'Opens every page once so the first visitor gets the fast version too.', 'tibospeed' ) . '
'; echo '
' . esc_html__( 'Convert images to WebP', 'tibospeed' ) . '' . esc_html( $wleft ? sprintf( /* translators: %s: number of images */ __( '%s images are waiting to be converted.', 'tibospeed' ), number_format_i18n( $wleft ) ) : __( 'All images are converted.', 'tibospeed' ) ) . '
'; echo '
' . esc_html__( 'Clean the database', 'tibospeed' ) . '' . esc_html( $junk ? sprintf( /* translators: %s: number of records */ __( '%s unnecessary records (revisions, spam, expired data…).', 'tibospeed' ), number_format_i18n( $junk ) ) : __( 'Nothing to clean.', 'tibospeed' ) ) . '
'; $ps = 'https://pagespeed.web.dev/analysis?url=' . rawurlencode( home_url( '/' ) ); echo '
' . esc_html__( 'Measure your speed', 'tibospeed' ) . '' . esc_html__( 'Google PageSpeed Insights for your home page. Add ?tibospeed=off to a URL to compare without optimization.', 'tibospeed' ) . '' . esc_html__( 'Mobile', 'tibospeed' ) . ' ↗' . esc_html__( 'Desktop', 'tibospeed' ) . ' ↗
'; echo '
'; // Yalnız dikkat isteyenler. $issues = array_filter( tibospeed_health(), function ( $h ) { return 'good' !== $h[0]; } ); tibospeed_card( __( 'Needs attention', 'tibospeed' ) ); if ( ! $issues ) { echo '

' . esc_html__( 'Everything looks good. Server, cache and scheduled tasks are working.', 'tibospeed' ) . '

'; } else { echo ''; } if ( ! tibospeed_dropin_ok() && tibospeed_get( 'cache' ) ) { echo '

' . esc_html__( 'Repair', 'tibospeed' ) . ''; if ( false === tibospeed_dropin_ours() ) { echo ' ' . esc_html__( 'Take over the cache file', 'tibospeed' ) . ''; } echo '

'; } echo '
'; tibospeed_card( __( 'Speed profile', 'tibospeed' ), __( 'Applied with one click; you can change individual settings on the tabs later.', 'tibospeed' ) ); echo '
'; foreach ( tibospeed_profiles() as $k => $p ) { $on = $k === $prof; echo '' . esc_html( $p[0] ) . ( 'dengeli' === $k ? ' ' . esc_html__( 'Recommended', 'tibospeed' ) . '' : '' ) . '' . esc_html( $p[1] ) . '' . ( $on ? '' . esc_html__( 'Active', 'tibospeed' ) . '' : '' ) . ''; } echo '
'; if ( 'ozel' === $prof ) { echo '

' . esc_html__( 'Custom settings are currently in use.', 'tibospeed' ) . '

'; } echo ''; tibospeed_card( __( 'Detected on your site', 'tibospeed' ) ); echo ''; if ( ! tibospeed_is_pro() ) { echo '

' . esc_html__( 'Go further with TiboSpeed Pro', 'tibospeed' ) . '

' . esc_html__( 'Explore Pro', 'tibospeed' ) . '
'; } } /** * Pro özellikleri. * * @return array */ function tibospeed_pro_features() { return array( array( __( 'Cloud-free critical CSS:', 'tibospeed' ), __( 'For each page type, the CSS visible on screen is measured on your site and inlined; the rest loads without blocking.', 'tibospeed' ) ), array( __( 'Measured LCP:', 'tibospeed' ), __( 'The largest image is actually measured on mobile and desktop and given priority.', 'tibospeed' ) ), array( __( 'Real visitor speed:', 'tibospeed' ), __( 'The LCP, INP and CLS your visitors experience, page by page (cookieless).', 'tibospeed' ) ), array( __( 'Self-healing optimization:', 'tibospeed' ), __( 'If a delayed script causes errors for visitors, it is excluded automatically.', 'tibospeed' ) ), array( __( 'AVIF and CDN:', 'tibospeed' ), __( 'Even smaller images and rewriting to your own CDN address.', 'tibospeed' ) ), ); } /** * Önbellek. */ function tibospeed_tab_onbellek() { tibospeed_card( __( 'Page cache', 'tibospeed' ), __( 'Pages are stored as ready-made HTML files. On Apache and LiteSpeed servers, these files are served without running PHP or WordPress at all: static-site speed.', 'tibospeed' ) ); tibospeed_f_toggle( 'cache', __( 'Page cache', 'tibospeed' ), __( 'Logged-in users, visitors with items in the cart, and cart / checkout / account pages are excluded from the cache automatically.', 'tibospeed' ) ); tibospeed_f_num( 'cache_hours', __( 'Cache lifetime', 'tibospeed' ), __( 'hours. When content changes, the related pages are refreshed instantly anyway; this lifetime is a safety net.', 'tibospeed' ), 1, 720 ); tibospeed_f_toggle( 'preload', __( 'Automatic preload', 'tibospeed' ), __( 'Purged pages are rebuilt in the background right away; visitors never get a slow page.', 'tibospeed' ) ); tibospeed_f_toggle( 'cache_mobile', __( 'Separate cache for mobile', 'tibospeed' ), __( 'Turn on only if your theme outputs different HTML on mobile (not needed for responsive themes or WebTibo themes).', 'tibospeed' ) ); tibospeed_f_toggle( 'browser_cache', __( 'Browser cache and compression', 'tibospeed' ), __( '1-year browser caching and gzip compression for images, CSS, JS and fonts (.htaccess).', 'tibospeed' ) ); echo '
' . esc_html__( 'Smart purge', 'tibospeed' ) . '

' . esc_html__( 'When a post is updated, only that post, the home page, its categories, tags, author page and (for products) the shop page are refreshed. Site-wide changes such as menus, theme settings, Elementor templates or plugin updates refresh the whole cache. No setup needed.', 'tibospeed' ) . '

'; echo ''; } /** * CSS ve JavaScript. */ function tibospeed_tab_dosyalar() { tibospeed_card( __( 'JavaScript', 'tibospeed' ), __( 'JavaScript is what slows page loading down the most.', 'tibospeed' ) ); tibospeed_f_toggle( 'js_defer', __( 'Safe defer', 'tibospeed' ), __( 'Scripts run after the page is rendered. WordPress\'s own safety rules are used: a script that would break if deferred is loaded normally.', 'tibospeed' ), __( 'Risk: very low', 'tibospeed' ) ); tibospeed_f_choice( 'js_delay', __( 'Delay until first interaction', 'tibospeed' ), array( 'off' => array( __( 'Off', 'tibospeed' ), __( 'No scripts are delayed.', 'tibospeed' ) ), 'third' => array( __( 'Analytics, ad and chat scripts', 'tibospeed' ), __( 'Google Analytics, Tag Manager, Meta Pixel, Hotjar, Clarity, live chat… run when the visitor scrolls, taps or after a few seconds. Recommended.', 'tibospeed' ) ), 'all' => array( __( 'All JavaScript', 'tibospeed' ), __( 'Highest score. Sliders, menus and animations start on the first interaction; check your site on mobile.', 'tibospeed' ) ), ) ); tibospeed_f_num( 'delay_timeout', __( 'Run delayed scripts at the latest after', 'tibospeed' ), __( 'seconds (0: on interaction only). Recommended so that analytics also counts visitors who leave without interacting.', 'tibospeed' ), 0, 60 ); echo ''; tibospeed_card( __( 'CSS and HTML', 'tibospeed' ) ); tibospeed_f_toggle( 'css_minify', __( 'CSS minification', 'tibospeed' ), __( 'Theme and plugin CSS files are served as minified copies. Original files are not touched.', 'tibospeed' ) ); tibospeed_f_toggle( 'html_minify', __( 'HTML minification', 'tibospeed' ), __( 'Unnecessary whitespace and comments are removed.', 'tibospeed' ) ); tibospeed_f_toggle( 'block_css_split', __( 'CSS only for blocks in use', 'tibospeed' ), __( 'Gutenberg block styles are loaded for the blocks used on the page instead of one large file.', 'tibospeed' ) ); echo ''; tibospeed_card( __( 'Fonts and connections', 'tibospeed' ) ); tibospeed_f_toggle( 'fonts_local', __( 'Host Google Fonts locally', 'tibospeed' ), __( 'Fonts are downloaded from Google once and served from your own server. Visitors don\'t connect to Google (also better for privacy). When enabled, the plugin connects to Google only to download the font files.', 'tibospeed' ) ); tibospeed_f_toggle( 'fonts_swap', __( 'Show text while fonts load', 'tibospeed' ), __( 'Adds font-display: swap; text appears immediately instead of a blank screen.', 'tibospeed' ) ); tibospeed_f_toggle( 'preconnect', __( 'Preconnect to external servers', 'tibospeed' ), __( 'Connections to external servers used on the page are opened early (up to 4).', 'tibospeed' ) ); tibospeed_f_choice( 'speculation', __( 'Instant page navigation', 'tibospeed' ), array( 'off' => array( __( 'Off', 'tibospeed' ), '' ), 'prefetch' => array( __( 'Prefetch', 'tibospeed' ), __( 'The next page is downloaded when the mouse hovers over a link. Recommended.', 'tibospeed' ) ), 'prerender' => array( __( 'Prerender', 'tibospeed' ), __( 'The next page is fully prepared in the background and opens instantly on click.', 'tibospeed' ) ), ) ); echo ''; tibospeed_card( __( 'WordPress cleanup', 'tibospeed' ) ); tibospeed_f_toggle( 'no_emoji', __( 'Remove the emoji script', 'tibospeed' ), __( 'All modern browsers display emojis themselves.', 'tibospeed' ) ); tibospeed_f_toggle( 'no_embeds', __( 'Remove the WordPress embed script', 'tibospeed' ), __( 'Embeds such as YouTube and X keep working.', 'tibospeed' ) ); tibospeed_f_toggle( 'no_dashicons', __( 'Don\'t load Dashicons for visitors', 'tibospeed' ), __( 'The admin icon font is loaded only for logged-in users.', 'tibospeed' ) ); tibospeed_f_toggle( 'head_clean', __( ' cleanup', 'tibospeed' ), __( 'RSD, wlwmanifest, shortlink and generator tags are removed.', 'tibospeed' ) ); tibospeed_f_choice( 'heartbeat', 'Heartbeat', array( 'default' => array( __( 'Default', 'tibospeed' ), '' ), 'reduce' => array( __( 'Reduced', 'tibospeed' ), __( 'Once a minute in the admin. Recommended.', 'tibospeed' ) ), 'off_front' => array( __( 'Off on the site', 'tibospeed' ), __( 'Reduced + never runs on visitor pages.', 'tibospeed' ) ), ) ); echo ''; } /** * Görsel ve video. */ function tibospeed_tab_medya() { tibospeed_card( __( 'Images', 'tibospeed' ) ); tibospeed_f_toggle( 'lcp', __( 'Prioritize the largest image (LCP)', 'tibospeed' ), __( 'The main image at the top of the page is loaded first and preloaded. This setting affects Google\'s speed score the most.', 'tibospeed' ) ); tibospeed_f_toggle( 'lazy', __( 'Lazy loading', 'tibospeed' ), __( 'Off-screen images and iframes load on scroll (a native browser feature, no JavaScript needed).', 'tibospeed' ) ); tibospeed_f_num( 'lazy_skip', __( 'Number of images to load immediately', 'tibospeed' ), __( 'So that the logo and top images aren\'t lazy loaded.', 'tibospeed' ), 0, 10 ); tibospeed_f_toggle( 'img_dims', __( 'Add missing width / height', 'tibospeed' ), __( 'Prevents content from shifting while the page loads (CLS).', 'tibospeed' ) ); echo ''; $w = tibospeed_webp_stats(); $ok = tibospeed_webp_supported(); tibospeed_card( 'WebP', __( 'Images are converted to WebP on your server; 25–35% smaller on average. No external service, quota or monthly fee.', 'tibospeed' ) ); tibospeed_f_toggle( 'webp', __( 'Generate and use WebP', 'tibospeed' ), __( 'New uploads are converted automatically. Originals are kept; if the WebP is larger, it isn\'t used.', 'tibospeed' ) ); tibospeed_f_num( 'webp_quality', __( 'Quality', 'tibospeed' ), __( '(80–85 recommended)', 'tibospeed' ), 40, 100 ); echo '
' . esc_html__( 'Convert existing images', 'tibospeed' ) . '

'; /* translators: 1: converted, 2: total, 3: saved size */ echo esc_html( sprintf( __( '%1$s / %2$s images converted, %3$s saved.', 'tibospeed' ), number_format_i18n( $w[1] ), number_format_i18n( $w[0] ), size_format( $w[2], 1 ) ? size_format( $w[2], 1 ) : '0 B' ) ); echo '

'; if ( ! $ok ) { echo '

' . esc_html__( 'Your server\'s image library doesn\'t support WebP. Ask your host to enable WebP support for GD or Imagick.', 'tibospeed' ) . '

'; } echo ''; tibospeed_card( __( 'Video', 'tibospeed' ) ); tibospeed_f_toggle( 'yt_facade', __( 'YouTube preview', 'tibospeed' ), __( 'YouTube videos are replaced with a lightweight preview image that looks the same; the video loads on click. Saves about 1 MB per video.', 'tibospeed' ) ); echo ''; } /** * WooCommerce ve Elementor. */ function tibospeed_tab_eklentiler() { tibospeed_card( 'WooCommerce' ); if ( ! class_exists( 'WooCommerce' ) ) { echo '

' . esc_html__( 'WooCommerce is not installed.', 'tibospeed' ) . '

'; } tibospeed_f_toggle( 'woo_fragments', __( 'Remove the "cart fragments" request when the cart is empty', 'tibospeed' ), __( 'WooCommerce sends a request to the server on every page to refresh the cart. When the cart is empty, this request is unnecessary and defeats the page cache.', 'tibospeed' ) ); tibospeed_f_toggle( 'woo_assets', __( 'Don\'t load WooCommerce files outside the shop', 'tibospeed' ), __( 'Blog posts and pages without products skip WooCommerce styles and scripts. Shop, product, cart, checkout and account pages, and pages with product blocks or shortcodes, are not affected. Check your header mini cart after enabling.', 'tibospeed' ) ); echo ''; echo ''; tibospeed_card( 'Elementor', __( 'Brings Elementor\'s own performance settings to their fastest values.', 'tibospeed' ) ); if ( ! defined( 'ELEMENTOR_VERSION' ) ) { echo '

' . esc_html__( 'Elementor is not installed.', 'tibospeed' ) . '

'; return; } echo ''; $all = true; foreach ( tibospeed_elementor_status() as $s ) { $all = $all && $s[3]; echo ''; } echo '
' . esc_html__( 'Setting', 'tibospeed' ) . '' . esc_html__( 'Status', 'tibospeed' ) . '
' . esc_html( $s[0] ) . '
' . esc_html( $s[4] ) . '
' . ( $s[3] ? '' . esc_html__( 'OK', 'tibospeed' ) . '' : '' . esc_html__( 'Not applied', 'tibospeed' ) . '' ) . '
'; if ( ! $all ) { echo '

' . esc_html__( 'Apply recommended Elementor settings', 'tibospeed' ) . '

'; } echo '

' . esc_html__( 'Elementor\'s "Element Caching" and "Lazy Load Background Images" experiments have no effect if they don\'t exist in your Elementor version. You can also see these settings under Elementor → Settings → Features.', 'tibospeed' ) . '

'; echo ''; } /** * Veritabanı. */ function tibospeed_tab_veritabani() { $c = tibospeed_db_counts(); tibospeed_card( __( 'Cleanup', 'tibospeed' ) ); echo ''; foreach ( tibospeed_db_items() as $k => $it ) { echo ''; } echo '
' . esc_html( $it[0] ) . '' . ( $it[1] ? '
' . esc_html( $it[1] ) . '' : '' ) . '
' . esc_html( number_format_i18n( $c[ $k ] ) ) . '

'; tibospeed_f_num( 'revisions_keep', __( 'Revisions to keep per post', 'tibospeed' ), __( '(new revisions are also limited to this number)', 'tibospeed' ), 0, 100 ); tibospeed_f_choice( 'db_auto', __( 'Automatic cleanup', 'tibospeed' ), array( '0' => array( __( 'Off', 'tibospeed' ), '' ), 'weekly' => array( __( 'Weekly', 'tibospeed' ), __( 'All items above except table optimization.', 'tibospeed' ) ), ) ); echo ''; $a = tibospeed_autoload_report(); tibospeed_card( __( 'Options loaded on every page (autoload)', 'tibospeed' ), __( 'This data is loaded into memory on every page load. Above 800 KB the site slows down; it is usually left over from deleted plugins.', 'tibospeed' ) ); $total = (int) $a[0]; echo '

' . esc_html( size_format( $total, 1 ) ) . '

'; echo ''; foreach ( (array) $a[1] as $r ) { echo ''; } echo '
' . esc_html__( 'Setting', 'tibospeed' ) . '' . esc_html__( 'Size', 'tibospeed' ) . '
' . esc_html( $r['n'] ) . '' . esc_html( size_format( (int) $r['b'], 1 ) ) . '
'; } /** * Gelişmiş. */ function tibospeed_tab_gelismis() { tibospeed_card( __( 'Exclusions', 'tibospeed' ) ); tibospeed_f_list( 'exclude_urls', __( 'URLs never to cache', 'tibospeed' ), __( 'A part of the URL, one per line. Example: /contact', 'tibospeed' ) ); tibospeed_f_list( 'exclude_cookies', __( 'Cookies that bypass the cache', 'tibospeed' ), __( 'Visitors with this cookie are not served from the cache (start of the cookie name).', 'tibospeed' ) ); tibospeed_f_list( 'ignore_params', __( 'Ignored URL parameters', 'tibospeed' ), __( 'Visitors arriving with these parameters (ad and campaign links) still get the fast cached page.', 'tibospeed' ) ); tibospeed_f_list( 'delay_exclude', __( 'JavaScript never to delay', 'tibospeed' ), __( 'A file name, script ID or a piece of the code. Example: slider.min.js', 'tibospeed' ) ); tibospeed_f_list( 'defer_exclude', __( 'Scripts never to defer', 'tibospeed' ), __( 'WordPress script handle. Example: my-theme-script', 'tibospeed' ) ); echo ''; tibospeed_card( __( 'Server', 'tibospeed' ) ); /* translators: %s: server type */ echo '

' . esc_html( sprintf( __( 'Server: %s', 'tibospeed' ), tibospeed_server() ) ) . '

'; if ( 'nginx' === tibospeed_server() ) { echo '

' . esc_html__( 'For static mode on Nginx, add this rule to your server configuration (your host can add it too):', 'tibospeed' ) . '

'; } else { echo '

' . esc_html__( 'The rule to use if you move your server to Nginx:', 'tibospeed' ) . '

'; } echo '
' . esc_html( tibospeed_nginx_rules() ) . '
'; echo '

' . esc_html__( 'Refresh setup', 'tibospeed' ) . ' ' . esc_html__( 'advanced-cache.php, wp-config.php and .htaccess are rewritten.', 'tibospeed' ) . '

'; echo ''; } /** * Pro tanıtımı. */ function tibospeed_tab_pro() { echo '

TiboSpeed Pro

' . esc_html__( 'No feature of the free version is locked. Pro does on your own site what competitors do in their cloud.', 'tibospeed' ) . '

' . esc_html__( 'Explore Pro', 'tibospeed' ) . '
'; } // The settings screen is a full app: other plugins' notices are not shown on it. add_action( 'in_admin_header', function () { $sc = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( $sc && 'toplevel_page_tibospeed' === $sc->id ) { remove_all_actions( 'admin_notices' ); remove_all_actions( 'all_admin_notices' ); } }, 1000 ); // WebTibo themes group their products under one "WebTibo" heading in the admin menu. add_filter( 'webtibo_menu_group', function ( $g ) { $g[] = 'tibospeed'; return $g; } );