ravinderk /
Give
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
|
|||
| 2 | /** |
||
| 3 | * Admin Footer |
||
| 4 | * |
||
| 5 | * @package Give |
||
| 6 | * @subpackage Admin/Footer |
||
| 7 | * @copyright Copyright (c) 2016, WordImpress |
||
| 8 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
||
| 9 | * @since 1.0 |
||
| 10 | */ |
||
| 11 | |||
| 12 | // Exit if accessed directly. |
||
| 13 | if ( ! defined( 'ABSPATH' ) ) { |
||
| 14 | exit; |
||
| 15 | } |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Add rating links to the admin dashboard |
||
| 19 | * |
||
| 20 | * @since 1.0 |
||
| 21 | * @global string $typenow |
||
| 22 | * |
||
| 23 | * @param string $footer_text The existing footer text |
||
| 24 | * |
||
| 25 | * @return string |
||
| 26 | */ |
||
| 27 | function give_admin_rate_us( $footer_text ) { |
||
| 28 | global $typenow; |
||
| 29 | |||
| 30 | if ( $typenow == 'give_forms' ) { |
||
| 31 | $rate_text = sprintf( |
||
| 32 | /* translators: %s: Link to 5 star rating */ |
||
| 33 | __( 'If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give' ), |
||
| 34 | '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" style="text-decoration:none;" data-rated="' . esc_attr__( 'Thanks :)', 'give' ) . '">★★★★★</a>' |
||
| 35 | ); |
||
| 36 | |||
| 37 | return $rate_text; |
||
| 38 | } else { |
||
| 39 | return $footer_text; |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | add_filter( 'admin_footer_text', 'give_admin_rate_us' ); |
||
| 44 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.