Sometimes it might be helpful to make the website visitor tick a checkbox to accept terms before allowing a file upload.
Sie müssen dieses Kontrollkästchen aktivieren, bevor Sie eine Datei hochladen können.
Mach weiter, überprüfe es.
If you are at all comfortable with doing a little coding, this can be accomplished with some simple JavaScript added to your theme and HTML in the page content. Here’s how:
Seiteninhalt
Place an HTML block above the Simple File List shortcode. This is simply a checkbox followed by your message. You can add a link to the full text if you want.
<p>
<input id="myCheckToUpoad" type="checkbox" name="Checkbox" value="YES">Check this Box.
</p>
JavaScript in your Theme
Der Schlüssel zum obigen Code ist der id="myCheckToUpoad"
. The JavaScript will hook into this and show or hide the upload form. You could also use this for the file list, or both.
Locate your current theme’s functions.php Datei.
Fügen Sie diesen Code hinzu und speichern Sie ihn.
// Function to output JavaScript in theme <head>
function myHeadHurts() { ?>
<script>
jQuery(document).ready(function() {
jQuery('#eeSFL_UploadForm').hide(); // Hide the form straight away
jQuery('#myCheckToUpload').on('click', function() { // The box is clicked...
// Either show or hide, depending if ticked or not
if (jQuery('#eeSFL_UploadForm').is(':visible')) {
jQuery('#eeSFL_UploadForm').slideUp(); // Hide
} else {
jQuery('#eeSFL_UploadForm').slideDown(); // Show
}
});
}); // END Ready Function
</script>
<?php }
// Hook into WordPress loading process
add_action('wp_head', 'myHeadHurts'); // Add to the page's <head>
Es gibt viele Verbesserungen, die an diesem Beispiel vorgenommen werden könnten, aber dies ist im Grunde alles, was Sie brauchen, um loszulegen.