getMessage(); $error_message .= "\n" . $exception->getTraceAsString(); } ALLSI_log( $error_message, 'ERROR' ); } if ( ! function_exists( 'ALLSI_get_logs_dir' ) ) { /** * Retrieve the absolute path to the plugin's logs directory within uploads. * * @since 6.1.7 * @return string Absolute path ending with trailing slash. */ function ALLSI_get_logs_dir() { $upload_dir = wp_upload_dir(); $base_dir = $upload_dir['basedir']; return trailingslashit( wp_normalize_path( $base_dir ) ) . 'all-sources-images/logs/'; } } if ( ! function_exists( 'ALLSI_ensure_logs_dir' ) ) { /** * Ensure the logs directory exists and is writable. * * @since 6.1.7 * @return string|false Absolute path when available; false on failure. */ function ALLSI_ensure_logs_dir() { $dir = ALLSI_get_logs_dir(); if ( ! file_exists( $dir ) ) { if ( ! wp_mkdir_p( $dir ) ) { ALLSI_log( 'Unable to create logs directory: ' . $dir, 'LOGS_DIR' ); return false; } } return $dir; } }