MP_Addon_CalculatorsZohoAddon
Source Source
File: calculator-zoho-add-on/calculator-zoho-add-on.php
class MP_Addon_CalculatorsZohoAddon {
/**
* Register functions.
* @since 1.0.0
* @access public
*/
public function register() {
load_plugin_textdomain( 'CalculatorsZohoAddon', 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_zoho']) && get_option( MortgagePlatform::$prefix . 'export' )['allow_zoho'] ) {
add_action( 'export_lead_data', array( new MP_Addon_Zoho, 'set_lead_data_to_zoho' ) );
}
add_filter( MortgagePlatform::$prefix . 'export', array( new MP_Addon_Zoho_Settings, 'filter_export_data_settings' ), 40 );
add_action( 'admin_menu', array( $this, 'add_zoho_addon' ), 50 );
add_action( 'init', array(new MP_Addon_Zoho, 'decode_state'), 9 );
add_action( 'admin_init', array( new MP_Addon_Zoho_Settings, 'register' ) , 40);
if(!empty(get_option(MortgagePlatform::$prefix . 'zoho_access_token'))){
add_action( 'add_meta_boxes', array( new MP_Addon_Zoho_Settings, 'zoho_metabox' ), 20 );
add_filter(MortgagePlatform::$prefix . 'add_connectors', array(new MP_Addon_Zoho_Settings, 'export_to_zoho'));
add_action(MortgagePlatform::$prefix . 'connector', array( new MP_Addon_Zoho, 'send_zoho_manually' ));
}
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
add_action( 'wp_ajax_zoho_revoke_token', array( new MP_Addon_Zoho, 'revoke_token' ) );
add_action( 'wp_ajax_zoho_send', array( new MP_Addon_Zoho, 'zoho_send_from_lead_page' ) );
add_action( 'wp_ajax_export_csv_zoho', array( new MP_Addon_Zoho, 'zoho_csv' ) );
}
/**
* Activate plugin.
* @since 1.0.0
* @access public
*/
public function activate() {
flush_rewrite_rules();
MP_Addon_Zoho_Settings::default_settings();
}
/**
* Deactivate plugin.
* @since 1.0.0
* @access public
*/
public function deactivate() {
flush_rewrite_rules();
}
/**
* Add Zoho add-on on the add-ons page.
* @access public
* @since 1.0.0
*/
public function add_zoho_addon() {
add_filter( 'mortgage_platform_addon_page', array( $this, 'addon_template' ) );
}
/**
* Zoho add-on template.
* @access public
* @since 1.0.0
*/
public function addon_template() {
?>
<div class="mortgage-calculator-addon">
<h3><?php echo esc_html__( 'Zoho add-on', 'CalculatorsZohoAddon' ); ?></h3>
<p><?php echo esc_html__( 'Description', 'CalculatorsZohoAddon' ); ?></p>
<a href="#"
class="addon"><?php echo esc_html__( 'install add-on', 'CalculatorsZohoAddon' ); ?></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'] || 'zoho' === $_GET['tab']) ) || 'post.php' === $hook ) {
wp_enqueue_script( 'addon_zoho_admin', plugins_url( 'assets/js/zoho-admin.js', __FILE__ ), array( 'jquery' ), '1.0.0', true );
wp_localize_script(
'addon_zoho_admin',
MortgagePlatform::$prefix . 'zoho',
array(
'nonce' => wp_create_nonce( MortgagePlatform::$prefix . 'zoho' ),
)
);
}
}
}
Methods Methods
- activate — Activate plugin.
- add_zoho_addon — Add Zoho add-on on the add-ons page.
- addon_template — Zoho 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. |