PluginProbe
Autoptimize / 3.1.7
Autoptimize v3.1.7
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 3.1.7, at classes/autoptimizePartners.php

154 lines 4.8 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 if ( is_multisite() && is_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network() ) {
24 add_action( 'network_admin_menu', array( $this, 'add_admin_menu' ) );
25 } else {
26 add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
27 }
28 }
29
30 protected function enabled()
31 {
32 return apply_filters( 'autoptimize_filter_show_partner_tabs', true );
33 }
34
35 public function add_partner_tabs( $in )
36 {
37 $in = array_merge(
38 $in,
39 array(
40 'ao_partners' => __( 'Optimize More!', 'autoptimize' ),
41 )
42 );
43
44 return $in;
45 }
46
47 public function add_admin_menu()
48 {
49 if ( $this->enabled() ) {
50 add_submenu_page( '', 'AO partner', 'AO partner', 'manage_options', 'ao_partners', array( $this, 'ao_partners_page' ) );
51 }
52 }
53
54 protected function get_ao_partner_feed_markup()
55 {
56 $no_feed_text = __( 'Have a look at <a href="http://optimizingmatters.com/">optimizingmatters.com</a> for Autoptimize power-ups!', 'autoptimize' );
57 $output = '';
58 if ( apply_filters( 'autoptimize_settingsscreen_remotehttp', true ) ) {
59 $rss = fetch_feed( 'http://feeds.feedburner.com/OptimizingMattersDownloads' );
60 $maxitems = 0;
61
62 if ( ! is_wp_error( $rss ) ) {
63 $maxitems = $rss->get_item_quantity( 20 );
64 $rss_items = $rss->get_items( 0, $maxitems );
65 }
66
67 if ( 0 == $maxitems ) {
68 $output .= $no_feed_text;
69 } else {
70 $output .= '<ul>';
71 foreach ( $rss_items as $item ) {
72 $item_url = esc_url( $item->get_permalink() );
73 $enclosure = $item->get_enclosure();
74
75 $output .= '<li class="itemDetail">';
76 $output .= '<h3 class="itemTitle"><a href="' . $item_url . '" target="_blank">' . esc_html( $item->get_title() ) . '</a></h3>';
77
78 if ( $enclosure && ( false !== strpos( $enclosure->get_type(), 'image' ) ) ) {
79 $img_url = esc_url( $enclosure->get_link() );
80 $output .= '<div class="itemImage"><a href="' . $item_url . '" target="_blank"><img src="' . $img_url . '"></a></div>';
81 }
82
83 $output .= '<div class="itemDescription">' . wp_kses_post( $item->get_description() ) . '</div>';
84 $output .= '<div class="itemButtonRow"><div class="itemButton button-secondary"><a href="' . $item_url . '" target="_blank">' . __( 'More info', 'autoptimize' ) . '</a></div></div>';
85 $output .= '</li>';
86 }
87 $output .= '</ul>';
88 }
89 } else {
90 $output .= $no_feed_text;
91 }
92
93 return $output;
94 }
95
96 public function ao_partners_page()
97 {
98 ?>
99 <style>
100 .itemDetail {
101 background: #fff;
102 width: 250px;
103 min-height: 290px;
104 border: 1px solid #ccc;
105 float: left;
106 padding: 15px;
107 position: relative;
108 margin: 0 10px 10px 0;
109 }
110 .itemTitle {
111 margin-top:0px;
112 margin-bottom:10px;
113 }
114 .itemImage {
115 text-align: center;
116 }
117 .itemImage img {
118 max-width: 95%;
119 max-height: 150px;
120 }
121 .itemDescription {
122 margin-bottom:30px;
123 }
124 .itemButtonRow {
125 position: absolute;
126 bottom: 10px;
127 right: 10px;
128 width:100%;
129 }
130 .itemButton {
131 float:right;
132 }
133 .itemButton a {
134 text-decoration: none;
135 color: #555;
136 }
137 .itemButton a:hover {
138 text-decoration: none;
139 color: #23282d;
140 }
141 </style>
142 <script>document.title = "Autoptimize: <?php _e( 'Optimize More!', 'autoptimize' ); ?> " + document.title;</script>
143 <div class="wrap">
144 <h1><?php apply_filters( 'autoptimize_filter_settings_is_pro', false ) ? _e( 'Autoptimize Pro Settings', 'autoptimize' ) : _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
145 <?php echo autoptimizeConfig::ao_admin_tabs(); ?>
146 <?php echo '<h2>' . __( "These Autoptimize power-ups and related services will improve your site's performance even more!", 'autoptimize' ) . '</h2>'; ?>
147 <div>
148 <?php echo $this->get_ao_partner_feed_markup(); ?>
149 </div>
150 </div>
151 <?php
152 }
153 }
154