PluginProbe
Autoptimize / 2.5.1
Autoptimize v2.5.1
2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 All 107 releases
autoptimize / classes / autoptimizePartners.php

autoptimizePartners.php in Autoptimize 2.5.1, at classes/autoptimizePartners.php

146 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handles adding "more tools" tab in AO admin settings page which promotes (future) AO
4 * addons and/or affiliate services.
5 */
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit;
9 }
10
11 class autoptimizePartners
12 {
13 public function __construct()
14 {
15 $this->run();
16 }
17
18 public function run()
19 {
20 if ( $this->enabled() ) {
21 add_filter( 'autoptimize_filter_settingsscreen_tabs', array( $this, 'add_partner_tabs' ), 10, 1 );
22 }
23 add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
24 }
25
26 protected function enabled()
27 {
28 return apply_filters( 'autoptimize_filter_show_partner_tabs', true );
29 }
30
31 public function add_partner_tabs( $in )
32 {
33 $in = array_merge( $in, array(
34 'ao_partners' => __( 'Optimize More!', 'autoptimize' ),
35 ) );
36
37 return $in;
38 }
39
40 public function add_admin_menu()
41 {
42 if ( $this->enabled() ) {
43 add_submenu_page( null, 'AO partner', 'AO partner', 'manage_options', 'ao_partners', array( $this, 'ao_partners_page' ) );
44 }
45 }
46
47 protected function get_ao_partner_feed_markup()
48 {
49 $no_feed_text = __( 'Have a look at <a href="http://optimizingmatters.com/">optimizingmatters.com</a> for Autoptimize power-ups!', 'autoptimize' );
50 $output = '';
51 if ( apply_filters( 'autoptimize_settingsscreen_remotehttp', true ) ) {
52 $rss = fetch_feed( 'http://feeds.feedburner.com/OptimizingMattersDownloads' );
53 $maxitems = 0;
54
55 if ( ! is_wp_error( $rss ) ) {
56 $maxitems = $rss->get_item_quantity( 20 );
57 $rss_items = $rss->get_items( 0, $maxitems );
58 }
59
60 if ( 0 == $maxitems ) {
61 $output .= $no_feed_text;
62 } else {
63 $output .= '<ul>';
64 foreach ( $rss_items as $item ) {
65 $item_url = esc_url( $item->get_permalink() );
66 $enclosure = $item->get_enclosure();
67
68 $output .= '<li class="itemDetail">';
69 $output .= '<h3 class="itemTitle"><a href="' . $item_url . '" target="_blank">' . esc_html( $item->get_title() ) . '</a></h3>';
70
71 if ( $enclosure && ( false !== strpos( $enclosure->get_type(), 'image' ) ) ) {
72 $img_url = esc_url( $enclosure->get_link() );
73 $output .= '<div class="itemImage"><a href="' . $item_url . '" target="_blank"><img src="' . $img_url . '"></a></div>';
74 }
75
76 $output .= '<div class="itemDescription">' . wp_kses_post( $item->get_description() ) . '</div>';
77 $output .= '<div class="itemButtonRow"><div class="itemButton button-secondary"><a href="' . $item_url . '" target="_blank">' . __( 'More info', 'autoptimize' ) . '</a></div></div>';
78 $output .= '</li>';
79 }
80 $output .= '</ul>';
81 }
82 } else {
83 $output .= $no_feed_text;
84 }
85
86 return $output;
87 }
88
89 public function ao_partners_page()
90 {
91 ?>
92 <style>
93 .itemDetail {
94 background: #fff;
95 width: 250px;
96 min-height: 290px;
97 border: 1px solid #ccc;
98 float: left;
99 padding: 15px;
100 position: relative;
101 margin: 0 10px 10px 0;
102 }
103 .itemTitle {
104 margin-top:0px;
105 margin-bottom:10px;
106 }
107 .itemImage {
108 text-align: center;
109 }
110 .itemImage img {
111 max-width: 95%;
112 max-height: 150px;
113 }
114 .itemDescription {
115 margin-bottom:30px;
116 }
117 .itemButtonRow {
118 position: absolute;
119 bottom: 10px;
120 right: 10px;
121 width:100%;
122 }
123 .itemButton {
124 float:right;
125 }
126 .itemButton a {
127 text-decoration: none;
128 color: #555;
129 }
130 .itemButton a:hover {
131 text-decoration: none;
132 color: #23282d;
133 }
134 </style>
135 <div class="wrap">
136 <h1><?php _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
137 <?php echo autoptimizeConfig::ao_admin_tabs(); ?>
138 <?php echo '<h2>' . __( "These Autoptimize power-ups and related services will improve your site's performance even more!", 'autoptimize' ) . '</h2>'; ?>
139 <div>
140 <?php echo $this->get_ao_partner_feed_markup(); ?>
141 </div>
142 </div>
143 <?php
144 }
145 }
146