🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:widgets.php
<?php /** * Widget Registration * * @package Ophiro_Ventures */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Custom widget: Journey CTA */ class Ophiro_Journey_CTA_Widget extends WP_Widget { public function __construct() { parent::__construct( 'ophiro_journey_cta', esc_html__( 'Ophiro: Journey CTA', 'ophiro' ), array( 'description' => esc_html__( 'Display a call-to-action for journeys.', 'ophiro' ) ) ); } public function widget( $args, $instance ) { $title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( 'Begin Your Journey', 'ophiro' ); $text = ! empty( $instance['text'] ) ? $instance['text'] : esc_html__( 'Let us craft your perfect Sri Lankan experience.', 'ophiro' ); $link = ! empty( $instance['link'] ) ? $instance['link'] : '#'; echo $args['before_widget']; if ( $title ) { echo $args['before_title'] . esc_html( $title ) . $args['after_title']; } ?> <p class="o-widget-cta__text"><?php echo esc_html( $text ); ?></p> <a href="<?php echo esc_url( $link ); ?>" class="o-btn o-btn--primary"><?php esc_html_e( 'Enquire Now', 'ophiro' ); ?></a> <?php echo $args['after_widget']; } public function form( $instance ) { $title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( 'Begin Your Journey', 'ophiro' ); $text = ! empty( $instance['text'] ) ? $instance['text'] : esc_html__( 'Let us craft your perfect Sri Lankan experience.', 'ophiro' ); $link = ! empty( $instance['link'] ) ? $instance['link'] : '#'; ?> <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'ophiro' ); ?></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( 'text' ) ); ?>"><?php esc_html_e( 'Text:', 'ophiro' ); ?></label> <textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"><?php echo esc_textarea( $text ); ?></textarea></p> <p><label for="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>"><?php esc_html_e( 'Link URL:', 'ophiro' ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'link' ) ); ?>" type="url" value="<?php echo esc_url( $link ); ?>"></p> <?php } public function update( $new_instance, $old_instance ) { $instance = array(); $instance['title'] = sanitize_text_field( $new_instance['title'] ); $instance['text'] = sanitize_textarea_field( $new_instance['text'] ); $instance['link'] = esc_url_raw( $new_instance['link'] ); return $instance; } } /** * Register custom widgets */ function ophiro_register_widgets() { register_widget( 'Ophiro_Journey_CTA_Widget' ); } add_action( 'widgets_init', 'ophiro_register_widgets' );
Save Changes
Cancel
Create New File
Create New Folder