1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156:
<?php
class CTA_Admin_Notices {
public function __construct() {
self::add_hooks();
}
public static function add_hooks() {
add_action('admin_notices', array( __CLASS__, 'get_more_templates_notice' ) );
}
public static function dont_install_call_to_action_templates_here() {
if( !current_user_can('activate_plugins') ) {
return;
}
$screen = get_current_screen();
if( $screen->id === 'themes' ||
$screen->id === 'theme-install' ||
$screen->id === 'update' && isset($_GET['action']) && $_GET['action'] === "upload-theme"
) {
$message_id = 'cta-installation';
if (self::check_if_viewed($message_id)) {
return;
}
$doc = 'http://docs.inboundnow.com/guide/installing-new-templates/';
$link = admin_url( 'edit.php?post_type=wp-call-to-action&page=wp_cta_templates_upload' );
?>
<div class="error" style="margin-bottom:10px;" id="inbound_notice_<?php echo $message_id; ?>">
<h3 style='font-weight:normal; margin-bottom:0px;padding-bottom:0px;'>
<strong>
<?php _e( 'Warning to Call to Action users:' , 'inbound-pro' ); ?>
</strong>
</h3>
<p style='font-weight:normal; margin-top:0px;margin-bottom:0px;'>
<?php echo "Call to action templates need to be installed in <strong><a href='".$link."'>Call to Action</a> > <a href='".$link."'>Manage templates area</a></strong>"; ?>
</p>
<a class="button button-large inbound_dismiss" href="#" id="<?php echo $message_id; ?>" data-notification-id="<?php echo $message_id; ?>" ><?php _e('Dismiss','inbound-pro'); ?></a>
<br><br>
</div>
<?php
self::javascript_dismiss_notice();
}
}
public static function get_more_templates_notice() {
global $pagenow;
if (!isset($_GET["page"])) {
return;
}
if( !current_user_can('activate_plugins') ) {
return;
}
if ( $_GET["page"] == "wp_cta_manage_templates" ) {
?>
<div id="more-templates-button" style="display:none;display:inline;">
<a target="_blank" href="https://www.inboundnow.com/marketplace/?show=cta" class="button new-lp-button button-primary button-large"><?php _e( 'Open Marketplace' , 'inbound-pro' ); ?></a>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
var moretemp = jQuery("#more-templates-button");
jQuery(".wrap h2").append(moretemp);
jQuery(moretemp).show();
});
</script>
<?php
}
}
public static function javascript_dismiss_notice() {
global $current_user;
$user_id = $current_user->ID;
?>
<script type="text/javascript">
jQuery( document ).ready(function() {
jQuery('body').on('click' , '.inbound_dismiss' , function() {
var notification_id = jQuery( this ).data('notification-id');
jQuery('#inbound_notice_' + notification_id).hide();
jQuery.ajax({
type: 'POST',
url: ajaxurl,
context: this,
data: {
action: 'inbound_dismiss_ajax',
notification_id: notification_id,
user_id: '<?php echo $user_id; ?>'
},
success: function (data) {
},
error: function (MLHttpRequest, textStatus, errorThrown) {
alert("Ajax not enabled");
}
});
})
});
</script>
<?php
}
public static function check_if_viewed( $notificaiton_id ) {
global $current_user;
$user_id = $current_user->ID;
return get_user_meta($user_id, 'inbound_notification_' . $notificaiton_id ) ;
}
}
new CTA_Admin_Notices;