ravinderk /
Give
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Admin Add-ons |
||
| 4 | * |
||
| 5 | * @package Give |
||
| 6 | * @subpackage Admin/Add-ons |
||
| 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-ons Page |
||
| 19 | * |
||
| 20 | * Renders the add-ons page content. |
||
| 21 | * |
||
| 22 | * @since 1.0 |
||
| 23 | * @return void |
||
| 24 | */ |
||
| 25 | function give_add_ons_page() { |
||
| 26 | ob_start(); ?> |
||
| 27 | <div class="wrap" id="give-add-ons"> |
||
| 28 | <h1><?php echo get_admin_page_title(); ?> |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 29 | — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e( 'View All Add-ons', 'give' ); ?> |
||
| 30 | <span class="dashicons dashicons-external"></span></a> |
||
| 31 | </h1> |
||
| 32 | |||
| 33 | <p><?php esc_html_e( 'The following Add-ons extend the functionality of Give.', 'give' ); ?></p> |
||
| 34 | <?php echo give_add_ons_get_feed(); ?> |
||
|
0 ignored issues
–
show
|
|||
| 35 | </div> |
||
| 36 | <?php |
||
| 37 | echo ob_get_clean(); |
||
|
0 ignored issues
–
show
|
|||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Add-ons Get Feed |
||
| 42 | * |
||
| 43 | * Gets the add-ons page feed. |
||
| 44 | * |
||
| 45 | * @since 1.0 |
||
| 46 | * @return string $cache |
||
| 47 | */ |
||
| 48 | function give_add_ons_get_feed() { |
||
| 49 | |||
| 50 | $addons_debug = false; //set to true to debug |
||
| 51 | $cache = Give_Cache::get( 'give_add_ons_feed', true ); |
||
| 52 | |||
| 53 | if ( $cache === false || $addons_debug === true && WP_DEBUG === true ) { |
||
|
0 ignored issues
–
show
|
|||
| 54 | $feed = wp_remote_get( 'https://givewp.com/downloads/feed/', array( 'sslverify' => false ) ); |
||
|
0 ignored issues
–
show
|
|||
| 55 | |||
| 56 | if ( ! is_wp_error( $feed ) ) { |
||
| 57 | if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) { |
||
| 58 | $cache = wp_remote_retrieve_body( $feed ); |
||
| 59 | Give_Cache::set( 'give_add_ons_feed', $cache, HOUR_IN_SECONDS, true ); |
||
| 60 | } |
||
| 61 | } else { |
||
| 62 | $cache = sprintf( |
||
| 63 | '<div class="error"><p>%s</p></div>', |
||
| 64 | esc_html__( 'There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give' ) |
||
| 65 | ); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | return $cache; |
||
| 70 | |||
| 71 | } |