| 1 |
<?php |
| 2 |
/** |
| 3 |
* Try to get addons from the transient. |
| 4 |
* |
| 5 |
* @var object |
| 6 |
*/ |
| 7 |
$items = get_transient( 'wpas_addonsx' ); |
| 8 |
setlocale( LC_MONETARY, get_locale() ); |
| 9 |
|
| 10 |
if ( false === $items ) { |
| 11 |
|
| 12 |
$route = esc_url( 'http://getawesomesupport.com/edd-api/products/' ); |
| 13 |
$api_key = trim( 'd83df1849d3204ed6641faa92ed55eb2' ); |
| 14 |
$token = trim( '39e17c3737d608900e2f403b55dda68d' ); |
| 15 |
$pagesize = 50; |
| 16 |
$endpoint = add_query_arg( array( 'key' => $api_key, 'token' => $token, 'number' => $pagesize ), $route ); |
| 17 |
$response = wp_remote_get( $endpoint ); |
| 18 |
|
| 19 |
if ( 200 === wp_remote_retrieve_response_code( $response ) ) { |
| 20 |
|
| 21 |
$body = wp_remote_retrieve_body( $response ); |
| 22 |
$content = json_decode( $body ); |
| 23 |
|
| 24 |
if ( is_object( $content ) && isset( $content->products ) ) { |
| 25 |
set_transient( 'wpas_addonsx', $content->products, 60 * 60 * 24 ); // Cache for 24 hours |
| 26 |
$items = $content->products; |
| 27 |
} |
| 28 |
|
| 29 |
} |
| 30 |
} |
| 31 |
?> |
| 32 |
|
| 33 |
<style type="text/css"> |
| 34 |
.wpas-addon-all { |
| 35 |
padding-top: 40px; |
| 36 |
} |
| 37 |
.wpas-addon-item + .wpas-addon-item { |
| 38 |
margin-top: 40px; |
| 39 |
padding-top: 40px; |
| 40 |
border-top: 1px solid #ddd; |
| 41 |
} |
| 42 |
.wpas-addon-item .inside { |
| 43 |
padding-left: 30px; |
| 44 |
} |
| 45 |
.wpas-addon-item h3 { |
| 46 |
margin-top: 0px; |
| 47 |
padding-top: 0px; |
| 48 |
} |
| 49 |
.wpas-addon-img { |
| 50 |
box-shadow: 0px 0px 25px rgba(0,0,0,0.25); |
| 51 |
} |
| 52 |
.wpas-addon-item-pricing { |
| 53 |
background: white; |
| 54 |
padding: 5px 10px; |
| 55 |
border: 1px solid #ddd; |
| 56 |
border-radius: 3px; |
| 57 |
} |
| 58 |
.wpas-btn-group .button-secondary { |
| 59 |
cursor: default; |
| 60 |
} |
| 61 |
</style> |
| 62 |
|
| 63 |
<div class="wrap about-wrap"> |
| 64 |
<h1>Addons</h1> |
| 65 |
<div class="about-text">Even though Awesome Support has a lot of built-in features, it is impossible to make everyone happy. This is why we have lots of addons to help you tailor your support system.</div> |
| 66 |
|
| 67 |
<div class="changelog wpas-addon-all"> |
| 68 |
<?php |
| 69 |
if ( false === $items ): |
| 70 |
?><p>To check out all our addons please visit <a href="http://getawesomesupport.com/addons" target="_blank">http://getawesomesupport.com/addons</a></p><?php |
| 71 |
else: |
| 72 |
|
| 73 |
foreach ( $items as $key => $item ): |
| 74 |
|
| 75 |
/* Get the item price */ |
| 76 |
$price = false; |
| 77 |
|
| 78 |
/* This item has a fixed price */ |
| 79 |
if ( isset( $item->pricing->amount ) ) { |
| 80 |
$price = number_format( $item->pricing->amount, 0 ); |
| 81 |
} |
| 82 |
|
| 83 |
/* This item has variable pricing */ |
| 84 |
/* 'singlesite' object element covers most pricing items for awesome support. */ |
| 85 |
/* But some items like paid support starts at 2 sites. Note the use of curly */ |
| 86 |
/* brackets for those because the object element starts with a number. */ |
| 87 |
else { |
| 88 |
if ( isset( $item->pricing->singlesite ) ) { |
| 89 |
$price = number_format( $item->pricing->singlesite, 0 ); |
| 90 |
} elseif ( isset( $item->pricing->{'2sites'} ) ) { |
| 91 |
$price = number_format( $item->pricing->{'2sites'}, 0 ); |
| 92 |
} elseif ( isset( $item->pricing->{'singleserver'} ) ) { |
| 93 |
$price = number_format( $item->pricing->{'singleserver'}, 0 ); |
| 94 |
} elseif ( isset( $item->pricing->singlesiteupdatesonlynosupport ) ) { |
| 95 |
$price = number_format( $item->pricing->singlesiteupdatesonlynosupport, 0 ); |
| 96 |
} |
| 97 |
} ?> |
| 98 |
|
| 99 |
<div class="row wpas-addon-item" id="wpas-addon-item-<?php echo intval( $item->info->id ); ?>"> |
| 100 |
<div class="col-xs-12 col-sm-6 col-md-5 col-lg-5 wpas-addon-img-wrap"> |
| 101 |
<?php if ( !empty( $item->info->thumbnail ) ): ?><img class="wpas-addon-img" src="<?php echo esc_url( $item->info->thumbnail ); ?>"><?php endif; ?> |
| 102 |
</div> |
| 103 |
<div class="col-xs-12 col-sm-6 col-md-7 col-lg-7"> |
| 104 |
<div class="inside"> |
| 105 |
<h3><?php echo esc_attr( $item->info->title ); ?> <small class="wpas-addon-item-pricing">from <?php if ( false !== $price ): ?><strong>$<?php echo esc_html( $price ); ?></strong><?php endif; ?></small></h3> |
| 106 |
<p><?php if ( !empty( $item->info->excerpt ) ): echo wp_kses_post( wpautop( $item->info->excerpt ) ); endif; ?></p> |
| 107 |
<div class="wpas-btn-group"> |
| 108 |
<span class="button-secondary"><?php if ( false !== $price ): ?>$<?php echo esc_html( $price ); ?><?php endif; ?></span><a class="button-primary" href="<?php echo esc_url( $item->info->link ); ?>&utm_source=plugin&utm_medium=addon_page&utm_campaign=promote_addons" target="_blank">Details and Buy</a> |
| 109 |
</div> |
| 110 |
</div> |
| 111 |
</div> |
| 112 |
</div> |
| 113 |
<?php endforeach; |
| 114 |
|
| 115 |
endif; ?> |
| 116 |
</div> |
| 117 |
</div> |