Created
October 22, 2025 23:12
-
-
Save zackkatz/84603c568ce36e9df06f75d825b54470 to your computer and use it in GitHub Desktop.
Update GravityKit logs path to be in the uploads folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Modify GravityKit log path to use WordPress uploads directory. | |
| * | |
| * @param string $log_path Default log path. | |
| * @return string Modified log path. | |
| */ | |
| add_filter( 'gk/foundation/logger/log-path', function( $log_path ) { | |
| $upload_dir = wp_upload_dir(); | |
| // Check if there's an error getting the upload directory. | |
| if ( ! empty( $upload_dir['error'] ) ) { | |
| return $log_path; // Fall back to default. | |
| } | |
| // Define custom log directory inside uploads. | |
| $custom_log_path = trailingslashit( $upload_dir['basedir'] ) . 'gravitykit-logs'; | |
| // Create the directory if it doesn't exist. | |
| if ( ! file_exists( $custom_log_path ) ) { | |
| wp_mkdir_p( $custom_log_path ); | |
| } | |
| return $custom_log_path; | |
| }, 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment