generate_qr_code();
$this->app_connected = get_option( 'post_smtp_mobile_app_connection' );
}
}
//Mobile App Notice
if ( isset( $_GET['page'] ) && 'postman' === $_GET['page'] ) {
if ( ! get_option( 'ps_dismissed_mobile_notice' ) ) {
add_action( 'admin_notices', array( $this, 'mobile_app_notice' ) );
}
}
}
/**
* Enqueue scripts
*
* @since 2.7.0
* @version 1.0.0
*/
public function admin_enqueue() {
wp_enqueue_script( 'post-smtp-mobile', POST_SMTP_URL . '/Postman/Mobile/assets/js/admin.js', array( 'jquery' ), POST_SMTP_VER );
wp_enqueue_style( 'post-smtp-mobile', POST_SMTP_URL . '/Postman/Mobile/assets/css/admin.css', array(), POST_SMTP_VER );
}
/**
* Add menu
*
* @since 2.7.0
* @version 1.0.0
*/
public function add_menu() {
add_submenu_page(
PostmanViewController::POSTMAN_MENU_SLUG,
__( 'Mobile Application', 'post-smtp' ),
sprintf( '%s', __( 'Mobile App', 'post-smtp' ), __( 'New', 'post-smtp' ) ),
'manage_options',
admin_url( 'admin.php?page=postman/configuration#mobile-app' ),
'',
3
);
}
/**
* Add tab
*
* @since 2.7.0
* @version 1.0.0
*/
public function tabs( $tabs ) {
$tabs['mobile-app'] = __( 'Mobile App', 'post-smtp' );
return $tabs;
}
/**
* Generate QR code
*
* @since 2.7.0
* @version 1.0.0
*/
public function generate_qr_code() {
include_once 'includes/phpqrcode/qrlib.php';
$nonce = get_transient( 'post_smtp_auth_nonce' );
$authkey = $nonce ? $nonce : $this->generate_auth_key();
$site_title = get_bloginfo( 'name' );
set_transient( 'post_smtp_auth_nonce', $authkey, 1800 );
$endpoint = site_url( "?authkey={$authkey}&site_title={$site_title}" );
ob_start();
QRcode::png( urlencode_deep( $endpoint ) );
$result_qr_content_in_png = ob_get_contents();
ob_end_clean();
// PHPQRCode change the content-type into image/png... we change it again into html
header("Content-type: text/html");
$this->qr_code = base64_encode( $result_qr_content_in_png );
}
/**
* Generate auth key
*
* @since 2.7.0
* @version 1.0.0
*/
private function generate_auth_key() {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
$chars .= '!@#$%^*()';
$chars .= '-_ []{}<>~`+,.;:/|';
$pass = array(); //remember to declare $pass as an array
$alphaLength = strlen( $chars ) - 1; //put the length -1 in cache
for ( $i = 0; $i < 32; $i++ ) {
$n = rand( 0, $alphaLength );
$pass[] = $chars[$n];
}
return implode( $pass ); //turn the array into a string
}
/**
* Section
*
* @since 2.7.0
* @version 1.0.0
*/
public function section() {
//Incompatible server
if( function_exists( 'ImageCreate' ) ):
?>
And you are done👍.
Want more details? Check out our complete guide Post SMTP Plugin with Mobile App
';
?>
Connected Device: ";
foreach( $this->app_connected as $device ) {
$url = admin_url( "admin.php?action=post_smtp_disconnect_app&auth_token={$device['fcm_token']}" );
$checked = $device['enable_notification'] == 1 ? 'checked="checked"' : '';
echo "{$device['device']} Disconnect";
echo '
';
echo sprintf(
'',
__( 'Send failed email notification' ),
$device['fcm_token'],
$checked
);
}
}
?>
| Easy Email Tracking | Quickly View Error Details |
| Get Instant Failure Notifications | Get Email Preview |
| Resend Failed Emails | Support For Multiple Sites (Coming Soon) |