1 <?php
2 3 4 5 6 7 8 9 10
11
12
13 if ( ! defined( 'ABSPATH' ) ) exit;
14
15 16 17 18 19 20 21 22 23
24 function edd_add_ons_init() {
25 global $edd_add_ons_page;
26 add_action( 'load-' . $edd_add_ons_page, 'edd_add_ons_check_feed' );
27 }
28 add_action( 'admin_menu', 'edd_add_ons_init');
29
30 31 32 33 34 35 36 37
38 function edd_add_ons_page() {
39 ob_start(); ?>
40 <div class="wrap" id="edd-add-ons">
41 <h2>
42 <?php _e( 'Add Ons for Easy Digital Downloads', 'edd' ); ?>
43 — <a href="http://easydigitaldownloads.com/extensions/?ref=1" class="button-primary" title="<?php _e( 'Browse All Extensions', 'edd' ); ?>" target="_blank"><?php _e( 'Browse All Extensions', 'edd' ); ?></a>
44 </h2>
45 <p><?php _e( 'These add-ons extend the functionality of Easy Digital Downloads.', 'edd' ); ?></p>
46 <?php echo edd_add_ons_get_feed(); ?>
47 </div>
48 <?php
49 echo ob_get_clean();
50 }
51
52 53 54 55 56 57 58 59
60 function edd_add_ons_get_feed() {
61 if ( false === ( $cache = get_transient( 'easydigitaldownloads_add_ons_feed' ) ) ) {
62 $feed = wp_remote_get( 'https://easydigitaldownloads.com/?feed=extensions', array( 'sslverify' => false ) );
63 if ( ! is_wp_error( $feed ) ) {
64 if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) {
65 $cache = wp_remote_retrieve_body( $feed );
66 set_transient( 'easydigitaldownloads_add_ons_feed', $cache, 3600 );
67 }
68 } else {
69 $cache = '<div class="error"><p>' . __( 'There was an error retrieving the extensions list from the server. Please try again later.', 'edd' ) . '</div>';
70 }
71 }
72 return $cache;
73 }