PluginProbe
Autoptimize / 3.1.11
Autoptimize v3.1.11
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 / autoptimizeProTab.php

autoptimizeProTab.php in Autoptimize 3.1.11, at classes/autoptimizeProTab.php

131 lines 5.4 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 autoptimizeProTab
12 {
13 /**
14 * Random title string.
15 *
16 * @var string
17 */
18 protected $rnd_title = null;
19
20 public function __construct()
21 {
22 // alternate between tab title every 5 minutes.
23 if ( floor( date( "i", time() ) / 5 ) %2 === 0 ) {
24 $this->rnd_title = esc_html__( 'Page Cache', 'autoptimize' );
25 } else {
26 $this->rnd_title = esc_html__( 'Pro Boosters', 'autoptimize' );
27 }
28
29 $this->run();
30 }
31
32 public function run()
33 {
34 if ( $this->enabled() ) {
35 add_filter( 'autoptimize_filter_settingsscreen_tabs', array( $this, 'add_pro_tabs' ), 10, 1 );
36 }
37 if ( is_multisite() && is_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network() ) {
38 add_action( 'network_admin_menu', array( $this, 'add_admin_menu' ) );
39 } else {
40 add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
41 }
42 }
43
44 protected function enabled()
45 {
46 return apply_filters( 'autoptimize_filter_show_partner_tabs', true );
47 }
48
49 public function add_pro_tabs( $in )
50 {
51 $in = array_merge(
52 $in,
53 array(
54 'ao_protab' => '&#x1F680; ' . $this->rnd_title
55 )
56 );
57
58 return $in;
59 }
60
61 public function add_admin_menu()
62 {
63 if ( $this->enabled() ) {
64 add_submenu_page( '', 'AO pro', 'AO pro', 'manage_options', 'ao_protab', array( $this, 'ao_pro_page' ) );
65 }
66 }
67
68 public function ao_pro_page()
69 {
70 ?>
71 <style>
72 .ao_settings_div {background: white;border: 1px solid #ccc;padding: 1px 15px;margin: 15px 10px 10px 0;font-size: 120% !important; padding-bottom:20px;}
73 .ao_settings_div p {font-size:110%;}
74
75 #aoprocontainer{width:100%;overflow:hidden;}
76 #aoprotxt{width:68%;float:left;}
77 #aoprobuy { background:#ba4102;text-align:center;border-radius:25px; }
78 #aoprobuy p {margin:.25em 1em}
79 #aoprobuy p#cta {font-size:150%;}
80 #aoproimg {width:28%;float:right;}
81
82 @media (max-width:699px) {
83 #aoproimg{display:none;}
84 #aoprotxt{width:100% !important;}
85 #aoprobuy{font-size:70%;}
86 }
87 </style>
88 <script>document.title = "Autoptimize: <?php echo $this->rnd_title ?> " + document.title;</script>
89 <div class="wrap">
90 <h1><?php apply_filters( 'autoptimize_filter_settings_is_pro', false ) ? esc_html_e( 'Autoptimize Pro Settings', 'autoptimize' ) : esc_html_e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
91 <?php
92 echo autoptimizeConfig::ao_admin_tabs();
93 $aopro_explanation = '';
94
95 $_transient = 'aopro_explain';
96 $_explain_html = 'https://misc.optimizingmatters.com/aopro_explain.html?ao_ver=';
97
98 // get the HTML with the explanation of what AOPro is.
99 if ( apply_filters( 'autoptimize_settingsscreen_remotehttp', true ) ) {
100 $aopro_explanation = get_transient( $_transient );
101 if ( empty( $aopro_explanation ) ) {
102 $ccss_expl_resp = wp_remote_get( $_explain_html . AUTOPTIMIZE_PLUGIN_VERSION );
103 if ( ! is_wp_error( $ccss_expl_resp ) ) {
104 if ( '200' == wp_remote_retrieve_response_code( $ccss_expl_resp ) ) {
105 $aopro_explanation = wp_kses_post( wp_remote_retrieve_body( $ccss_expl_resp ) );
106 set_transient( $_transient, $aopro_explanation, WEEK_IN_SECONDS );
107 }
108 }
109 }
110 }
111
112 // placeholder text in case HTML is empty.
113 if ( empty( $aopro_explanation ) ) {
114 // translators: h2, strong but also 2 links.
115 $aopro_explanation = sprintf( esc_html__( '%1$sAdd more power to Autoptimize with Pro!%2$s%3$sAs a user of Autoptimize you understand %5$sthe importance of having a fast site%6$s. Autoptimize Pro is a premium Power-Up extending AO by adding %5$simage optimization, CDN, automatic critical CSS rules generation and page caching but also providing extra “booster” options%6$s, all in one handy subscription to make your site even faster!%4$s%3$sHave a look at %7$shttps://autoptimize.com/pro/%8$s for more info or %9$sclick here to buy now%10$s!%4$s', 'autoptimize' ), '<h2>', '</h2>', '<p>', '</p>', '<strong>', '</strong>', '<a href="https://autoptimize.com/pro/" target="_blank">', '</a>', '<a href="https://checkout.freemius.com/mode/dialog/plugin/10906/plan/18508/?currency=auto" target="_blank">', '</a>' );
116 } else {
117 // we were able to fetch the explenation, so add the JS to show correct language.
118 $aopro_explanation .= "<script>jQuery('.ao_i18n').hide();d=document;lang=d.getElementsByTagName('html')[0].getAttribute('lang').substring(0,2);if(d.getElementById(lang)!= null){jQuery('#'+lang).show();}else{jQuery('#default').show();}</script>";
119 }
120 ?>
121 <div class="ao_settings_div">
122 <?php
123 // and echo it.
124 echo $aopro_explanation;
125 ?>
126 </div>
127 </div>
128 <?php
129 }
130 }
131