| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; // Exit if accessed directly. |
| 5 |
} |
| 6 |
|
| 7 |
?> |
| 8 |
<div class="wrap"> |
| 9 |
<h2><?php _e( 'Front End PM - Extensions', 'front-end-pm' ); ?></h2> |
| 10 |
|
| 11 |
<?php |
| 12 |
$extensions = get_transient( 'fep_extensions' ); |
| 13 |
|
| 14 |
if ( false === $extensions ) { |
| 15 |
$response = wp_remote_get( 'https://www.shamimsplugins.com/wp-json/api/v1/extensions/front-end-pm', array('timeout' => 15, 'sslverify' => false, 'decompress' => false) ); |
| 16 |
|
| 17 |
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) { |
| 18 |
echo '<div class="error">Error loading extensions. Please reload the page again!</div>'; |
| 19 |
return false; |
| 20 |
} |
| 21 |
$extensions = json_decode( wp_remote_retrieve_body( $response ) ); |
| 22 |
|
| 23 |
set_transient( 'fep_extensions', $extensions, 12 * HOUR_IN_SECONDS ); |
| 24 |
} |
| 25 |
|
| 26 |
if ( count( $extensions ) ) { |
| 27 |
foreach ($extensions as $slug => $extension ) { |
| 28 |
?> |
| 29 |
|
| 30 |
<div class="fep-extensions"> |
| 31 |
<div class="thumbnail"> |
| 32 |
<a href="<?php echo add_query_arg(array('utm_campaign'=>'admin','utm_source'=>'extensions','utm_medium'=>'thumbnail'),$extension->url); ?>" target="_blank"> |
| 33 |
<img src="<?php echo $extension->thumbnail_url ? $extension->thumbnail_url : FEP_PLUGIN_URL . 'assets/images/default-extensions-img.jpg'; ?>" alt="<?php echo esc_attr( $extension->title ); ?>" /> |
| 34 |
</a> |
| 35 |
</div> |
| 36 |
|
| 37 |
<div class="details"> |
| 38 |
<h3 class="title"> |
| 39 |
<a href="<?php echo add_query_arg(array('utm_campaign'=>'admin','utm_source'=>'extensions','utm_medium'=>'title'),$extension->url); ?>" target="_blank"><?php echo $extension->title; ?></a> |
| 40 |
</h3> |
| 41 |
|
| 42 |
<div class="text"><?php echo $extension->excerpt ? fep_get_the_excerpt( 50, $extension->excerpt ) : ''; ?></div> |
| 43 |
</div> |
| 44 |
|
| 45 |
<div class="links"> |
| 46 |
<?php if ( function_exists( str_replace( '-', '_', $slug ) . '_activate' ) ) { ?> |
| 47 |
<a class="button button-disabled" href="<?php echo add_query_arg(array('utm_campaign'=>'admin','utm_source'=>'extensions','utm_medium'=>'installed'),$extension->url); ?>" target="_blank"><?php _e( 'Installed', 'front-end-pm' ); ?></a> |
| 48 |
<?php } else { ?> |
| 49 |
<a class="button" href="<?php echo add_query_arg(array('utm_campaign'=>'admin','utm_source'=>'extensions','utm_medium'=>'view_details'),$extension->url); ?>" target="_blank"><?php _e( 'View Details', 'front-end-pm' ); ?></a> |
| 50 |
<?php } ?> |
| 51 |
</div> |
| 52 |
</div> |
| 53 |
|
| 54 |
<?php |
| 55 |
} |
| 56 |
} else { |
| 57 |
echo '<div class="error">Error loading extensions. Please reload the page again!</div>'; |
| 58 |
} |
| 59 |
?> |
| 60 |
|
| 61 |
<style type="text/css"> |
| 62 |
.fep-extensions { |
| 63 |
width: 220px; |
| 64 |
float: left; |
| 65 |
margin: 10px; |
| 66 |
border: 1px solid #E6E6E6; |
| 67 |
} |
| 68 |
|
| 69 |
.fep-extensions .thumbnail img { |
| 70 |
max-width: 220px; |
| 71 |
max-height: 140px; |
| 72 |
} |
| 73 |
|
| 74 |
.fep-extensions .details { |
| 75 |
padding: 6px 10px 10px; |
| 76 |
min-height: 10px; |
| 77 |
background: #fff; |
| 78 |
} |
| 79 |
|
| 80 |
.fep-extensions .details h3.title { |
| 81 |
margin: 5px 0 10px; |
| 82 |
padding: 0; |
| 83 |
} |
| 84 |
|
| 85 |
.fep-extensions .details h3.title a { |
| 86 |
text-decoration: none; |
| 87 |
color: #111; |
| 88 |
} |
| 89 |
|
| 90 |
.fep-extensions .links { |
| 91 |
padding: 10px; |
| 92 |
background: #F5F5F5; |
| 93 |
border-top: 1px solid #E6E6E6; |
| 94 |
} |
| 95 |
|
| 96 |
.fep-extensions .links a.button.disabled { |
| 97 |
background: #eee; |
| 98 |
} |
| 99 |
</style> |
| 100 |
|
| 101 |
</div> |
| 102 |
|