| 1 |
<?php |
| 2 |
/* |
| 3 |
Classlessly add a "more tools" tab to promote (future) AO addons and/ or affiliate services |
| 4 |
*/ |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 7 |
|
| 8 |
add_action('admin_init', 'ao_partner_tabs_preinit'); |
| 9 |
function ao_partner_tabs_preinit() { |
| 10 |
if (apply_filters('autoptimize_filter_show_partner_tabs',true)) { |
| 11 |
add_filter('autoptimize_filter_settingsscreen_tabs','ao_add_partner_tabs'); |
| 12 |
} |
| 13 |
} |
| 14 |
|
| 15 |
function ao_add_partner_tabs($in) { |
| 16 |
$in=array_merge($in,array('ao_partners' => __('Optimize More!','autoptimize'))); |
| 17 |
return $in; |
| 18 |
} |
| 19 |
|
| 20 |
add_action('admin_menu','ao_partners_init'); |
| 21 |
function ao_partners_init() { |
| 22 |
if (apply_filters('autoptimize_filter_show_partner_tabs',true)) { |
| 23 |
$hook=add_submenu_page(NULL,'AO partner','AO partner','manage_options','ao_partners','ao_partners'); |
| 24 |
// register_settings here as well if needed |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
function ao_partners() { |
| 29 |
?> |
| 30 |
<style> |
| 31 |
.itemDetail { |
| 32 |
background: #fff; |
| 33 |
width: 250px; |
| 34 |
min-height: 290px; |
| 35 |
border: 1px solid #ccc; |
| 36 |
float: left; |
| 37 |
padding: 15px; |
| 38 |
position: relative; |
| 39 |
margin: 0 10px 10px 0; |
| 40 |
} |
| 41 |
.itemTitle { |
| 42 |
margin-top:0px; |
| 43 |
margin-bottom:10px; |
| 44 |
} |
| 45 |
.itemImage { |
| 46 |
text-align: center; |
| 47 |
} |
| 48 |
.itemImage img { |
| 49 |
max-width: 95%; |
| 50 |
max-height: 150px; |
| 51 |
} |
| 52 |
.itemDescription { |
| 53 |
margin-bottom:30px; |
| 54 |
} |
| 55 |
.itemButtonRow { |
| 56 |
position: absolute; |
| 57 |
bottom: 10px; |
| 58 |
right: 10px; |
| 59 |
width:100%; |
| 60 |
} |
| 61 |
.itemButton { |
| 62 |
float:right; |
| 63 |
} |
| 64 |
.itemButton a { |
| 65 |
text-decoration: none; |
| 66 |
color: #555; |
| 67 |
} |
| 68 |
.itemButton a:hover { |
| 69 |
text-decoration: none; |
| 70 |
color: #23282d; |
| 71 |
} |
| 72 |
</style> |
| 73 |
<div class="wrap"> |
| 74 |
<h1><?php _e('Autoptimize Settings','autoptimize'); ?></h1> |
| 75 |
<?php echo autoptimizeConfig::ao_admin_tabs(); ?> |
| 76 |
<?php |
| 77 |
echo '<h2>'. __("These Autoptimize power-ups and related services will improve your site's performance even more!",'autoptimize') . '</h2>'; |
| 78 |
?> |
| 79 |
<div> |
| 80 |
<?php getAOPartnerFeed(); ?> |
| 81 |
</div> |
| 82 |
</div> |
| 83 |
<?php |
| 84 |
} |
| 85 |
|
| 86 |
function getAOPartnerFeed() { |
| 87 |
$noFeedText=__( 'Have a look at <a href="http://optimizingmatters.com/">optimizingmatters.com</a> for Autoptimize power-ups!', 'autoptimize' ); |
| 88 |
|
| 89 |
if (apply_filters('autoptimize_settingsscreen_remotehttp',true)) { |
| 90 |
$rss = fetch_feed( "http://feeds.feedburner.com/OptimizingMattersDownloads" ); |
| 91 |
$maxitems = 0; |
| 92 |
|
| 93 |
if ( ! is_wp_error( $rss ) ) { |
| 94 |
$maxitems = $rss->get_item_quantity( 20 ); |
| 95 |
$rss_items = $rss->get_items( 0, $maxitems ); |
| 96 |
} ?> |
| 97 |
<ul> |
| 98 |
<?php |
| 99 |
if ( $maxitems == 0 ) { |
| 100 |
echo $noFeedText; |
| 101 |
} else { |
| 102 |
foreach ( $rss_items as $item ) : |
| 103 |
$itemURL = esc_url( $item->get_permalink() ); ?> |
| 104 |
<li class="itemDetail"> |
| 105 |
<h3 class="itemTitle"><a href="<?php echo $itemURL; ?>" target="_blank"><?php echo esc_html( $item->get_title() ); ?></a></h3> |
| 106 |
<?php |
| 107 |
if (($enclosure = $item->get_enclosure()) && (strpos($enclosure->get_type(),"image")!==false) ) { |
| 108 |
$itemImgURL=esc_url($enclosure->get_link()); |
| 109 |
echo "<div class=\"itemImage\"><a href=\"".$itemURL."\" target=\"_blank\"><img src=\"".$itemImgURL."\"/></a></div>"; |
| 110 |
} |
| 111 |
?> |
| 112 |
<div class="itemDescription"><?php echo wp_kses_post($item -> get_description() ); ?></div> |
| 113 |
<div class="itemButtonRow"><div class="itemButton button-secondary"><a href="<?php echo $itemURL; ?>" target="_blank"><?php _e('More info','autoptimize'); ?></a></div></div> |
| 114 |
</li> |
| 115 |
<?php endforeach; ?> |
| 116 |
<?php } ?> |
| 117 |
</ul> |
| 118 |
<?php |
| 119 |
} else { |
| 120 |
echo $noFeedText; |
| 121 |
} |
| 122 |
} |
| 123 |
|