| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.9/wp-content/themes/woodmart/inc/widgets/ |
Upload File : |
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* AJAX search widget
*
* @package woodmart§
*/
if ( ! defined( 'WOODMART_THEME_DIR' ) ) {
exit( 'No direct script access allowed' );
}
/**
* Register AJAX search widget.
*/
class WOODMART_Widget_Search extends WPH_Widget {
/**
* Constructor.
*/
public function __construct() {
if ( ! woodmart_woocommerce_installed() ) {
return;
}
$args = array(
'label' => esc_html__( 'WOODMART AJAX Search', 'woodmart' ),
'description' => esc_html__( 'Search form by products with AJAX', 'woodmart' ),
'slug' => 'woodmart-ajax-search',
);
$args['fields'] = array(
array(
'id' => 'title',
'type' => 'text',
'std' => esc_html__( 'Search products', 'woodmart' ),
'name' => esc_html__( 'Title', 'woodmart' ),
),
array(
'id' => 'post_type',
'type' => 'dropdown',
'std' => 'product',
'name' => esc_html__( 'Search post type', 'woodmart' ),
'fields' => array(
esc_html__( 'Product', 'woodmart' ) => 'product',
esc_html__( 'Post', 'woodmart' ) => 'post',
esc_html__( 'Portfolio', 'woodmart' ) => 'portfolio',
),
),
array(
'id' => 'number',
'type' => 'number',
'std' => 4,
'name' => esc_html__( 'Number of products to show', 'woodmart' ),
),
array(
'id' => 'price',
'type' => 'checkbox',
'std' => 1,
'name' => esc_html__( 'Show price', 'woodmart' ),
),
array(
'id' => 'thumbnail',
'type' => 'checkbox',
'std' => 1,
'name' => esc_html__( 'Show thumbnail', 'woodmart' ),
),
array(
'id' => 'categories',
'type' => 'checkbox',
'std' => 1,
'name' => esc_html__( 'Show categories', 'woodmart' ),
),
);
$this->create_widget( $args );
}
/**
* Render widget.
*
* @param array $args Widget arguments.
* @param array $instance Widget instance.
*/
public function widget( $args, $instance ) {
extract( $args ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
echo wp_kses_post( $before_widget );
$number = empty( $instance['number'] ) ? 3 : absint( $instance['number'] );
$thumbnail = empty( $instance['thumbnail'] ) ? 0 : absint( $instance['thumbnail'] );
$price = empty( $instance['price'] ) ? 0 : absint( $instance['price'] );
$post_type = empty( $instance['post_type'] ) ? 'product' : $instance['post_type'];
$categories = true;
if ( isset( $instance['categories'] ) ) {
$categories = empty( $instance['categories'] ) ? 0 : absint( $instance['price'] );
}
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance );
if ( $title ) {
echo wp_kses_post( $before_title ) . $title . wp_kses_post( $after_title ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
woodmart_search_form(
array(
'ajax' => true,
'count' => $number,
'thumbnail' => $thumbnail,
'show_categories' => $categories,
'post_type' => $post_type,
'price' => $price,
)
);
echo wp_kses_post( $after_widget );
}
/**
* Form.
*
* @param array $instance Instance.
*/
public function form( $instance ) { // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod
parent::form( $instance );
}
}