Making WordPress.org

Changeset 14057


Ignore:
Timestamp:
09/16/2024 10:23:45 PM (4 months ago)
Author:
coffee2code
Message:

Photo Directory, Admin: Add rejection stats to 'Photo Contributor' metabox.

Fixes #7774.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/assets/css/admin.css

    r14046 r14057  
    22    display: none;
    33}
     4.photo-contributor-rejection-stats {
     5    width: 100%;
     6}
     7.photo-contributor-rejection-stats table {
     8    text-align: left;
     9    width: 100%;
     10}
     11
    412.fixed .column-wporg-photo { font-weight: bold; width: 180px; }
    513.status-flagged {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/admin.php

    r14047 r14057  
    11701170            ?>
    11711171            </div>
     1172            <div class="photo-contributor-rejection-stats">
     1173                <h4><?php esc_html_e( 'Rejection stats:', 'wporg-photos' ); ?></h4>
     1174                <?php
     1175                    $rejection_reasons = Rejection::get_user_rejection_reasons( $author->ID );
     1176                    $submission_errors_key = 'submission-error';
     1177                    $submission_errors_count = 0;
     1178
     1179                    // Omit submission errors since they don't count as rejections, but do note the count.
     1180                    if ( ! empty( $rejection_reasons[ $submission_errors_key ] ) ) {
     1181                        $submission_errors_count = $rejection_reasons[ $submission_errors_key ];
     1182                        unset( $rejection_reasons[ $submission_errors_key ] );
     1183                    }
     1184
     1185                    $total_rejections = array_reduce( array_values( $rejection_reasons ), function ( $total, $i ) { return $total += $i; }, 0 );
     1186                    $all_reasons = Rejection::get_rejection_reasons();
     1187
     1188                    if ( $rejection_reasons ) {
     1189                        echo '<table>';
     1190                        echo '<tr><th>' . __( 'Reason', 'wporg-photos' ) . '</th><th>' . __( 'Total', 'wporg-photos' ) . '</th><th>%</th></tr>';
     1191                    }
     1192                    foreach ( $rejection_reasons as $reason => $count ) {
     1193                        echo '<tr>';
     1194                        echo '<td title="' . esc_attr( $all_reasons[ $reason ]['label'] ?? '' ) . '">' . esc_html( $reason ) . '</td>';
     1195                        echo '<td>' . number_format_i18n( $count ) . '</td>';
     1196                        echo '<td>' . number_format_i18n( ( $count / $total_rejections ) * 100, 2 ) . '%</td>';
     1197                        echo "</tr>\n";
     1198                    }
     1199                    if ( $rejection_reasons ) {
     1200                        echo "</table>\n";
     1201                    }
     1202
     1203                    echo '<p>';
     1204                    /* translators: %s: Rejection rate as a percentage. */
     1205                    printf( __( 'Total rejection rate: %s', 'wporg-photos'), '<strong>' . round( ( $total_rejections / ( $photos_count + $total_rejections ) ) * 100, 2 ) .'%</strong>' );
     1206                    echo "</p>\n";
     1207
     1208                    if ( $submission_errors_count ) {
     1209                        echo '<p>';
     1210                        /* translators: %s: The number of submission errors. */
     1211                        printf( __( 'Submission errors (which are\'t counted as submissions): %s', 'wporg-photos' ), $submission_errors_count );
     1212                        echo "</p>\n";
     1213                    }
     1214                ?>
     1215            </div>
    11721216        </div>
    11731217
Note: See TracChangeset for help on using the changeset viewer.