Changeset 12110
- Timestamp:
- 10/07/2022 07:42:52 AM (2 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/assets/js/submit.js
r12091 r12110 11 11 } 12 12 13 // Prevent double-submission of upload form. 13 // Add checkbox to set/unset all other confirmation checkboxes. 14 if ( PhotoDir.user_can_toggle_all_checkboxes ) { 15 const checkboxDiv = document.createElement( 'div' ); 16 checkboxDiv.setAttribute('class', 'confirmation-checkbox-toggle-container'); 17 const checkboxLabel = document.createElement( 'label' ); 18 const checkboxToggle = document.createElement( 'input' ); 19 checkboxDiv.insertAdjacentElement( 'afterbegin', checkboxLabel ); 20 checkboxLabel.insertAdjacentElement( 'afterbegin', checkboxToggle ); 21 checkboxToggle.setAttribute('class', 'confirmation-checkbox-toggle'); 22 checkboxToggle.setAttribute('name', 'confirmation-checkbox-toggle'); 23 checkboxToggle.setAttribute('type', 'checkbox'); 24 checkboxLabel.insertAdjacentText( 'beforeend', ' ' + PhotoDir.toggle_all_checkboxes ); 25 checkboxToggle.addEventListener( 'change', e => { 26 const newState = e.target.checked; 27 // For checkboxes not matching the current toggle state, click them so that they do. 28 document.querySelectorAll('.upload-checkbox-wrapper input[type="checkbox"]:not(.confirmation-checkbox-toggle)').forEach( v => { 29 if ( v.checked !== newState ) { 30 v.click(); 31 } 32 } ); 33 } ); 34 document.querySelector('.upload-checkbox-wrapper p').insertAdjacentElement( 'afterend', checkboxDiv ); 35 } 36 14 37 const photo_fieldset = document.getElementById('wporg-photo-upload'); 15 38 if ( null === photo_fieldset ) { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/uploads.php
r12092 r12110 285 285 'min_file_dimension' => self::get_minimum_photo_dimension(), 286 286 'msg_validating_dimensions' => __( 'Validating photo dimensions…', 'wporg-photos' ), 287 288 // Toggle all confirmation checkboxes for upload. 289 'user_can_toggle_all_checkboxes' => User::can_toggle_confirmation_checkboxes(), 290 'toggle_all_checkboxes' => __( 'As a contributor of many photos, I am well aware of the requirements listed below and agree to them all.', 'wporg-photos' ), 287 291 ] 288 292 ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/user.php
r12057 r12110 19 19 */ 20 20 const MAX_PENDING_SUBMISSIONS = 5; 21 22 /** 23 * The number of published posts before a given user is permitted to toggle 24 * all of the confirmation checkboxes when submitting a photo. 25 * 26 * @var int 27 */ 28 const TOGGLE_ALL_THRESHOLD = 30; 21 29 22 30 public static function init() { … … 89 97 } 90 98 99 /** 100 * Determines if a user is eligible to toggle all confirmation checkboxes on 101 * the photo upload form. 102 * 103 * The intent is that users who have submitted a decent number of published 104 * photos are as aware of the listed criteria as they're going to be and have 105 * demonstrated that they are able to abide by them. 106 * 107 * @todo Handle eventual case when a new checkbox is added or one is changed 108 * enough to warrant making the user manually re-check the checkboxes. 109 * The latest checkbox update date can be stored as a constant and, if 110 * set, the contributor must also have a post (or N posts) published 111 * after that date to requalify for the bulk toggle. 112 * 113 * @param int $user_id Optional. The user ID. If not defined, assumes current 114 * user. Default false. 115 * @return bool True if user can toggle confirmation checkboxes, else false. 116 */ 117 public static function can_toggle_confirmation_checkboxes( $user_id = false ) { 118 $can = false; 119 120 if ( ! $user_id ) { 121 $user_id = get_current_user_id(); 122 } 123 124 if ( $user_id && self::count_published_photos( $user_id ) >= self::TOGGLE_ALL_THRESHOLD ) { 125 $can = true; 126 } 127 128 return $can; 129 } 130 91 131 } 92 132
Note: See TracChangeset
for help on using the changeset viewer.