| Server IP : 188.114.97.2 / Your IP : 104.23.197.230 Web Server : Apache/2.4.59 (Debian) System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 User : edlftp ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/nicolasj/temp/fusion-core/includes/widget/ |
Upload File : |
<?php
/**
* Widget Class.
*
* @author ThemeFusion
* @copyright (c) Copyright by ThemeFusion
* @link https://theme-fusion.com
* @package Fusion Core
* @subpackage Core
*/
// Do not allow directly accessing this file.
if ( ! defined( 'ABSPATH' ) ) {
exit( 'Direct script access denied.' );
}
/**
* Widget class.
*/
class Fusion_Widget_Recent_Works extends WP_Widget {
/**
* Constructor.
*
* @access public
*/
public function __construct() {
$widget_ops = [
'classname' => 'recent_works',
'description' => __( 'Recent works from the portfolio.', 'fusion-core' ),
];
$control_ops = [
'id_base' => 'recent_works-widget',
];
parent::__construct( 'recent_works-widget', __( 'Avada: Recent Works', 'fusion-core' ), $widget_ops, $control_ops );
}
/**
* Echoes the widget content.
*
* @access public
* @param array $args Display arguments including 'before_title', 'after_title',
* 'before_widget', and 'after_widget'.
* @param array $instance The settings for the particular instance of the widget.
*/
public function widget( $args, $instance ) {
extract( $args );
$title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' );
$number = isset( $instance['number'] ) ? $instance['number'] : 6;
echo $before_widget; // phpcs:ignore WordPress.Security.EscapeOutput
if ( $title ) {
echo $before_title . $title . $after_title; // phpcs:ignore WordPress.Security.EscapeOutput
}
?>
<div class="recent-works-items clearfix">
<?php
$args = [
'post_type' => 'avada_portfolio',
'posts_per_page' => $number,
'has_password' => false,
];
$portfolio = FusionCore_Plugin::fusion_core_cached_query( $args );
?>
<?php if ( $portfolio->have_posts() ) : ?>
<?php while ( $portfolio->have_posts() ) : ?>
<?php $portfolio->the_post(); ?>
<?php if ( has_post_thumbnail() ) : ?>
<?php $url_check = get_post_meta( get_the_ID(), 'pyre_link_icon_url', true ); ?>
<?php $new_permalink = ( ! empty( $url_check ) ) ? $url_check : get_permalink(); ?>
<?php $link_icon_target = get_post_meta( get_the_ID(), 'pyre_link_icon_target', true ); ?>
<?php $link_target = ( 'yes' === $link_icon_target ) ? '_blank' : '_self'; ?>
<?php $rel = ( 'yes' === $link_icon_target ) ? 'noopener noreferrer' : ''; ?>
<a href="<?php echo esc_url_raw( $new_permalink ); ?>" target="<?php echo esc_attr( $link_target ); ?>" rel="<?php echo esc_attr( $rel ); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail( 'recent-works-thumbnail' ); ?>
</a>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</div>
<?php
echo $after_widget; // phpcs:ignore WordPress.Security.EscapeOutput
}
/**
* Updates a particular instance of a widget.
*
* This function should check that `$new_instance` is set correctly. The newly-calculated
* value of `$instance` should be returned. If false is returned, the instance won't be
* saved/updated.
*
* @access public
* @param array $new_instance New settings for this instance as input by the user via
* WP_Widget::form().
* @param array $old_instance Old settings for this instance.
* @return array Settings to save or bool false to cancel saving.
*/
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = isset( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : ''; // phpcs:ignore WordPress.WP.AlternativeFunctions
$instance['number'] = isset( $new_instance['number'] ) ? $new_instance['number'] : '';
return $instance;
}
/**
* Outputs the settings update form.
*
* @access public
* @param array $instance Current settings.
*/
public function form( $instance ) {
$defaults = [
'title' => __( 'Recent Works', 'fusion-core' ),
'number' => 6,
];
$instance = wp_parse_args( (array) $instance, $defaults );
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_attr_e( 'Title:', 'fusion-core' ); ?></label>
<input class="widefat" 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'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_attr_e( 'Number of items to show:', 'fusion-core' ); ?></label>
<input class="widefat" type="text" style="width: 30px;" id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" value="<?php echo esc_attr( $instance['number'] ); ?>" />
</p>
<?php
}
}
/* Omit closing PHP tag to avoid "Headers already sent" issues. */