HEX
Server: Apache
System: Linux webd004.cluster130.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User: frenchy (106757)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/frenchy/refonte2023/wordpress/wp-content/plugins/ova-framework/widgets/give-recent-widget.php
<?php
// Creating the widget 
class chursy_list_give_widget extends WP_Widget {

    function __construct() {

        $widget_ops = array(
            'classname'                   => 'widget_list_give',
            'description'                 => esc_html__( 'Get list give', 'ova-framework' ),
            'customize_selective_refresh' => true,
        );
        parent::__construct( 'give_recent', esc_html__( 'List Give', 'ova-framework' ), $widget_ops );
    }

    public function widget( $args, $instance ) {

        $title = apply_filters( 'widget_title', $instance['title'] );
        $title = ! empty( $title ) ? $title : esc_html__( 'Urgent Causes', 'ova-framework' );

        $hierarchical = ! empty( $instance['hierarchical'] ) ? '1' : '0';

        echo $args['before_widget'];

        if ( $title ) {
            echo $args['before_title'] . $title . $args['after_title'];
        }
        
        $posts_per_page = apply_filters( 'ova-give-recent-widget', 3 );

        $args_event = array(
            'post_type' => 'give_forms',
            'post_status' => 'publish',
            'posts_per_page' => $posts_per_page,
            'orderby' => 'ID',
            'order'   => 'DESC',
        );

        $list_event = get_posts( $args_event );

        if ($list_event) { ?>

            <div class="list-give">

                <?php foreach ( $list_event as $k => $event ) {
                    $id         = $event->ID;
                    $title      = get_the_title( $id );

                    $thumbnail      = wp_get_attachment_image_url(get_post_thumbnail_id($id) , 'thumbnail' );
                    if ( $thumbnail == '') {
                        $thumbnail  =  \Elementor\Utils::get_placeholder_image_src();
                    }
                    
                    $link       = get_the_permalink( $id );
                    $show_goal  = give_get_meta( $id, '_give_goal_option', true );

                    $chursy_progress_stats = apply_filters( 'chursy_progress_stats', $id );

                ?>

                    <div class="item-give">

                        <div class="ova-thumb-nail">
                            <a href="<?php echo esc_url($link); ?>" style="background-image:url(<?php echo esc_url( $thumbnail ) ?>)">
                            </a>
                        </div>

                        <div class="ova-content">

                            <h3 class="title">
                               <a href="<?php echo esc_url($link); ?>">
                                   <?php echo esc_html($title); ?>
                               </a>
                            </h3>

                            <div class="raised">
                                <?php if( isset($chursy_progress_stats['actual']) ) { ?>
                                    <div class="income">
                                        <span class="rain"><?php esc_html_e( 'Raised', 'ova-framework' ); ?></span>
                                        <span><?php echo esc_html( $chursy_progress_stats['actual'] ); ?></span>      
                                    </div>
                                <?php } ?>
                                
                                <?php if( $show_goal != 'disabled' && isset($chursy_progress_stats['goal']) ) { ?>   
                                    <div class="goal">
                                         <span class="ingo"><?php esc_html_e( ' / ', 'ova-framework' ); ?></span>
                                        <span><?php echo esc_html( $chursy_progress_stats['goal'] ); ?></span>
                                    </div>
                                <?php } ?>
                            </div>

                            <div class="donate_remaining">
                                <a href="<?php the_permalink($id); ?>" class="donate"><?php esc_html_e( 'Donates', 'ova-framework' ); ?></a>
                            </div>

                       </div>

                    </div>

                <?php } ?>

            </div>

        <?php }

        echo $args['after_widget'];

    }

    public function form( $instance ) {
       
        // Defaults.
        $instance     = wp_parse_args( (array) $instance, array( 'title' => '' ) );

        ?>

        <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'ova-framework' ); ?></label>
        <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /></p>

        <?php 
    }

    public function update( $new_instance, $old_instance ) {
        $instance                 = $old_instance;
        $instance['title']        = sanitize_text_field( $new_instance['title'] );

        return $instance;
    }

} 

function chursy_list_give_load_widget() {
    register_widget( 'chursy_list_give_widget' );
}

if( class_exists('Give') ){
    add_action( 'widgets_init', 'chursy_list_give_load_widget' );    
}