MortgagePlatform
Class MortgagePlatform.
Source Source
File: mortgage-platform/mortgage-platform.php
class MortgagePlatform {
/**
* Plugin basename.
*
* @var string plugin basename
*
* @since 1.0.0
* @access public
*/
public $plugin;
/**
* Plugin version.
*
* @var string plugin version
*
* @since 1.0.0
* @access public
* @static
*/
public static $mortgage_platform_version = '1.0.0';
/**
* Plugin name.
*
* @var string plugin name
*
* @since 1.0.0
* @access public
* @static
*/
public static $plugin_name = 'Mortgage Platform';
/**
* Plugin domain.
*
* @var string plugin domain
*
* @since 1.0.0
* @access public
* @static
*/
public static $domain = 'mortgage_platform';
/**
* Plugin prefix.
*
* @var string plugin prefix
*
* @since 1.0.0
* @access public
* @static
*/
public static $prefix = 'mortgage_platform_';
/**
* Shortcode name.
*
* @var string shortcode name
*
* @since 1.0.0
* @access public
* @static
*/
public static $shortcode_widget = 'mp-mortgage-calculator';
/**
* Calculator Page for iframe embed.
*
* @var string page name
*
* @since 1.0.0
* @access public
* @static
*/
public static $page_title = '__Mortgage Calculator';
/**
* Calculator Page slug for iframe embed.
*
* @var string page slug
*
* @since 1.0.0
* @access public
* @static
*/
public static $page_name = 'mortgagecalculator-iframe';
/**
* Post type of the leads.
*
* @var string post type name
*
* @since 1.0.0
* @access public
* @static
*/
public static $lead = 'mortgage_leads';
/**
* Post type of the abandoned leads.
*
* @var string post type name
*
* @since 1.0.0
* @access public
* @static
*/
public static $abandoned_lead = 'mortgage_ab_leads';
/**
* MortgagePlatform constructor.
*
* @since 1.0.0
* @access public
*/
public function __construct() {
$this->plugin = plugin_basename( __FILE__ );
}
/**
* Register Platform functions.
*
* @since 1.0.0
* @access public
*/
public function register() {
add_filter( "plugin_action_links_$this->plugin", array( $this, 'settings_link' ) );
add_filter( "plugin_action_links_$this->plugin", array( $this, 'addons_link' ) );
load_plugin_textdomain( self::$domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
/**
* Init hook to add Mortgage Platform add-ons.
*
* @since 1.0.0
*/
do_action( 'mortgage_platform_addons' );
}
/**
* Set link of settings in plugins page.
*
* Add link of setting in an array of plugins links that display on the plugin page.
*
* @param array $links array links of plugins
*
* @since 1.0.0
* @access public
*
* @return array
*/
public function settings_link( $links ) {
$settings_link = '<a href="admin.php?page=' . self::$domain . '">' . __( 'Settings', 'mortgage_platform' ) . '</a>';
array_push( $links, $settings_link );
return $links;
}
/**
* Set link of add-ons in plugins page.
*
* Add link of add-ons in an array of plugins links that display on the plugin page.
*
* @param array $links array links of plugins
*
* @since 1.0.0
* @access public
*
* @return mixed
*/
public function addons_link( $links ) {
$settings_link = '<a href="admin.php?page=mortgage-platform-addons">' . __( 'Add-ons', 'mortgage_platform' ) . '</a>';
array_push( $links, $settings_link );
return $links;
}
/**
* Activate plugin.
*
* @since 1.0.0
* @access public
*/
public function activate() {
flush_rewrite_rules();
$register = new MP_Calculator_Register();
$register->create_page();
if ( ! get_option( self::$prefix . 'mortgage_calculator' ) ) {
$default_settings = new MP_Register();
update_option( self::$prefix . 'mortgage_calculator', $default_settings->default_settings() );
}
if ( ! get_option( self::$prefix . 'style' ) ) {
$default_settings = new MP_Register();
update_option( self::$prefix . 'style', $default_settings->default_style_settings() );
}
}
/**
* Deactivate plugin.
*
* @since 1.0.0
* @access public
*/
public function deactivate() {
flush_rewrite_rules();
}
/**
* Debug function.
*
* @param $data data for debugging
* @param bool $die die or not
* @param bool $print 'print' or 'var_dump'
*
* @since 1.0.0
* @access public
* @ignore
*/
public static function debug( $data, $die = true, $print = true ) {
if ( $print ) {
echo '<pre>';
print_r( $data );
echo '</pre>';
} else {
var_dump( $data );
}
if ( $die ) {
wp_die();
}
}
}
Methods Methods
- __construct — MortgagePlatform constructor.
- activate — Activate plugin.
- addons_link — Set link of add-ons in plugins page.
- deactivate — Deactivate plugin.
- register — Register Platform functions.
- settings_link — Set link of settings in plugins page.
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |