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: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218:
<?php
class Landing_Pages_Admin_Notices {
public function __construct() {
self::add_hooks();
}
public static function add_hooks() {
add_action('admin_notices', array( __CLASS__, 'dont_install_landing_page_templates_here'));
add_action('admin_notices', array( __CLASS__, 'get_more_templates_notice' ) );
add_action('admin_notices', array( __CLASS__, 'permalink_structure_notice' ) );
}
public static function dont_install_landing_page_templates_here() {
$screen = get_current_screen();
if( $screen->id === 'themes' ||
$screen->id === 'theme-install' ||
$screen->id === 'update' && isset($_GET['action']) && $_GET['action'] === "upload-theme"
) {
if( !current_user_can('activate_plugins') ) {
return;
}
$message_id = 'landing-page-installation';
if (is_plugin_active('landing-pages/landing-pages.php')) {
$lp = true;
$message_id = 'landing-page-installation';
}
if (is_plugin_active('cta/calls-to-action.php')) {
$cta = true;
$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=landing-page&page=lp_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( 'Attention Landing Page Users:' , 'inbound-pro' ); ?>
</strong>
</h3>
<p style='font-weight:normal; margin-top:0px;margin-bottom:0px;'><?php _e( sprintf( 'If you are trying to install a <strong>landing page template</strong> from Inbound Now, %s Please Follow these instructions%s' , '<a href=\'http://docs.inboundnow.com/guide/installing-new-templates/\' target=\'_blank\'>' , '</a>' ) , 'inbound-pro' ); ?>
<br>
<?php echo "Landing page templates need to be installed <a href='".$link."'>here</a> in the <strong><a href='".$link."'>Landing pages</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;
$page_string = isset($_GET["page"]) ? $_GET["page"] : "null";
if ((($pagenow == 'edit.php') && ($page_string == "lp_manage_templates")) || (($pagenow == "post-new.php") && (isset($_GET['post_type']) && $_GET['post_type'] == "landing-page"))) {
if( !current_user_can('activate_plugins') ) {
return;
}
?>
<div id="more-templates-button" style="display:none;">
<a target="_blank" href="https://www.inboundnow.com/marketplace/?show=landing-pages" class="button new-lp-button button-primary button-large"><?php _e( 'Download Additional Landing Page Templates' , 'inbound-pro' ); ?></a>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
var moretemp = jQuery("#more-templates-button");
jQuery("#bulk_actions").prepend(moretemp);
jQuery(".lp-selection-heading h1").append(moretemp);
jQuery(".lp-selection-heading #more-templates").css("float","right");
jQuery(moretemp).show();
});
</script>
<?php
}
}
public static function permalink_structure_notice(){
global $pagenow;
if ( !get_option('permalink_structure') ) {
if( !current_user_can('activate_plugins') ) {
return;
}
?>
<div class="error">
<p>
<?php _e( 'We\'ve noticed that your permalink settings are set to the default setting. Landing Page varation roation is not possible on this setting. To enable roation please go into Settings->Permalinks and update them to a different format.' , 'inbound-pro' ); ?>
</p>
</div>
<?php
}
}
public static function acf5_required(){
global $post;
$screen = get_current_screen();
if ( !isset($post) || $screen->id == 'landing-pages' ||$screen->id == 'edit-landing-page' || $post->post_status !='publish' ) {
return;
}
$extension_data = Landing_Pages_Load_Extensions::get_extended_data();;
$current_template = Landing_Pages_Variations::get_current_template($post->ID);
if ( defined('ACF_PRO') || !isset($extension_data[$current_template]['info']['data_type']) || $extension_data[$current_template]['info']['data_type'] != 'acf5' ) {
return;
}
?>
<div class="error">
<p>
<?php echo sprintf(__('This landing page template requires %sInbound Pro Plugin + active subscription%s or the %sInbound Premium Template Support Extension%s to operate. Please download the best available option and activate it as a plugin to continue working with this template.', 'landing-pages'), '<a href="https://www.inboundnow.com/pricing/">', '</a>', '<a href="https://www.inboundnow.com/account/">', '</a>'); ?>
</p>
</div>
<?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 ) ;
}
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
}
}
new Landing_Pages_Admin_Notices;