![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/walla3t.corals.io/wp-content/plugins/apper-core/includes/ |
<?php /** * Register Address Widget to WordPress * * @since 1.0.0 */ add_action( 'widgets_init', function(){ register_widget( 'Acm_Address_Widget' ); }); class Acm_Address_Widget extends WP_Widget { // class constructor public function __construct() { $widget_ops = array( 'classname' => 'acm_address_widget', 'description' => esc_html__( 'Store Address and contact details', 'apper' ), ); parent::__construct( 'acm_address_widget', esc_html__( 'Store Address', 'apper' ), $widget_ops ); } // output the option form field in admin Widgets screen public function form( $instance ) { $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; $address = ! empty( $instance['address'] ) ? $instance['address'] : ''; $email = ! empty( $instance['email'] ) ? $instance['email'] : ''; $phone = ! empty( $instance['phone'] ) ? $instance['phone'] : ''; ?> <p> <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"> <?php esc_attr_e( 'Widget Title', 'apper' ); ?> </label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"> </p> <p> <label for="<?php echo esc_attr( $this->get_field_id( 'address' ) ); ?>"> <?php esc_attr_e( 'Address', 'apper' ); ?> </label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'address' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'address' ) ); ?>" type="text" value="<?php echo esc_attr( $address ); ?>"> </p> <p> <label for="<?php echo esc_attr( $this->get_field_id( 'email' ) ); ?>"> <?php esc_attr_e( 'Email', 'apper' ); ?> </label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'email' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'email' ) ); ?>" type="text" value="<?php echo esc_attr( $email ); ?>"> </p> <p> <label for="<?php echo esc_attr( $this->get_field_id( 'phone' ) ); ?>"> <?php esc_attr_e( 'Phone number', 'apper' ); ?> </label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'phone' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'phone' ) ); ?>" type="text" value="<?php echo esc_attr( $phone ); ?>"> </p> <?php } // save options public function update( $new_instance, $old_instance ) { $instance = array(); $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; $instance['address'] = ( ! empty( $new_instance['address'] ) ) ? strip_tags( $new_instance['address'] ) : ''; $instance['email'] = ( ! empty( $new_instance['email'] ) ) ? strip_tags( $new_instance['email'] ) : ''; $instance['phone'] = ( ! empty( $new_instance['phone'] ) ) ? strip_tags( $new_instance['phone'] ) : ''; return $instance; } // output the widget content on the front-end public function widget( $args, $instance ) { echo wp_kses_post( $args['before_widget'] ); if ( ! empty( $instance['title'] ) ) { echo wp_kses_post( $args['before_title'] ) . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title']; } ?> <div class="apper-business-address-widget"> <?php if ( ! empty( $instance['address'] ) ) { ?> <div class="apper-business-address"> <?php echo wp_kses_post( $instance['address'] ); ?> </div> <?php } if ( ! empty( $instance['email'] ) ) { ?> <div class="apper-business-email"> <?php echo wp_kses_post( $instance['email'] ) ?> </div> <?php } if ( ! empty( $instance['phone'] ) ) { ?> <div class="apper-business-phone"> <?php echo wp_kses_post( $instance['phone'] ) ?> </div> <?php } ?> </div> <?php echo wp_kses_post ( $args['after_widget'] ); } }