| Server IP : 5.129.245.98 / Your IP : 216.73.216.246 Web Server : Apache/2.4.66 (Debian) System : Linux 1b8c17c336b9 6.8.0-111-generic #111-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 11 23:16:02 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/plugins/content-egg/application/ |
Upload File : |
<?php
namespace ContentEgg\application;
defined('\ABSPATH') || exit;
use ContentEgg\application\components\CEWidget;
/**
* ProductSearchWidget class file
*
* @author keywordrush.com <support@keywordrush.com>
* @link https://www.keywordrush.com
* @copyright Copyright © 2025 keywordrush.com
*/
class ProductSearchWidget extends CEWidget
{
public function slug()
{
return 'cegg_product_search';
}
public function description()
{
return __('A search form for affiliate products.', 'content-egg');
}
protected function name()
{
return __('CE: Product Search', 'content-egg');
}
public function classname()
{
return 'widget widget_search';
}
public function settings()
{
return
array(
'title' => array(
'type' => 'text',
'default' => '',
'title' => __('Title', 'content-egg'),
),
);
}
/**
* Front-end display of widget.
*/
public function widget($args, $instance)
{
$this->beforeWidget($args, $instance);
// Use current theme search form if it exists
echo self::getSearchForm(); // phpcs:ignore
$this->afterWidget($args, $instance);
}
public static function getSearchForm()
{
$search_form_template = \locate_template('ce-product-searchform.php');
if ($search_form_template)
{
ob_start();
require($search_form_template);
$form = ob_get_clean();
}
else
{
// standart wp search from
$form = \get_search_form(false);
if (\get_option('permalink_structure'))
$form = preg_replace('/action=["\'].+?["\']/', 'action="' . self::getSearchFormUri() . '"', $form);
else
$form = preg_replace('/<\/form>/', '<input type="hidden" name="pagename" value="' . \esc_attr(ProductSearch::getPageSlug()) . '"></form>', $form);
$form = preg_replace('/placeholder=".+?"/', 'placeholder="' . esc_attr(__('Product Search...', 'content-egg-tpl')) . '"', $form);
}
return $form;
}
public static function getSearchFormUri()
{
if (\get_option('permalink_structure'))
return \esc_url(\home_url(ProductSearch::getPageSlug()));
else
return \esc_url(\home_url('/'));
}
}