Initial commit

This commit is contained in:
2020-01-04 20:41:09 +01:00
commit 150d0179fc
1328 changed files with 186900 additions and 0 deletions

View File

@@ -0,0 +1,752 @@
<?php
/**
* ColorMag Admin Class.
*
* @author ThemeGrill
* @package ColorMag
* @since 1.1.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'ColorMag_Admin' ) ) :
/**
* ColorMag_Admin Class.
*/
class ColorMag_Admin {
/**
* Constructor.
*/
public function __construct() {
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_action( 'wp_loaded', array( __CLASS__, 'hide_notices' ) );
add_action( 'wp_loaded', array( $this, 'admin_notice' ) );
add_action( 'wp_ajax_import_button', array( $this, 'colormag_ajax_import_button_handler' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'colormag_ajax_enqueue_scripts' ) );
}
/**
* Localize array for import button AJAX request.
*/
public function colormag_ajax_enqueue_scripts() {
wp_enqueue_script( 'updates' );
wp_enqueue_script( 'colormag-plugin-install-helper', get_template_directory_uri() . '/inc/admin/js/plugin-handle.js', array( 'jquery' ), 1, true );
wp_localize_script(
'colormag-plugin-install-helper', 'colormag_plugin_helper',
array(
'activating' => esc_html__( 'Activating ', 'colormag' ),
)
);
$translation_array = array(
'uri' => esc_url( admin_url( '/themes.php?page=demo-importer&browse=all&colormag-hide-notice=welcome' ) ),
'btn_text' => esc_html__( 'Processing...', 'colormag' ),
'nonce' => wp_create_nonce( 'colormag_demo_import_nonce' ),
);
wp_localize_script( 'colormag-plugin-install-helper', 'colormag_redirect_demo_page', $translation_array );
}
/**
* Handle the AJAX process while import or get started button clicked.
*/
public function colormag_ajax_import_button_handler() {
check_ajax_referer( 'colormag_demo_import_nonce', 'security' );
$state = '';
if ( is_plugin_active( 'themegrill-demo-importer/themegrill-demo-importer.php' ) ) {
$state = 'activated';
} elseif ( file_exists( WP_PLUGIN_DIR . '/themegrill-demo-importer/themegrill-demo-importer.php' ) ) {
$state = 'installed';
}
if ( 'activated' === $state ) {
$response['redirect'] = admin_url( '/themes.php?page=demo-importer&browse=all&colormag-hide-notice=welcome' );
} elseif ( 'installed' === $state ) {
$response['redirect'] = admin_url( '/themes.php?page=demo-importer&browse=all&colormag-hide-notice=welcome' );
if ( current_user_can( 'activate_plugin' ) ) {
$result = activate_plugin( 'themegrill-demo-importer/themegrill-demo-importer.php' );
if ( is_wp_error( $result ) ) {
$response['errorCode'] = $result->get_error_code();
$response['errorMessage'] = $result->get_error_message();
}
}
} else {
wp_enqueue_script( 'plugin-install' );
$response['redirect'] = admin_url( '/themes.php?page=demo-importer&browse=all&colormag-hide-notice=welcome' );
/**
* Install Plugin.
*/
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
$api = plugins_api( 'plugin_information', array(
'slug' => sanitize_key( wp_unslash( 'themegrill-demo-importer' ) ),
'fields' => array(
'sections' => false,
),
) );
$skin = new WP_Ajax_Upgrader_Skin();
$upgrader = new Plugin_Upgrader( $skin );
$result = $upgrader->install( $api->download_link );
if ( $result ) {
$response['installed'] = 'succeed';
} else {
$response['installed'] = 'failed';
}
// Activate plugin.
if ( current_user_can( 'activate_plugin' ) ) {
$result = activate_plugin( 'themegrill-demo-importer/themegrill-demo-importer.php' );
if ( is_wp_error( $result ) ) {
$response['errorCode'] = $result->get_error_code();
$response['errorMessage'] = $result->get_error_message();
}
}
}
wp_send_json( $response );
exit();
}
/**
* Add admin menu.
*/
public function admin_menu() {
$theme = wp_get_theme( get_template() );
$page = add_theme_page( esc_html__( 'About', 'colormag' ) . ' ' . $theme->display( 'Name' ), esc_html__( 'About', 'colormag' ) . ' ' . $theme->display( 'Name' ), 'activate_plugins', 'colormag-sitelibrary', array(
$this,
'sitelibrary_screen',
) );
add_action( 'admin_print_styles-' . $page, array( $this, 'enqueue_styles' ) );
}
/**
* Enqueue styles.
*/
public function enqueue_styles() {
global $colormag_version;
wp_enqueue_style( 'colormag-welcome', get_template_directory_uri() . '/css/admin/welcome.css', array(), $colormag_version );
}
/**
* Add admin notice.
*/
public function admin_notice() {
global $colormag_version, $pagenow;
wp_enqueue_style( 'colormag-message', get_template_directory_uri() . '/css/admin/message.css', array(), $colormag_version );
// Let's bail on theme activation.
$notice_nag = get_option( 'colormag_admin_notice_welcome' );
if ( ! $notice_nag ) {
add_action( 'admin_notices', array( $this, 'welcome_notice' ) );
}
}
/**
* Hide a notice if the GET variable is set.
*/
public static function hide_notices() {
if ( isset( $_GET['colormag-hide-notice'] ) && isset( $_GET['_colormag_notice_nonce'] ) ) {
if ( ! wp_verify_nonce( $_GET['_colormag_notice_nonce'], 'colormag_hide_notices_nonce' ) ) {
wp_die( __( 'Action failed. Please refresh the page and retry.', 'colormag' ) );
}
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __( 'Cheatin&#8217; huh?', 'colormag' ) );
}
$hide_notice = sanitize_text_field( $_GET['colormag-hide-notice'] );
update_option( 'colormag_admin_notice_' . $hide_notice, 1 );
// Hide.
if ( 'welcome' === $_GET['colormag-hide-notice'] ) {
update_option( 'colormag_admin_notice_' . $hide_notice, 1 );
} else { // Show.
delete_option( 'colormag_admin_notice_' . $hide_notice );
}
}
}
/**
* Show welcome notice.
*/
public function welcome_notice() {
?>
<div id="message" class="updated colormag-message">
<a class="colormag-message-close notice-dismiss" href="<?php echo esc_url( wp_nonce_url( remove_query_arg( array( 'activated' ), add_query_arg( 'colormag-hide-notice', 'welcome' ) ), 'colormag_hide_notices_nonce', '_colormag_notice_nonce' ) ); ?>">
<?php esc_html_e( 'Dismiss', 'colormag' ); ?>
</a>
<div class="colormag-message-wrapper">
<div class="colormag-logo">
<img src="<?php echo get_template_directory_uri(); ?>/img/colormag-getting-started-logo.png" alt="<?php esc_html_e( 'ColorMag', 'colormag' ); ?>" /><?php // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped, Squiz.PHP.EmbeddedPhp.SpacingBeforeClose ?>
</div>
<p>
<?php printf( esc_html__( 'Welcome! Thank you for choosing ColorMag! To fully take advantage of the best our theme can offer please make sure you visit our %swelcome page%s.', 'colormag' ), '<a href="' . esc_url( admin_url( 'themes.php?page=colormag-welcome' ) ) . '">', '</a>' ); ?>
<span class="plugin-install-notice"><?php esc_html_e( 'Clicking the button below will install and activate the ThemeGrill demo importer plugin.', 'colormag' ); ?></span>
</p>
<div class="submit">
<a class="btn-get-started button button-primary button-hero" href="#" data-name="" data-slug="" aria-label="<?php esc_html_e( 'Get started with ColorMag', 'colormag' ); ?>"><?php esc_html_e( 'Get started with ColorMag', 'colormag' ); ?></a>
</div>
</div>
</div>
<?php
}
/**
* Intro text/links shown to all about pages.
*
* @access private
*/
private function intro() {
global $colormag_version;
$theme = wp_get_theme( get_template() );
?>
<div class="header">
<div class="info">
<h1>
<?php esc_html_e( 'About', 'colormag' ); ?>
<?php echo $theme->display( 'Name' ); ?>
<span class="version-container"><?php echo esc_html( $colormag_version ); ?></span>
</h1>
<div class="tg-about-text about-text">
<?php echo $theme->display( 'Description' ); ?>
</div>
<a href="https://themegrill.com/" target="_blank" class="wp-badge tg-welcome-logo"></a>
</div>
</div>
<p class="colormag-actions">
<a href="<?php echo esc_url( 'https://themegrill.com/themes/colormag/?utm_source=colormag-about&utm_medium=theme-info-link&utm_campaign=theme-info' ); ?>" class="button button-secondary" target="_blank"><?php esc_html_e( 'Theme Info', 'colormag' ); ?></a>
<a href="<?php echo esc_url( apply_filters( 'colormag_pro_theme_url', 'https://demo.themegrill.com/colormag/' ) ); ?>" class="button button-secondary docs" target="_blank"><?php esc_html_e( 'View Demo', 'colormag' ); ?></a>
<a href="<?php echo esc_url( apply_filters( 'colormag_pro_theme_url', 'https://themegrill.com/themes/colormag/?utm_source=colormag-about&utm_medium=view-pro-link&utm_campaign=view-pro#free-vs-pro' ) ); ?>" class="button button-primary docs" target="_blank"><?php esc_html_e( 'View PRO version', 'colormag' ); ?></a>
<a href="<?php echo esc_url( apply_filters( 'colormag_pro_theme_url', 'https://wordpress.org/support/theme/colormag/reviews/?filter=5' ) ); ?>" class="button button-secondary docs" target="_blank"><?php esc_html_e( 'Rate this theme', 'colormag' ); ?></a>
</p>
<h2 class="nav-tab-wrapper">
<a class="nav-tab <?php if ( empty( $_GET['tab'] ) && $_GET['page'] == 'colormag-sitelibrary' ) {
echo 'nav-tab-active';
} ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'colormag-sitelibrary' ), 'themes.php' ) ) ); ?>">
<?php esc_html_e( 'Site Library', 'colormag' ); ?>
</a>
<a class="nav-tab <?php if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'welcome' ) {
echo 'nav-tab-active';
} ?>" href="<?php echo esc_url( admin_url( add_query_arg( array(
'page' => 'colormag-sitelibrary',
'tab' => 'welcome',
), 'themes.php' ) ) ); ?>">
<?php esc_html_e( 'Getting Started', 'colormag' ); ?>
</a>
<a class="nav-tab <?php if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'supported_plugins' ) {
echo 'nav-tab-active';
} ?>" href="<?php echo esc_url( admin_url( add_query_arg( array(
'page' => 'colormag-sitelibrary',
'tab' => 'supported_plugins',
), 'themes.php' ) ) ); ?>">
<?php esc_html_e( 'Recommended Plugins', 'colormag' ); ?>
</a>
<a class="nav-tab <?php if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'free_vs_pro' ) {
echo 'nav-tab-active';
} ?>" href="<?php echo esc_url( admin_url( add_query_arg( array(
'page' => 'colormag-sitelibrary',
'tab' => 'free_vs_pro',
), 'themes.php' ) ) ); ?>">
<?php esc_html_e( 'Free Vs Pro', 'colormag' ); ?>
</a>
<a class="nav-tab <?php if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'changelog' ) {
echo 'nav-tab-active';
} ?>" href="<?php echo esc_url( admin_url( add_query_arg( array(
'page' => 'colormag-sitelibrary',
'tab' => 'changelog',
), 'themes.php' ) ) ); ?>">
<?php esc_html_e( 'Changelog', 'colormag' ); ?>
</a>
</h2>
<?php
}
/**
* Site library screen page.
*/
public function sitelibrary_screen() {
$current_tab = empty( $_GET['tab'] ) ? 'library' : sanitize_title( $_GET['tab'] );
// Look for a {$current_tab}_screen method.
if ( is_callable( array( $this, $current_tab . '_screen' ) ) ) {
return $this->{$current_tab . '_screen'}();
}
// Fallback to about screen.
return $this->sitelibrary_display_screen();
}
/**
* Render site library.
*/
public function sitelibrary_display_screen() {
?>
<div class="wrap about-wrap">
<?php
$this->intro();
?>
<div class="plugin-install-notice">
<?php esc_html_e( 'Clicking the "Import" button in any of the demos below will install and activate the ThemeGrill demo importer plugin.', 'colormag' ); ?>
</div>
<?php
// Display site library.
echo ColorMag_Site_Library::colormag_site_library_page_content();
?>
</div>
<?php
}
/**
* Welcome screen page.
*/
public function welcome_screen() {
$this->about_screen();
}
/**
* Output the about screen.
*/
public function about_screen() {
$theme = wp_get_theme( get_template() );
?>
<div class="wrap about-wrap">
<?php $this->intro(); ?>
<div class="changelog point-releases">
<div class="under-the-hood two-col">
<div class="col">
<h3><?php esc_html_e( 'Import Demo', 'colormag' ); ?></h3>
<p><?php esc_html_e( 'Needs ThemeGrill Demo Importer plugin.', 'colormag' ) ?></p>
<div class="submit">
<a class="btn-get-started button button-primary button-hero" href="#" data-name="" data-slug="" aria-label="<?php esc_html_e( 'Import', 'colormag' ); ?>"><?php esc_html_e( 'Import', 'colormag' ); ?></a>
</div>
</div>
<div class="col">
<h3><?php esc_html_e( 'Theme Customizer', 'colormag' ); ?></h3>
<p><?php esc_html_e( 'All Theme Options are available via Customize screen.', 'colormag' ) ?></p>
<p>
<a href="<?php echo admin_url( 'customize.php' ); ?>" class="button button-secondary"><?php esc_html_e( 'Customize', 'colormag' ); ?></a>
</p>
</div>
<div class="col">
<h3><?php esc_html_e( 'Documentation', 'colormag' ); ?></h3>
<p><?php esc_html_e( 'Please view our documentation page to setup the theme.', 'colormag' ) ?></p>
<p>
<a href="<?php echo esc_url( 'https://docs.themegrill.com/colormag/?utm_source=colormag-about&utm_medium=documentation-link&utm_campaign=documentation' ); ?>" class="button button-secondary" target="_blank"><?php esc_html_e( 'Documentation', 'colormag' ); ?></a>
</p>
</div>
<div class="col">
<h3><?php esc_html_e( 'Got theme support question?', 'colormag' ); ?></h3>
<p><?php esc_html_e( 'Please put it in our dedicated support forum.', 'colormag' ) ?></p>
<p>
<a href="<?php echo esc_url( 'https://themegrill.com/support-forum/?utm_source=colormag-about&utm_medium=support-forum-link&utm_campaign=support-forum' ); ?>" class="button button-secondary" target="_blank"><?php esc_html_e( 'Support', 'colormag' ); ?></a>
</p>
</div>
<div class="col">
<h3><?php esc_html_e( 'Need more features?', 'colormag' ); ?></h3>
<p><?php esc_html_e( 'Upgrade to PRO version for more exciting features.', 'colormag' ) ?></p>
<p>
<a href="<?php echo esc_url( 'https://themegrill.com/themes/colormag/?utm_source=colormag-about&utm_medium=view-pro-link&utm_campaign=view-pro#free-vs-pro' ); ?>" class="button button-secondary" target="_blank"><?php esc_html_e( 'View PRO version', 'colormag' ); ?></a>
</p>
</div>
<div class="col">
<h3><?php esc_html_e( 'Got sales related question?', 'colormag' ); ?></h3>
<p><?php esc_html_e( 'Please send it via our sales contact page.', 'colormag' ) ?></p>
<p>
<a href="<?php echo esc_url( 'https://themegrill.com/contact/?utm_source=colormag-about&utm_medium=contact-page-link&utm_campaign=contact-page' ); ?>" class="button button-secondary" target="_blank"><?php esc_html_e( 'Contact Page', 'colormag' ); ?></a>
</p>
</div>
<div class="col">
<h3>
<?php
esc_html_e( 'Translate', 'colormag' );
echo ' ' . $theme->display( 'Name' );
?>
</h3>
<p><?php esc_html_e( 'Click below to translate this theme into your own language.', 'colormag' ) ?></p>
<p>
<a href="<?php echo esc_url( 'https://translate.wordpress.org/projects/wp-themes/colormag' ); ?>" class="button button-secondary" target="_blank">
<?php
esc_html_e( 'Translate', 'colormag' );
echo ' ' . $theme->display( 'Name' );
?>
</a>
</p>
</div>
</div>
</div>
<div class="return-to-dashboard colormag">
<?php if ( current_user_can( 'update_core' ) && isset( $_GET['updated'] ) ) : ?>
<a href="<?php echo esc_url( self_admin_url( 'update-core.php' ) ); ?>">
<?php is_multisite() ? esc_html_e( 'Return to Updates', 'colormag' ) : esc_html_e( 'Return to Dashboard &rarr; Updates', 'colormag' ); ?>
</a> |
<?php endif; ?>
<a href="<?php echo esc_url( self_admin_url() ); ?>"><?php is_blog_admin() ? esc_html_e( 'Go to Dashboard &rarr; Home', 'colormag' ) : esc_html_e( 'Go to Dashboard', 'colormag' ); ?></a>
</div>
</div>
<?php
}
/**
* Output the changelog screen.
*/
public function changelog_screen() {
global $wp_filesystem;
?>
<div class="wrap about-wrap">
<?php $this->intro(); ?>
<p class="about-description"><?php esc_html_e( 'View changelog below:', 'colormag' ); ?></p>
<?php
$changelog_file = apply_filters( 'colormag_changelog_file', get_template_directory() . '/readme.txt' );
// Check if the changelog file exists and is readable.
if ( $changelog_file && is_readable( $changelog_file ) ) {
WP_Filesystem();
$changelog = $wp_filesystem->get_contents( $changelog_file );
$changelog_list = $this->parse_changelog( $changelog );
echo wp_kses_post( $changelog_list );
}
?>
</div>
<?php
}
/**
* Parse changelog from readme file.
*
* @param string $content
*
* @return string
*/
private function parse_changelog( $content ) {
$matches = null;
$regexp = '~==\s*Changelog\s*==(.*)($)~Uis';
$changelog = '';
if ( preg_match( $regexp, $content, $matches ) ) {
$changes = explode( '\r\n', trim( $matches[1] ) );
$changelog .= '<pre class="changelog">';
foreach ( $changes as $index => $line ) {
$changelog .= wp_kses_post( preg_replace( '~(=\s*Version\s*(\d+(?:\.\d+)+)\s*=|$)~Uis', '<span class="title">${1}</span>', $line ) );
}
$changelog .= '</pre>';
}
return wp_kses_post( $changelog );
}
/**
* Output the supported plugins screen.
*/
public function supported_plugins_screen() {
?>
<div class="wrap about-wrap">
<?php $this->intro(); ?>
<p class="about-description"><?php esc_html_e( 'This theme recommends following plugins:', 'colormag' ); ?></p>
<ol>
<li>
<a href="<?php echo esc_url( 'https://wordpress.org/plugins/social-icons/' ); ?>" target="_blank"><?php esc_html_e( 'Social Icons', 'colormag' ); ?></a>
<?php esc_html_e( ' by ThemeGrill', 'colormag' ); ?>
</li>
<li>
<a href="<?php echo esc_url( 'https://wordpress.org/plugins/easy-social-sharing/' ); ?>" target="_blank"><?php esc_html_e( 'Easy Social Sharing', 'colormag' ); ?></a>
<?php esc_html_e( ' by ThemeGrill', 'colormag' ); ?>
</li>
<li>
<a href="<?php echo esc_url( 'https://wordpress.org/plugins/everest-forms/' ); ?>" target="_blank"><?php esc_html_e( 'Everest Forms Easy Contact Form and Form Builder', 'colormag' ); ?></a>
<?php esc_html_e( ' by WPEverest', 'colormag' ); ?></li>
<li>
<a href="<?php echo esc_url( 'https://wordpress.org/plugins/wp-pagenavi/' ); ?>" target="_blank"><?php esc_html_e( 'WP-PageNavi', 'colormag' ); ?></a>
</li>
<li>
<a href="<?php echo esc_url( 'https://wordpress.org/plugins/woocommerce/' ); ?>" target="_blank"><?php esc_html_e( 'WooCommerce', 'colormag' ); ?></a>
</li>
<li>
<a href="<?php echo esc_url( 'https://wordpress.org/plugins/polylang/' ); ?>" target="_blank"><?php esc_html_e( 'Polylang', 'colormag' ); ?></a>
<?php esc_html_e( 'Fully Compatible in Pro Version', 'colormag' ); ?>
</li>
<li>
<a href="<?php echo esc_url( 'https://wpml.org/' ); ?>" target="_blank"><?php esc_html_e( 'WPML', 'colormag' ); ?></a>
<?php esc_html_e( 'Fully Compatible in Pro Version', 'colormag' ); ?>
</li>
</ol>
</div>
<?php
}
/**
* Output the free vs pro screen.
*/
public function free_vs_pro_screen() {
?>
<div class="wrap about-wrap">
<?php $this->intro(); ?>
<p class="about-description"><?php esc_html_e( 'Upgrade to PRO version for more exciting features.', 'colormag' ); ?></p>
<table>
<thead>
<tr>
<th class="table-feature-title"><h3><?php esc_html_e( 'Features', 'colormag' ); ?></h3></th>
<th><h3><?php esc_html_e( 'ColorMag', 'colormag' ); ?></h3></th>
<th><h3><?php esc_html_e( 'ColorMag Pro', 'colormag' ); ?></h3></th>
</tr>
</thead>
<tbody>
<tr>
<td><h3><?php esc_html_e( 'Support', 'colormag' ); ?></h3></td>
<td><?php esc_html_e( 'Forum', 'colormag' ); ?></td>
<td><?php esc_html_e( 'Forum + Emails/Support Ticket', 'colormag' ); ?></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Color Options', 'colormag' ); ?></h3></td>
<td><?php esc_html_e( '1', 'colormag' ); ?></td>
<td><?php esc_html_e( '22', 'colormag' ); ?></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Primary color option', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Font Size Options', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Google Fonts Options', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><?php esc_html_e( '600+', 'colormag' ); ?></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Custom Widgets', 'colormag' ); ?></h3></td>
<td><?php esc_html_e( '7', 'colormag' ); ?></td>
<td><?php esc_html_e( '16', 'colormag' ); ?></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Social Icons', 'colormag' ); ?></h3></td>
<td><?php esc_html_e( '6', 'colormag' ); ?></td>
<td><?php esc_html_e( '18 + 6 Custom', 'colormag' ); ?></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Social Sharing', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Custom Menu', 'colormag' ); ?></h3></td>
<td><?php esc_html_e( '1', 'colormag' ); ?></td>
<td><?php esc_html_e( '2', 'colormag' ); ?></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Footer Sidebar', 'colormag' ); ?></h3></td>
<td><?php esc_html_e( '4', 'colormag' ); ?></td>
<td><?php esc_html_e( '7', 'colormag' ); ?></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Site Layout Option', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Options in Breaking News', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Unique Post System', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Change Read More Text', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Related Posts', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Author Biography', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Author Biography with Social Icons', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Footer Copyright Editor', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: 125x125 Advertisement', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: 300x250 Advertisement', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: 728x90 Advertisement', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: Featured Category Slider', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: Highlighted Posts', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: Random Posts Widget', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: Tabbed Widget', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: Videos', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: Featured Posts (Style 1)', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: Featured Posts (Style 2)', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: Featured Posts (Style 3)', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: Featured Posts (Style 4)', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: Featured Posts (Style 5)', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: Featured Posts (Style 6)', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'TG: Featured Posts (Style 7)', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Category Color Options', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'WPML Compatible', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'Polylang Compatible', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-no"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td><h3><?php esc_html_e( 'WooCommerce Compatible', 'colormag' ); ?></h3></td>
<td><span class="dashicons dashicons-yes"></span></td>
<td><span class="dashicons dashicons-yes"></span></td>
</tr>
<tr>
<td></td>
<td></td>
<td class="btn-wrapper">
<a href="<?php echo esc_url( apply_filters( 'colormag_pro_theme_url', 'https://themegrill.com/themes/colormag/?utm_source=colormag-free-vs-pro-table&utm_medium=view-pro-link&utm_campaign=view-pro#free-vs-pro' ) ); ?>" class="button button-secondary docs" target="_blank"><?php esc_html_e( 'View Pro', 'colormag' ); ?></a>
</td>
</tr>
</tbody>
</table>
</div>
<?php
}
}
endif;
return new ColorMag_Admin();

View File

@@ -0,0 +1,152 @@
<?php
/**
* ColorMag_Site_Library class to fetch the
* theme demo configs from GitHub repo.
*
* @package ColorMag
*/
/**
* Class responsible for showcasing the theme demo
* in ThemeGrill Demo page.
*
* Class ColorMag_Site_Library
*/
class ColorMag_Site_Library {
/**
* Constructor function.
*
* ColorMag_Site_Library constructor.
*/
public function __construct() {
$this->colormag_site_library_demo_packages();
}
/**
* Demo config packages
*/
public function colormag_site_library_demo_packages() {
$this->colormag_site_library_get_demos();
}
/**
* Get the demo packages.
*
* @return array|mixed|null|object|string
*/
public static function colormag_site_library_get_demos() {
$template = 'colormag';
$packages = get_transient( 'colormag_site_library_theme_' . $template );
if ( false === $packages ) {
$raw_packages = wp_safe_remote_get( "https://raw.githubusercontent.com/themegrill/themegrill-demo-pack/master/configs/{$template}.json" );
if ( ! is_wp_error( $raw_packages ) ) {
$packages = json_decode( wp_remote_retrieve_body( $raw_packages ) );
if ( $packages ) {
set_transient( 'colormag_site_library_theme_' . $template, $packages, WEEK_IN_SECONDS );
}
}
}
return $packages;
}
/**
* Returns the content value filtered to display
* the demos of available themes via ThemeGrill Demo Pack
* config file.
*
* @return string The filtered post content.
*/
public static function colormag_site_library_page_content() {
$template = 'colormag';
$output = '';
$demo_packages = self::colormag_site_library_get_demos();
if ( isset( $demo_packages ) ) :
$output .= '<div id="wpbody" class="tg-demo-showcase">';
$output .= '<div id="wpbody-content">';
$output .= '<div class="wrap">';
$output .= '<div class="wp-filter hide-if-no-js">';
// Renders the theme lists.
$output .= '<h2 class="screen-reader-text hide-if-no-js">' . esc_html__( 'Themes list', 'colormag' ) . '</h2><!-- .screen-reader-text.hide-if-no-js -->';
$output .= '<div class="theme-browser content-filterable">';
$output .= '<div class="themes row wp-clearfix">';
foreach ( $demo_packages->demos as $demo_package_demo => $demo_package_data ) {
$output .= '<div class="theme col-md-4 col-sm-6 col-lg-4 ' . $demo_package_demo . '">';
// Inner wrapper.
$output .= '<div class="theme-inner">';
// Displays the theme demo screenshot.
$output .= '<div class="screenshot">';
$output .= '<img src="' . esc_url( 'https://raw.githubusercontent.com/themegrill/themegrill-demo-pack/master/resources/' . $template . '/' . $demo_package_demo ) . '/screenshot.jpg" alt="' . esc_attr( $demo_package_demo ) . '">';
$output .= '</div><!-- .screenshot -->';
// Displays the pro tag.
if ( isset( $demo_package_data->isPro ) ) {
$output .= '<span class="premium-demo-banner">';
$output .= esc_html__( 'Pro', 'colormag' );
$output .= '</span><!-- .premium-demo-banner -->';
}
// Wrap details on div.
$output .= '<div class="theme-details">';
// Theme id container details.
$output .= '<div class="theme-id-container">';
// Display the theme name.
$output .= '<h2 class="theme-name" id="' . $demo_package_demo . '-name">';
$output .= $demo_package_data->title;
$output .= '</h2><!-- .theme-name -->';
// Display the theme action buttons.
$output .= '<div class="theme-actions">';
// Import button.
if ( ! isset( $demo_package_data->isPro ) ) {
$output .= '<a class="btn-get-started button button-primary button-small preview install-demo-preview" href="#" data-name="themegrill-demo-importer" data-slug="themegrill-demo-importer" aria-label="' . esc_html__( 'Get started with ColorMag', 'colormag' ) . '">' . esc_html__( 'Import', 'colormag' ) . '</a>';
}
// Displays the preview now button.
$output .= '<a class="button button-small preview install-demo-preview" href="' . esc_url( $demo_package_data->preview ) . '" target="_blank">';
$output .= esc_html__( 'Preview', 'colormag' );
$output .= '</a>';
// Displays the buy now button.
if ( isset( $demo_package_data->isPro ) ) {
$output .= '<a class="button button-small button-primary purchase-now" href="' . $demo_packages->homepage . '" target="_blank">';
$output .= esc_html__( 'Buy Now', 'colormag' );
$output .= '</a><!-- .button.button-primary.purchase-now -->';
}
$output .= '</div><!-- .theme-actions -->';
$output .= '</div><!-- .theme-id-container -->';
$output .= '</div><!-- .theme-details -->';
$output .= '</div><!-- .theme-inner -->';
$output .= '</div><!-- .theme -->';
}
$output .= '</div><!-- .themes.wp-clearfix -->';
$output .= '</div><!-- .theme-browser.content-filterable -->';
$output .= '</div><!-- .wp-filter.hide-if-no-js -->';
$output .= '</div><!-- .wrap -->';
$output .= '</div><!-- #wpbody-content -->';
$output .= '</div><!-- #wpbody -->';
endif;
return $output;
}
}
new ColorMag_Site_Library();

View File

@@ -0,0 +1,185 @@
<?php
/**
* ColorMag Theme Review Notice Class.
*
* @author ThemeGrill
* @package ColorMag
* @since 1.3.9
*/
// Exit if directly accessed.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class to display the theme review notice for this theme after certain period.
*
* Class ColorMag_Theme_Review_Notice
*/
class ColorMag_Theme_Review_Notice {
/**
* Constructor function to include the required functionality for the class.
*
* ColorMag_Theme_Review_Notice constructor.
*/
public function __construct() {
add_action( 'after_setup_theme', array( $this, 'colormag_theme_rating_notice' ) );
add_action( 'switch_theme', array( $this, 'colormag_theme_rating_notice_data_remove' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'colormag_theme_rating_notice_enqueue' ) );
}
/**
* Set the required option value as needed for theme review notice.
*/
public function colormag_theme_rating_notice() {
// Set the installed time in `colormag_theme_installed_time` option table.
$option = get_option( 'colormag_theme_installed_time' );
if ( ! $option ) {
update_option( 'colormag_theme_installed_time', time() );
}
add_action( 'admin_notices', array( $this, 'colormag_theme_review_notice' ), 0 );
add_action( 'admin_init', array( $this, 'colormag_ignore_theme_review_notice' ), 0 );
add_action( 'admin_init', array( $this, 'colormag_ignore_theme_review_notice_partially' ), 0 );
}
/**
* Display the theme review notice.
*/
public function colormag_theme_review_notice() {
global $current_user;
$user_id = $current_user->ID;
$current_user = wp_get_current_user();
$ignored_notice = get_user_meta( $user_id, 'colormag_ignore_theme_review_notice', true );
$ignored_notice_partially = get_user_meta( $user_id, 'nag_colormag_ignore_theme_review_notice_partially', true );
/**
* Return from notice display if:
*
* 1. The theme installed is less than 15 day ago.
* 2. If the user has ignored the message partially for 15 day.
* 3. Dismiss always if clicked on 'I Already Did' button.
*/
if ( ( get_option( 'colormag_theme_installed_time' ) > strtotime( '-15 day' ) ) || ( $ignored_notice_partially > strtotime( '-15 day' ) ) || ( $ignored_notice ) ) {
return;
}
?>
<div class="notice updated theme-review-notice" style="position:relative;">
<p>
<?php
printf(
/* Translators: %1$s current user display name. */
esc_html__(
'Howdy, %1$s! It seems that you have been using this theme for more than 15 days. We hope you are happy with everything that the theme has to offer. If you can spare a minute, please help us by leaving a 5-star review on WordPress.org. By spreading the love, we can continue to develop new amazing features in the future, for free!', 'colormag'
),
'<strong>' . esc_html( $current_user->display_name ) . '</strong>'
);
?>
</p>
<div class="links">
<a href="https://wordpress.org/support/theme/colormag/reviews/?filter=5#new-post" class="btn button-primary" target="_blank">
<span class="dashicons dashicons-thumbs-up"></span>
<span><?php esc_html_e( 'Sure', 'colormag' ); ?></span>
</a>
<a href="?nag_colormag_ignore_theme_review_notice_partially=0" class="btn button-secondary">
<span class="dashicons dashicons-calendar"></span>
<span><?php esc_html_e( 'Maybe later', 'colormag' ); ?></span>
</a>
<a href="?nag_colormag_ignore_theme_review_notice=0" class="btn button-secondary">
<span class="dashicons dashicons-smiley"></span>
<span><?php esc_html_e( 'I already did', 'colormag' ); ?></span>
</a>
<a href="<?php echo esc_url( 'https://themegrill.com/support-forum/forum/colormag-free/' ); ?>" class="btn button-secondary" target="_blank">
<span class="dashicons dashicons-edit"></span>
<span><?php esc_html_e( 'Got theme support question?', 'colormag' ); ?></span>
</a>
</div>
<a class="notice-dismiss" style="text-decoration:none;" href="?nag_colormag_ignore_theme_review_notice_partially=0"></a>
</div>
<?php
}
/**
* Function to remove the theme review notice permanently as requested by the user.
*/
public function colormag_ignore_theme_review_notice() {
global $current_user;
$user_id = $current_user->ID;
/* If user clicks to ignore the notice, add that to their user meta */
if ( isset( $_GET['nag_colormag_ignore_theme_review_notice'] ) && '0' == $_GET['nag_colormag_ignore_theme_review_notice'] ) {
add_user_meta( $user_id, 'colormag_ignore_theme_review_notice', 'true', true );
}
}
/**
* Function to remove the theme review notice partially as requested by the user.
*/
public function colormag_ignore_theme_review_notice_partially() {
global $current_user;
$user_id = $current_user->ID;
/* If user clicks to ignore the notice, add that to their user meta */
if ( isset( $_GET['nag_colormag_ignore_theme_review_notice_partially'] ) && '0' == $_GET['nag_colormag_ignore_theme_review_notice_partially'] ) {
update_user_meta( $user_id, 'nag_colormag_ignore_theme_review_notice_partially', time() );
}
}
/**
* Remove the data set after the theme has been switched to other theme.
*/
public function colormag_theme_rating_notice_data_remove() {
global $current_user;
$user_id = $current_user->ID;
$theme_installed_time = get_option( 'colormag_theme_installed_time' );
$ignored_notice = get_user_meta( $user_id, 'colormag_ignore_theme_review_notice', true );
$ignored_notice_partially = get_user_meta( $user_id, 'nag_colormag_ignore_theme_review_notice_partially', true );
// Delete options data.
if ( $theme_installed_time ) {
delete_option( 'colormag_theme_installed_time' );
}
// Delete permanent notice remove data.
if ( $ignored_notice ) {
delete_user_meta( $user_id, 'colormag_ignore_theme_review_notice' );
}
// Delete partial notice remove data.
if ( $ignored_notice_partially ) {
delete_user_meta( $user_id, 'nag_colormag_ignore_theme_review_notice_partially' );
}
}
/**
* Enqueue the required CSS file for theme review notice on admin page.
*/
public function colormag_theme_rating_notice_enqueue() {
wp_enqueue_style( 'colormag-theme-review-notice', get_template_directory_uri() . '/css/admin/theme-review-notice.css' );
}
}
new ColorMag_Theme_Review_Notice();

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 908 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -0,0 +1,62 @@
/**
* Remove activate button and replace with activation in progress button.
*
* @package ColorMag
*/
/**
* Import button
*/
jQuery( document ).ready( function ( $ ) {
$( '.btn-get-started' ).click( function ( e ) {
e.preventDefault();
var extra_uri, redirect_uri, state, dismiss_nonce;
// Show About > import button while processing.
if ( jQuery( this ).parents( '.theme-actions' ).length ) {
jQuery( this ).parents( '.theme-actions' ).css( 'opacity', '1' );
}
// Show updating gif icon.
jQuery( this ).addClass( 'updating-message' );
// Change button text.
jQuery( this ).text( colormag_redirect_demo_page.btn_text );
// Assign `TG demo importer` plugin state for processing from PHP.
if ( $( this ).hasClass( 'tdi-activated' ) ) { // Installed and activated.
state = 'activated';
} else if ( $( this ).hasClass( 'tdi-installed' ) ) { // Installed but not activated.
state = 'installed';
} else { // Not installed.
state = '';
}
var data = {
action : 'import_button',
security : colormag_redirect_demo_page.nonce,
state : state
};
$.ajax( {
type : "POST",
url : ajaxurl, // URL to "wp-admin/admin-ajax.php"
data : data,
success : function ( response ) {
extra_uri = '';
if ( jQuery( '.colormag-message-close' ).length ) {
dismiss_nonce = jQuery( '.colormag-message-close' ).attr( 'href' ).split( '_colormag_notice_nonce=' )[1];
extra_uri = '&_colormag_notice_nonce=' + dismiss_nonce;
}
redirect_uri = response.redirect + extra_uri;
window.location.href = redirect_uri;
},
error : function ( xhr, ajaxOptions, thrownError ) {
console.log( thrownError );
}
} );
} );
} );

View File

@@ -0,0 +1,109 @@
<?php
/**
* This fucntion is responsible for rendering metaboxes in single post area
*
* @package ThemeGrill
* @subpackage ColorMag
* @since ColorMag 1.0
*/
add_action( 'add_meta_boxes', 'colormag_add_custom_box' );
/**
* Add Meta Boxes.
*/
function colormag_add_custom_box() {
// Adding layout meta box for page
add_meta_box( 'page-layout', __( 'Select Layout', 'colormag' ), 'colormag_page_layout', 'page', 'side', 'default' );
// Adding layout meta box for
add_meta_box( 'page-layout', __( 'Select Layout', 'colormag' ), 'colormag_page_layout', 'post', 'side', 'default' );
}
/****************************************************************************************/
global $page_layout;
$page_layout = array(
'default-layout' => array(
'id' => 'colormag_page_layout',
'value' => 'default_layout',
'label' => __( 'Default Layout', 'colormag' )
),
'right-sidebar' => array(
'id' => 'colormag_page_layout',
'value' => 'right_sidebar',
'label' => __( 'Right Sidebar', 'colormag' )
),
'left-sidebar' => array(
'id' => 'colormag_page_layout',
'value' => 'left_sidebar',
'label' => __( 'Left Sidebar', 'colormag' )
),
'no-sidebar-full-width' => array(
'id' => 'colormag_page_layout',
'value' => 'no_sidebar_full_width',
'label' => __( 'No Sidebar Full Width', 'colormag' )
),
'no-sidebar-content-centered' => array(
'id' => 'colormag_page_layout',
'value' => 'no_sidebar_content_centered',
'label' => __( 'No Sidebar Content Centered', 'colormag' )
)
);
/****************************************************************************************/
/**
* Displays metabox to for select layout option
*/
function colormag_page_layout() {
global $page_layout, $post;
// Use nonce for verification
wp_nonce_field( basename( __FILE__ ), 'custom_meta_box_nonce' );
foreach ($page_layout as $field) {
$layout_meta = get_post_meta( $post->ID, $field['id'], true );
if( empty( $layout_meta ) ) { $layout_meta = 'default_layout'; }
?>
<input class="post-format" type="radio" name="<?php echo $field['id']; ?>" value="<?php echo $field['value']; ?>" <?php checked( $field['value'], $layout_meta ); ?>/>
<label class="post-format-icon"><?php echo $field['label']; ?></label><br/>
<?php
}
}
/****************************************************************************************/
add_action('pre_post_update', 'colormag_save_custom_meta');
/**
* save the custom metabox data
* @hooked to pre_post_update hook
*/
function colormag_save_custom_meta( $post_id ) {
global $page_layout, $post;
// Verify the nonce before proceeding.
if ( !isset( $_POST[ 'custom_meta_box_nonce' ] ) || !wp_verify_nonce( $_POST[ 'custom_meta_box_nonce' ], basename( __FILE__ ) ) )
return;
// Stop WP from clearing custom fields on autosave
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE)
return;
if ('page' == $_POST['post_type']) {
if (!current_user_can( 'edit_page', $post_id ) )
return $post_id;
}
elseif (!current_user_can( 'edit_post', $post_id ) ) {
return $post_id;
}
foreach ($page_layout as $field) {
//Execute this saving function
$old = get_post_meta( $post_id, $field['id'], true);
$new = $_POST[$field['id']];
if ($new && $new != $old) {
update_post_meta($post_id, $field['id'], $new);
} elseif ('' == $new && $old) {
delete_post_meta($post_id, $field['id'], $old);
}
} // end foreach
}