Skip to content

Commit

Permalink
Merge pull request #7 from nileshc-bsf/new-mautic-user-pass
Browse files Browse the repository at this point in the history
[NEW] - Mautic new connection option with Username and Password added.
  • Loading branch information
patilvikasj authored Sep 19, 2019
2 parents f5d9b7b + 2ba68cc commit c21e4a4
Show file tree
Hide file tree
Showing 6 changed files with 419 additions and 117 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
**Contributors:** [brainstormforce](https://profiles.wordpress.org/brainstormforce)
**Tags:** mautic, contacts, api, count, email
**Requires at least:** 4.1
**Stable tag:** 1.0.2
**Stable tag:** 1.0.3
**Tested up to:** 5.2

Display your Mautic Contacts count on your website
Expand All @@ -28,14 +28,17 @@ A very useful plugin to display your mautic contacts count on your website. This

## Changelog ##

# Version 1.0.2
### Version 1.0.3 ###
- Improvement: Add Username/Password API authentication method which is more reliable.

### Version 1.0.2 ###
- Fix: Prevent fatal error when plugin incorrect response is received.

# Version 1.0.1
### Version 1.0.1 ###
- Improvement: Change the Cron to update contacts count to be executed every week rather than every day, making fewer requests to Mautic
- Fix: Add correct comma separate formatting for the contacts count.

# Version 1.0.0
### Version 1.0.0 ###
- Initial Release.

## Installation ##
Expand Down
3 changes: 2 additions & 1 deletion assets/css/bsfm-cnt-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
background-color: #b4b9be;
padding: 3px 6px;
color: #fff;
}
}

39 changes: 39 additions & 0 deletions assets/js/bsfm-cnt-admin-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
(function( $ ) {

var ContactInMautic = {

/**
* Initializes the services logic.
*
* @return void
* @since 1.0.3
*/
init: function()
{
$( document ).on( 'change', '.bsfm-mautic-type', this._changeMauticType );
},

_changeMauticType: function() {
var val = $( this ).val();
if( val != 'mautic_api' ) {
$( '.contacts-in-mautic-text-bsfm-username' ).show();
$( '.contacts-in-mautic-text-bsfm-password' ).show();

$( '.contacts-in-mautic-text-bsfm-public-key' ).hide();
$( '.contacts-in-mautic-text-bsfm-secret-key' ).hide();
} else {
$( '.contacts-in-mautic-text-bsfm-username' ).hide();
$( '.contacts-in-mautic-text-bsfm-password' ).hide();

$( '.contacts-in-mautic-text-bsfm-public-key' ).show();
$( '.contacts-in-mautic-text-bsfm-secret-key' ).show();
}
}
};


$ ( function() {
ContactInMautic.init();
});

})(jQuery);
62 changes: 62 additions & 0 deletions classes/class-bsf-cm-auto-update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* Plugin auto update class.
*
* @package Contacts in Mautic
* @author Brainstormforce
* @link http://brainstormforce.com
* @since 1.0.3
*/

/**
* Bsf_CM_Auto_Update initial setup
*
* @since 1.0.3
*/
class Bsf_CM_Auto_Update {

/**
* Constructor
*/
public function __construct() {
// Plugin Updates.
add_action( 'admin_init', __CLASS__ . '::init' );
}

/**
* Implement plugin auto update logic.
*
* @since 1.0.3
* @return void
*/
public static function init() {

// Get auto saved version number.
$saved_version = get_option( 'bsf_contact_mautic_version' );

// If the version option not present then just create it.
if ( false === $saved_version ) {
add_option( 'bsf_contact_mautic_version', BSF_CONTACT_MAUTIC_VERSION );
}

// If equals then return.
if ( version_compare( $saved_version, BSF_CONTACT_MAUTIC_VERSION, '=' ) ) {
return;
}

// Set the Mautic connection type option.
$check_option = get_option( 'bsf_mautic_connection_type' );
if ( false === $check_option ){
add_option( 'bsf_mautic_connection_type', 'mautic_api' );
}

// Update auto saved version number.
update_option( 'bsf_contact_mautic_version', BSF_CONTACT_MAUTIC_VERSION );
}

}

/**
* calling 'Bsf_CM_Auto_Update' Constructor
*/
new Bsf_CM_Auto_Update();
Loading

0 comments on commit c21e4a4

Please sign in to comment.