$dir['basedir'] . '/gpx', 'url' => $dir['baseurl'] . '/gpx', 'subdir' => '/gpx', ) + $dir; } function wpgpxmaps_move_uploaded_file($uploadedfile) { // Register our path override. add_filter( 'upload_dir', 'wpgpxmaps_181088_upload_dir' ); $upload_overrides = array( 'test_form' => false, 'test_type' => false ); // Do our thing. WordPress will move the file to 'uploads/gpx'. $result = wp_handle_upload( $uploadedfile , $upload_overrides); // Set everything back to normal. remove_filter( 'upload_dir', 'wpgpxmaps_181088_upload_dir' ); if ( $result && isset( $result['error'] )) { echo "

". esc_html( $result['error'] )."

"; } return ( $result && !isset( $result['error'] )); } /* The First Div (for body) starts in wp-gpx-admin.php */ if ( isset( $_POST['clearcache'] ) ) { if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( $_GET['_wpnonce'] ), 'wpgpx_clearcache_nonce' . $entry ) ) { echo '

'; esc_html_e( 'Cache is now empty!', 'wp-gpx-maps' ); echo '

'; wpgpxmaps_recursive_remove_directory( $cacheGpxPath, true ); } } if ( is_writable( $realGpxPath ) ) { ?>
'; ?> $value) { if ($uploaded_files['name'][$key]) { $file = array( 'name' => $uploaded_files['name'][$key], 'type' => $uploaded_files['type'][$key], 'tmp_name' => $uploaded_files['tmp_name'][$key], 'error' => $uploaded_files['error'][$key], 'size' => $uploaded_files['size'][$key] ); $uploadingFileName = basename( $file['name'] ); if ( preg_match( $gpxRegEx, $uploadingFileName ) ) { if ( wpgpxmaps_move_uploaded_file( $file ) ) { echo '

'; printf( /* translators: %1s: GPX file name */ esc_html__( 'The file %1s has been successfully uploaded.', 'wp-gpx-maps' ), '' . esc_html( $uploadingFileName ) . '' ); echo '

'; } else { echo '

'; esc_html_e( 'There was an error uploading the file, please try again!', 'wp-gpx-maps' ); echo '

'; } } else { echo '

'; esc_html_e( 'The file type is not supported!', 'wp-gpx-maps' ); echo '

'; } } } // Remove the override to avoid affecting other uploads remove_filter('upload_dir', 'custom_upload_dir'); } ?>

'; printf( /* translators: %1s: Relative path of the GPX folder */ esc_html__( 'Your folder for GPX files %1s is not writable. Please change the folder permissions.', 'wp-gpx-maps' ), '' . esc_html( $relativeGpxPath ) . '' ); echo '

'; ?>

'; printf( /* translators: %1s: GPX file name */ esc_html__( 'The file %1s has been successfully deleted.', 'wp-gpx-maps' ), '' . esc_html( $entry ) . '' ); echo '

'; } else { echo '

'; printf( /* translators: %1s: GPX file name */ esc_html__( 'The file %1s could not be deleted.', 'wp-gpx-maps' ), '' . esc_html( $entry ) . '' ); echo '

'; } } else { $myFile = $realGpxPath . '/' . $entry; $myGpxFileNames[] = array( 'name' => $entry, 'size' => filesize( $myFile ), 'lastedit' => filemtime( $myFile ), 'nonce' => wp_create_nonce( 'wpgpx_deletefile_nonce_' . $entry ), ); } } } closedir( $handle ); } if ( is_readable( $realGpxPath ) && $handle = opendir( $realGpxPath ) ) { while ( false !== ( $entry = readdir( $handle ) ) ) { if ( preg_match( $gpxRegEx, $entry ) ) { $filenames[] = $realGpxPath . '/' . $entry; } } closedir( $handle ); } ?>