Commit 4e6c04c9 authored by Kenny Hall's avatar Kenny Hall

Added dismissable link for the Whip action.

parent be0060a4
......@@ -5,20 +5,29 @@ class NF_Whip
/**
* NF_Whip constructor.
* Hooks into the WordPress admin notice system and calls our whip_message.
* @Since 3.2.19
*/
public function __construct()
{
add_action( 'admin_notices', array( $this, 'whip_message' ) );
// Gets our transient
$transient = get_transient( 'nf_dismiss_whip' );
// Checks our transient and fires the message.
if( false == $transient && current_user_can('administrator') ) {
add_action( 'admin_notices', array( $this, 'whip_message' ) );
$this->set_dismiss();
}
}
/**
* Whip Message
* Builds and outputs our message.
* @Since 3.2.19
*/
public function whip_message()
{
// Builds our Whip message.
$message = array();
$message[] = '<strong>' . __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP.', 'ninja-forms' ) . "</strong><br /><br />";
$message[] = __( 'PHP is the programming language that WordPress, Ninja Forms, and themes are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you to this notice.', 'ninja-forms' ) . "<br /><br />";
$message[] = '<strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'ninja-forms' ) . '</strong><br /><br />';
......@@ -29,15 +38,34 @@ class NF_Whip
'</a>'
);
$message[] = '<strong>' . __( 'Can\'t update? Ask your host!', 'ninja-forms' ) . '</strong><br /><br />';
$message[] = sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. Yoast has %1$sexamples here%2$s. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %3$sWordPress hosting partners%2$s.','ninja-forms' ) . '<br />',
$message[] = sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. Yoast has %1$sexamples here%2$s. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %3$sWordPress hosting partners%2$s.','ninja-forms' ) . '<br /><br /><br />' ,
'<a href="https://yoa.st/wh" target="_blank">',
'</a>',
sprintf( '<a href="%1$s" target="_blank">', esc_url( 'https://wordpress.org/hosting/' ) )
);
// Builds our
$message[] = sprintf( __( '%1$sDismiss this for 4 weeks.%2$s', 'ninja-forms' ) . '<br />',
'<a href="' . admin_url() . 'admin.php?page=ninja-forms&dismiss-whip-message=true" target="_self">',
'</a>'
);
// Change our array to string to be displayed.
$message = implode( $message, "\n" );
// Output our message.
echo '<div class="notice notice-error" style="padding: 20px">' . $message . '</div>';
}
/**
* Set Dismiss
* Sets a transient for 4 weeks out that will remove the whip notice.
* @Since 3.2.19
*/
public function set_dismiss()
{
if( isset( $_GET[ 'page' ] ) && 'ninja-forms' == $_GET[ 'page' ] && 'true' == $_GET[ 'dismiss-whip-message' ] ) {
set_transient( 'nf_dismiss_whip', 1, 60 * 60 * 24 * 28 );
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment