diff --git a/includes/deprecated.php b/includes/deprecated.php
new file mode 100644
index 00000000..effc1f94
--- /dev/null
+++ b/includes/deprecated.php
@@ -0,0 +1,57 @@
+ '10461',
- 'slug' => 'post-smtp',
- 'type' => 'plugin',
- 'public_key' => 'pk_28fcefa3d0ae86f8cdf6b7f71c0cc',
- 'is_premium' => false,
- 'has_addons' => false,
- 'bundle_id' => '10910',
- 'bundle_public_key' => 'pk_c5110ef04ba30cd57dd970a269a1a',
- 'has_paid_plans' => false,
- 'menu' => array(
- 'slug' => 'postman',
- 'first-path' => 'admin.php?page=postman/configuration_wizard',
- 'account' => false,
- ),
- ) );
- }
-
- return $ps_fs;
- }
-
- // Init Freemius.
- ps_fs();
- // Signal that SDK was initiated.
- do_action( 'ps_fs_loaded' );
-}
+if ( ! function_exists( 'post_smtp_fs' ) ) {
+ /**
+ * Initializes and returns the Freemius instance, storing it in the global `$ps_fs`.
+ *
+ * @since 2.1.1
+ * @version 1.0
+ *
+ * @return \Freemius The initialized Freemius instance.
+ * @throws \Freemius_Exception If there is an error during Freemius initialization.
+ */
+ function post_smtp_fs(): Freemius {
+ global $ps_fs;
+
+ if ( isset( $ps_fs ) ) {
+ return $ps_fs;
+ }
+
+ // Include Freemius SDK.
+ require_once __DIR__ . '/freemius/start.php';
+
+ $ps_fs = fs_dynamic_init(
+ array(
+ 'id' => '10461',
+ 'slug' => 'post-smtp',
+ 'type' => 'plugin',
+ 'public_key' => 'pk_28fcefa3d0ae86f8cdf6b7f71c0cc',
+ 'is_premium' => false,
+ 'has_addons' => false,
+ 'bundle_id' => '10910',
+ 'bundle_public_key' => 'pk_c5110ef04ba30cd57dd970a269a1a',
+ 'has_paid_plans' => false,
+ 'menu' => array(
+ 'slug' => 'postman',
+ 'first-path' => 'admin.php?page=postman/configuration_wizard',
+ 'account' => false,
+ ),
+ )
+ );
+
+ return $ps_fs;
+ }
-function ps_fs_custom_connect_message_on_update(
- $message,
- $user_first_name,
- $product_title,
- $user_login,
- $site_link,
- $freemius_link
-) {
- return sprintf(
- '
' .
- ''
- );
+ // Init Freemius.
+ post_smtp_fs();
+
+ // Signal that SDK was initiated.
+ do_action_deprecated( 'ps_fs_loaded', array(), '3.0.0', 'post_smtp_fs_loaded' );
+ do_action( 'post_smtp_fs_loaded' );
}
-
-ps_fs()->add_filter('connect_message', 'ps_fs_custom_connect_message_on_update', 10, 6);
-function ps_fs_custom_icon() {
- return dirname( __FILE__ ) . '/assets/images/icons/optin.png';
+/**
+ * Retrieves the 'Stay on the safe side' message.
+ *
+ * @since 3.0.0
+ *
+ * @return string Escaped message.
+ */
+function post_smtp_fs_custom_connect_message_on_update(): string {
+ return sprintf(
+ '' .
+ esc_html__( 'Stay on the safe side', 'post-smtp' ),
+ esc_html__( 'Receive our plugin\'s alert in case of critical security and feature updates and allow non-sensitive diagnostic tracking.', 'post-smtp' )
+ );
}
-
-ps_fs()->add_filter( 'plugin_icon' , 'ps_fs_custom_icon' );
+post_smtp_fs()->add_filter( 'connect_message', 'ps_fs_custom_connect_message_on_update', 10, 0 );
/**
+ * Retrieves the opt-in icon.
+ *
+ * @since 3.0.0
+ *
+ * @return string
+ */
+function post_smtp_fs_custom_icon(): string {
+ return __DIR__ . '/assets/images/icons/optin.png';
+}
+
+post_smtp_fs()->add_filter( 'plugin_icon', 'post_smtp_fs_custom_icon' );
+
+/*
* DO some check and Start Postman
*/
define( 'POST_SMTP_BASE', __FILE__ );
define( 'POST_SMTP_PATH', __DIR__ );
-define( 'POST_SMTP_URL', plugins_url('', POST_SMTP_BASE ) );
+define( 'POST_SMTP_URL', plugins_url( '', POST_SMTP_BASE ) );
define( 'POST_SMTP_VER', '3.0.0' );
define( 'POST_SMTP_DB_VERSION', '1.0.1' );
define( 'POST_SMTP_ASSETS', plugin_dir_url( __FILE__ ) . 'assets/' );
-$postman_smtp_exist = in_array( 'postman-smtp/postman-smtp.php', (array) get_option( 'active_plugins', array() ) );
-$required_php_version = version_compare( PHP_VERSION, '5.6.0', '<' );
+$postman_smtp_exist = in_array(
+ 'postman-smtp/postman-smtp.php',
+ (array) get_option( 'active_plugins', array() ),
+ true
+);
+
+$post_smtp_required_php_version = version_compare( PHP_VERSION, '7.0', '<' );
-if ( $postman_smtp_exist || $required_php_version ) {
+if ( $postman_smtp_exist || $post_smtp_required_php_version ) {
add_action( 'admin_init', 'post_smtp_plugin_deactivate' );
if ( $postman_smtp_exist ) {
add_action( 'admin_notices', 'post_smtp_plugin_admin_notice' );
}
- if ( $required_php_version ) {
+ if ( $post_smtp_required_php_version ) {
add_action( 'admin_notices', 'post_smtp_plugin_admin_notice_version' );
}
} else {
post_smtp_start( memory_get_usage() );
}
-
+/**
+ * Deactivates the Post SMTP plugin.
+ */
function post_smtp_plugin_deactivate() {
- deactivate_plugins( plugin_basename( __FILE__ ) );
+ deactivate_plugins( plugin_basename( __FILE__ ) );
}
+/**
+ * Displays an admin notice about the required PHP version.
+ */
function post_smtp_plugin_admin_notice_version() {
- echo '';
+ echo '
+ ';
if ( isset( $_GET['activate'] ) ) {
- unset( $_GET['activate'] ); }
+ unset( $_GET['activate'] );
+ }
}
+/**
+ * Displays an admin notice that the original Postman SMTP plugin must be disabled first.
+ */
function post_smtp_plugin_admin_notice() {
- echo 'Post SMTP plugin is a fork (twin brother) of the original Postman SMTP, you must disable Postman SMTP to use this plugin.
';
+ echo '
+
+
Post SMTP plugin is a fork (clone) of the original Postman SMTP, you must disable Postman SMTP to use this plugin.
+
';
if ( isset( $_GET['activate'] ) ) {
- unset( $_GET['activate'] ); }
+ unset( $_GET['activate'] );
+ }
}
/**
+ * Prints script to dismiss the notice that the plugin is not configured.
+ *
* @todo
+ * @since 3.0.0
*/
-function post_dismiss_not_configured() {
+function post_smtp_dismiss_not_configured() {
?>
- true );
+ wp_register_script( 'post-smtp-localize', POST_SMTP_URL . '/script/localize.js', array(), POST_SMTP_VER, $args );
+ wp_localize_script( 'post-smtp-localize', 'post_smtp_localize', $localize );
+ wp_enqueue_script( 'post-smtp-localize' );
+ wp_enqueue_script( 'post-smtp-hooks', POST_SMTP_URL . '/script/post-smtp-hooks.js', array(), POST_SMTP_VER, $args );
}
add_action( 'admin_enqueue_scripts', 'post_smtp_general_scripts', 8 );
/**
* Create the main Postman class to start Postman
*
- * @param mixed $startingMemory
+ * @param int $starting_memory The amount of memory, in bytes, that's being
+ * allocated to the PHP script when initialising Postman.
*/
-function post_smtp_start( $startingMemory ) {
- post_setupPostman();
- PostmanUtils::logMemoryUse( $startingMemory, 'Postman' );
+function post_smtp_start( $starting_memory ) {
+ post_smtp_setup_postman();
+ PostmanUtils::logMemoryUse( $starting_memory, 'Postman' );
}
/**
* Instantiate the mail Postman class
+ *
+ * @since 3.0.0
*/
-function post_setupPostman() {
+function post_smtp_setup_postman() {
require_once 'Postman/Postman.php';
- $kevinCostner = new Postman( __FILE__, POST_SMTP_VER );
- do_action( 'post_smtp_init');
-}
\ No newline at end of file
+ $postman = new Postman( __FILE__, POST_SMTP_VER );
+ do_action( 'post_smtp_init' );
+}
+
+require_once __DIR__ . 'includes/deprecated.php';