$max_template_size ) { $size_mb = round( $size / 1048576, 2 ); $max_mb = round( $max_template_size / 1048576, 2 ); throw new TemplateSizeException( sprintf( 'La taille du template (%s MB) dépasse la limite configurée (%s MB)', esc_html( $size_mb ), esc_html( $max_mb ) ) ); } } /** * Retourne les informations des limites actuelles. */ public static function get_limits_info(): array { $settings = pdfib_get_option( 'pdfib_settings', array() ); $request_time = (float) sanitize_text_field( wp_unslash( $GLOBALS['_SERVER']['REQUEST_TIME_FLOAT'] ?? '0' ) ); return array( 'max_execution_time' => isset( $settings['max_execution_time'] ) ? \intval( $settings['max_execution_time'] ) : 300, 'memory_limit' => \intval( pdfib_get_option( 'pdfib_canvas_memory_limit_php', 256 ) ) . 'M', 'max_template_size' => isset( $settings['max_template_size'] ) ? \intval( $settings['max_template_size'] ) : 52428800, 'current_memory_usage' => memory_get_usage( true ), 'peak_memory_usage' => memory_get_peak_usage( true ), 'current_execution_time' => round( microtime( true ) - $request_time, 2 ), ); } } // Initialiser au chargement. SecurityLimitsHandler::init();