MP_Addon_CalculatorsHubspotAddon
Source Source
File: calculator-hubspot-add-on/calculator-hubspot-add-on.php
class MP_Addon_CalculatorsHubspotAddon {
/**
* Register functions.
*
* @since 1.0.0
* @access public
*/
public function register() {
load_plugin_textdomain( 'CalculatorsHubspotAddon', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
add_action( 'mortgage_platform_addons', array( $this, 'init' ), 10 );
}
/**
* Init function.
*
* @since 1.0.0
* @access public
*/
public function init() {
if ( isset(get_option( MortgagePlatform::$prefix . 'export' )['allow_hubspot']) && get_option( MortgagePlatform::$prefix . 'export' )['allow_hubspot'] ) {
add_action('export_lead_data', array(new MP_Addon_Hubspot,'set_lead_data_to_hubspot'));
}
add_filter( MortgagePlatform::$prefix . 'export', array( new MP_Addon_Hubspot_Settings, 'filter_export_data_settings' ), 30 );
add_action('admin_menu', array($this, 'add_hubspot_addon'), 50);
add_action( 'admin_init', array( new MP_Addon_Hubspot_Settings, 'register' ) , 40);
if(isset(get_option( MortgagePlatform::$prefix . 'hubspot' )['hubspot_api_key']) && !empty(get_option( MortgagePlatform::$prefix . 'hubspot' )['hubspot_api_key'])){
add_action( 'add_meta_boxes', array( new MP_Addon_Hubspot_Settings, 'hubspot_metabox' ), 20 );
add_filter(MortgagePlatform::$prefix . 'add_connectors', array(new MP_Addon_Hubspot_Settings, 'export_to_hubspot'));
add_action(MortgagePlatform::$prefix . 'connector', array( new MP_Addon_Hubspot, 'send_hubspot_manually' ));
}
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
add_action( 'wp_ajax_hubspot_send', array( new MP_Addon_Hubspot, 'hubspot_send_from_lead_page' ) );
add_action( 'wp_ajax_export_csv_hubspot', array( new MP_Addon_Hubspot, 'hubspot_csv' ) );
}
/**
* Add Hubspot add-on to Mortgage Platform.
*
* @access public
* @since 1.0.0
*/
public function add_hubspot_addon() {
add_filter('mortgage_platform_addon_page', array($this, 'addon_template'));
}
/**
* Hubspot add-on template.
*
* @access public
* @since 1.0.0
*/
public function addon_template() {
?>
<div class="mortgage-calculator-addon">
<h3><?php echo esc_html__('Hubspot add-on','CalculatorsHubspotAddon'); ?></h3>
<p><?php echo esc_html__('Description','CalculatorsHubspotAddon'); ?></p>
<a href="#" class="addon"><?php echo esc_html__('install add-on','CalculatorsHubspotAddon'); ?></a>
</div>
<?php
}
/**
* Enqueue admin scripts.
* @access public
* @since 1.0.0
*/
public function enqueue_admin_scripts( $hook ) {
if (('toplevel_page_mortgage_platform' === $hook && 'mortgage_platform' === $_GET['page'] && isset($_GET['tab']) && 'export' === $_GET['tab']) || 'post.php' === $hook) {
wp_enqueue_script( 'addon_hubspot_admin', plugins_url( 'assets/js/hubspot-admin.js', __FILE__ ), array( 'jquery' ), '1.0.0', true );
wp_localize_script(
'addon_hubspot_admin',
MortgagePlatform::$prefix . 'hubspot',
array(
'nonce' => wp_create_nonce( MortgagePlatform::$prefix . 'hubspot' ),
)
);
}
}
/**
* Activate plugin.
*
* @since 1.0.0
* @access public
*/
public function activate() {
flush_rewrite_rules();
}
/**
* Deactivate plugin.
*
* @since 1.0.0
* @access public
*/
public function deactivate() {
flush_rewrite_rules();
}
}
Methods Methods
- activate — Activate plugin.
- add_hubspot_addon — Add Hubspot add-on to Mortgage Platform.
- addon_template — Hubspot add-on template.
- deactivate — Deactivate plugin.
- enqueue_admin_scripts — Enqueue admin scripts.
- init — Init function.
- register — Register functions.
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |