Opal-Estate-Pro/inc/widgets/mortgage-calculator.php
2019-09-10 11:27:33 +07:00

63 lines
1.8 KiB
PHP
Executable File

<?php
/**
* Mortgage widget.
*
* A helper class for outputting common HTML elements, such as product drop downs
*
* @package Opalestate
* @since 1.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Opalestate_Mortgage_Calculator_Widget' ) ) {
class Opalestate_Mortgage_Calculator_Widget extends WP_Widget {
public function __construct() {
parent::__construct(
// Base ID of your widget
'opalestate_mortgage_calculate_widget',
// Widget name will appear in UI
__( 'Estate: Mortgage Calculator', 'opalestate-pro' ),
// Widget description
[ 'description' => esc_html__( 'Mortgage Calculator widget.', 'opalestate-pro' ), ]
);
}
public function widget( $instance, $args ) {
extract( $args );
extract( $instance );
//Check
$tpl = OPALESTATE_THEMER_WIDGET_TEMPLATES . 'parts/mortgage-calculator.php';
$tpl_default = OPALESTATE_PLUGIN_DIR . 'templates/parts/mortgage-calculator.php';
if ( is_file( $tpl ) ) {
$tpl_default = $tpl;
}
require $tpl_default;
}
public function form( $instance ) {
//Set up some default widget settings.
$defaults = [
'title' => esc_html__( 'Mortgage Calculator', 'opalestate-pro' ),
];
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'opalestate-pro' ); ?></label>
<input type="text" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
value="<?php echo esc_attr( $instance['title'] ); ?>" style="width:100%;"/>
</p>
<?php
}
}
}
register_widget( 'Opalestate_Mortgage_Calculator_Widget' );