| Conditions | 2 |
| Paths | 2 |
| Total Lines | 77 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 91 | function give_dashboard_stats_widget() { |
||
| 92 | |||
| 93 | if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
||
| 94 | return; |
||
| 95 | } |
||
| 96 | $stats = new Give_Payment_Stats(); ?> |
||
| 97 | |||
| 98 | <div class="give-dashboard-widget"> |
||
| 99 | |||
| 100 | <div class="give-dashboard-today give-clearfix"> |
||
| 101 | <h3 class="give-dashboard-date-today"><?php echo date_i18n( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3> |
||
|
|
|||
| 102 | |||
| 103 | <p class="give-dashboard-happy-day"><?php |
||
| 104 | printf( |
||
| 105 | /* translators: %s: day of the week */ |
||
| 106 | __( 'Happy %s!', 'give' ), |
||
| 107 | date_i18n( 'l', current_time( 'timestamp' ) ) |
||
| 108 | ); |
||
| 109 | ?></p> |
||
| 110 | |||
| 111 | <p class="give-dashboard-today-earnings"><?php |
||
| 112 | $earnings_today = $stats->get_earnings( 0, 'today', false ); |
||
| 113 | echo give_currency_filter( give_format_amount( $earnings_today, array( 'sanitize' => false ) ) ); |
||
| 114 | ?></p> |
||
| 115 | |||
| 116 | <p class="give-donations-today"><?php |
||
| 117 | $donations_today = $stats->get_sales( 0, 'today', false ); |
||
| 118 | printf( |
||
| 119 | /* translators: %s: daily donation count */ |
||
| 120 | __( '%s donations today', 'give' ), |
||
| 121 | give_format_amount( $donations_today, array( 'decimal' => false, 'sanitize' => false ) ) |
||
| 122 | ); |
||
| 123 | ?></p> |
||
| 124 | |||
| 125 | </div> |
||
| 126 | |||
| 127 | |||
| 128 | <table class="give-table-stats"> |
||
| 129 | <thead style="display: none;"> |
||
| 130 | <tr> |
||
| 131 | <th><?php _e( 'This Week', 'give' ); ?></th> |
||
| 132 | <th><?php _e( 'This Month', 'give' ); ?></th> |
||
| 133 | <th><?php _e( 'Past 30 Days', 'give' ); ?></th> |
||
| 134 | </tr> |
||
| 135 | </thead> |
||
| 136 | <tbody> |
||
| 137 | <tr id="give-table-stats-tr-1"> |
||
| 138 | <td> |
||
| 139 | <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ), array( 'sanitize' => false ) ) ); ?></p> |
||
| 140 | |||
| 141 | <p class="give-dashboard-stat-total-label"><?php _e( 'This Week', 'give' ); ?></p> |
||
| 142 | </td> |
||
| 143 | <td> |
||
| 144 | <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ), array( 'sanitize' => false ) ) ); ?></p> |
||
| 145 | |||
| 146 | <p class="give-dashboard-stat-total-label"><?php _e( 'This Month', 'give' ); ?></p> |
||
| 147 | </td> |
||
| 148 | </tr> |
||
| 149 | <tr id="give-table-stats-tr-2"> |
||
| 150 | <td> |
||
| 151 | <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ), array( 'sanitize' => false ) ) ) ?></p> |
||
| 152 | |||
| 153 | <p class="give-dashboard-stat-total-label"><?php _e( 'Last Month', 'give' ); ?></p> |
||
| 154 | </td> |
||
| 155 | <td> |
||
| 156 | <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_quarter' ), array( 'sanitize' => false ) ) ) ?></p> |
||
| 157 | |||
| 158 | <p class="give-dashboard-stat-total-label"><?php _e( 'This Quarter', 'give' ); ?></p> |
||
| 159 | </td> |
||
| 160 | </tr> |
||
| 161 | </tbody> |
||
| 162 | </table> |
||
| 163 | |||
| 164 | </div> |
||
| 165 | |||
| 166 | <?php |
||
| 167 | } |
||
| 168 | |||
| 212 |