403Webshell
Server IP : 66.29.132.124  /  Your IP : 3.15.203.195
Web Server : LiteSpeed
System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : wavevlvu ( 1524)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/wavevlvu/misswavenigeria.com/wp-content/plugins/totalcontest-lite/src/Widgets/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/wavevlvu/misswavenigeria.com/wp-content/plugins/totalcontest-lite/src/Widgets/Countdown.php
<?php

namespace TotalContest\Widgets;

use TotalContestVendors\TotalCore\Helpers\Arrays;


/**
 * Class Countdown
 * @package TotalContest\Widgets
 */
class Countdown extends Base {
	public function __construct() {
		$widgetOptions = [
			'classname'   => 'totalcontest-widget-countdown',
			'description' => esc_html__( 'TotalContest contest countdown widget', 'totalcontest' ),
		];
		parent::__construct( 'totalcontest_countdown', esc_html__( '[TotalContest] Contest countdown', 'totalcontest' ), $widgetOptions );
	}

	public function content( $args, $instance ) {
		if ( ! empty( $instance['contest'] ) ):
			$contest = TotalContest( 'contests.repository' )->getById( $instance['contest'] );
			$type    = $instance['type'];
			$format  = $instance['format'];
			$until   = $instance['until'];

			if ( $until === 'start' ):
				$interval = $contest->getTimeLeftToStart( $type );
			elseif ( $until === 'end' ):
				$interval = $contest->getTimeLeftToEnd( $type );
			endif;

			if ( isset( $interval ) && $interval instanceof \DateInterval ):
				echo (string) $interval->format( $format );
			endif;
		endif;
	}

	public function fields( $fields, $instance ) {
		$instance = Arrays::parse( $instance, [
			'contest' => null,
			'type'    => 'vote',
			'format'  => '%a days and %h hours',
			'until'   => 'start',
		] );
		// Contest field
		foreach ( (array) get_posts( 'post_type=contest&posts_per_page=-1' ) as $post ):
			$contests[ $post->ID ] = $post->post_title;
		endforeach;
		$fields['contest'] = TotalContest( 'form.field.select' )->setOptions( [
			'class'   => 'widefat',
			'name'    => esc_attr( $this->get_field_name( 'contest' ) ),
			'label'   => esc_html__( 'Contest:', 'totalcontest' ),
			'options' => $contests,
		] )->setValue( $instance['contest'] ?: '' );

		// Type
		$fields['type'] = TotalContest( 'form.field.select' )->setOptions( [
			'class'   => 'widefat',
			'name'    => esc_attr( $this->get_field_name( 'type' ) ),
			'label'   => esc_html__( 'Type:', 'totalcontest' ),
			'options' => [
				'contest' => esc_html__( 'Contest', 'totalcontest' ),
				'vote'    => esc_html__( 'Voting', 'totalcontest' ),
			],
		] )->setValue( $instance['type'] ?: 'contest' );

		// Format
		$fields['format'] = TotalContest( 'form.field.text' )->setOptions( [
			'class' => 'widefat',
			'name'  => esc_attr( $this->get_field_name( 'format' ) ),
			'label' => esc_html__( 'Format:', 'totalcontest' ),
		] )->setValue( $instance['format'] ?: '%a days and %h hours' );

		// Until
		$fields['until'] = TotalContest( 'form.field.select' )->setOptions( [
			'class'   => 'widefat',
			'name'    => esc_attr( $this->get_field_name( 'until' ) ),
			'label'   => esc_html__( 'Until:', 'totalcontest' ),
			'options' => [
				'start' => esc_html__( 'Start', 'totalcontest' ),
				'end'   => esc_html__( 'End', 'totalcontest' ),
			],
		] )->setValue( $instance['until'] ?: 'start' );

		return $fields;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit