first commit
This commit is contained in:
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
/**
|
||||
* Init admin page actions : Welcome, help page
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'HU_admin_page' ) ) :
|
||||
class HU_admin_page {
|
||||
static $instance;
|
||||
public $support_url;
|
||||
|
||||
function __construct () {
|
||||
self::$instance =& $this;
|
||||
//build the support url
|
||||
//build the support url
|
||||
$this -> support_url = HU_IS_PRO ? esc_url( sprintf( '%ssupport' , 'presscustomizr.com/' ) ) : esc_url('wordpress.org/support/theme/hueman');
|
||||
//fix #wpfooter absolute positioning in the welcome and about pages
|
||||
add_action( 'admin_print_styles' , array( $this, 'hu_fix_wp_footer_link_style') );
|
||||
|
||||
//add welcome page in menu
|
||||
add_action( 'admin_menu' , array( $this , 'hu_add_welcome_page' ));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract changelog of latest version from readme.txt file
|
||||
*
|
||||
*/
|
||||
function hu_print_changelog() {
|
||||
if( ! file_exists(HU_BASE."readme.txt") ) {
|
||||
return;
|
||||
}
|
||||
if( ! is_readable(HU_BASE."readme.txt") ) {
|
||||
echo '<p>The changelog in readme.txt is not readable.</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
$html = '';
|
||||
$stylelines = explode("\n", implode('', file(HU_BASE."readme.txt")));
|
||||
$read = false;
|
||||
$is_title = false;
|
||||
|
||||
foreach ($stylelines as $line) {
|
||||
$is_title = 0 === strpos($line, '= ');
|
||||
|
||||
//we start reading after current version title
|
||||
if ( 0 === strpos($line, '= '.HUEMAN_VER) ) {
|
||||
$read = true;
|
||||
}
|
||||
|
||||
if ( ! $read )
|
||||
continue;
|
||||
|
||||
if ( $is_title ) {
|
||||
$html .= sprintf( '<strong>%1$s</strong><br/>', esc_attr( $line ) );
|
||||
} else {
|
||||
$html .= sprintf( '<i>%1$s</i><br/>', esc_attr( $line ) );
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="hueman-changelog" class="changelog">
|
||||
<h3><?php printf( __( 'Changelog' , 'hueman' ) , HUEMAN_VER ); ?></h3>
|
||||
<p><?php echo $html ?></p>
|
||||
<p><strong><?php printf('<a href="%1$s" title="%2$s" target="_blank" rel="noopener noreferrer">%2$s %3$s</a>',
|
||||
HU_WEBSITE . "/category/hueman-releases/",
|
||||
__( "Read the latest release notes" , "hueman" ),
|
||||
is_rtl() ? '«' : '»'
|
||||
); ?></strong></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Inspired by Easy Digital Download plugin by Pippin Williamson
|
||||
* @since 3.2.1
|
||||
*/
|
||||
function hu_config_infos() {
|
||||
global $wpdb;
|
||||
//get WP_Theme
|
||||
$theme_data = wp_get_theme();
|
||||
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
||||
$parent_theme = $theme_data->Template;
|
||||
if ( ! empty( $parent_theme ) ) {
|
||||
$parent_theme_data = wp_get_theme( $parent_theme );
|
||||
$parent_theme = $parent_theme_data->Name . ' ' . $parent_theme_data->Version;
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="hu-config-info">
|
||||
<h3><?php _e( 'System Information', 'hueman' ); ?></h3>
|
||||
<h4 style="text-align: left"><?php _e( 'Please include the following information when posting support requests' , 'hueman' ) ?></h4>
|
||||
<textarea readonly="readonly" onclick="this.focus();this.select()" id="system-info-textarea" name="tc-sysinfo" title="<?php _e( 'To copy the system infos, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'hueman' ); ?>" style="width: 100%;min-height: 800px;font-family: Menlo,Monaco,monospace;background: 0 0;white-space: pre;overflow: auto;display:block;">
|
||||
<?php do_action( '__system_config_before' ); ?>
|
||||
# SITE_URL: <?php echo site_url() . "\n"; ?>
|
||||
# HOME_URL: <?php echo esc_url( home_url() ) . "\n"; ?>
|
||||
# IS MULTISITE : <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
|
||||
|
||||
# ACTIVE THEME : <?php echo $theme . "\n"; ?>
|
||||
<?php if ( $parent_theme !== $theme ) : ?>
|
||||
# PARENT THEME : <?php echo $parent_theme . "\n"; ?>
|
||||
<?php endif; ?>
|
||||
# WP VERSION : <?php echo get_bloginfo( 'version' ) . "\n"; ?>
|
||||
# PERMALINK STRUCTURE : <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
|
||||
<?php
|
||||
$plugins = get_plugins();
|
||||
$active_plugins = get_option( 'active_plugins', array() );
|
||||
?>
|
||||
<?php if ( empty($active_plugins) ) : ?>
|
||||
# NO ACTIVE PLUGINS
|
||||
<?php else : ?>
|
||||
# <?php echo count($active_plugins); ?> ACTIVE PLUGINS :
|
||||
<?php
|
||||
foreach ( $plugins as $plugin_path => $plugin ) {
|
||||
// If the plugin isn't active, don't show it.
|
||||
if ( ! in_array( $plugin_path, $active_plugins ) )
|
||||
continue;
|
||||
|
||||
echo ' - ' . $plugin['Name'] . ' (version ' . $plugin['Version'] .')' ."\n";
|
||||
}
|
||||
?>
|
||||
<?php endif;//end if active plugins not empty ?>
|
||||
<?php
|
||||
if ( is_multisite() ) :
|
||||
?>
|
||||
# NETWORK ACTIVE PLUGINS:
|
||||
<?php
|
||||
$plugins = wp_get_active_network_plugins();
|
||||
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
||||
|
||||
foreach ( $plugins as $plugin_path ) {
|
||||
$plugin_base = plugin_basename( $plugin_path );
|
||||
|
||||
// If the plugin isn't active, don't show it.
|
||||
if ( ! array_key_exists( $plugin_base, $active_plugins ) )
|
||||
continue;
|
||||
|
||||
$plugin = get_plugin_data( $plugin_path );
|
||||
|
||||
echo ' - ' . $plugin['Name'] . ' ( version ' . $plugin['Version'] .' )' ."\n";
|
||||
}
|
||||
endif;
|
||||
//GET MYSQL VERSION
|
||||
global $wpdb;
|
||||
$mysql_ver = ( ! empty( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) ? @mysqli_get_server_info( $wpdb->dbh ) : '';
|
||||
?>
|
||||
|
||||
# PHP Version: <?php echo PHP_VERSION . "\n"; ?>
|
||||
# MySQL Version: <?php echo $mysql_ver . "\n"; ?>
|
||||
# Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
|
||||
|
||||
# WordPress Memory Limit: <?php echo ( $this -> hu_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
|
||||
# PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
|
||||
# PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
|
||||
# PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
|
||||
# PHP Upload Max Filesize:<?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
|
||||
# PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
|
||||
# PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
|
||||
# PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
|
||||
# PHP Allow URL File Open:<?php echo ini_get( 'allow_url_fopen' ) ? "Yes" : "No\n"; ?>
|
||||
|
||||
# WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
|
||||
|
||||
# Show On Front: <?php echo get_option( 'show_on_front' ) . "\n" ?>
|
||||
# Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . '(#' . $id . ')' . "\n" ?>
|
||||
# Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . '(#' . $id . ')' . "\n" ?>
|
||||
<?php do_action( '__system_config_after' ); ?>
|
||||
</textarea>
|
||||
</div><?php // .wrap ?>
|
||||
</div>
|
||||
<?php
|
||||
}//end of function
|
||||
|
||||
|
||||
/**
|
||||
* TC Let To Num
|
||||
*
|
||||
* Does Size Conversions
|
||||
*
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
function hu_let_to_num( $v ) {
|
||||
$l = substr( $v, -1 );
|
||||
$ret = substr( $v, 0, -1 );
|
||||
|
||||
switch ( strtoupper( $l ) ) {
|
||||
case 'P': // fall-through
|
||||
case 'T': // fall-through
|
||||
case 'G': // fall-through
|
||||
case 'M': // fall-through
|
||||
case 'K': // fall-through
|
||||
$ret *= 1024;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* hook : admin_print_styles
|
||||
* fix the absolute positioning of the wp footer admin link in the welcome pages
|
||||
* @return void
|
||||
*/
|
||||
function hu_fix_wp_footer_link_style() {
|
||||
$screen = get_current_screen();
|
||||
if ( ! is_object( $screen ) || 'appearance_page_welcome' != $screen-> id )
|
||||
return;
|
||||
?>
|
||||
<style id="tc-fix-wp-footer-position">
|
||||
.wp-admin #wpfooter {bottom: inherit;}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add fallback admin page.
|
||||
* @package Hueman
|
||||
* @since Hueman 1.1
|
||||
*/
|
||||
function hu_add_welcome_page() {
|
||||
$_name = __( 'About Hueman' , 'hueman' );
|
||||
$_name = HU_IS_PRO ? sprintf( '%s Pro', $_name ) : $_name;
|
||||
|
||||
$theme_page = add_theme_page(
|
||||
$_name, // Name of page
|
||||
$_name, // Label in menu
|
||||
'edit_theme_options' , // Capability required
|
||||
'welcome.php' , // Menu slug, used to uniquely identify the page
|
||||
array( $this , 'hu_welcome_panel' ) //function to be called to output the content of this page
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render welcome admin page.
|
||||
* @package Hueman
|
||||
* @since Hueman 3.0.4
|
||||
*/
|
||||
function hu_welcome_panel() {
|
||||
$_theme_name = HU_IS_PRO ? 'Hueman Pro' : 'Hueman';
|
||||
|
||||
?>
|
||||
<div class="hueman-admin-panel">
|
||||
<div class="about-text tc-welcome">
|
||||
<?php
|
||||
$title = sprintf( '<h1 class="czr-welcome-title">%1$s %2$s %3$s :)</h1>',
|
||||
__( "Thank you for using", "hueman" ),
|
||||
$_theme_name,
|
||||
HUEMAN_VER
|
||||
);
|
||||
echo convert_smilies( $title );
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( !HU_IS_PRO ) {
|
||||
printf( '<h4>%1$s ❤️.</h4><h4>%2$s</h4><h4>%3$s 🙏</h4><h3 style="font-weight:bold">%4$s</h3>',
|
||||
sprintf( __( "If you enjoy using the Hueman theme for your website, you will love %s", "hueman"),
|
||||
sprintf( '<a style="color:#d87f00" href="%1$s" title="%2$s" target="_blank" rel="noopener noreferrer">%2$s</a>', 'https://presscustomizr.com/hueman-pro/', __("Hueman Pro", "hueman") )
|
||||
),
|
||||
__("With Hueman Pro, you get premium features like infinite scrolling, footer and header customization, font customizer and many more. In addition, our premium support will be there to help you resolve any issue you may have with the theme. When installing Hueman Pro, all your previous options used in Hueman free are kept.", 'hueman'),
|
||||
__('And of course your support allows us to keep the theme at the highest level for your website. Thank you!', 'hueman'),
|
||||
'Limited offer : get 25% off with code HELLO2022.' . ' <a class="hu-pro-link-in-dashboard" href="https://presscustomizr.com/hueman-pro/" rel="noopener noreferrer" title="Go Pro" target="_blank">Go Pro</a> <span style="color: #f07829;font-size: 26px;" class="dashicons dashicons-external"></span>'
|
||||
);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php echo $this->hu_print_changelog(); ?>
|
||||
|
||||
|
||||
<div class="czr-col-50 first-col">
|
||||
<h3 style="font-size:1.3em;"><?php _e( 'Knowledge base','hueman' ); ?></h3>
|
||||
<p><?php _e( "We have prepared a complete online documentation of the theme.",'hueman' ) ?></br>
|
||||
<a class="button-primary review-hueman" href="<?php echo 'https://docs.presscustomizr.com/' ?>" target="_blank"><?php _e('Hueman Documentation','hueman'); ?></a></p>
|
||||
<!-- Place this tag where you want the widget to render. -->
|
||||
</div>
|
||||
|
||||
<div class="czr-col-50">
|
||||
<h3 style="font-size:1.3em;"><?php _e( 'Share your feedback','hueman' ); ?></h3>
|
||||
<p><?php _e( 'If you are happy with the theme, say it on wordpress.org and give Hueman a nice review!','hueman' ) ?></br>
|
||||
<a class="button-primary review-hueman" href="<?php echo esc_url('wordpress.org/support/view/theme-reviews/hueman') ?>" target="_blank"><?php _e('Share a review','hueman'); ?></a></p>
|
||||
</div>
|
||||
|
||||
<?php echo $this->hu_config_infos() ?>
|
||||
</div><!-- //#hueman-admin-panel -->
|
||||
<?php
|
||||
}
|
||||
|
||||
}//end of class
|
||||
endif;
|
||||
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
/**
|
||||
* Update notifications system in WP admin
|
||||
*/
|
||||
if ( !class_exists( 'HU_admin_update_notification' ) ) :
|
||||
class HU_admin_update_notification {
|
||||
static $instance;
|
||||
|
||||
function __construct () {
|
||||
self::$instance =& $this;
|
||||
|
||||
//UPDATE NOTICE
|
||||
if( !defined( 'HU_SHOW_UPDATE_NOTIFICATION' ) ) { define( 'HU_SHOW_UPDATE_NOTIFICATION', HUEMAN_VER !== '3.7.3' ); }
|
||||
add_action( 'admin_notices' , array( $this, 'hu_may_be_display_update_notice') );
|
||||
//always add the ajax action
|
||||
add_action( 'wp_ajax_dismiss_hueman_update_notice' , array( $this , 'hu_dismiss_update_notice_action' ) );
|
||||
add_action( 'admin_footer' , array( $this , 'hu_write_ajax_dismis_script' ) );
|
||||
/* beautify admin notice text using some defaults the_content filter callbacks */
|
||||
foreach ( array( 'wptexturize', 'convert_smilies', 'wpautop') as $callback ) {
|
||||
if ( function_exists( $callback ) )
|
||||
add_filter( 'hu_update_notice', $callback );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**********************************************************************************
|
||||
* UPDATE NOTICE
|
||||
* User gets notified when the version stores in the db option 'last_update_notice'
|
||||
* is < current version of the theme (HUEMAN_VER)
|
||||
* User can dismiss the notice and the option get updated by ajax to the current version
|
||||
* The notice will be displayed a maximum of 5 times and will be automatically dismissed until the next update.
|
||||
* => users won't be notified again until the next update.
|
||||
**********************************************************************************/
|
||||
/**
|
||||
* hook : admin_notices
|
||||
*/
|
||||
function hu_may_be_display_update_notice() {
|
||||
if ( !defined('HU_SHOW_UPDATE_NOTIFICATION') || !HU_SHOW_UPDATE_NOTIFICATION )
|
||||
return;
|
||||
$screen = get_current_screen();
|
||||
if ( is_object($screen) && 'appearance_page_welcome' === $screen-> id )
|
||||
return;
|
||||
|
||||
$opt_name = 'last_update_notice';
|
||||
$last_update_notice_values = hu_get_option($opt_name);
|
||||
$show_new_notice = false;
|
||||
$display_ct = 10;
|
||||
|
||||
if ( !$last_update_notice_values || !is_array($last_update_notice_values) ) {
|
||||
//first time user of the theme, the option does not exist
|
||||
// 1) initialize it => set it to the current Hueman version, displayed 0 times.
|
||||
// 2) update in db
|
||||
$last_update_notice_values = array( "version" => HUEMAN_VER, "display_count" => 0 );
|
||||
HU_utils::$inst->hu_set_option( $opt_name, $last_update_notice_values );
|
||||
//already user of the theme ?
|
||||
if ( hu_user_started_before_version( HUEMAN_VER ) )
|
||||
$show_new_notice = true;
|
||||
}
|
||||
|
||||
$_db_version = $last_update_notice_values["version"];
|
||||
$_db_displayed_count = $last_update_notice_values["display_count"];
|
||||
|
||||
//user who just upgraded the theme will be notified until he/she clicks on the dismiss link
|
||||
//or until the notice has been displayed n times.
|
||||
if ( version_compare( HUEMAN_VER, $_db_version , '>' ) ) {
|
||||
//CASE 1 : displayed less than n times
|
||||
if ( $_db_displayed_count < $display_ct ) {
|
||||
$show_new_notice = true;
|
||||
//increments the counter
|
||||
(int) $_db_displayed_count++;
|
||||
$last_update_notice_values["display_count"] = $_db_displayed_count;
|
||||
//updates the option val with the new count
|
||||
HU_utils::$inst->hu_set_option( $opt_name, $last_update_notice_values );
|
||||
}
|
||||
//CASE 2 : displayed n times => automatic dismiss
|
||||
else {
|
||||
//reset option value with new version and counter to 0
|
||||
$new_val = array( "version" => HUEMAN_VER, "display_count" => 0 );
|
||||
HU_utils::$inst->hu_set_option( $opt_name, $new_val );
|
||||
}//end else
|
||||
}//end if
|
||||
|
||||
//always display in dev mode
|
||||
$show_new_notice = ( defined('CZR_DEV') && CZR_DEV ) || $show_new_notice;
|
||||
if ( !$show_new_notice )
|
||||
return;
|
||||
//prefixed HU_Plugin_Activation because of the possible issue : https://github.com/presscustomizr/customizr/issues/1603
|
||||
if ( !hu_is_plugin_active('nimble-builder/nimble-builder.php') && class_exists('HU_Plugin_Activation') && !HU_Plugin_Activation::get_instance()->hu_is_notice_dismissed() )
|
||||
return;
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div class="notice notice-info czr-update-notice" style="position:relative;">
|
||||
<?php
|
||||
echo apply_filters(
|
||||
'hu_update_notice',
|
||||
sprintf('<h3>➡️ %1$s %2$s %3$s %4$s. <strong><a href="%5$s" title="%6$s">%6$s %7$s</a></strong></h3>',
|
||||
__( "You have recently updated to", "hueman"),
|
||||
HU_IS_PRO ? 'Hueman Pro' : 'Hueman',
|
||||
__( "version", "hueman"),
|
||||
HUEMAN_VER,
|
||||
admin_url() .'themes.php?page=welcome.php',
|
||||
__( "Make sure to read the changelog" , "hueman" ),
|
||||
is_rtl() ? '«' : '»'
|
||||
)
|
||||
);
|
||||
?>
|
||||
<p style="text-align:right;position: absolute;font-size: 1.1em;<?php echo is_rtl()? 'left' : 'right';?>: 7px;bottom: -6px;">
|
||||
<?php printf('<a href="#" title="%1$s" class="tc-dismiss-update-notice"> ( %1$s <strong>X</strong> ) </a>',
|
||||
__('close' , 'hueman')
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
$_html = ob_get_clean();
|
||||
echo $_html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hook : wp_ajax_dismiss_hueman_update_notice
|
||||
* => sets the last_update_notice to the current Hueman version when user click on dismiss notice link
|
||||
*/
|
||||
function hu_dismiss_update_notice_action() {
|
||||
check_ajax_referer( 'dismiss-update-notice-nonce', 'dismissUpdateNoticeNonce' );
|
||||
//reset option value with new version and counter to 0
|
||||
$new_val = array( "version" => HUEMAN_VER, "display_count" => 0 );
|
||||
HU_utils::$inst->hu_set_option( 'last_update_notice', $new_val );
|
||||
wp_die();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* hook : admin_footer
|
||||
*/
|
||||
function hu_write_ajax_dismis_script() {
|
||||
?>
|
||||
<script id="tc-dismiss-update-notice">
|
||||
( function($){
|
||||
var _ajax_action = function( $_el ) {
|
||||
var AjaxUrl = "<?php echo admin_url( 'admin-ajax.php' ); ?>",
|
||||
_query = {
|
||||
action : 'dismiss_hueman_update_notice',
|
||||
dismissUpdateNoticeNonce : "<?php echo wp_create_nonce( 'dismiss-update-notice-nonce' ); ?>"
|
||||
},
|
||||
$ = jQuery,
|
||||
request = $.post( AjaxUrl, _query );
|
||||
|
||||
request.fail( function ( response ) {
|
||||
//console.log('response when failed : ', response);
|
||||
});
|
||||
request.done( function( response ) {
|
||||
//console.log('RESPONSE DONE', $_el, response);
|
||||
// Check if the user is logged out.
|
||||
if ( '0' === response )
|
||||
return;
|
||||
// Check for cheaters.
|
||||
if ( '-1' === response )
|
||||
return;
|
||||
});
|
||||
};//end of fn
|
||||
|
||||
//on load
|
||||
$( function($) {
|
||||
$('.tc-dismiss-update-notice').on('click', function( e ) {
|
||||
e.preventDefault();
|
||||
$(this).closest('.czr-update-notice').slideToggle('fast');
|
||||
_ajax_action( $(this) );
|
||||
} );
|
||||
} );
|
||||
|
||||
} )( jQuery );
|
||||
|
||||
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
}//end of class
|
||||
endif;
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
//@return bool
|
||||
function hu_rec_notice_is_dismissed( $notice_id = '' ) {
|
||||
$notice_id = ( empty( $notice_id ) || !is_string( $notice_id ) ) ? REC_NOTICE_ID : $notice_id;
|
||||
$dismissed = get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true );
|
||||
$dismissed_array = array_filter( explode( ',', (string) $dismissed ) );
|
||||
return ( defined('NIMBLE_RECOMMENDATION_OFF') && true === NIMBLE_RECOMMENDATION_OFF ) || in_array( $notice_id, $dismissed_array );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'admin_notices', 'hu_maybe_render_rec_notice' );
|
||||
function hu_maybe_render_rec_notice() {
|
||||
$screen = get_current_screen();
|
||||
if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
|
||||
return;
|
||||
}
|
||||
if ( hu_rec_notice_is_dismissed( REC_NOTICE_ID ) )
|
||||
return;
|
||||
|
||||
$plugin = 'nimble-builder/nimble-builder.php';
|
||||
$installed_plugins = get_plugins();
|
||||
$is_nimble_installed = isset( $installed_plugins[ $plugin ] );
|
||||
|
||||
if ( $is_nimble_installed ) {
|
||||
if ( !current_user_can( 'activate_plugins' ) ) {
|
||||
return;
|
||||
}
|
||||
$button_text = __( 'Activate Nimble Builder Now', 'hueman' );
|
||||
$button_link = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin );
|
||||
} else {
|
||||
if ( !current_user_can( 'install_plugins' ) ) {
|
||||
return;
|
||||
}
|
||||
$button_text = __( 'Install Nimble Builder Now', 'hueman' );
|
||||
$button_link = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=nimble-builder' ), 'install-plugin_nimble-builder' );
|
||||
}
|
||||
|
||||
if ( hu_rec_notice_is_dismissed( PREV_REC_NOTICE_ID ) ) {
|
||||
hu_print_s_rec_notice( $button_text, $button_link );
|
||||
} else {
|
||||
hu_print_l_rec_notice( $button_text, $button_link );
|
||||
}
|
||||
}
|
||||
|
||||
function hu_print_l_rec_notice( $button_text, $button_link ) {
|
||||
$heading = sprintf( __('Hueman theme recommends %1$s.', 'hueman' ),
|
||||
sprintf('<a href="%1$s" class="thickbox" target="_blank">%2$s</a>',
|
||||
wp_nonce_url( 'plugin-install.php?tab=plugin-information&plugin=nimble-builder&TB_iframe=true&width=640&height=500'),
|
||||
__('Nimble Page Builder', 'hueman')
|
||||
)
|
||||
);
|
||||
|
||||
$message = sprintf( '<span style="font-weight:normal;">%1$s<br/> %2$s<br/>%3$s<br/>%4$s</span>',
|
||||
__( 'Developers of the Hueman theme have created Nimble Builder, a free, powerful yet easy-to-use page builder already active on 50K+ WordPress websites.', 'hueman'),
|
||||
__( 'It allows you to drag and drop mobile-ready sections on <i>really</i> any page of your site, including home, posts, pages, products, archives, 404, search pages, ...', 'hueman' ),
|
||||
sprintf(
|
||||
__( 'You can insert simple text zones, but also create %1$s, insert post grids, column structures, buttons, widget zones, maps, icons, and much more, or use pre-designed sections with professional %2$s.', 'hueman'),
|
||||
sprintf('<a href="%1$s" target="_blank" title="%2$s">%2$s</a>', esc_url('nimblebuilder.com/mp4-video-background-with-delay/'), __('video backgrounds', 'hueman') ),
|
||||
sprintf('<a href="%1$s" target="_blank" title="%2$s">%2$s</a>', esc_url('demo.presscustomizr.com/nimble-builder/'), __('parallax effect', 'hueman') )
|
||||
),
|
||||
__( "The plugin is lightweight and has been designed to integrate seamlessly with Hueman and any WordPress theme.", 'hueman')
|
||||
);
|
||||
|
||||
$notice_id = REC_NOTICE_ID;
|
||||
?>
|
||||
<script>
|
||||
jQuery( function( $ ) {
|
||||
// .notice-dismiss button markup is added by WP
|
||||
$( <?php echo wp_json_encode( "#$notice_id" ); ?> ).on( 'click', '.notice-dismiss', function() {
|
||||
$(this).closest('.is-dismissible').slideUp('fast');//<= this line is not mandatory since WP has its own way to remove the is-dismissible block
|
||||
$.post( ajaxurl, {
|
||||
pointer: <?php echo wp_json_encode( $notice_id ); ?>,
|
||||
action: 'dismiss-wp-pointer'
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
</script>
|
||||
<div class="notice updated is-dismissible czr-nimble-rec-notice" id="<?php echo esc_attr( $notice_id ); ?>">
|
||||
<div class="czr-nimble-rec-notice-inner">
|
||||
<div class="czr-rec-text-block">
|
||||
<h3><span class="czr-nimble-rec-notice-icon"><img src="<?php echo esc_url( get_template_directory_uri() ) . '/assets/admin/img/nimble_icon.svg'; ?>" alt="Nimble Builder Logo" /></span><span class="czr-nimble-rec-notice-title"><?php echo $heading; ?></span></h3>
|
||||
<p><?php echo $message; ?></p>
|
||||
<span class="czr-rec-button"><a class="button button-primary button-hero activate-now" href="<?php echo esc_attr( $button_link ); ?>" data-name="Nimble Builder" data-slug="nimble-builder"><?php echo $button_text; ?></a></span>
|
||||
</div>
|
||||
<div class="czr-tgmpa-img-block"><img src="https://api.nimblebuilder.com/wp-content/uploads/2020/07/nimble_and_hueman_145.gif" alt="Nimble Builder" title="Nimble Builder" class="czr-nimble-img"></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function hu_print_s_rec_notice( $button_text, $button_link ) {
|
||||
$heading = sprintf( __('Hueman theme recommends the simple and smart %1$s companion ( free 😍 ) to help you build pages %2$s.', 'hueman' ),
|
||||
sprintf('<a href="%1$s" class="thickbox" target="_blank">%2$s</a>',
|
||||
wp_nonce_url( 'plugin-install.php?tab=plugin-information&plugin=nimble-builder&TB_iframe=true&width=640&height=500'),
|
||||
__('Nimble Builder', 'hueman')
|
||||
),
|
||||
sprintf('<a href="https://nimblebuilder.com/landing-page-one/" target="_blank" rel="noreferrer noopener">%1$s</a>',
|
||||
__('like this', 'hueman')
|
||||
)
|
||||
);
|
||||
$notice_id = REC_NOTICE_ID;
|
||||
?>
|
||||
<script>
|
||||
jQuery( function( $ ) {
|
||||
$( <?php echo wp_json_encode( "#$notice_id" ); ?> ).on( 'click', '.notice-dismiss', function() {
|
||||
$.post( ajaxurl, {
|
||||
pointer: <?php echo wp_json_encode( $notice_id ); ?>,
|
||||
action: 'dismiss-wp-pointer'
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
</script>
|
||||
<div class="notice updated is-dismissible czr-nimble-rec-notice" id="<?php echo esc_attr( $notice_id ); ?>">
|
||||
<div class="czr-nimble-rec-notice-inner">
|
||||
<div class="">
|
||||
<h3><span class="czr-nimble-rec-notice-icon"><img src="<?php echo esc_url( get_template_directory_uri() ) . '/assets/admin/img/nimble_icon.svg'; ?>" alt="Nimble Builder Logo" /></span><span class="czr-nimble-rec-notice-title"><?php echo $heading; ?></span>
|
||||
<span class=""><a class="button button-primary activate-now" href="<?php echo esc_attr( $button_link ); ?>" data-name="Nimble Builder" data-slug="nimble-builder"><?php echo $button_text; ?></a></span>
|
||||
</h3>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
Reference in New Issue
Block a user