Skip to content

Commit

Permalink
minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed May 28, 2020
1 parent 21d14b1 commit e79c34f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
48 changes: 37 additions & 11 deletions inc/AdminPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,46 @@ public function details_tab( $current_tab ) {
<div class="inside">
<div style="display:grid;grid-template-columns:repeat(auto-fit, minmax(30em, 1fr));grid-gap:1px;background:#aaa;">
<div class="carbon-offset-pending" style="padding:2em;background:#fff;">
<h2 style="line-height:3;text-align:center;"><?php esc_html_e( 'Pending Carbon Footprint', 'carbon-offset' ); ?></h2>
<p class="description"><?php esc_html_e( 'Each visit and transaction on your website generates carbon emissions. In this section you can see the impact these have, and offset your site\'s emissions to the planet.', 'carbon-offset' ); ?></p>
<p style="font-size:4em;font-weight:200;text-align:center;line-height:1;"><?php echo esc_html( round( $carbon_data['carbon_pending'] / 1000, 1 ) ); ?>kg</p>
<h2 style="line-height:3;text-align:center;">
<?php esc_html_e( 'Pending Carbon Footprint', 'carbon-offset' ); ?>
</h2>
<p class="description">
<?php esc_html_e( 'Each visit and transaction on your website generates carbon emissions. In this section you can see the impact these have, and offset your site\'s emissions to the planet.', 'carbon-offset' ); ?>
</p>
<?php
$styles = 'font-size:4em;font-weight:200;text-align:center;line-height:1;';
if ( 0 >= $carbon_data['carbon_pending'] ) {
$styles .= 'color:#46B450;';
} elseif ( 10000 <= $carbon_data['carbon_pending'] ) {
$styles .= 'color:#dc3232;';
}
?>
<p style="<?php echo esc_attr( $styles ); ?>">
<?php echo esc_html( round( $carbon_data['carbon_pending'] / 1000, 1 ) ); ?>kg
</p>
<p style="font-size:1.5em;font-weight:200;text-align:center;">(<?php echo (float) $carbon_data['carbon_pending']; ?>grams)</p>
<?php do_action( 'carbon_offset_admin_page_pending_inside' ); ?>
</div>
<div class="carbon-offset-complete" style="padding:2em;background:#fff;">
<h2 style="line-height:3;text-align:center;"><?php esc_html_e( 'Carbon Footprint already offset', 'carbon-offset' ); ?></h2>
<?php if ( 0 < $carbon_data['carbon_offset'] ) : ?>
<p class="description"><?php esc_html_e( 'In this section you can see the carbon you have already offset. Future purchases will add up to this number.', 'carbon-offset' ); ?></p>
<?php else : ?>
<p class="description"><?php esc_html_e( 'Once you purchase a carbon offset, the weight of that carbon will be shown here.', 'carbon-offset' ); ?></p>
<?php endif; ?>
<p style="font-size:4em;font-weight:200;text-align:center;"><?php echo (float) round( $carbon_data['carbon_offset'] ) / 1000; ?>kg</p>
<h2 style="line-height:3;text-align:center;">
<?php esc_html_e( 'Carbon Footprint already offset', 'carbon-offset' ); ?>
</h2>
<p class="description">
<?php if ( 0 < $carbon_data['carbon_offset'] ) : ?>
<?php esc_html_e( 'In this section you can see the carbon you have already offset. Future purchases will add up to this number.', 'carbon-offset' ); ?>
<?php else : ?>
<?php esc_html_e( 'Once you purchase a carbon offset, the weight of that carbon will be shown here.', 'carbon-offset' ); ?>
<?php endif; ?>
</p>
<?php
$styles = 'font-size:4em;font-weight:200;text-align:center;line-height:1;';
if ( $carbon_data['carbon_offset'] >= $carbon_data['carbon_pending'] ) {
$styles .= 'color:#46B450;';
}
?>
<p style="<?php echo esc_attr( $styles ); ?>">
<?php echo (float) round( $carbon_data['carbon_offset'] ) / 1000; ?>kg
</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -295,7 +321,7 @@ public function settings_fields( $values ) {

<label id="footprint-label">
<strong>
<?php esc_html_e( 'Carbon Footprint Per Page Load (fallback value)', 'carbon-offset' ); ?>
<?php esc_html_e( 'Carbon Footprint Per Page Load (fallback value, in grams)', 'carbon-offset' ); ?>
</strong>
</label>
<p id="footprint-desciption" class="description" style="max-width: 50em;">
Expand Down
5 changes: 4 additions & 1 deletion inc/PaymentAPICloverly.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ private function the_transaction_html( $weight ) {
<a class="button" href="<?php echo esc_url( $body->pretty_url ); ?>" target="_blank" rel="nofollow">
<?php esc_html_e( 'View Receipt', 'carbon-offset' ); ?>
</a>
<button class="button" onclick="location.reload();">
<?php esc_html_e( 'Refresh Page', 'carbon-offset' ); ?>
</button>
</p>
</div>
<?php
Expand Down Expand Up @@ -345,7 +348,7 @@ public function admin_page_pending_inside() {
<?php add_action( 'admin_footer', [ $this, 'the_script' ] ); ?>
<div style="text-align:center;">
<label>
<p><?php esc_html_e( 'How many Kg should we offset?', 'carbon-offset' ); ?></p>
<p><?php esc_html_e( 'How many Kg should we offset? (All transactions are one-time).', 'carbon-offset' ); ?></p>
<input id="carbon-footeprint-offset-kg" type="number" value="<?php echo (float) round( $this->get_pending_weight() ) / 1000; ?>"/>
</label>
<button class="button" id="carbon-footprint-cloverly-estimate"><?php esc_html_e( 'Estimate Cost', 'carbon-offset' ); ?></button>
Expand Down
2 changes: 1 addition & 1 deletion inc/WebsiteCarbon.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function get_carbon_data() {
$cache = get_transient( 'carbon_offset_' . md5( $url ) );

// Cache was found, return it.
if ( false !== $cache ) {
if ( $cache ) {
return $cache;
}

Expand Down

0 comments on commit e79c34f

Please sign in to comment.