| 1 |
<?php |
| 2 |
/** |
| 3 |
* Render key panel. |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* Function that renders key panel. |
| 8 |
* |
| 9 |
* @param string $key API Key. |
| 10 |
* @param string $status API Key status. |
| 11 |
* @param string $status_msg Status message. |
| 12 |
* @param string $message Message. |
| 13 |
* @param string $color Color to highlight message in. |
| 14 |
*/ |
| 15 |
function ao_ccss_render_key( $key, $status, $status_msg, $message, $color ) { |
| 16 |
if ( defined( 'AO_PRO_VERSION' ) && has_filter( 'autoptimize_filter_ccss_key' ) ) { |
| 17 |
?> |
| 18 |
<input type="hidden" id="autoptimize_ccss_key" name="autoptimize_ccss_key" value=""> |
| 19 |
<?php |
| 20 |
return; |
| 21 |
} |
| 22 |
|
| 23 |
if ( defined( 'AUTOPTIMIZE_CRITICALCSS_API_KEY' ) ) { |
| 24 |
$key = __( 'API key provided by your host/ WordPress administrator, no need to enter anything here. In case of problems with the API key, contact your host/ WordPress administrator.', 'autoptimize' ); |
| 25 |
} else if ( has_filter( 'autoptimize_filter_ccss_key' ) ) { |
| 26 |
$key = __( 'API Key provided by a filter, no need to enter anything here.', 'autoptimize' ); |
| 27 |
} |
| 28 |
|
| 29 |
?> |
| 30 |
<ul id="key-panel"> |
| 31 |
<li class="itemDetail"> |
| 32 |
<h2 class="itemTitle fleft"><?php _e( 'API Key', 'autoptimize' ); ?>: <span style="color:<?php echo $color; ?>;"><?php echo $status_msg; ?></span></h2> |
| 33 |
<button type="button" class="toggle-btn"> |
| 34 |
<?php if ( 'valid' != $status ) { ?> |
| 35 |
<span class="toggle-indicator dashicons dashicons-arrow-up"></span> |
| 36 |
<?php } else { ?> |
| 37 |
<span class="toggle-indicator dashicons dashicons-arrow-up dashicons-arrow-down"></span> |
| 38 |
<?php } ?> |
| 39 |
</button> |
| 40 |
<?php if ( 'valid' != $status ) { ?> |
| 41 |
<div class="collapsible"> |
| 42 |
<?php } else { ?> |
| 43 |
<div class="collapsible hidden"> |
| 44 |
<?php } ?> |
| 45 |
<?php if ( 'valid' != $status ) { ?> |
| 46 |
<div style="clear:both;padding:2px 10px;border-left:solid;border-left-width:5px;border-left-color:<?php echo $color; ?>;background-color:white;"> |
| 47 |
<p><?php echo $message; ?></p> |
| 48 |
</div> |
| 49 |
<?php } ?> |
| 50 |
<table id="key" class="form-table"> |
| 51 |
<tr> |
| 52 |
<th scope="row"> |
| 53 |
<?php _e( 'Your API Key', 'autoptimize' ); ?> |
| 54 |
</th> |
| 55 |
<td> |
| 56 |
<textarea id="autoptimize_ccss_key" name="autoptimize_ccss_key" rows='3' style="width:100%;" placeholder="<?php _e( 'Please enter your criticalcss.com API key here.', 'autoptimize' ); ?>"><?php echo trim( esc_textarea( $key ) ); ?></textarea> |
| 57 |
<p class="notes"> |
| 58 |
<?php _e( 'Enter your <a href="https://criticalcss.com/account/api-keys?aff=1" target="_blank">criticalcss.com</a> API key above. The key is revalidated every time a new job is sent to it.<br />To obtain your API key, go to <a href="https://criticalcss.com/account/api-keys?aff=1" target="_blank">criticalcss.com</a> > Account > API Keys.<br />Requests to generate a critical CSS via the API are priced at £5 per domain per month.<br /><strong>Not sure yet? With the <a href="https://criticalcss.com/faq/?aff=1#trial" target="_blank">30 day money back guarantee</a>, you have nothing to lose!</strong>', 'autoptimize' ); ?> |
| 59 |
</p> |
| 60 |
</td> |
| 61 |
</tr> |
| 62 |
</table> |
| 63 |
</div> |
| 64 |
</li> |
| 65 |
</ul> |
| 66 |
<?php |
| 67 |
} |
| 68 |
|