????
| Current Path : /home2/morganrand/www/wp-content/themes/wanderfuls-2/framework/addons/ |
| Current File : /home2/morganrand/www/wp-content/themes/wanderfuls-2/framework/addons/changelog.php |
<?php
/**
* Displays changelog in the admin
*
* @package Wanderfuls WordPress theme
* @subpackage Framework
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Start Class
class TB_Theme_Changelog {
private $transient;
/**
* Start things up
*
* @since 2.0.0
*/
public function __construct() {
// Add changelog admin panel
add_action( 'admin_menu', array( $this, 'add_page' ), 100 );
// Custom styles for changelog
add_action( 'admin_print_styles-'. TB_ADMIN_PANEL_HOOK_PREFIX . '-changelog', array( $this,'css' ), 40 );
// Delete transient
if ( isset( $_GET['tb_refresh_changelog'] ) ) {
delete_transient( 'tb_theme_changelog' );
}
// Get transient
else {
$this->transient = get_transient( 'tb_theme_changelog' );
}
}
/**
* Add sub menu page
*
* @since 2.0.0
*/
public function add_page() {
add_submenu_page(
TB_THEME_PANEL_SLUG,
__( 'Changelog', 'tb' ),
__( 'Changelog', 'tb' ),
'administrator',
TB_THEME_PANEL_SLUG .'-changelog',
array( $this, 'create_admin_page' )
);
}
/**
* Display admin page
*
* @since 2.0.0
*/
public function create_admin_page() { ?>
<div class="wrap">
<h1><?php _e( 'Theme Changelog', 'tb' ); ?></h1>
<p><a href="<?php echo esc_url( admin_url( 'admin.php?page=tb-panel-changelog&tb_refresh_changelog=true' ) ); ?>" title="<?php _e( 'Refresh', 'tb' ); ?>" class="button button-secondary"><?php _e( 'Refresh', 'tb' ); ?></a></p>
<div class="tb-theme-changelog clr">
<?php
// Display transient
if ( $this->transient ) {
echo $this->transient;
}
// Get changelog from remote url
else {
$response = wp_safe_remote_get( 'http://tbplorer-themes.com/total/remote-changelog/' );
if ( is_array( $response ) ) {
$header = $response['headers'];
if ( ! empty( $response['body'] ) ) {
echo $response['body'];
set_transient( 'tb_theme_changelog', $response['body'], 24 * HOUR_IN_SECONDS );
}
} else {
'Sorry could not retrieve the changelog, our servers may be down. Please try again later. Sorry for the inconvenience!';
}
} ?>
<p><a href="http://techbooth.in/" class="button button-primary" target="_blank"><?php _e( 'Full Changelog', 'tb' ); ?></a></p>
</div><!-- .tb-theme-changelog -->
</div><!-- .wrap -->
<?php }
/**
* Admin css
*
* @since 2.0.0
*/
public function css() { ?>
<style type="text/css">
.tb-changelog-entry { margin-bottom: 30px; background: #fff; padding: 30px; }
.tb-changelog-entry li:first-child { padding-top: 0; }
.tb-changelog-entry li:last-child { padding-bottom: 0; border: 0; }
.tb-changelog-entry li { padding: 10px 0; margin: 0 !important; border-bottom: 1px solid #eee; }
.wrap .tb-changelog-entry h2 { margin: -30px -30px 30px; border-bottom: 1px solid #ededed; padding: 15px 30px; font-size: 18px; font-weight: normal; color: #777; }
.tb-theme-changelog .span-blue,
.tb-theme-changelog .span-green,
.tb-theme-changelog .span-yellow,
.tb-theme-changelog .span-red {
display: inline-block;
moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
font-size: 10px;
font-weight: bold;
font-weight: 500;
padding: 3px 0;
width: 60px;
text-align: center;
text-transform: uppercase;
color: #fff;
display: inline-block;
line-height: 1em;
margin-right: 10px;
}
.tb-theme-changelog .span-green { background: #77cc33; }
.tb-theme-changelog .span-blue { background: #0099cc; }
.tb-theme-changelog .span-yellow { background: #ffcc33; }
.tb-theme-changelog .span-red { background: #DD5858; }
.tb-version-number { color: #000; font-weight: bold; }
</style>
<?php }
}
new TB_Theme_Changelog();