Commit inicial - WordPress Análisis de Precios Unitarios

- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,134 @@
<?php
if (!class_exists("wpdreamsAnimations")) {
/**
* Class wpdreamsAnimations
*
* Creates an animation selector. The animation declarations can be found in the css/animations.css file.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2012, Ernest Marcinko
*/
class wpdreamsAnimations extends wpdreamsType {
private $animations, $selected;
function getType() {
parent::getType();
$this->processData();
echo "<div class='wpdreamsAnimations'>";
echo "<label for='wpdreamsAnimations_" . self::$_instancenumber . "'>" . $this->label . "</label>";
echo "<select isparam=1 class='wpdreamsanimationselect' id='wpdreamsanimationselect_" . self::$_instancenumber . "' name='" . $this->name . "'>";
foreach ($this->animations as $key => $animation) {
if (strpos($key, 'groupstart') !== false) {
echo "<optgroup label='" . $animation . "'>";
continue;
}
if (strpos($key, 'groupend') !== false) {
echo "</optgroup>";
continue;
}
if ($animation == $this->selected)
echo "<option value='" . $key . "' selected='selected'>" . $animation . "</option>";
else
echo "<option value='" . $key . "'>" . $animation . "</option>";
}
echo "</select>";
echo "<span>" . __('Hi there!', 'ajax-search-pro') . "</span>";
echo "<div class='triggerer'></div>
</div>";
}
function processData() {
$this->data = str_replace("\n", "", $this->data);
$this->selected = $this->data;
$this->animations = array(
"voidanim" => "No animation",
"groupstart 1" => "Simple",
"flash" => "flash",
"bounce" => "bounce",
"shake" => "shake",
"tada" => "tada",
"swing" => "swing",
"wobble" => "wobble",
"pulse" => "pulse",
"groupend 1" => "x",
"groupstart 2" => "Flippin",
"flip" => "flip",
"flipInX" => "flipInX",
"flipOutX" => "flipOutX",
"flipInY" => "flipInY",
"flipOutY" => "flipOutY",
"groupend 2" => "x",
"groupstart 3" => "Fade in",
"fadeIn" => "fadeIn",
"fadeInUp" => "fadeInUp",
"fadeInDown" => "fadeInDown",
"fadeInLeft" => "fadeInLeft",
"fadeInRight" => "fadeInRight",
"fadeInUpBig" => "fadeInUpBig",
"fadeInDownBig" => "fadeInDownBig",
"fadeInLeftBig" => "fadeInLeftBig",
"fadeInRightBig" => "fadeInRightBig",
"groupend 3" => "x",
"groupstart 4" => "Fade Out",
"fadeOut" => "fadeOut",
"fadeOutUp" => "fadeOutUp",
"fadeOutDown" => "fadeOutDown",
"fadeOutLeft" => "fadeOutLeft",
"fadeOutRight" => "fadeOutUpBig",
"fadeOutDownBig" => "fadeOutDownBig",
"fadeOutLeftBig" => "fadeOutLeftBig",
"fadeOutRightBig" => "fadeOutRightBig",
"groupend 4" => "x",
"groupstart 5" => "Bounce In",
"bounceIn" => "bounceIn",
"bounceInDown" => "bounceInDown",
"bounceInUp" => "bounceInUp",
"bounceInLeft" => "bounceInLeft",
"bounceInRight" => "bounceInRight",
"groupend 5" => "x",
"groupstart 6" => "Bounce Out",
"bounceOut" => "bounceOut",
"bounceOutDown" => "bounceOutDown",
"bounceOutUp" => "bounceOutUp",
"bounceOutLeft" => "bounceOutLeft",
"bounceOutRight" => "bounceOutRight",
"groupend 6" => "x",
"groupstart 7" => "Rotate in",
"rotateIn" => "rotateIn",
"rotateInDownLeft" => "rotateInDownLeft",
"rotateInDownRight" => "rotateInDownRight",
"rotateInUpLeft" => "rotateInUpLeft",
"rotateInUpRight" => "rotateInUpRight",
"groupend 7" => "x",
"groupstart 8" => "Rotate Out",
"rotateOut" => "rotateOut",
"rotateOutDownLeft" => "rotateOutDownLeft",
"rotateOutDownRight" => "rotateOutDownRight",
"rotateOutUpLeft" => "rotateOutUpLeft",
"rotateOutUpRight" => "rotateOutUpRight",
"groupend 8" => "x",
"groupstart 9" => "LightSpeed",
"lightSpeedIn" => "lightSpeedIn",
"lightSpeedOut" => "lightSpeedOut",
"groupend" => "x",
"groupstart" => "Special",
"hinge" => "hinge",
"rollIn" => "rollIn",
"rollOut" => "rollOut",
"groupend 9" => "x"
);
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,137 @@
<?php
if (!class_exists("wpdreamsBlogselect")) {
/**
* Class wpdreamsBlogselect
*
* Creates a blog selection drag and drop UI element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2012, Ernest Marcinko
*/
class wpdreamsBlogselect extends wpdreamsType {
private $useall = "";
private $blogs, $selected;
function getType() {
parent::getType();
$this->processData();
if ( function_exists( 'get_sites' ) ) {
$this->blogs = get_sites(array('number' => 1000));
} else {
$this->blogs = array();
}
echo "
<div class='wpdreamsBlogselect' id='wpdreamsBlogselect" . self::$_instancenumber . "'>
<fieldset>
<legend>" . $this->label . "</legend>";
echo "<div style='text-align:left; margin: 10px 38px;'><label>" . __('Use all blogs?', 'ajax-search-pro') . " <input type='checkbox' class='use-all-blogs' ".$this->useall."></label></div>";
echo "<div class='bs-cont'>";
if ($this->useall != "")
echo "<div class='bs-overlay'></div>";
else
echo "<div class='bs-overlay hiddend'></div>";
echo '<div class="sortablecontainer"><p>' . __('Available blogs', 'ajax-search-pro') . '</p><ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
if ( !is_wp_error($this->blogs) ) {
foreach ($this->blogs as $k => $blog) {
if ( $this->selected == null || !in_array($blog->id, $this->selected) ) {
echo '<li class="ui-state-default" bid="' . $blog->id . '">' . $blog->blogname . '</li>';
}
}
}
echo "</ul></div>";
echo '<div class="sortablecontainer"><p>' . __('Drag here the blogs you want to use!', 'ajax-search-pro') . '</p><ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">';
if ( $this->selected != null && count($this->selected)>0 && function_exists('get_blog_details') ) {
foreach ($this->selected as $k => $v) {
$blog = get_blog_details($v);
if ( !is_wp_error($blog) && isset($blog->blogname) ) {
echo '<li class="ui-state-default" bid="' . $v . '">' . $blog->blogname . '</li>';
}
}
}
echo "</ul></div><div class='clear'></div>";
echo "</div>";
echo "
<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>";
echo "
<input type='hidden' value='wpdreamsBlogselect' name='classname-" . $this->name . "'>";
?>
<script>
(function ($) {
$(document).ready(function () {
var selector = "#sortable<?php echo self::$_instancenumber ?>, #sortable_conn<?php echo self::$_instancenumber ?>";
$(selector).sortable({
connectWith: ".connectedSortable"
}, {
update: function (event, ui) {
}
}).disableSelection();
$(selector).on('sortupdate', function(event, ui) {
if (typeof ui !== 'undefined')
parent = $(ui.item).parent();
else
parent = $(event.target);
while ( !parent.hasClass('wpdreamsBlogselect') ) {
parent = $(parent).parent();
}
var items = $('ul[id*=sortable_conn] li', parent);
var hidden = $('input[name=<?php echo $this->name; ?>]', parent);
var checkbox = $('.use-all-blogs', parent);
var val = "";
items.each(function () {
val += "|" + $(this).attr('bid');
});
if (checkbox.prop('checked')) {
val = val.substring(1) + "xxx1";
$('.bs-overlay', parent).removeClass('hiddend');
} else {
val = val.substring(1);
$('.bs-overlay', parent).addClass('hiddend');
}
hidden.val(val);
});
$("#wpdreamsBlogselect<?php echo self::$_instancenumber ?> input.use-all-blogs").on('click', function(){
$(selector).trigger("sortupdate");
});
});
}(jQuery));
</script>
<?php
echo "
</fieldset>
</div>";
}
function processData() {
$this->data = str_replace("\n", "", $this->data);
$this->selected = null;
if (!empty($this->data)) {
// Check for the use-all checkbox
$tmp = explode( "xxx", $this->data );
if (isset($tmp[1]))
$this->useall = "checked='checked'";
// Get the selected IDs
if ($tmp[0] != "")
$this->selected = explode( "|", $tmp[0] );
} else {
$this->useall = "";
}
}
final function getData() {
return $this->data;
}
final function getSelected() {
if ($this->useall != '')
return "all";
return $this->selected;
}
}
}

View File

@@ -0,0 +1,82 @@
<?php
if (!class_exists("wpdreamsBorder")) {
/**
* Class wpdreamsBorder
*
* Creates a CSS border defining element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsBorder extends wpdreamsType {
private $topleft;
private $topright;
private $bottomright;
private $bottomleft;
private $color;
private $width;
private $style;
private $border_styles = array(
'none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'
);
function getType() {
parent::getType();
$this->processData();
?>
<div class='wpdreamsBorder'>
<fieldset>
<legend><?php echo $this->label; ?></legend>
<div class="item-flex">
<div>
<label><?php echo __('Style', 'ajax-search-pro'); ?><select class='smaller _xx_style_xx_'>
<?php foreach($this->border_styles as $option): ?>
<option value="<?php echo $option; ?>"<?php echo $this->style == $option ? ' selected="selected"' : ''; ?>><?php echo $option; ?></option>
<?php endforeach; ?>
</select></label>
</div>
<div class="wpd_br_to_disable">
<label><?php echo __('Width', 'ajax-search-pro'); ?>
<input type='text' class='twodigit _xx_width_xx_' value="<?php echo $this->width; ?>"/>px
</label>
<?php new wpdreamsColorPickerDummy("", "Color", (isset($this->color) ? $this->color : "#000000")); ?>
</div>
<fieldset class="wpd_border_radius">
<legend><?php echo __('Border Radius', 'ajax-search-pro'); ?></legend>
<label><?php echo __('Top left', 'ajax-search-pro'); ?><input type='text' class='twodigit _xx_topleft_xx_' value="<?php echo $this->topleft; ?>" />px</label>
<label><?php echo __('Top right', 'ajax-search-pro'); ?><input type='text' class='twodigit _xx_topright_xx_' value="<?php echo $this->topright; ?>" />px</label><br>
<label><?php echo __('Bottom right', 'ajax-search-pro'); ?><input type='text' class='twodigit _xx_bottomright_xx_' value="<?php echo $this->bottomright; ?>" />px</label>
<label><?php echo __('Bottom left', 'ajax-search-pro'); ?><input type='text' class='twodigit _xx_bottomleft_xx_' value="<?php echo $this->bottomleft; ?>" />px</label>
</fieldset>
</div>
</fieldset>
<input isparam=1 type='hidden' value="<?php echo $this->data; ?>" name="<?php echo $this->name; ?>">
<div class='triggerer'></div>
</div>
<?php
}
function processData() {
$this->data = str_replace("\n", "", $this->data);
preg_match("/border-radius:(.*?)px(.*?)px(.*?)px(.*?)px;/", $this->data, $matches);
$this->topleft = $matches[1];
$this->topright = $matches[2];
$this->bottomright = $matches[3];
$this->bottomleft = $matches[4];
preg_match("/border:(.*?)px (.*?) (.*?);/", $this->data, $matches);
$this->width = $matches[1];
$this->style = $matches[2];
$this->color = $matches[3];
}
final function getData() {
return $this->data;
}
}
}

View File

@@ -0,0 +1,81 @@
<?php
if (!class_exists("wpdreamsBoxShadow")) {
/**
* Class wpdreamsBoxShadow
*
* Creates a CSS box-shadow defining element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2018, Ernest Marcinko
*/
class wpdreamsBoxShadow extends wpdreamsType {
private $color;
private $inset;
private $hlength;
private $vlength;
private $blurradius;
private $spread;
private $shadow_styles = array(
array('inset', 'Inset'),
array('', 'None')
);
function getType() {
parent::getType();
$this->processData();
?>
<div class='wpdreamsBoxShadow'>
<fieldset>
<legend><?php echo $this->label; ?></legend>
<div class="item-flex">
<div>
<label><?php echo __('Style', 'ajax-search-pro'); ?><select class='smaller _xx_inset_xx_'>
<?php foreach($this->shadow_styles as $option): ?>
<option value="<?php echo $option[0]; ?>"<?php echo $this->inset == $option[0] ? ' selected="selected"' : ''; ?>><?php echo $option[1]; ?></option>
<?php endforeach; ?>
</select></label>
<?php new wpdreamsColorPickerDummy("", "Color", (isset($this->color) ? $this->color : "#000000")); ?>
</div>
<fieldset class="wpd_shadow_size">
<legend><?php echo __('Shadow size', 'ajax-search-pro'); ?></legend>
<label><?php echo __('Horizontal offset', 'ajax-search-pro'); ?><input type='text' class='twodigit _xx_hlength_xx_' value="<?php echo $this->hlength; ?>" />px</label>
<label><?php echo __('Vertical offset', 'ajax-search-pro'); ?><input type='text' class='twodigit _xx_vlength_xx_' value="<?php echo $this->vlength; ?>" />px</label><br>
<label><?php echo __('Blur radius', 'ajax-search-pro'); ?><input type='text' class='twodigit _xx_blurradius_xx_' value="<?php echo $this->blurradius; ?>" />px</label>
<label><?php echo __('Spread', 'ajax-search-pro'); ?><input type='text' class='twodigit _xx_spread_xx_' value="<?php echo $this->spread; ?>" />px</label>
</fieldset>
</div>
</fieldset>
<input isparam=1 type='hidden' value="<?php echo $this->data; ?>" name="<?php echo $this->name; ?>">
<div class='triggerer'></div>
</div>
<?php
}
function processData() {
$this->data = str_replace("\n", "", $this->data);
preg_match("/box-shadow:(.*?)px (.*?)px (.*?)px (.*?)px (.*?);/", $this->data, $matches);
$ci = $matches[5];
preg_match("/(.*?) inset/", $ci, $_matches);
if ($_matches != null && isset($_matches[1])) {
$this->color = $_matches[1];
$this->inset = "inset";
} else {
$this->color = $ci;
$this->inset = "";
}
$this->hlength = $matches[1];
$this->vlength = $matches[2];
$this->blurradius = $matches[3];
$this->spread = $matches[4];
}
final function getData() {
return $this->data;
}
}
}

View File

@@ -0,0 +1,92 @@
<?php
if (!class_exists("wpdreamsBP_XProfileFields")) {
/**
* Class wpdreamsBP_XProfileFields
*
* Creates a BuddyPress profile fields selector UI element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsBP_XProfileFields extends wpdreamsType {
private $selected;
private $types;
function getType() {
$profile_fields = $this->getProfileFields();
$pf_array = array();
foreach ($profile_fields as $pf)
$pf_array[$pf->id] = $pf;
parent::getType();
$this->processData();
$this->types = $profile_fields;
echo "
<div class='wpdreamsBP_XProfileFields' id='wpdreamsBP_XProfileFields-" . self::$_instancenumber . "'>
<fieldset>
<legend>" . $this->label . "</legend>";
echo '<div class="sortablecontainer" id="sortablecontainer' . self::$_instancenumber . '">
<div class="arrow-all-left"></div>
<div class="arrow-all-right"></div>
' . __('Available profile fields', 'ajax-search-pro') . '<ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->types != null && is_array($this->types)) {
foreach ($this->types as $k => $v) {
if ($this->selected == null || !in_array($v->id, $this->selected)) {
echo '<li class="ui-state-default" bid="' . $v->id . '">' . $v->name . '</li>';
}
}
}
echo "</ul></div>";
echo '<div class="sortablecontainer">' . __('Drag here the fields you want to search!', 'ajax-search-pro') . '<ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->selected != null && is_array($this->selected)) {
foreach ($this->selected as $k => $v) {
if ( isset($pf_array[$v]) ) {
echo '<li class="ui-state-default" bid="' . $pf_array[$v]->id . '">' . $pf_array[$v]->name . '</li>';
}
}
}
echo "</ul></div>";
echo "
<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>";
echo "
<input type='hidden' value='wpdreamsBP_XProfileFields' name='classname-" . $this->name . "'>";
echo "
</fieldset>
</div>";
}
function getProfileFields() {
global $wpdb;
$table_name = $wpdb->base_prefix . "bp_xprofile_fields";
if( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name )
return $wpdb->get_results(
"SELECT * FROM $table_name LIMIT 200"
);
else
return array();
}
function processData() {
$this->data = str_replace("\n", "", $this->data);
if ($this->data != "")
$this->selected = explode("|", $this->data);
else
$this->selected = null;
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,415 @@
<?php
use WPDRMS\ASP\Utils\Script;
defined('ABSPATH') or die("You can't access this file directly.");
if ( !class_exists("wd_frontFilters") ) {
class wd_frontFilters extends wpdreamsType {
/* Data structure actually used in the output option */
private static $default_data = array(
// The column options
'columns' => array(),
// Array of active filters
'filters' => array(/*
array(
'module_name' => 'generic',
'data' => array(..)
),
...
*/),
);
/* Additional default data, not used in the output */
private static $default_data_addition = array(
// Each item in the array of active filters
'columns_item' => array(
'min-width'=> '180px',
'max-width'=> '320px'
),
// Each item in the array of active filters
'filters_item' => array(
'module_name' => 'generic',
'data' => array()
),
);
private $processed_data;
private $version = '1.0'; // Used in CSS and JS enqueue
private $css_files = array(
array(
'handle' => 'wd-ff-main-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/css/main.css'
)
);
private $js_files = array(
array(
'handle' => 'wd-ff-main-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/js/main.js',
'dependencies' => array('jquery')
)
);
private static $default = array(
// Content type filter defaults
'content_type' => array(
'option' => array(
'label' => 'Filter by content type',
'display_mode' => 'checkboxes',
'items' => array(),
'required' => false,
'required_text' => 'Please select an option!'
),
'item' => array(
'label' => '',
'selected' => false,
'id' => 0, // Can be numeric, as well as a field name etc..
'level' => 0,
'default' => false
),
'choices' => array(
-1 => 'Choose One/Select all',
'cpt' => 'Custom post types',
'comments' => 'Comments',
'taxonomies' => 'Taxonomy terms',
'users' => 'Users',
'blogs' => 'Multisite blogs',
'buddypress' => 'BuddyPress content',
'attachments' => 'Attachments'
)
),
// Post type filter defaults
'post_type' => array(
'option' => array(
'label' => 'Filter by Custom Post Type',
'display_mode' => 'checkboxes',
'items' => array(),
'required' => false,
'required_text' => 'Please select an option!'
),
'item' => array(
'label' => '',
'selected' => false,
'id' => 0, // Can be numeric, as well as a field name etc..
'level' => 0,
'default' => false
),
'choices' => array(
-1 => 'Choose One/Select all',
'post' => 'Posts',
'pages' => 'Pages'
)
),
// From date filter defaults
'date_from' => array(
'option' => array(
'label' => 'Content from',
'placeholder' => 'Choose date',
'required' => false,
'required_text' => 'Please select an option!',
'date_format' => 'dd-mm-yy',
'date_type' => 'relative_date', // date or relative_date
'date' => '2020-01-01',
'relative_date' => array(2,0,0) // Y, M, D before current
)
),
// To date filter defaults
'date_to' => array(
'option' => array(
'label' => 'Content to',
'placeholder' => 'Choose date',
'required' => false,
'required_text' => 'Please select an option!',
'date_format' => 'dd-mm-yy',
'date_type' => 'relative_date', // date or relative_date
'date' => '2020-01-01',
'relative_date' => array(0,0,0) // Y, M, D before current
)
),
'taxonomy' => array(
'option' => array(
'label' => 'Filter by Categories',
'display_mode' => 'checkboxes',
'display_mode_args' => array(),
'type' => 'exclude', // include (exclude all, include selected), exclude (include all, exclude selected)
'items' => array(),
'taxonomy' => 'category',
'required' => false,
'required_text' => 'Please select an option!',
'hide_empty' => false,
'maintain_hierarchy' => true,
'term_orderby' => 'name', //name, count, ID,
'term_order' => 'ASC', // ASC DESC,
'allow_empty' => false // allow results where the terms are not associated with the post type object
),
'display_mode_args' => array(
'checkboxes' => array(
'default_state' => 'unchecked', // checked, unchecked
'hide_children_on_unchecked' => true
)
),
'item' => array(
'label' => '',
'selected' => false,
'id' => 0, // Can be numeric, as well as a field name etc..
'level' => 0,
'default' => false
),
'choices' => array(
-1 => 'Choose One/Select all',
0 => 'Display all from taxonomy'
)
),
// Custom field filter defaults
'custom_field' => array(
'option' => array(
'label' => 'Filter by Custom Field',
'display_mode' => 'checkboxes',
'display_mode_args' => array(),
'items' => array(),
'field' => 'field_name',
'field_source' => 'postmeta', // postmeta, usermeta
'operator' => 'like',
'required' => false,
'required_text' => 'Please select an option!',
'allow_empty' => false // allow results where the field is not associated with the post type object
),
'display_mode_args' => array(
'checkboxes' => array(
'logic' => 'OR', // OR, AND
'hide_children_on_unchecked' => true
),
'dropdown' => array(
'placeholder' => '',
'logic' => 'OR', // OR, AND, ANDSE
'multiple' => false
),
'dropdownsearch' => array(
'placeholder' => ''
),
'multisearch' => array(
'placeholder' => ''
),
'slider' => array(
'slider_prefix' => '-,',
'slider_suffix' => '.',
'slider_step' => 1,
'slider_from' => 1,
'slider_to' => 1000,
'slider_decimals' => 0,
'slider_t_separator' => ' ',
'operator' => 'let'
),
'range' => array(
'range_prefix' => '-,',
'range_suffix' => '.',
'range_step' => 1,
'range_from' => 1,
'range_to' => 1000,
'range_decimals' => 0,
'range_t_separator' => ' '
),
'datepicker' => array(
'placeholder' => '',
'date_format' => 'dd/mm/yy',
'date_store_format' => 'datetime' // datetime, acf, timestamp
),
),
'item' => array(
'label' => '',
'selected' => false,
'id' => 0, // Can be numeric, as well as a field name etc..
'level' => 0,
'default' => false
),
'choices' => array(
-1 => 'Choose One/Select all'
)
),
'button' => array(
'option' => array(
'label' => 'Reset',
'type' => 'reset' // reset, search
),
)
);
private static $core_modules = array(
'WD_FrontFilters_Module_Abstract' => array(
'name' => 'abstract',
'file' => 'class-abstract.php'
),
'WD_FrontFilters_Module_Generic' => array(
'name' => 'generic', // must be the same as the module name (new Module_Class)->name
'file' => 'class-generic.php'
),
'WD_FrontFilters_Module_DateFrom' => array(
'name' => 'date_from',
'file' => 'class-date-from.php'
),
'WD_FrontFilters_Module_DateTo' => array(
'name' => 'date_to',
'file' => 'class-date-to.php'
),
'WD_FrontFilters_Module_ContentType' => array(
'name' => 'content_type',
'file' => 'class-content-type.php'
),
'WD_FrontFilters_Module_PostType' => array(
'name' => 'post_type',
'file' => 'class-post-type.php'
),
'WD_FrontFilters_Module_Taxonomy' => array(
'name' => 'taxonomy',
'file' => 'class-taxonomy.php'
)
);
private static $core_modules_noinit = array(
'WD_FrontFilters_Module_Abstract'
);
private $modules = array();
public function getType() {
spl_autoload_register(array(static::class, 'autoload'));
parent::getType();
$this->processData();
// Modules
try {
foreach ( array_diff(array_keys(self::$core_modules), self::$core_modules_noinit) as $module ) {
$o = new $module;
if ( !isset($this->modules[$o->getType()]) ) {
$this->modules[$o->getType()] = $o;
} else {
throw new Exception('Module with name ' . $o->getType() . ' already exists.');
}
}
} catch (Exception $e) {
echo $e->getMessage();
}
$this->loadAssets();
// Output
ob_start();
include('wd_frontfilters/views/wd-frontfilters.php');
echo ob_get_clean();
}
public static function autoload( $class ) {
if ( isset(self::$core_modules[$class]) ) {
include_once('wd_frontfilters/modules/' . self::$core_modules[$class]['file']);
}
}
public static function manualLoad() {
if ( wd_asp()->manager->getContext() == 'special' ) {
foreach (self::$core_modules as $class => $data) {
include_once('wd_frontfilters/modules/' . self::$core_modules[$class]['file']);
$class::ajax();
}
}
}
public static function getDataByOptions( $options = array() ) {
spl_autoload_register(array(static::class, 'autoload'));
$return = array_merge(self::$default_data, $options);
// Column data
foreach ( $return['columns'] as &$column ) {
$column = array_merge(self::$default_data_addition['columns_item'], $column);
}
// Module data
foreach ( $return['filters'] as &$filter ) {
$filter = array_merge(self::$default_data_addition['filters_item'], $filter);
foreach ( self::$core_modules as $class => $module ) {
if ( $module['name'] == $filter['module_name'] ) {
$filter['data'] = $class::getData($filter['data']);
break;
}
}
}
return $return;
}
public static function getFiltersByOptions( $options = array(), $column = false, $parse = true ) {
if ( $parse ) {
$options = static::getDataByOptions( $options );
}
if ( $column === false ) {
return $options['filters'];
} else {
$filters = array();
foreach ( $options['filters'] as $filter ) {
if ( $filter['column'] == $column ) {
$filters[] = $filter;
}
}
return $filters;
}
}
public function getFilters( $column = false ) {
if ( $column === false ) {
return $this->processed_data['filters'];
} else {
$filters = array();
foreach ( $this->processed_data['filters'] as $filter ) {
if ( $filter['column'] == $column ) {
$filters[] = $filter;
}
}
return $filters;
}
}
private function getModules() {
return $this->modules;
}
private function loadAssets(){
foreach ( $this->css_files as $css ) {
$css = array_merge(array(
'dependencies' => array(),
'version' => 1,
'media' => 'all'
), $css);
wp_enqueue_style($css['handle'], $css['file'], $css['dependencies'], $this->version, $css['media']);
}
foreach ( $this->js_files as $js ) {
$js = array_merge(array(
'dependencies' => array(),
'version' => 1,
'in_footer' => true
), $js);
wp_enqueue_script($js['handle'], $js['file'], $js['dependencies'], $this->version, $js['in_footer']);
}
$modules_default = array();
foreach ( $this->modules as $module ) {
$modules_default[$module->getType()] = array(
'data' => $module->getData(array(), true)
);
}
Script::objectToInlineScript('wd-ff-main-module', 'WD_FrontFilters', array(
'modulesDefault' => $modules_default
));
}
private function processData() {
// Make sure that the correct variables are used
$this->processed_data = static::getDataByOptions( $this->decode_param($this->data) );
$this->data = $this->encode_param($this->processed_data);
}
}
// Trigger manual loader of module clases, in case of Ajax Requests
wd_frontFilters::manualLoad();
}

View File

@@ -0,0 +1,26 @@
<?php
if (!class_exists("wpdreamsColorPicker")) {
/**
* Class wpdreamsColorPicker
*
* A simple color picker UI.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsColorPicker extends wpdreamsType {
function getType() {
parent::getType();
$this->data = wpdreams_admin_hex2rgb($this->data);
echo "<div class='wpdreamsColorPicker'>";
if ($this->label != "")
echo "<label for='wpdreamscolorpicker_" . self::$_instancenumber . "'>" . $this->label . "</label>";
echo "<input isparam=1 type='text' class='color' id='" . $this->name . "' id='wpdreamscolorpicker_" . self::$_instancenumber . "' name='" . $this->name . "' id='wpdreamscolorpicker_" . self::$_instancenumber . "' value='" . $this->data . "' />";
echo "<div class='triggerer'></div>
</div>";
}
}
}

View File

@@ -0,0 +1,27 @@
<?php
if (!class_exists("wpdreamsColorPickerDummy")) {
/**
* Class wpdreamsColorPickerDummy
*
* A dummy colorpicker for using inside other elements. This does not have a frontend trigger method,
* so it can't be changed by the themeChooser class.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsColorPickerDummy extends wpdreamsType {
function getType() {
$this->data = wpdreams_admin_hex2rgb($this->data);
$this->name = $this->name . "_colorpicker";
echo "<span class='wpdreamsColorPicker'>";
if ($this->label != "")
echo "<label for='wpdreamscolorpicker_" . self::$_instancenumber . "'>" . $this->label . "</label>";
echo "<input type='text' class='color' id='wpdreamscolorpicker_" . self::$_instancenumber . "' name='" . $this->name . "' value='" . $this->data . "' />";
echo "<div class='triggerer'></div>
</span>";
}
}
}

View File

@@ -0,0 +1,74 @@
<?php
if (!class_exists("wpdreamsCustomArraySelect")) {
/**
* Class wpdreamsCustomArraySelect
*
* A customisable drop down UI element, supports multiple select boxes chained.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsCustomArraySelect extends wpdreamsType {
private $optionsArr = array();
private $selectedArr = array();
function getType() {
parent::getType();
$this->processData();
echo "<div class='wpdreamsCustomArraySelect'>";
foreach ($this->optionsArr as $k => $options) {
// label for each box
if ( is_array($this->label) && $this->label[$k] != '' )
echo "<label for='" .$k. "wpdreamscustomarrayselect_" . self::$_instancenumber . "'>" . $this->label[$k] . "</label>";
// this is not the parameter, its just a dummy
echo "<select class='wpdreamscustomarrayselect' id='" .$k. "wpdreamscustomarrayselect_" . self::$_instancenumber . "' name='dummy-" . $this->name . "'>";
foreach ($options as $kk => $option) {
if (($option['value'] . "") == ($this->selectedArr[$k] . ""))
echo "<option value='" . $option['value'] . "' selected='selected'>" . $option['option'] . "</option>";
else
echo "<option value='" . $option['value'] . "'>" . $option['option'] . "</option>";
}
echo "</select>";
}
echo "
<input type='hidden' isparam=1 name='" . $this->name . "' value='".$this->data."' />
<input type='hidden' value='wpdreamsCustomArraySelect' name='classname-" . $this->name . "'>
</div>";
}
function processData() {
if ( is_array($this->data) ) {
// invoked on the backend
$this->optionsArr = $this->data['optionsArr'];
$this->selectedArr = explode('||', $this->data['value']);
// change the data to the actual value
$this->data = $this->data['value'];
} else {
// invoked by wpdreams_parse_params(), when saving
$this->selectedArr = explode('||', $this->data);
}
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selectedArr;
}
}
}

View File

@@ -0,0 +1,84 @@
<?php
if (!class_exists("wpdreamsCustomFields")) {
/**
* Class wpdreamsCustomFields
*
* A custom field selector UI element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsCustomFields extends wpdreamsType {
private $selected;
private $args = array(
"show_pods" => false
);
function getType() {
parent::getType();
$this->processData();
$inst = self::$_instancenumber; // Need this, as the static variable is overwritten when the callback is created
echo "
<div class='wpdreamsCustomFields' id='wpdreamsCustomFields-" . $inst . "'>
<fieldset>
<legend>" . $this->label . "</legend>";
echo '<div class="draggablecontainer" id="draggablecontainer' . $inst . '">
<div class="arrow-all-left"></div>
<div class="arrow-all-right"></div><div style="margin: -3px 0 5px -5px;">';
new wd_CFSearchCallBack('wdcfs_' . $inst, '',
array(
'value' => '',
'args' => array(
'callback' => 'wd_cf_ajax_callback',
'show_pods' => $this->args['show_pods'],
'limit' => 40
)
)
);
echo '</div><ul id="sortable' . $inst . '" class="connectedSortable">
' . __('Use the search bar above to look for custom fields', 'ajax-search-pro') . '
</ul></div>
<div class="sortablecontainer"><p>' . __('Drag here the custom fields you want to use!', 'ajax-search-pro') . '</p><ul id="sortable_conn' . $inst . '" class="connectedSortable">';
if ($this->selected != null && is_array($this->selected)) {
foreach ($this->selected as $k => $v) {
echo '<li class="ui-state-default" cf_name="' . $v . '">' . str_replace('__pods__', '[PODs] ', $v) . '<a class="deleteIcon"></a></li>';
}
}
echo "</ul></div>
<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>
<input type='hidden' value='wpdreamsCustomFields' name='classname-" . $this->name . "'>
</fieldset>
</div>";
}
function processData() {
if ( is_array($this->data) ) {
$this->args = array_merge($this->args, $this->data);
if ( isset($this->data['value']) ) {
// If called from back-end non-post context
$this->data = $this->data['value'];
}
}
$this->data = str_replace("\n", "", $this->data);
if ($this->data != "")
$this->selected = explode("|", $this->data);
else
$this->selected = null;
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,71 @@
<?php
if (!class_exists("wpdreamsCustomPostTypesAll")) {
/**
* Class wpdreamsCustomPostTypesAll
*
* A custom post types selector UI element with.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsCustomPostTypesAll extends wpdreamsType {
private $selected;
private $types;
function getType() {
parent::getType();
$this->processData();
$this->types = get_post_types();
echo "
<div class='wpdreamsCustomPostTypesAll' id='wpdreamsCustomPostTypesAll-" . self::$_instancenumber . "'>
<fieldset>
<legend>" . $this->label . "</legend>";
echo '<div class="sortablecontainer" id="sortablecontainer' . self::$_instancenumber . '">
<div class="arrow-all-left"></div>
<div class="arrow-all-right"></div>
<p>' . __('Available post types', 'ajax-search-pro') . '</p><ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->types != null && is_array($this->types)) {
foreach ($this->types as $k => $v) {
if ($this->selected == null || !in_array($v, $this->selected)) {
echo '<li class="ui-state-default">' . $k . '</li>';
}
}
}
echo "</ul></div>";
echo '<div class="sortablecontainer"><p>' . __('Drag here the post types you want to use!', 'ajax-search-pro') . '</p>
<ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->selected != null && is_array($this->selected)) {
foreach ($this->selected as $k => $v) {
echo '<li class="ui-state-default">' . $v . '</li>';
}
}
echo "</ul></div>";
echo "
<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>";
echo "
<input type='hidden' value='wpdreamsCustomPostTypesAll' name='classname-" . $this->name . "'>";
echo "
</fieldset>
</div>";
}
function processData() {
$this->data = str_replace("\n", "", $this->data);
if ($this->data != "")
$this->selected = explode("|", $this->data);
else
$this->selected = null;
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,111 @@
<?php
if ( !class_exists('wpdreamsCustomPostTypes') ) {
/**
* Class wpdreamsCustomPostTypes
*
* A custom post types selector UI element with.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2017, Ernest Marcinko
*/
class wpdreamsCustomPostTypes extends wpdreamsType {
private $types = array();
private $selected = array();
private $args = array(
'exclude' => array(),
'include' => array(),
);
function getType() {
parent::getType();
$this->processData();
echo "
<div class='wpdreamsCustomPostTypes' id='wpdreamsCustomPostTypes-" . self::$_instancenumber . "'>
<fieldset>
<legend>" . $this->label . '</legend>';
echo '<div class="sortablecontainer" id="sortablecontainer' . self::$_instancenumber . '">
<div class="arrow-all-left"></div>
<div class="arrow-all-right"></div>
<p>' . __('Available post types', 'ajax-search-pro') . '</p><ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
if ( $this->types != null && is_array($this->types) ) {
foreach ( $this->types as $k => $v ) {
if ( $this->selected == null || !in_array($k, $this->selected) ) {
echo '<li class="ui-state-default" data-ptype="' . $k . '">'
. $v->labels->name .
'<span class="extra_info">[' . $k . ']</span></li>';
}
}
}
echo '</ul></div>';
echo '<div class="sortablecontainer"><p>' . __('Drag here the post types you want to use!', 'ajax-search-pro') . '</p>
<ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">';
if ( $this->selected != null && is_array($this->selected) ) {
foreach ( $this->selected as $k => $v ) {
if ( isset($this->types[ trim($v) ]) ) {
echo '<li class="ui-state-default" data-ptype="' . $v . '">'
. $this->types[ trim($v) ]->labels->name .
'<span class="extra_info">[' . $v . ']</span></li>';
}
}
}
echo '</ul></div>';
echo "<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>";
echo "<input type='hidden' value='wpdreamsCustomPostTypes' name='classname-" . $this->name . "'>";
echo '
</fieldset>
</div>';
}
function processData() {
// Get the args first if exists
if ( is_array($this->data) && isset($this->data['args']) ) {
$this->args = array_merge($this->args, $this->data['args']);
}
$this->args['exclude'] = array_unique(
array_merge($this->args['exclude'], self::NON_DISPLAYABLE_POST_TYPES)
);
if ( !empty($this->args['exclude']) && !empty($this->args['include']) ) {
$this->args['exclude'] = array_diff($this->args['exclude'], $this->args['include']);
}
$this->getPostTypes();
if ( is_array($this->data) && isset($this->data['value']) ) {
// If called from back-end non-post context
$this->selected = $this->decode_param($this->data['value']);
$this->data = $this->encode_param($this->data['value']);
} else {
// POST method or something else
$this->selected = $this->decode_param($this->data);
$this->data = $this->encode_param($this->data);
}
}
private function getPostTypes() {
$this->types = get_post_types('', 'objects');
foreach ( $this->types as $k => &$v ) {
if ( count($this->args['exclude']) > 0 && in_array($k, $this->args['exclude']) ) {
unset($this->types[ $k ]);
continue;
}
if ( $k == 'attachment' ) {
$v->labels->name = 'Attachment - Media';
}
}
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,91 @@
<?php
if ( !class_exists('wpdreamsCustomPostTypesEditable') ) {
/**
* Class wpdreamsCustomPostTypesEditable
*
* A custom post types selector UI element with editable titles.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsCustomPostTypesEditable extends wpdreamsType {
private $selected, $_t, $types;
function getType() {
parent::getType();
$this->processData();
echo "
<div class='wpdreamsCustomPostTypesEditable' id='wpdreamsCustomPostTypesEditable-" . self::$_instancenumber . "'>
<fieldset>
<legend>" . $this->label . '</legend>';
echo '<div class="sortablecontainer" id="sortablecontainer' . self::$_instancenumber . '">
<p>' . __('Available post types', 'ajax-search-pro') . '</p><ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
if ( $this->types != null && is_array($this->types) ) {
foreach ( $this->types as $k => $v ) {
if ( $this->selected == null || !wd_in_array_r($v, $this->selected) ) {
echo '<li class="ui-state-default ui-left" style="background: #ddd;">
<label>' . $k . '</label>
<input type="text" value="' . $v->label . '"/>
</li>';
}
}
}
echo '</ul></div>';
echo '<div class="sortablecontainer"><p>' . __('Drag here the post types you want to use!', 'ajax-search-pro') . '</p>
<ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">';
if ( $this->selected != null && is_array($this->selected) ) {
foreach ( $this->selected as $k => $v ) {
echo '<li class="ui-state-default ui-left" style="background: #ddd;">
<label>' . esc_html($v[0]) . '</label>
<input type="text" value="' . esc_attr($v[1]) . '"/>
</li>';
}
}
echo '</ul></div>';
echo "
<input isparam=1 type='hidden' value='" . esc_attr($this->data) . "' name='" . $this->name . "'>";
echo "
<input type='hidden' value='wpdreamsCustomPostTypesEditable' name='classname-" . $this->name . "'>";
echo '
</fieldset>
</div>';
}
function processData() {
$this->data = stripslashes(str_replace("\n", '', $this->data));
if ( $this->data != '' ) {
$this->_t = explode('|', $this->data);
foreach ( $this->_t as $k => $v ) {
$this->selected[] = explode(';', $v);
}
} else {
$this->selected = null;
}
$this->types = get_post_types(
array(
'public' => true,
'_builtin' => false,
),
'objects',
'OR'
);
foreach ( $this->types as $k => $v ) {
if ( in_array($k, self::NON_DISPLAYABLE_POST_TYPES) ) {
unset($this->types[ $k ]);
}
}
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,72 @@
<?php /** @noinspection PhpMultipleClassDeclarationsInspection */
if (!class_exists("wpdreamsCustomSelect")) {
/**
* Class wpdreamsCustomSelect
*
* A customisable dropdown UI element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsCustomSelect extends wpdreamsType {
private $selects, $selected, $iconMsg, $icon = 'none';
public function getType() {
parent::getType();
$this->processData();
echo "<div class='wpdreamsCustomSelect'>";
echo "<label for='wpdreamscustomselect_" . self::$_instancenumber . "'>" . $this->label . "</label>";
if ( $this->icon != 'none' ) {
?>
<span
title="<?php echo $this->iconMsg[$this->icon] ?? ''; ?>"
class="wpd-txt-small-icon wpd-txt-small-icon-<?php echo $this->icon ?>">
</span>
<?php
}
echo "<select isparam=1 class='wpdreamscustomselect' id='wpdreamscustomselect_" . self::$_instancenumber . "' name='" . $this->name . "'>";
foreach ($this->selects as $sel) {
$disabled = isset($sel['disabled']) ? ' disabled' : '';
if (is_array($sel)) {
if (($sel['value'] . "") == ($this->selected . ""))
echo "<option value='" . $sel['value'] . "' selected='selected'" . $disabled . ">" . $sel['option'] . "</option>";
else
echo "<option value='" . $sel['value'] . "'>" . $sel['option'] . "</option>";
} else {
if (($sel . "") == ($this->selected . ""))
echo "<option value='" . $sel . "' selected='selected'>" . $sel . "</option>";
else
echo "<option value='" . $sel . "'>" . $sel . "</option>";
}
}
echo "</select>";
echo "<div class='triggerer'></div>
</div>";
}
public function processData() {
$this->iconMsg = array(
'phone' => __('Phone devices, on 0px to 640px widths', 'ajax-search-pro'),
'tablet' => __('Tablet devices, on 641px to 1024px widths', 'ajax-search-pro'),
'desktop' => __('Desktop devices, 1025px width and higher', 'ajax-search-pro')
);
$this->selects = array();
$this->icon = $this->data['icon'] ?? $this->icon;
$this->selects = $this->data['selects'];
$this->selected = $this->data['value'];
}
public final function getData() {
return $this->data;
}
public final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,88 @@
<?php
if (!class_exists("wd_DateFilterPost")) {
/**
* Class wd_DateFilter
*
* Displays a date filter configuration element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/wpdreams/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_DateFilterPost extends wpdreamsType {
protected $raw, $selected;
function getType() {
parent::getType();
$this->processData();
?>
<div class="wd_DateFilter" id="wd_DateFilter-<?php echo self::$_instancenumber; ?>">
<div class="wd_col_40"></div>
<div class="wd_col_60" style="line-height: 33px; vertical-align: top;">
<label><?php echo $this->label; ?>aa</label>
<select aria-label="<?php echo __('Date type', 'ajax-search-pro'); ?>" class="wd_di_state">
<option value="date"><?php echo __('Date', 'ajax-search-pro'); ?></option>
<option value="rel_date"><?php echo __('Relative Date', 'ajax-search-pro'); ?></option>
<option value="earliest_date"><?php echo __('Earliest Post Date', 'ajax-search-pro'); ?></option>
<option value="latest_date"><?php echo __('Latest Post Date', 'ajax-search-pro'); ?></option>
<option value="disabled"><?php echo __('Disabled', 'ajax-search-pro'); ?></option>
</select><br>
<div class="wd_di_date" style="display: inline;">
<input type="text" class="wd_di_date"/>
<p class="descMsg">
<?php echo __('Empty value can be used, in that case the placeholder text will appear.', 'ajax-search-pro'); ?>
</p>
</div>
<div class="wd_di_rel_date" style="display: inline;">
<input aria-label="<?php echo __('Years', 'ajax-search-pro'); ?>"
class="wd_di_yy twodigit" value=""/>&nbsp;<?php echo __('years', 'ajax-search-pro'); ?>
<input aria-label="<?php echo __('Months', 'ajax-search-pro'); ?>"
class="wd_di_mm twodigit" value=""/>&nbsp;<?php echo __('months', 'ajax-search-pro'); ?>
<input aria-label="<?php echo __('Days before current date', 'ajax-search-pro'); ?>"
class="wd_di_dd twodigit" value=""/>&nbsp;<?php echo __('days before current date', 'ajax-search-pro'); ?>
<p class="descMsg">
<?php echo __('It is possible to use negative values as well.', 'ajax-search-pro'); ?>
</p>
</div>
</div>
<div style="clear:both;"></div>
<input isparam=1 type="hidden" value='<?php echo $this->data; ?>' name="<?php echo $this->name; ?>">
<input type='hidden' value='wd_DateFilter' name='classname-<?php echo $this->name; ?>'>
<div style="clear:both;"></div>
</div>
<?php
}
function processData() {
/**
* Expected raw format
*
* [0] state: date|rel_date|disabled
* [1] date: yyyy-mm-dd
* [2] rel_date: 0,0,0
*/
$this->raw = explode("|", $this->data);
if ( $this->raw[2] != "" )
$this->raw[2] = explode(",", $this->raw[2]);
$this->selected = array(
"state" => $this->raw[0],
"date" => $this->raw[1],
"rel_date" => $this->raw[2]
);
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,86 @@
<?php
if (!class_exists("wd_DateFilter")) {
/**
* Class wd_DateFilter
*
* Displays a date filter configuration element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/wpdreams/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_DateFilter extends wpdreamsType {
protected $raw, $selected;
function getType() {
parent::getType();
$this->processData();
?>
<div class="wd_DateFilter" id="wd_DateFilter-<?php echo self::$_instancenumber; ?>">
<div class="wd_col_40"></div>
<div class="wd_col_60" style="line-height: 33px; vertical-align: top;">
<label><?php echo $this->label; ?></label>
<select aria-label="<?php echo __('Date type', 'ajax-search-pro'); ?>" class="wd_di_state">
<option value="date"><?php echo __('Date', 'ajax-search-pro'); ?></option>
<option value="rel_date"><?php echo __('Relative Date', 'ajax-search-pro'); ?></option>
<option value="disabled"><?php echo __('Disabled', 'ajax-search-pro'); ?></option>
</select><br>
<div class="wd_di_date" style="display: inline;">
<input type="text" class="wd_di_date"/>
<p class="descMsg">
<?php echo __('Empty value can be used, in that case the placeholder text will appear.', 'ajax-search-pro'); ?>
</p>
</div>
<div class="wd_di_rel_date" style="display: inline;">
<input aria-label="<?php echo __('Years', 'ajax-search-pro'); ?>"
class="wd_di_yy twodigit" value=""/>&nbsp;<?php echo __('years', 'ajax-search-pro'); ?>
<input aria-label="<?php echo __('Months', 'ajax-search-pro'); ?>"
class="wd_di_mm twodigit" value=""/>&nbsp;<?php echo __('months', 'ajax-search-pro'); ?>
<input aria-label="<?php echo __('Days before current date', 'ajax-search-pro'); ?>"
class="wd_di_dd twodigit" value=""/>&nbsp;<?php echo __('days before current date', 'ajax-search-pro'); ?>
<p class="descMsg">
<?php echo __('It is possible to use negative values as well.', 'ajax-search-pro'); ?>
</p>
</div>
</div>
<div style="clear:both;"></div>
<input isparam=1 type="hidden" value='<?php echo $this->data; ?>' name="<?php echo $this->name; ?>">
<input type='hidden' value='wd_DateFilter' name='classname-<?php echo $this->name; ?>'>
<div style="clear:both;"></div>
</div>
<?php
}
function processData() {
/**
* Expected raw format
*
* [0] state: date|rel_date|disabled
* [1] date: yyyy-mm-dd
* [2] rel_date: 0,0,0
*/
$this->raw = explode("|", $this->data);
if ( $this->raw[2] != "" )
$this->raw[2] = explode(",", $this->raw[2]);
$this->selected = array(
"state" => $this->raw[0],
"date" => $this->raw[1],
"rel_date" => $this->raw[2]
);
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,108 @@
<?php
if (!class_exists("wd_DateInterval")) {
/**
* Class wd_DateInterval
*
* Displays a tag selector element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_DateInterval extends wpdreamsType {
private $raw, $selected;
function getType() {
parent::getType();
$this->processData();
?>
<div class="wd_DateInterval" id="wd_DateInterval-<?php echo self::$_instancenumber; ?>">
<div class="wd_col_20"></div>
<div class="wd_col_40" style="line-height: 33px; vertical-align: top;">
<select aria-label="<?php echo __('Mode', 'ajax-search-pro'); ?>" class="wd_di_mode">
<option value="exclude"><?php echo __('Exclude', 'ajax-search-pro'); ?></option>
<option value="include"><?php echo __('Include', 'ajax-search-pro'); ?></option>
</select>&nbsp;from:
<select aria-label="<?php echo __('Type', 'ajax-search-pro'); ?>" class="wd_di_from">
<option value="date"><?php echo __('Date', 'ajax-search-pro'); ?></option>
<option value="rel_date"><?php echo __('Relative Date', 'ajax-search-pro'); ?></option>
<option value="disabled"><?php echo __('Disabled', 'ajax-search-pro'); ?></option>
</select>
<input type='hidden' class="wd_di_fromDate"/>
<div class="wd_di_fromreld" style="display: inline;">
<input aria-label="<?php echo __('Years', 'ajax-search-pro'); ?>"
class="wd_di_fromyy twodigit" value=""/>&nbsp;<?php echo __('years', 'ajax-search-pro'); ?>
<input aria-label="<?php echo __('Months', 'ajax-search-pro'); ?>"
class="wd_di_frommm twodigit" value=""/>&nbsp;<?php echo __('months', 'ajax-search-pro'); ?>
<input aria-label="<?php echo __('Days before current date', 'ajax-search-pro'); ?>"
class="wd_di_fromdd twodigit" value=""/>&nbsp;<?php echo __('days before current date', 'ajax-search-pro'); ?>
</div>
</div>
<div class="wd_col_40" style="line-height: 33px; vertical-align: top;">
<?php echo __('to:', 'ajax-search-pro'); ?>
<select aria-label="<?php echo __('Type', 'ajax-search-pro'); ?>" class="wd_di_to">
<option value="date"><?php echo __('Date', 'ajax-search-pro'); ?></option>
<option value="rel_date"><?php echo __('Relative Date', 'ajax-search-pro'); ?></option>
<option value="disabled"><?php echo __('Disabled', 'ajax-search-pro'); ?></option>
</select><br>
<input class="wd_di_toDate"/>
<div class="wd_di_toreld" style="display: inline;">
<input aria-label="<?php echo __('Years', 'ajax-search-pro'); ?>"
class="wd_di_toyy twodigit" value=""/>&nbsp;<?php echo __('years', 'ajax-search-pro'); ?>
<input aria-label="<?php echo __('Months', 'ajax-search-pro'); ?>"
class="wd_di_tomm twodigit" value=""/>&nbsp;<?php echo __('months', 'ajax-search-pro'); ?>
<input aria-label="<?php echo __('Days before current date', 'ajax-search-pro'); ?>"
class="wd_di_todd twodigit" value=""/>&nbsp;<?php echo __('days before current date', 'ajax-search-pro'); ?>
</div>
</div>
<div style="clear:both;"></div>
<input isparam=1 type="hidden" value='<?php echo $this->data; ?>' name="<?php echo $this->name; ?>">
<input type='hidden' value='wd_DateInterval' name='classname-<?php echo $this->name; ?>'>
<div style="clear:both;"></div>
</div>
<?php
}
function processData() {
/**
* Expected raw format
*
* [0] mode: exclude|include
* [1] from: disabled|date|interval
* [2] to: disabled|date|interval
* [3] fromDate: yyyy-mm-dd
* [4] toDate: yyyy-mm-dd
* [5] fromInt: 0,0,0
* [6] toInt: 0,0,0
*/
$this->raw = explode("|", $this->data);
if ( $this->raw[5] != "" )
$this->raw[5] = explode(",", $this->raw[5]);
if ( $this->raw[6] != "" )
$this->raw[6] = explode(",", $this->raw[6]);
$this->selected = array(
"mode" => $this->raw[0],
"from" => $this->raw[1],
"to" => $this->raw[2],
"fromDate" => $this->raw[3],
"toDate"=> $this->raw[4],
"fromInt"=> $this->raw[5],
"toInt" => $this->raw[6]
);
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,79 @@
<?php
if (!class_exists("wpdreamsDraggable")) {
/**
* Class wpdreamsDraggable
*
* A draggable selector UI element with custom values.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsDraggable extends wpdreamsType {
private $selects, $selected;
function getType() {
$verified_sel = array();
parent::getType();
$this->processData();
echo "
<div class='wpdreamsDraggable' id='wpdreamsDraggable-" . self::$_instancenumber . "'>
<fieldset>
<legend>" . $this->label . "</legend>";
if (isset($this->data['description']))
echo "<p class='descMsg'>" . $this->data['description'] . "</p>";
echo '<div class="sortablecontainer" id="sortablecontainer' . self::$_instancenumber . '">
<ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
foreach ($this->selects as $k => $v) {
if (!in_array($k, $this->selected))
echo '<li class="ui-state-default" key="'.$k.'">' . $v . '</li>';
}
echo "</ul></div>";
echo '<div class="sortablecontainer"><ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->selected != null && is_array($this->selected)) {
foreach ($this->selected as $k => $v) {
if ( isset($this->selects[$v]) ) {
echo '<li class="ui-state-default" key="'.$v.'">' . $this->selects[$v] . '</li>';
$verified_sel[] = $v;
}
}
}
echo "</ul></div>";
echo "
<input isparam=1 type='hidden' value='" . implode("|", $verified_sel) . "' name='" . $this->name . "'>";
echo "
<input type='hidden' value='wpdreamsDraggable' name='classname-" . $this->name . "'>";
echo "
</fieldset>
</div>";
}
function processData() {
if (is_array($this->data)) {
if (isset($this->data['selects']) && is_array($this->data['selects']))
$this->selects = $this->data['selects'];
else
$this->selects = array();
if ( is_array($this->data) && isset($this->data['value']) )
$this->selected = explode("|", $this->data['value']);
else
$this->selected = array();
} else {
$this->selects = array();
$this->selected = explode("|", $this->data);
}
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,170 @@
<?php
if (!class_exists("wpdreamsFontComplete")) {
/**
* Class wpdreamsFontComplete
*
* A more advanced font selector UI element with font-shadow included.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2018, Ernest Marcinko
*/
class wpdreamsFontComplete extends wpdreamsType {
public static $loadedFonts = array();
private $font, $weight, $size, $lineheight, $color, $vlength, $hlength, $blurradius, $tsColor;
private $fonts = array(
'classic' => array("Arial, Helvetica, sans-serif","Arial Black, Gadget, sans-serif","Comic Sans MS, cursive","Courier New, Courier, monospace","Georgia, serif","Impact, Charcoal, sans-serif","Lucida Console, Monaco, monospace","Lucida Sans Unicode, Lucida Grande, sans-serif","Palatino Linotype, Book Antiqua, Palatino, serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif","Symbol","Webdings","Wingdings, Zapf Dingbats","MS Sans Serif, Geneva, sans-serif","MS Serif, New York, serif"),
'google' => array("Allan","Allerta","Allerta Stencil","Anonymous Pro","Arimo","Arvo","Bentham","Buda","Cabin","Calligraffitti","Cantarell","Cardo","Cherry Cream Soda","Chewy","Coda","Coming Soon","Copse","Corben","Cousine","Covered By Your Grace","Crafty Girls","Crimson Text","Crushed","Cuprum","Droid Sans","Droid Sans Mono","Droid Serif","Fontdiner Swanky","GFS Didot","GFS Neohellenic","Geo","Gruppo","Hanuman","Homemade Apple","IM Fell DW Pica","IM Fell DW Pica SC","IM Fell Double Pica","IM Fell Double Pica SC","IM Fell English","IM Fell English SC","IM Fell French Canon","IM Fell French Canon SC","IM Fell Great Primer","IM Fell Great Primer SC","Inconsolata","Irish Growler","Josefin Sans","Josefin Slab","Just Another Hand","Just Me Again Down Here","Kenia","Kranky","Kristi","Lato","Lekton","Lobster","Luckiest Guy","Merriweather","Molengo","Mountains of Christmas","Neucha","Neuton","Nobile","OFL Sorts Mill Goudy TT","Old Standard TT","Orbitron","Open Sans","PT Sans","PT Sans Caption","PT Sans Narrow","Permanent Marker","Philosopher","Puritan","Raleway","Reenie Beanie","Rock Salt","Schoolbell","Slackey","Sniglet","Sunshiney","Syncopate","Tangerine","Tinos","Ubuntu","UnifrakturCook","UnifrakturMaguntia","Unkempt","Vibur","Vollkorn","Walter Turncoat","Yanone Kaffeesatz")
);
/**
* Helper method to be used before printing the font styles. Converts font families to apostrophed versions.
*
* @param $font
* @return mixed
*/
public static function font($font) {
preg_match("/family:(.*?);/", $font, $fonts);
if ( isset($fonts[1]) ) {
$f = explode(',', str_replace(array('"', "'"), '', $fonts[1]));
foreach ($f as &$_f) {
if ( trim($_f) != 'inherit' )
$_f = '"' . trim($_f) . '"';
else
$_f = trim($_f);
}
$f = implode(',', $f);
return preg_replace("/family:(.*?);/", 'family:'.$f.';', $font);
} else {
return $font;
}
}
function getType() {
parent::getType();
$this->processData();
$inherit = $this->font == 'inherit';
$custom_font = !$inherit && !in_array($this->font, $this->fonts['classic']) && !in_array($this->font, $this->fonts['google']) ? $this->font : '';
?>
<div class='wpdreamsFontComplete'>
<fieldset>
<legend><?php echo $this->label; ?></legend>
<div class="item-flex">
<div class="wd_fonts_type">
<?php new wpdreamsColorPickerDummy("", "", (isset($this->color) ? $this->color : "#000000")); ?>
<label>
<select class="wd_fonts_select">
<option value="inherit"<?php echo $inherit ? ' selected="selected"' : ''; ?>><?php _e('inherit', 'ajax-search-pro'); ?></option>
<option value="custom"<?php echo $custom_font == '' ? '' : ' selected="selected"'; ?>><?php _e('Custom Font', 'ajax-search-pro'); ?></option>
<option disabled="disabled">----------- <?php _e('Classic Fonts', 'ajax-search-pro'); ?> ---------</option>
<?php foreach($this->fonts['classic'] as $font): ?>
<option value="<?php echo $font; ?>"
<?php echo $this->font == $font ? ' selected="selected"' : ''; ?>
style="font-family: <?php echo $font; ?>">
<?php echo $font; ?>
</option>
<?php endforeach; ?>
<option disabled="disabled">----------- <?php _e('Google Fonts', 'ajax-search-pro'); ?> ---------</option>
<?php foreach($this->fonts['google'] as $font): ?>
<option value="<?php echo $font; ?>"
<?php echo $this->font == $font ? ' selected="selected"' : ''; ?>
style="font-family: <?php echo $font; ?>">
<?php echo $font; ?>
</option>
<?php endforeach; ?>
</select>
</label>
<select class="wd_font_weight">
<option value="normal"<?php echo $this->weight == 'normal' ? ' selected="selected"' : ''; ?>>Normal</option>
<option value="bold"<?php echo $this->weight == 'bold' ? ' selected="selected"' : ''; ?>>Bold</option>
</select>
<label class="wd_fonts_custom hiddend">
<?php _e('Custom font name:', 'ajax-search-pro'); ?>
<input type='text' class="wd_fonts_custom" value="<?php echo $custom_font; ?>">
</label>
<div class="wd_fonts_dimensions">
<label>
<?php _e('Size', 'ajax-search-pro'); ?>
<input type='text' class="wd_fonts_size fourdigit" value="<?php echo $this->size; ?>">
</label>
<label>
<?php _e('Line height', 'ajax-search-pro'); ?>
<input type='text' class="wd_fonts_line fourdigit" value="<?php echo $this->lineheight; ?>">
</label>
<div class="descMsg"><?php _e('With dimensions, ex.:', 'ajax-search-pro'); ?> 10em, 10px or 110%</div>
</div>
</div>
<fieldset class="wpd_font_shadow">
<legend><?php _e('Font shadow', 'ajax-search-pro'); ?></legend>
<label><?php _e('Vertical offset', 'ajax-search-pro'); ?><input type='text' class='twodigit _xx_hlength_xx_' value="<?php echo $this->hlength; ?>"/>px</label>
<label><?php _e('Horizontal offset', 'ajax-search-pro'); ?><input type='text' class='twodigit _xx_vlength_xx_' value="<?php echo $this->vlength; ?>"/>px</label><br>
<label><?php _e('Blur radius', 'ajax-search-pro'); ?><input type='text' class='twodigit _xx_blurradius_xx_' value="<?php echo $this->blurradius; ?>"/>px</label>
<?php new wpdreamsColorPickerDummy('', __('Shadow color', 'ajax-search-pro'), (isset($this->tsColor) ? $this->tsColor : "#000000")); ?>
</fieldset>
</div>
</fieldset>
<input type='hidden' value='wpdreamsFontComplete' name="wpdfont-<?php echo $this->name; ?>">
<input isparam=1 type='hidden' value="<?php echo $this->data; ?>" name="<?php echo $this->name; ?>">
<div class='triggerer'></div>
</div>
<?php
}
function processData() {
$this->data = str_replace('\\', "", stripcslashes($this->data));
preg_match("/family:(.*?);/", $this->data, $_fonts);
$this->font = str_replace(array('--g--', "'", '"'), '', $_fonts[1]);
preg_match("/weight:(.*?);/", $this->data, $_weight);
$this->weight = $_weight[1];
preg_match("/color:(.*?);/", $this->data, $_color);
$this->color = $_color[1];
preg_match("/size:(.*?);/", $this->data, $_size);
$this->size = $_size[1];
preg_match("/height:(.*?);/", $this->data, $_lineheight);
$this->lineheight = $_lineheight[1];
preg_match("/text-shadow:(.*?)px (.*?)px (.*?)px (.*?);/", $this->data, $matches);
// Backwards compatibility
if (is_array($matches) && isset($matches[1])) {
$this->hlength = $matches[1];
$this->vlength = $matches[2];
$this->blurradius = $matches[3];
$this->tsColor = $matches[4];
} else {
$this->hlength = '0';
$this->vlength = '0';
$this->blurradius = '0';
$this->tsColor = 'rgba(255, 255, 255, 0)';
}
}
final function getData() {
return $this->data;
}
final function getImport() {
$font = str_replace("--g--", "", trim($this->font));
if ( $font != '' && in_array($font, $this->fonts['google']) ) {
$font = str_replace(" ", "+", $font);
if ( isset(self::$loadedFonts[$font]) )
return '';
self::$loadedFonts[$font] = true;
ob_start();
?>
@import url(https://fonts.googleapis.com/css?family=<?php echo $font; ?>:300|<?php echo $font; ?>:400|<?php echo $font; ?>:700);
<?php
$out = ob_get_contents();
ob_end_clean();
return $out;
} else {
return '';
}
}
}
}

View File

@@ -0,0 +1,60 @@
<?php
if (!class_exists("wpdreamsFour")) {
/**
* Class wpdreamsFour
*
* Holds four separate values in four input boxes labeled: Top Bottom Right Left.
* Good input choice for CSS padding, margin, border-width etc..
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsFour extends wpdreamsType {
private $top, $bottom, $right, $left, $desc;
function getType() {
parent::getType();
$this->processData();
echo "
<div class='wpdreamsFour'>
<fieldset>
<legend>" . $this->label . "</legend>";
echo "
<label>" . __('Top', 'ajax-search-pro') . "</label><input type='text' class='threedigit' name='topleft' value='" . $this->top . "' />
<label>" . __('Bottom', 'ajax-search-pro') . "</label><input type='text' class='threedigit' name='bottomright' value='" . $this->bottom . "' />
<label>" . __('Right', 'ajax-search-pro') . "</label><input type='text' class='threedigit' name='topright' value='" . $this->right . "' />
<label>" . __('Left', 'ajax-search-pro') . "</label><input type='text' class='threedigit' name='bottomleft' value='" . $this->left . "' />
<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>
<div class='triggerer'></div>
<p class='descMsg'>$this->desc</p>
</fieldset>
</div>";
}
function processData() {
$this->desc = $this->data['desc'];
$this->data = str_replace("\n", "", $this->data['value']);
preg_match("/\|\|(.*?)\|\|(.*?)\|\|(.*?)\|\|(.*?)\|\|/", $this->data, $matches);
$this->top = $matches[1];
$this->bottom = $matches[2];
$this->right = $matches[3];
$this->left = $matches[4];
}
final function getData() {
return $this->data;
}
final function getSelected() {
return array(
"top" => $this->top,
"bottom" => $this->bottom,
"right" => $this->right,
"left" => $this->left
);
}
}
}

View File

@@ -0,0 +1,73 @@
<?php
if (!class_exists("wpdreamsGradient")) {
class wpdreamsGradient extends wpdreamsType {
/**
* Class wpdreamsGradient
*
* A simple gradient selector with two color inputs. Radial and Linear supported.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2018, Ernest Marcinko
*/
private $is_gradient, $grad_type, $leftcolor, $rightcolor, $rotation;
function getType() {
parent::getType();
$this->processData();
?>
<div class='wpdreamsGradient'>
<label><?php echo esc_attr($this->label); ?></label>
<select class='grad_bg_type'>
<option value='0'<?php echo $this->is_gradient == 1 ? 'selected' : ''; ?>>Solid</option>
<option value='1'<?php echo $this->is_gradient == 0 ? 'selected' : ''; ?>>Gradient</option>
</select>
<?php
new wpdreamsColorPickerDummy('leftcolor_' . self::$_instancenumber, "", $this->leftcolor);
new wpdreamsColorPickerDummy('rightcolor_' . self::$_instancenumber, "", $this->rightcolor);
?>
<select class='grad_type'>
<option value='1' <?php echo $this->grad_type == 1 ? 'selected' : ''; ?>>Linear</option>
<option value='0' <?php echo $this->grad_type == 0 ? 'selected' : ''; ?>>Radial</option>
</select>
<div class="grad_ex"></div>
<div class="grad_slider">
<div class="dslider" data-rotation="<?php echo esc_attr($this->rotation); ?>"></div>
<div class='ddisplay'>
<div class='dbg'></div>
</div>
<div class="dtxt"><?php echo esc_attr($this->rotation); ?></div>&#176;
</div>
<input isparam=1 type='hidden' class='gradient' name="<?php echo esc_attr($this->name); ?>" value="<?php echo esc_attr($this->data); ?>"/>
<div class='triggerer'></div>
</div>
<?php
}
function processData() {
$this->data = str_replace("\n", "", $this->data);
if ( preg_match("/(.*?)-(.*?)-(.*?)-(.*)/", $this->data, $matches) ) {
$this->grad_type = $matches[1];
$this->rotation = $matches[2];
if ($this->rotation == null || $this->rotation == '') $this->rotation = 0;
$this->leftcolor = wpdreams_admin_hex2rgb($matches[3]);
$this->rightcolor = wpdreams_admin_hex2rgb($matches[4]);
} else {
$this->grad_type = 0;
$this->rotation = 180;
$this->leftcolor = $this->data;
$this->rightcolor = $this->data;
}
$this->data = $this->grad_type . '-' . $this->rotation . '-' . $this->leftcolor . '-' . $this->rightcolor;
}
final function getData() {
return $this->data;
}
}
}

View File

@@ -0,0 +1,19 @@
<?php
if (!class_exists("wpdreamsHidden")) {
/**
* Class wpdreamsHidden
*
* Just a hidden input field.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsHidden extends wpdreamsType {
function getType() {
echo "<input type='hidden' id='wpdreamshidden_" . self::$_instancenumber . "' name='" . $this->name . "' value='" . $this->data . "' />";
}
}
}

View File

@@ -0,0 +1,51 @@
<?php
if (!class_exists("wpdreamsImageRadio")) {
/**
* Class wpdreamsImageRadio
*
* Displays selectable images like radio buttons.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsImageRadio extends wpdreamsType {
private $selects, $selected;
function getType() {
parent::getType();
$this->processData();
echo "<div class='wpdreamsImageRadio'>";
echo "<label class='radioimage'>" . $this->label . "</label>";
$i = 1;
foreach ($this->selects as $radio) {
$radio = trim($radio);
$selected = !(strpos($radio, $this->selected) === false);
echo "
<img num='" . $i . "' sel = '".$radio."' src='" . plugins_url() . $radio . "' class='radioimage" . (($selected) ? ' selected' : '') . "'/>
";
$i++;
}
echo "<input isparam=1 type='hidden' class='realvalue' value='" . $this->selected . "' name='" . $this->name . "'>";
//echo "<input type='hidden' value='wpdreamsImageRadio' name='classname-" . $this->name . "'>";
echo "<div class='triggerer'></div>
</div>";
}
function processData() {
$this->selects = $this->defaultData['images'];
$this->selected = $this->data['value'];
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,221 @@
<?php
if (!class_exists("wpdreamsLanguageSelect")) {
/**
* Class wpdreamsLanguageSelect
*
* Displays a language select box.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsLanguageSelect extends wpdreamsType {
private $languages = array(
'ab' => 'Abkhazian',
'aa' => 'Afar',
'af' => 'Afrikaans',
'ak' => 'Akan',
'sq' => 'Albanian',
'am' => 'Amharic',
'ar' => 'Arabic',
'an' => 'Aragonese',
'hy' => 'Armenian',
'as' => 'Assamese',
'av' => 'Avaric',
'ae' => 'Avestan',
'ay' => 'Aymara',
'az' => 'Azerbaijani',
'bm' => 'Bambara',
'ba' => 'Bashkir',
'eu' => 'Basque',
'be' => 'Belarusian',
'bn' => 'Bengali',
'bh' => 'Bihari',
'bi' => 'Bislama',
'nb' => 'Bokmal',
'bs' => 'Bosnian',
'br' => 'Breton',
'bg' => 'Bulgarian',
'my' => 'Burmese',
'ca' => 'Catalan',
'km' => 'Central Khmer',
'ch' => 'Chamorro',
'ce' => 'Chechen',
'ny' => 'Chewa',
'zh' => 'Chinese',
'cu' => 'Church Slavic',
'cv' => 'Chuvash',
'kw' => 'Cornish',
'co' => 'Corsican',
'cr' => 'Cree',
'hr' => 'Croatian',
'cs' => 'Czech',
'da' => 'Danish',
'dv' => 'Dhivehi',
'nl' => 'Dutch',
'dz' => 'Dzongkha',
'en' => 'English',
'eo' => 'Esperanto',
'et' => 'Estonian',
'ee' => 'Ewe',
'fo' => 'Faroese',
'fj' => 'Fijian',
'fi' => 'Finnish',
'fr' => 'French',
'ff' => 'Fulah',
'gd' => 'Gaelic',
'gl' => 'Galician',
'lg' => 'Ganda',
'ka' => 'Georgian',
'de' => 'German',
'ki' => 'Gikuyu',
'el' => 'Greek',
'kl' => 'Greenlandic',
'gn' => 'Guarani',
'gu' => 'Gujarati',
'ht' => 'Haitian',
'ha' => 'Hausa',
'he' => 'Hebrew',
'hz' => 'Herero',
'hi' => 'Hindi',
'ho' => 'Hiri Motu',
'hu' => 'Hungarian',
'is' => 'Icelandic',
'io' => 'Ido',
'ig' => 'Igbo',
'id' => 'Indonesian',
'ia' => 'Interlingua',
'iu' => 'Inuktitut',
'ik' => 'Inupiaq',
'ga' => 'Irish',
'it' => 'Italian',
'ja' => 'Japanese',
'jv' => 'Javanese',
'kn' => 'Kannada',
'kr' => 'Kanuri',
'ks' => 'Kashmiri',
'kk' => 'Kazakh',
'rw' => 'Kinyarwanda',
'kv' => 'Komi',
'kg' => 'Kongo',
'ko' => 'Korean',
'ku' => 'Kurdish',
'kj' => 'Kwanyama',
'ky' => 'Kyrgyz',
'lo' => 'Lao',
'la' => 'Latin',
'lv' => 'Latvian',
'lb' => 'Letzeburgesch',
'li' => 'Limburgan',
'ln' => 'Lingala',
'lt' => 'Lithuanian',
'lu' => 'Luba-Katanga',
'mk' => 'Macedonian',
'mg' => 'Malagasy',
'ms' => 'Malay',
'ml' => 'Malayalam',
'mt' => 'Maltese',
'gv' => 'Manx',
'mi' => 'Maori',
'mr' => 'Marathi',
'mh' => 'Marshallese',
'mn' => 'Mongolian',
'na' => 'Nauru',
'nv' => 'Navajo',
'ng' => 'Ndonga',
'ne' => 'Nepali',
'nd' => 'North Ndebele',
'se' => 'Northern Sami',
'no' => 'Norwegian',
'nn' => 'Norwegian Nynorsk',
'ie' => 'Occidental',
'oc' => 'Occitan',
'oj' => 'Ojibwa',
'or' => 'Oriya',
'om' => 'Oromo',
'os' => 'Ossetian',
'pi' => 'Pali',
'fa' => 'Persian',
'pl' => 'Polish',
'pt' => 'Portuguese',
'pa' => 'Punjabi',
'ps' => 'Pushto',
'qu' => 'Quechua',
'ro' => 'Romanian',
'rm' => 'Romansh',
'rn' => 'Rundi',
'ru' => 'Russian',
'sm' => 'Samoan',
'sg' => 'Sango',
'sa' => 'Sanskrit',
'sc' => 'Sardinian',
'sr' => 'Serbian',
'sn' => 'Shona',
'ii' => 'Sichuan Yi',
'sd' => 'Sindhi',
'si' => 'Sinhalese',
'sk' => 'Slovak',
'sl' => 'Slovenian',
'so' => 'Somali',
'st' => 'Southern Sotho',
'nr' => 'South Ndebele',
'es' => 'Spanish',
'su' => 'Sundanese',
'sw' => 'Swahili',
'ss' => 'Swati',
'sv' => 'Swedish',
'tl' => 'Tagalog',
'ty' => 'Tahitian',
'tg' => 'Tajik',
'ta' => 'Tamil',
'tt' => 'Tatar',
'te' => 'Telugu',
'th' => 'Thai',
'bo' => 'Tibetan',
'ti' => 'Tigrinya',
'to' => 'Tonga',
'ts' => 'Tsonga',
'tn' => 'Tswana',
'tr' => 'Turkish',
'tk' => 'Turkmen',
'tw' => 'Twi',
'uk' => 'Ukrainian',
'ur' => 'Urdu',
'ug' => 'Uyghur',
'uz' => 'Uzbek',
've' => 'Venda',
'vi' => 'Vietnamese',
'vo' => 'VolapA1k',
'wa' => 'Walloon',
'cy' => 'Welsh',
'fy' => 'Western Frisian',
'wo' => 'Wolof',
'xh' => 'Xhosa',
'yi' => 'Yiddish',
'yo' => 'Yoruba',
'za' => 'Zhuang',
'zu' => 'Zulu'
);
function getType() {
parent::getType();
echo "<div class='wpdreamsLanguageSelect'>";
echo "<label for='wpdreamslanguageselect_" . self::$_instancenumber . "'>" . $this->label . "</label>";
echo "<select class='wpdreamsselect' id='wpdreamsselect_" . self::$_instancenumber . "' name='" . $this->name . "'>";
foreach ($this->languages as $k => $v) {
if ($k == $this->data)
echo "<option value='" . $k . "' selected='selected'>" . $v . "</option>";
else
echo "<option value='" . $k . "'>" . $v . "</option>";
}
echo "</select>";
echo "</div>";
}
final function getData() {
return $this->data;
}
}
}

View File

@@ -0,0 +1,83 @@
<?php
if (!class_exists("wpdreamsLoaderSelect")) {
/**
* Class wpdreamsLoaderSelect
*
* Displays CSS loaders to select
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsLoaderSelect extends wpdreamsType {
public static $loaders = array(
"ball-pulse" => 3,
"ball-grid-pulse" => 9,
"simple-circle" => 0,
"ball-clip-rotate" => 1,
"ball-clip-rotate-simple" => 2,
"ball-clip-rotate-multiple" => 2,
"ball-rotate" => 1,
"cube-transition" => 2,
"ball-scale" => 1,
"line-scale" => 5,
"line-scale-party" => 4,
"ball-scale-multiple" => 3,
"ball-pulse-sync" => 3,
"ball-beat" => 3,
"line-scale-pulse-out" => 5,
"line-scale-pulse-out-rapid" => 5,
"ball-scale-ripple" => 1,
"ball-scale-ripple-multiple" => 3,
"ball-spin-fade-loader" => 8,
"line-spin-fade-loader" => 8,
"ball-grid-beat" => 9
);
private $selected;
function getType() {
parent::getType();
$this->processData();
wp_enqueue_style("wpdreams_loaders", ASP_URL_NP . 'css/style.loaders.css', array(), ASP_CURR_VER_STRING);
echo "<div class='wpdreamsLoaderSelect'>";
echo "<label class='loaderselect'>" . $this->label . "</label>";
foreach (wpdreamsLoaderSelect::$loaders as $loader => $div_count) {
$loader = trim($loader);
$selected = $this->selected == $loader;
echo "<div sel = '" . $loader . "' class='proloading asp-select-loader" . (($selected) ? '-selected' : '') . "'>
<div class='asp_loader'>
<div class='asp_loader-inner asp_".$loader."'>
";
for($i=0;$i<$div_count;$i++) {
echo "
<div></div>
";
}
echo "</div>
</div>
</div>";
}
echo "<input isparam=1 type='hidden' class='realvalue' value='" . $this->selected . "' name='" . $this->name . "'>";
echo "<div class='triggerer'></div>
</div>";
}
function processData() {
$this->selected = $this->data;
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,48 @@
<?php
if (!class_exists("wpdreamsNumericUnit")) {
/**
* Class wpdreamsNumericUnit
*
* Displays a numeric input box with up-down arrows.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsNumericUnit extends wpdreamsType {
private $units, $numeric, $selected;
function getType() {
parent::getType();
$this->processData();
echo "
<div class='wpdreamsNumericUnit'>";
echo "<label>" . $this->label . "</label><input type='text' class='twodigit' name='numeric' value='" . $this->numeric . "' />";
echo "<div class='wpdreams-updown'><div class='wpdreams-uparrow'></div><div class='wpdreams-downarrow'></div></div>";
echo "<select name='units'>";
foreach ($this->units as $key => $value) {
echo "<option value='" . $key . "' " . (($key == $this->selected) ? 'selected=selected' : '') . ">" . $value . "</option>";
}
echo "</select>";
echo "
<input isparam=1 type='hidden' value='" . $this->data['value'] . "' name='" . $this->name . "'>
<div class='triggerer'></div>
</div>";
}
function processData() {
$this->units = $this->data['units'];
$this->data['value'] = str_replace("\n", "", $this->data['value']);
preg_match("/([0-9]+)(.*)/", $this->data['value'], $matches);
$this->numeric = $matches[1];
$this->selected = $matches[2];
}
final function getData() {
return $this->data;
}
}
}

View File

@@ -0,0 +1,55 @@
<?php
if (!class_exists("wpdreamsSortable")) {
/**
* Class wpdreamsCustomPostTypes
*
* A sortable based on jQuery UI
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsSortable extends wpdreamsType {
private $types;
function getType() {
parent::getType();
$this->processData();
echo "
<div class='wpdreamsSortable' id='wpdreamsSortable-" . self::$_instancenumber . "'>";
echo '<div class="sortablecontainer" style="float:right;"><p>'.$this->label.'</p><ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->types != null && is_array($this->types)) {
foreach ($this->types as $k => $v) {
echo '<li class="ui-state-default">' . $v . '</li>';
}
}
echo "
</ul></div>
<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>";
echo "
<input type='hidden' value='wpdreamsSortable' name='classname-" . $this->name . "'>";
?>
</div>
<div class="clear"></div>
<?php
}
function processData() {
$this->data = str_replace("\n", "", $this->data);
if ($this->data != "")
$this->types = explode("|", $this->data);
else
$this->types = array();
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->types;
}
}
}

View File

@@ -0,0 +1,250 @@
<?php
use WPDRMS\ASP\Utils\Ajax;
if (!class_exists("wpdreamsSelectTags")) {
/**
* Class wpdreamsSelectTags
*
* Displays a tag selector element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2015, Ernest Marcinko
*/
class wpdreamsSelectTags extends wpdreamsType {
private $active, $display_mode, $source, $all_status, $tag_ids, $c_tag_ids, $defaultTag, $selected;
function getType() {
parent::getType();
$this->processData();
?>
<div class="wpdreamsSelectTags" id="wpdreamsSelectTags-<?php echo self::$_instancenumber; ?>">
<div class="wpdreamsYesNoSt<?php echo $this->active == 1 ? " active" : ""; ?>">
<label><?php echo $this->label; ?></label>
<div class='wpdreamsYesNoInner'></div>
</div>
&nbsp;&nbsp;<?php echo __('as', 'ajax-search-pro'); ?>&nbsp;
<select class="wd_tagDisplayMode">
<option value="checkboxes"<?php echo $this->display_mode == "checkboxes" ? " selected" : ""; ?>>
<?php echo __('Checkboxes', 'ajax-search-pro'); ?>
</option>
<option value="dropdown"<?php echo $this->display_mode == "dropdown" ? " selected" : ""; ?>>
<?php echo __('Drop-down list', 'ajax-search-pro'); ?>
</option>
<option value="dropdownsearch"<?php echo $this->display_mode == "dropdownsearch" ? " selected" : ""; ?>>
<?php echo __('Drop-down list with search', 'ajax-search-pro'); ?>
</option>
<option value="multisearch"<?php echo $this->display_mode == "multisearch" ? " selected" : ""; ?>>
<?php echo __('Multiselect list with search', 'ajax-search-pro'); ?>
</option>
<option value="radio"<?php echo $this->display_mode == "radio" ? " selected" : ""; ?>>
<?php echo __('Radio buttons', 'ajax-search-pro'); ?>
</option>
</select>
&nbsp;<?php echo __('and show', 'ajax-search-pro'); ?>&nbsp;
<select class="wd_tagSelectSource">
<option value="all"<?php echo $this->source == "all" ? " selected" : ""; ?>>
<?php echo __('All tags', 'ajax-search-pro'); ?>
</option>
<option value="selected"<?php echo $this->source == "selected" ? " selected" : ""; ?>>
<?php echo __('Selected tags', 'ajax-search-pro'); ?>
</option>
</select>
<?php
$rule = "checkboxes-all";
$showthis = ( strpos($rule, $this->source) !== false &&
strpos($rule, $this->display_mode) !== false ) ? "" : " hiddend";
?>
<div showif="<?php echo $rule; ?>" class="showif_c wd_tagAllStatus<?php echo $showthis; ?>">
<label><?php echo __('Checkbox statuses', 'ajax-search-pro'); ?></label>
<select class="wd_tagAllStatus">
<option value="checked"<?php echo $this->all_status == "checked" ? " selected" : ""; ?>>
<?php echo __('Checked', 'ajax-search-pro'); ?>
</option>
<option value="unchecked"<?php echo $this->all_status == "unchecked" ? " selected" : ""; ?>>
<?php echo __('Unchecked', 'ajax-search-pro'); ?>
</option>
</select>
</div>
<?php
$rule1 = "checkboxes-dropdown-dropdownsearch-multisearch-radio-selected";
$rule2 = "dropdown-dropdownsearch-multisearch-radio-all";
$showthis = ( strpos($rule1, $this->source) !== false &&
strpos($rule1, $this->display_mode) !== false ) ? "" : " hiddend";
$showlabel = ( strpos($rule2, $this->source) !== false &&
strpos($rule2, $this->display_mode) !== false ) ? "" : " hiddend";
if ($showthis == " hiddend") {
$showthis = $showlabel;
}
?>
<div showif="<?php echo $rule1."|".$rule2; ?>"
class="showif_c wd_tagSelSearch<?php echo $showthis; ?>">
<label showif="<?php echo $rule2; ?>" class="showif_c<?php echo $showlabel; ?>">
<?php echo __('Default selected tag', 'ajax-search-pro'); ?>
</label>
<span class="loading-small hiddend"></span>
<div class="wd_ts_close hiddend">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<polygon id="x-mark-icon" points="438.393,374.595 319.757,255.977 438.378,137.348 374.595,73.607 255.995,192.225 137.375,73.622 73.607,137.352 192.246,255.983 73.622,374.625 137.352,438.393 256.002,319.734 374.652,438.378 "></polygon>
</svg>
</div>
<input type="hidden" class="wd_tag_search_nonce" value="<?php echo wp_create_nonce( 'wd_tag_search_nonce' ); ?>">
<input type="text" value="" placeholder="<?php esc_attr_e('Search for tags', 'ajax-search-pro'); ?>" class="wd_tagSelectSearch">
<div class="wd_tagSearchResults"></div>
</div>
<?php
$rule = "checkboxes-dropdown-dropdownsearch-multisearch-radio-selected";
$showthis = ( strpos($rule, $this->source) !== false &&
strpos($rule, $this->display_mode) !== false ) ? "" : " hiddend";
?>
<div showif="<?php echo $rule; ?>"
class="showif_c ts_selected wd_tagSelectContent<?php echo $showthis; ?>">
<?php
$tags = $this->getTagsOrdered();
foreach ($tags as $tag) {
echo "<span class='wd_tag' tagid='".$tag->term_id."'>
<a class='wd_tag_remove'></a>
<a class='".( in_array($tag->term_id, $this->c_tag_ids) ? "wd_tag_checked" : "wd_tag_unchecked")."'></a>".$tag->name."</span>";
}
?>
</div>
<?php
$rule = "dropdown-dropdownsearch-multisearch-radio-all";
$showthis = ( strpos($rule, $this->source) !== false &&
strpos($rule, $this->display_mode) !== false ) ? "" : " hiddend";
?>
<div showif="<?php echo $rule; ?>"
class="showif_c ts_all wd_tagSelectContent<?php echo $showthis; ?>">
<?php
if ( !empty($this->defaultTag) ) {
$the_tag = get_tag($this->defaultTag);
if ( isset( $the_tag->name) ) {
echo "<span class='wd_tag' tagid='".$the_tag->term_id."'>
<a class='wd_tag_remove'></a>
</a>".$the_tag->name."</span>";
}
}
?>
</div>
<?php
$rule = "dropdown-dropdownsearch-multisearch-radio-selected";
$showthis = ( strpos($rule, $this->source) !== false &&
strpos($rule, $this->display_mode) !== false ) ? "" : " hiddend";
?>
<div showif="<?php echo $rule; ?>"
class="descMsg showif_c<?php echo $showthis; ?>">
<?php echo __('Note: If you have multiple items checked, the <strong>last checked</strong> item will be selected as default.', 'ajax-search-pro'); ?>
</div>
<?php
$rule = "dropdown-dropdownsearch-multisearch-radio-all";
$showthis = ( strpos($rule, $this->source) !== false &&
strpos($rule, $this->display_mode) !== false ) ? "" : " hiddend";
?>
<div showif="<?php echo $rule; ?>"
class="descMsg showif_c<?php echo $showthis; ?>">
<?php echo __( "Note: If you don't have a default selected tag, the <strong>first tag</strong> will be selected as default.", 'ajax-search-pro'); ?>
</div>
<input isparam=1 type="hidden" value='<?php echo $this->data; ?>' name="<?php echo $this->name; ?>">
<input type='hidden' value='wpdreamsSelectTags' name='classname-<?php echo $this->name; ?>'>
</div>
<?php
}
function processData() {
$_raw = explode("|", $this->data);
$this->active = $_raw[0];
// Display mode
$this->display_mode = $_raw[1];
// Source
$this->source = $_raw[2];
// All tags checked or unchecked?
$this->all_status = $_raw[3];
// Selected tag ids
$_raw[4] = trim($_raw[4]);
// Checked tag ids
$_raw[5] = trim($_raw[5]);
// Default for drop and radio
$this->defaultTag = trim($_raw[6]);
if ($_raw[4] != "")
$this->tag_ids = explode(",", $_raw[4]);
else
$this->tag_ids = array();
if ($_raw[5] != "")
$this->c_tag_ids = explode(",", $_raw[5]);
else
$this->c_tag_ids = array();
$this->selected = array(
"active" => $this->active,
"display_mode" => $this->display_mode,
"source" => $this->source,
"all_status" => $this->all_status,
"tag_ids"=> $this->tag_ids,
"checked_tag_ids"=> $this->c_tag_ids,
"default_tag" => $this->defaultTag
);
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
private function getTagsOrdered() {
if ( empty($this->tag_ids) ) return array();
$tag_keys_arr = array();
$final_tags_arr = array();
foreach ($this->tag_ids as $position => $tag_id) {
$tag_keys_arr[$tag_id] = $position;
}
$tags = get_terms("post_tag", array("include" => $this->tag_ids));
foreach ($tags as $tag) {
$final_tags_arr[$tag_keys_arr[$tag->term_id]] = $tag;
}
ksort($final_tags_arr);
return $final_tags_arr;
}
static function searchTag() {
if (
isset($_POST['wd_tag_phrase'], $_POST['wd_tag_search_nonce']) &&
( current_user_can( 'manage_options' ) || apply_filters('wpdrms/backend/options/ajax/user_role_override', false) ) &&
wp_verify_nonce( $_POST["wd_tag_search_nonce"], 'wd_tag_search_nonce' )
) {
$ret = "";
$phrase = $_POST["wd_tag_phrase"];
$tags = get_terms(array("post_tag"), array('search' => $phrase, 'number' => 10));
if ( count($tags) > 0 )
foreach ($tags as $tag) {
$ret .= "<p>".$tag->name."<span termid='".$tag->term_id."'>>>" . __('USE', 'ajax-search-pro') . "</span></p>";
}
else
$ret = "No tags found for this phrase";
Ajax::prepareHeaders();
print "!!WDSTART!!" . $ret . "!!WDEND!!";
}
die();
}
}
}
if ( !has_action('wp_ajax_wd_search_tag') )
add_action('wp_ajax_wd_search_tag', 'wpdreamsSelectTags::searchTag');

View File

@@ -0,0 +1,103 @@
<?php
use WPDRMS\ASP\Utils\Ajax;
if (!class_exists("wpdreamsSearchTags")) {
/**
* Class wpdreamsSearchTags
*
* Displays a tag selector element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2015, Ernest Marcinko
*/
class wpdreamsSearchTags extends wpdreamsType {
private $selected;
function getType() {
parent::getType();
$this->processData();
?>
<div class="wpdreamsSearchTags" id="wpdreamsSearchTags-<?php echo self::$_instancenumber; ?>">
<fieldset>
<legend><?php echo $this->label; ?></legend>
<div class="wd_tagSelSearch">
<span class="loading-small hiddend"></span>
<div class="wd_ts_close hiddend">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<polygon id="x-mark-icon" points="438.393,374.595 319.757,255.977 438.378,137.348 374.595,73.607 255.995,192.225 137.375,73.622 73.607,137.352 192.246,255.983 73.622,374.625 137.352,438.393 256.002,319.734 374.652,438.378 "></polygon>
</svg>
</div>
<input type="hidden" class="wd_tag_search_nonce" value="<?php echo wp_create_nonce( 'wd_tag_search_nonce' ); ?>">
<input type="text" value="" placeholder="<?php esc_attr_e('Search for tags', 'ajax-search-pro'); ?>" class="wd_tagSelectSearch">
<div class="wd_tagSearchResults"></div>
</div>
<div class="wd_tagSelectContent">
<?php
$tags = array();
if ( count($this->selected) > 0 )
$tags = get_terms("post_tag", array("include" => $this->selected));
foreach ($tags as $tag) {
echo "<span class='wd_tag' tagid='".$tag->term_id."'>
<a class='wd_tag_remove'></a>
".$tag->name."</span>";
}
?>
</div>
<input isparam=1 type="hidden" value='<?php echo $this->data; ?>' name="<?php echo $this->name; ?>">
<input type='hidden' value='wpdreamsSearchTags' name='classname-<?php echo $this->name; ?>'>
</fieldset>
</div>
<?php
}
function processData() {
$this->data = trim($this->data);
if ( $this->data!= "")
$this->selected = explode("|", $this->data);
else
$this->selected = array();
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
static function searchTag() {
if (
isset($_POST['wd_tag_phrase'], $_POST['wd_tag_search_nonce']) &&
( current_user_can( 'manage_options' ) || apply_filters('wpdrms/backend/options/ajax/user_role_override', false) ) &&
wp_verify_nonce( $_POST["wd_tag_search_nonce"], 'wd_tag_search_nonce' )
) {
$phrase = $_POST["wd_tag_phrase"];
$tags = get_terms(array("post_tag"), array('search' => $phrase, 'number' => 50));
$ret = "";
if ( count($tags) > 0 )
foreach ($tags as $tag) {
$ret .= "<p>".$tag->name."<span termid='".$tag->term_id."'>>>" . __('ADD', 'ajax-search-pro') . "</span></p>";
}
else
$ret = __('No tags found for this phrase', 'ajax-search-pro');
Ajax::prepareHeaders();
print "!!WDSTART!!" . $ret . "!!WDEND!!";
}
die();
}
}
}
if ( !has_action('wp_ajax_wd_search_tags') )
add_action('wp_ajax_wd_search_tags', 'wpdreamsSearchTags::searchTag');

View File

@@ -0,0 +1,105 @@
<?php
if (!class_exists("wpdreamsTaxonomySelect")) {
/**
* Class wpdreamsTaxonomySelect
*
* A taxonomy drag and drop UI element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsTaxonomySelect extends wpdreamsType {
private $types, $selected, $otype, $v;
private $exclude = array(
'product_visibility', 'product_type'
);
function getType() {
parent::getType();
$this->processData();
$this->types = $this->getAllTaxonomies();
echo "
<div class='wpdreamsTaxonomySelect' id='wpdreamsTaxonomySelect-" . self::$_instancenumber . "'>
<fieldset>
<legend>" . $this->label . "</legend>";
echo '<div class="sortablecontainer" id="sortablecontainer' . self::$_instancenumber . '">
<div class="arrow-all-left"></div>
<div class="arrow-all-right"></div>
<p>Available taxonomies</p>
<ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->types != null && is_array($this->types)) {
foreach ($this->types as $tax) {
$custom_post_type = "";
if ( isset($tax->object_type, $tax->object_type[0]) )
$custom_post_type = $tax->object_type[0] . " - ";
if ( in_array($tax->name, $this->exclude) )
continue;
if ($this->selected == null || !wd_in_array_r($tax->name, $this->selected)) {
echo '<li class="ui-state-default" taxonomy="' . $tax->name . '">' . $custom_post_type . $tax->labels->name . '<span class="extra_info">[' . $tax->name . ']</span></li>';
}
}
}
echo "</ul></div>";
echo '<div class="sortablecontainer">' . __('Drag here the taxonomies you want to ', 'ajax-search-pro') . '<b>' . $this->otype . '</b>!</p><ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->selected != null && is_array($this->selected)) {
foreach ($this->selected as $_tax) {
$tax = get_taxonomy( $_tax );
$custom_post_type = "";
if (isset($tax->object_type) && $tax->object_type[0] != null)
$custom_post_type = $tax->object_type[0] . " - ";
if (isset($tax->name))
echo '<li class="ui-state-default" taxonomy="' . $tax->name . '">' . $custom_post_type . $tax->labels->name . '<span class="extra_info">[' . $tax->name . ']</span></li>';
}
}
echo "</ul></div>";
echo "
<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>
<input type='hidden' value='wpdreamsTaxonomySelect' name='classname-" . $this->name . "'>";
echo "
</fieldset>
</div>";
}
function getAllTaxonomies() {
$args = array(
'_builtin' => false
);
$output = 'objects'; // or objects
$operator = 'and'; // 'and' or 'or'
$taxonomies = get_taxonomies($args, $output, $operator);
return $taxonomies;
}
function processData() {
if (is_array($this->data) && isset($this->data['type']) && isset($this->data['value'])) {
$this->otype = $this->data['type'];
$this->v = str_replace("\n", "", $this->data["value"]);
$this->data = $this->data["value"];
} else {
$this->otype = "include";
$this->v = str_replace("\n", "", $this->data);
}
$this->selected = array();
if ($this->v != "") {
$this->selected = explode("|", $this->v);
} else {
$this->selected = null;
}
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,77 @@
<?php /** @noinspection PhpInconsistentReturnPointsInspection */
if (!class_exists("wpdreamsTermMeta")) {
/**
* Class wpdreamsTermMeta
*
* A term meta selector UI element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsTermMeta extends wpdreamsType {
private $types, $selected;
function getType() {
parent::getType();
global $wpdb;
$this->processData();
// Bail if term meta table is not installed.
if ( get_option( 'db_version' ) < 34370 ) {
echo "<input isparam=1 type='hidden' value='' name='" . $this->name . "'>";
return false;
}
$this->types = $wpdb->get_results("SELECT DISTINCT(meta_key) FROM " . $wpdb->termmeta . " LIMIT 1500", ARRAY_A);
echo "
<div class='wpdreamsTermMeta' id='wpdreamsTermMeta-" . self::$_instancenumber . "'>
<fieldset>
<legend>" . $this->label . "</legend>";
echo '<div class="sortablecontainer" id="sortablecontainer' . self::$_instancenumber . '">
<div class="arrow-all-left"></div>
<div class="arrow-all-right"></div>
<p>' . __('Available term meta keys', 'ajax-search-pro') . '</p><ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->types != null && is_array($this->types)) {
foreach ($this->types as $k => $v) {
if ($this->selected == null || !in_array($v['meta_key'], $this->selected)) {
echo '<li class="ui-state-default">' . $v['meta_key'] . '</li>';
}
}
}
echo "</ul></div>";
echo '<div class="sortablecontainer"><p>' . __('Drag here the meta keys you want to use!', 'ajax-search-pro') . '</p><ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->selected != null && is_array($this->selected)) {
foreach ($this->selected as $k => $v) {
echo '<li class="ui-state-default">' . $v . '</li>';
}
}
echo "</ul></div>";
echo "
<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>";
echo "
<input type='hidden' value='wpdreamsTermMeta' name='classname-" . $this->name . "'>";
echo "
</fieldset>
</div>";
}
function processData() {
$this->data = str_replace("\n", "", $this->data);
if ($this->data != "")
$this->selected = explode("|", $this->data);
else
$this->selected = null;
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* Class wpdreamsText
*
* A simple text input field.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
if (!class_exists("wpdreamsText")) {
class wpdreamsText extends wpdreamsType {
public function getType() {
parent::getType();
echo "<div class='wpdreamsText'>";
if ($this->label != "")
echo "<label for='wpdreamstext_" . self::$_instancenumber . "'>" . $this->label . "</label>";
echo "<input isparam=1 type='text' id='wpdreamstext_" . self::$_instancenumber . "' name='" . $this->name . "' value=\"" . stripslashes(esc_html($this->data)) . "\" />";
echo "
<div class='triggerer'></div>
</div>";
}
}
}

View File

@@ -0,0 +1,21 @@
<?php
if (!class_exists("wd_TextareaExpandable")) {
/**
* Class wpdreamsTextarea
*
* A simple textarea field.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://codecanyon.net/user/wpdreams/portfolio
* @copyright Copyright (c) 2019, Ernest Marcinko
*/
class wd_TextareaExpandable extends wpdreamsType {
public function getType() {
parent::getType();
echo "<label class='wd_textarea_expandable' for='wd_textareae_" . self::$_instancenumber . "'>" . $this->label . "</label>";
echo "<textarea rows='1' data-min-rows='2' class='wd_textarea_expandable' id='wd_textareae_" . self::$_instancenumber . "' name='" . $this->name . "'>" . stripslashes(esc_html($this->data)) . "</textarea>";
}
}
}

View File

@@ -0,0 +1,21 @@
<?php
if (!class_exists("wpdreamsTextarea")) {
/**
* Class wpdreamsTextarea
*
* A simple textarea field.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsTextarea extends wpdreamsType {
public function getType() {
parent::getType();
echo "<label style='vertical-align: top;' for='wpdreamstextarea_" . self::$_instancenumber . "'>" . $this->label . "</label>";
echo "<textarea id='wpdreamstextarea_" . self::$_instancenumber . "' name='" . $this->name . "'>" . stripslashes(esc_html($this->data)) . "</textarea>";
}
}
}

View File

@@ -0,0 +1,57 @@
<?php /** @noinspection PhpMultipleClassDeclarationsInspection */
if (!class_exists("wpdreamsTextSmall")) {
/**
* Class wpdreamsTextSmall
*
* A 5 characters wide text input field.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsTextSmall extends wpdreamsType {
private $icon = 'none';
private $suffix = '';
private $inputClasses = '';
private $iconMsg;
function getType() {
parent::getType();
$this->processData();
echo "<div class='wpdreamsTextSmall'>";
if ($this->label != "")
echo "<label for='wpdreamstextsmall_" . self::$_instancenumber . "'>" . $this->label . "</label>";
if ( $this->icon != 'none' ) {
?>
<span
title="<?php echo $this->iconMsg[$this->icon] ?? ''; ?>"
class="wpd-txt-small-icon wpd-txt-small-icon-<?php echo $this->icon ?>">
</span>
<?php
}
echo "<input isparam=1 class='small ".$this->inputClasses."' type='text' id='wpdreamstextsmall_" . self::$_instancenumber . "' name='" . $this->name . "' value=\"" . stripslashes(esc_html($this->value)) . "\" />";
echo $this->suffix;
echo "
<div class='triggerer'></div>
</div>";
}
public function processData() {
$this->iconMsg = array(
'phone' => __('Phone devices, on 0px to 640px widths', 'ajax-search-pro'),
'tablet' => __('Tablet devices, on 641px to 1024px widths', 'ajax-search-pro'),
'desktop' => __('Desktop devices, 1025px width and higher', 'ajax-search-pro')
);
if ( is_array($this->data) ) {
$this->icon = $this->data['icon'] ?? $this->icon;
$this->suffix = $this->data['suffix'] ?? $this->suffix;
$this->inputClasses = $this->data['inputClasses'] ?? $this->inputClasses;
}
}
}
}

View File

@@ -0,0 +1,84 @@
<?php
if (!class_exists("wpdreamsThemeChooser")) {
/**
* Class wpdreamsThemeChooser
*
* Theme selector class. Uses the json decoded data do form each theme.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsThemeChooser extends wpdreamsType {
private $themes, $selected;
function getType() {
parent::getType();
$this->processData();
echo "
<div class='wpdreamsThemeChooser'>
<fieldset style='background:#FAFAFA;padding:0;'>
<label style='color:#333' for='wpdreamsThemeChooser_" . self::$_instancenumber . "'>" . $this->label . "</label>";
$decodedData = $this->themes;
echo "<select id='wpdreamsThemeChooser_" . self::$_instancenumber . "' name='" . $this->name . "'>
<option value=''>Select</option>";
foreach ($decodedData as $name => $theme) {
$selected = $name == $this->selected ? " selected='selected'" : "";
if ($theme === false)
echo "<option value='" . $name . "' disabled>" . $name . "</option>";
else
echo "<option value='" . $name . "' " . $selected.">&nbsp;&nbsp;" . $name . "</option>";
}
echo "</select>";
foreach ($decodedData as $name => $theme) {
if ($theme === false) continue;
echo "<div name='" . $name . "' style='display:none;'>";
echo json_encode($theme);
echo "</div>";
}
echo "
<span></span>
<input id='asp_import_theme' class='submit wd_button_red' type='button' value='Import'>
<input id='asp_export_theme' class='submit wd_button_blue' type='button' value='Export'>
<p class='descMsg'>" . __('Changes not take effect on the frontend until you save them.', 'ajax-search-pro') . "</p>
</fieldset>";
?>
<div id="wpd_imex_modal_bg" class="wpd-modal-bg"></div>
<div id="wpd_import_modal" class="wpd-modal hiddend">
<h3 style="font-family: 'Open Sans',sans-serif;text-align: left; margin-top: 0;margin-left: 7px; font-size: 18px; font-weight: 600;"><?php echo __('Import theme', 'ajax-search-pro'); ?></h3>
<div class="wpd-modal-close"></div>
<div class="wpd_md_col">
<p class="descMsg"><?php echo __('Paste the exported theme here', 'ajax-search-pro'); ?></p>
<textarea></textarea><br>
<div class="errorMsg hiddend"><?php echo __('Invalid or missing data, please try again!', 'ajax-search-pro'); ?></div>
<input id='asp_import_theme_btn' class='submit wd_button_red' type='button' value='<?php echo __('Import', 'ajax-search-pro'); ?>'>
</div>
</div>
<div id="wpd_export_modal" class="wpd-modal hiddend">
<h3 style="font-family: 'Open Sans',sans-serif;text-align: left; margin-top: 0;margin-left: 7px; font-size: 18px; font-weight: 600;"><?php echo __('Export theme', 'ajax-search-pro'); ?></h3>
<div class="wpd-modal-close"></div>
<div class="wpd_md_col">
<p class="descMsg"><?php echo __('Copy this text and save it on your computer', 'ajax-search-pro'); ?></p>
<textarea></textarea>
</div>
</div>
<?php
echo "</div>";
}
function processData() {
$this->themes = $this->data['themes'];
$this->selected = $this->data['value'];
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,220 @@
<?php
if ( !class_exists('wpdreamsType') ) {
/**
* (abstract) Class wpdreamsType
*
* Parent of each type defined in this directory. This class should not be used to make an instance.
* Each new child type should follow this general interpretation.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2012, Ernest Marcinko
*/
abstract class wpdreamsType {
protected static $_instancenumber = 0;
protected static $_errors = 0;
protected static $_globalerrormsg = 'Only integer values are accepted!';
protected $name, $label, $constraints, $errormsg, $defaultData, $newData, $isError;
protected $value; // Contains only the value
protected $data; // Contains everything passed (arguments and value), array or string
const NON_DISPLAYABLE_POST_TYPES = array(
'revision',
'nav_menu_item',
'attachment',
'peepso-post',
'peepso-comment',
'acf',
'shop_order',
'shop_order_refund',
'elementor_library',
'elementor_font',
'elementor_icons',
'oembed_cache',
'user_request',
'wp_block',
'shop_coupon',
'avada_page_options',
'_pods_template',
'_pods_pod',
'_pods_field',
'bp-email',
'lbmn_archive',
'lbmn_footer',
'mc4wp-form',
'elementor-front',
'elementor-icon',
'tablepress_table',
'fusion_template',
'fusion_element',
'wc_product_tab',
'customize_changeset',
'wpcf7_contact_form',
'dslc_templates',
'acf-field',
'acf-group',
'acf-groups',
'acf-field-group',
'custom_css',
'wp_template',
'wp_font_face',
'wp_font_family',
'wp_navigation',
'wp_template_part',
'wp_global_styles',
'shop_order_placehold',
'elementor_snippet',
'ngg_album',
'ngg_gallery',
'displayed_gallery',
'display_type',
'gal_display_source',
);
function __construct( $name, $label, $data, $constraints = null, $errormsg = '' ) {
$this->name = $name;
$this->label = $label;
$this->constraints = $constraints;
$this->errormsg = $errormsg;
$this->defaultData = $data; // Preserving constructor default data after posting
$this->data = $data;
$this->value = is_array($this->data) && isset($this->data['value']) ? $this->data['value'] : $this->data;
$this->isError = false;
++self::$_instancenumber;
$this->getType();
}
/**
* Returns the raw data passed to the class
*
* @return mixed
*/
function getData() {
return $this->data;
}
/**
* Returns the name passed in the constructor
*
* @return string
*/
final function getName() {
return $this->name;
}
/**
* Checks if there was an error within any child
*
* @return bool
*/
final function getError() {
return $this->isError;
}
/**
* Gets the current error message or the global error if not defined
*
* @return string
*/
final function getErrorMsg() {
return $this->errormsg;
}
/**
* Triggers or sets an error message.
*
* @param $error
* @param string $errormsg
*/
final function setError( $error, $errormsg = '' ) {
if ( $errormsg != '' ) {
$this->errormsg = $errormsg;
}
if ( $error ) {
++self::$_errors;
$this->isError = true;
}
}
/**
* Cheks the newly posted data against possible constraints
*
* @return bool
*/
final protected function checkData() {
$this->newData = $_POST[ $this->name ];
if ( is_array($this->constraints) ) {
foreach ( $this->constraints as $key => $val ) {
if ( $this->constraints[ $key ]['op'] == 'eq' ) {
if ( $val['func']($this->newData) == $this->constraints[ $key ]['val'] ) {
} else {
$this->setError(true);
return false;
}
} elseif ( $this->constraints[ $key ]['op'] == 'ge' ) {
if ( $val['func']($this->newData) >= $this->constraints[ $key ]['val'] ) {
} else {
$this->setError(true);
return false;
}
} elseif ( $val['func']($this->newData) < $this->constraints[ $key ]['val'] ) {
} else {
$this->setError(true);
return false;
}
}
}
return true;
}
/**
* Called in the constructor by default.
*
* Checks for errors when a new value was posted.
*/
protected function getType() {
if ( isset($_POST[ $this->name ]) ) {
if ( !$this->checkData() || $this->getError() ) {
/*errormessage*/
echo "<div class='errorMsg'>" . ( ( $this->errormsg != '' ) ? $this->errormsg : self::$_globalerrormsg ) . '</div>';
} elseif ( is_array($this->data) && isset($this->data['value']) ) {
$this->data['value'] = $_POST[ $this->name ];
$this->value = $this->data['value'];
} else {
$this->data = $_POST[ $this->name ];
$this->value = $this->data;
}
}
}
protected function decode_param( $v ) {
if ( gettype($v) === 'string' && substr($v, 0, strlen('_decode_')) === '_decode_' ) {
$v = substr($v, strlen('_decode_'));
$v = json_decode(base64_decode($v), true);
}
return $v;
}
protected function encode_param( $v ) {
// No need to decode
if ( gettype($v) === 'string' && substr($v, 0, strlen('_decode_')) === '_decode_' ) {
return $v;
} else {
return '_decode_' . base64_encode(json_encode($v));
}
}
/**
* Returns the error count
*
* @return int
*/
public static function getErrorNum() {
return self::$_errors;
}
}
}

View File

@@ -0,0 +1,43 @@
<?php
if (!class_exists("wpdreamsUpload")) {
/**
* Class wpdreamsUpload
*
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsUpload extends wpdreamsType {
function getType() {
parent::getType();
$this->processData();
?>
<div class='wpdreamsUpload' id='wpdreamsUpload<?php echo self::$_instancenumber; ?>'>
<label for='wpdreamsUpload_input<?php echo self::$_instancenumber; ?>'>
<?php echo $this->label; ?>
</label>
<input id="wpdreamsUpload_input<?php echo self::$_instancenumber; ?>" type="text"
class="wdUploadText"
size="36" name="<?php echo $this->name; ?>"
value="<?php echo $this->data; ?>"/>
<input id="wpdreamsUpload_button<?php echo self::$_instancenumber; ?>"
class="wdUploadButton button" type="button"
value="Upload"/>
</div>
<?php
}
function processData() {}
final function getData() {
return $this->data;
}
final function getSelected() {}
final function getItems() {}
}
}

View File

@@ -0,0 +1,74 @@
<?php
if (!class_exists("wpdreamsUserRoleSelect")) {
/**
* Class wpdreamsUsermetaSelect
*
* A user meta selector UI element.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/wpdreams/portfolio
* @copyright Copyright (c) 2015, Ernest Marcinko
*/
class wpdreamsUserRoleSelect extends wpdreamsType {
private $selected, $types;
function getType() {
parent::getType();
$this->processData();
$this->types = $this->getEditableRoles();
echo "
<div class='wpdreamsUserRoleSelect' id='wpdreamsUserRoleSelect-" . self::$_instancenumber . "'>
<fieldset>
<legend>" . $this->label . "</legend>";
echo '<div class="sortablecontainer" id="sortablecontainer' . self::$_instancenumber . '">
<div class="arrow-all-left"></div>
<div class="arrow-all-right"></div>
<p>' . __('Available user roles', 'ajax-search-pro') . '</p><ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->types != null && is_array($this->types)) {
foreach ($this->types as $_role => $_data) {
if ($this->selected == null || !in_array($_role, $this->selected)) {
echo '<li class="ui-state-default">' . $_role . '</li>';
}
}
}
echo "</ul></div>";
echo '<div class="sortablecontainer"><p>' . __('Drag here the user roles you want to exclude!', 'ajax-search-pro') . '</p><ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->selected != null && is_array($this->selected)) {
foreach ($this->selected as $k => $v) {
echo '<li class="ui-state-default">' . $v . '</li>';
}
}
echo "</ul></div>";
echo "
<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>";
echo "
<input type='hidden' value='wpdreamsUserRoleSelect' name='classname-" . $this->name . "'>";
echo "
</fieldset>
</div>";
}
function processData() {
$this->data = str_replace("\n", "", $this->data);
if ($this->data != "")
$this->selected = explode("|", $this->data);
else
$this->selected = null;
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
function getEditableRoles() {
global $wp_roles;
return $wp_roles->roles;
}
}
}

View File

@@ -0,0 +1,71 @@
<?php
if (!class_exists("wd_ANInputs")) {
/**
* Class wd_ANInputs
*
* AlphaNumeric inputs class - Prints N number of alphanumeric inputs (for paddings, margins etc..)
* Stores the values space separated
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2018, Ernest Marcinko
*/
class wd_ANInputs extends wpdreamsType {
private $args = array(
'inputs' => array(
array('Top', '0'),
array('Right', '0'),
array('Bottom', '0'),
array('Left', '0')
),
'input_class' => 'threedigit',
'input_default' => '0',
);
private $inputs = array();
function getType() {
parent::getType();
$this->processData();
?>
<div class="wd_an_inputs" id='wd_an_inputs-<?php echo self::$_instancenumber; ?>'>
<fieldset>
<legend><?php echo $this->label; ?></legend>
<?php foreach ($this->inputs as $k => $value): ?>
<label>
<?php echo isset($this->args['inputs'][$k], $this->args['inputs'][$k][0]) ? $this->args['inputs'][$k][0] : ''; ?>
<input type="text" data-default="<?php echo $this->args['input_default']; ?>"
class="wd_an_noparam <?php echo $this->args['input_class']; ?>"
value="<?php echo $value; ?>">
</label>
<?php endforeach; ?>
</fieldset>
<input isparam=1 type='hidden' value='<?php echo $this->data; ?>' name='<?php echo $this->name; ?>'>
<div class='triggerer'></div>
</div>
<?php
}
function processData() {
// Get the args first if exists
if (is_array($this->data) && isset($this->data['args']))
$this->args = array_merge($this->args, $this->data['args']);
if (is_array($this->data) && isset($this->data['value'])) {
// If called from back-end non-post context
$this->data = $this->data['value'];
}
$this->data = trim(str_replace(array("\n", ' '), array("", ' '), $this->data));
$this->inputs = explode(' ', $this->data);
foreach ($this->inputs as $k => $v) {
if ($v == '')
unset($this->inputs[$k]);
}
}
final function getData() {
return $this->data;
}
}
}

View File

@@ -0,0 +1,175 @@
<?php
use WPDRMS\ASP\Utils\Ajax;
if (!class_exists("wd_CFSearchCallBack")) {
/**
* Class wd_CFSearchCallBack
*
* Custom field search for both post meta and user meta tables, which passes the results to a JS callback method
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_CFSearchCallBack extends wpdreamsType {
private static $delimiter = '!!!CFRES!!!';
private $args = array(
'callback' => '', // javacsript function name in the windows scope | if empty, shows results
'search_values' => 0,
'limit' => 15,
'controls_position' => 'right',
'class' => '',
'usermeta' => 0,
'show_pods' => false
);
public function getType() {
parent::getType();
$this->processData();
$this->args['delimiter'] = self::$delimiter;
?>
<div class='wd_cf_search<?php echo $this->args['class'] != '' ? ' '.$this->args['class'] : "";?>'
id='wd_cf_search-<?php echo self::$_instancenumber; ?>'>
<?php if ($this->args['controls_position'] == 'left') $this->printControls(); ?>
<?php echo $this->label; ?> <input type="search" name="<?php echo $this->name; ?>"
class="wd_cf_search"
value="<?php echo (is_array($this->data) && isset($this->data['value'])) ? $this->data['value'] : $this->data; ?>"
placeholder="<?php esc_attr_e('Search custom fields..', 'ajax-search-pro'); ?>"/>
<input type="hidden" class="wd_cf_search_nonce" value="<?php echo wp_create_nonce( 'wd_cf_search_nonce' ); ?>">
<input type='hidden' value="<?php echo base64_encode(json_encode($this->args)); ?>" class="wd_args">
<?php if ($this->args['controls_position'] != 'left') $this->printControls(); ?>
<div class="wd_cf_search_res"></div>
</div>
<?php
}
private function printControls() {
?>
<span class="loading-small hiddend"></span>
<div class="wd_ts_close hiddend">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<polygon id="x-mark-icon" points="438.393,374.595 319.757,255.977 438.378,137.348 374.595,73.607 255.995,192.225 137.375,73.622 73.607,137.352 192.246,255.983 73.622,374.625 137.352,438.393 256.002,319.734 374.652,438.378 "></polygon>
</svg>
</div>
<?php
}
public static function searchCF()
{
global $wpdb;
if (
isset($_POST['wd_phrase'], $_POST['wd_cf_search_nonce']) &&
( current_user_can( 'manage_options' ) || apply_filters('wpdrms/backend/options/ajax/user_role_override', false) ) &&
wp_verify_nonce( $_POST["wd_cf_search_nonce"], 'wd_cf_search_nonce' )
) {
// Exact matches
$phrase = trim($_POST['wd_phrase']) . '%';
$data = json_decode(base64_decode($_POST['wd_args']), true);
if ($data['usermeta'])
$table = $wpdb->usermeta;
else
$table = $wpdb->postmeta;
if ($data['search_values'] == 1) {
$cf_query = $wpdb->prepare(
"SELECT DISTINCT(meta_key) FROM $table WHERE meta_key LIKE '%s' OR meta_value LIKE '%s' ORDER BY meta_key ASC LIMIT %d",
$phrase, $phrase, $data['limit']);
} else {
$cf_query = $wpdb->prepare(
"SELECT DISTINCT(meta_key) FROM $table WHERE meta_key LIKE '%s' ORDER BY meta_key ASC LIMIT %d",
$phrase, $data['limit']);
}
$cf_results = $wpdb->get_results( $cf_query, OBJECT );
$remaining_limit = $data['limit'] - count($cf_results);
if ( $remaining_limit > 0 ) {
// Fuzzy matches
$not_in_query = '';
$not_in = array();
foreach ($cf_results as $r) {
$not_in[] = $r->meta_key;
}
if (count($not_in) > 0) {
$not_in_query = " AND meta_key NOT IN ('" . implode("','", $not_in) . "')";
}
$phrase = '%' . trim($_POST['wd_phrase']) . '%';
if ($data['search_values'] == 1) {
$cf_query = $wpdb->prepare(
"SELECT DISTINCT(meta_key) FROM $table WHERE (meta_key LIKE '%s' OR meta_value LIKE '%s') $not_in_query ORDER BY meta_key ASC LIMIT %d",
$phrase, $phrase, $remaining_limit);
} else {
$cf_query = $wpdb->prepare(
"SELECT DISTINCT(meta_key) FROM $table WHERE (meta_key LIKE '%s') $not_in_query ORDER BY meta_key ASC LIMIT %d",
$phrase, $remaining_limit);
}
$cf_results = array_merge($cf_results, $wpdb->get_results($cf_query, OBJECT));
}
if ( $data['show_pods'] )
$pods_fields = self::searchPods($_POST['wd_phrase']);
else
$pods_fields = array();
Ajax::prepareHeaders();
print_r(self::$delimiter . json_encode(array_merge($pods_fields, $cf_results)) . self::$delimiter);
}
die();
}
private static function searchPods($s) {
$ret = array();
if ( function_exists('pods_api') ) {
// Filter table storage based fields only
$pods = get_posts(array(
'fields' => 'ids',
'posts_per_page' => -1,
'post_type' => '_pods_pod',
'meta_query' => array(
array(
'key' => 'storage',
'value' => 'table',
'compare' => 'LIKE'
)
)
));
if ( !is_wp_error($pods) && !empty($pods) ) {
$pods_fields = get_posts(array(
'fields' => 'post_name',
'posts_per_page' => -1,
's' => $s,
'post_type' => '_pods_field',
'post_parent__in' => $pods // Only filtered parents by table storage type
));
if ( !is_wp_error($pods_fields) && !empty($pods_fields) ) {
$ret = array();
foreach ($pods_fields as $f) {
$ret[] = array('meta_key' => '__pods__' . $f->post_name);
}
}
}
}
return $ret;
}
public function processData() {
// Get the args first if exists
if ( is_array($this->data) && isset($this->data['args']) )
$this->args = array_merge($this->args, $this->data['args']);
if ( is_array($this->data) && isset($this->data['value']) ) {
// If called from back-end non-post context
$this->data = $this->data['value'];
}
}
public final function getData() {
return $this->data;
}
}
}
if ( !has_action('wp_ajax_wd_search_cf') )
add_action('wp_ajax_wd_search_cf', 'wd_CFSearchCallBack::searchCF');

View File

@@ -0,0 +1,82 @@
<?php
if (!class_exists("wd_CPT_Editable")) {
/**
* Class wd_CPT_Editable
*
* A new custom post types selector UI element with editable titles, supporting built in post types
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_CPT_Editable extends wpdreamsType {
private $types, $selected;
public function getType() {
parent::getType();
$this->processData();
echo "
<div class='wd_cpt_editable' id='wd_cpt_editable-" . self::$_instancenumber . "'>
<fieldset>
<legend>" . $this->label . "</legend>";
echo '<div class="sortablecontainer" id="sortablecontainer' . self::$_instancenumber . '">
<p>' . __('Available post types', 'ajax-search-pro') . '</p><ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->types != null && is_array($this->types)) {
foreach ($this->types as $k => $v) {
if ($this->selected == null || !wd_in_array_r($k, $this->selected)) {
echo '<li class="ui-state-default ui-left" style="background: #ddd;">
<label>' . $k . '</label>
<input type="text" value="' . $v->labels->name . '"/>
</li>';
}
}
}
echo "</ul></div>";
echo '<div class="sortablecontainer"><p>' . __('Drag here the post types you want to use!', 'ajax-search-pro') . '</p><ul id="sortable_conn' . self::$_instancenumber . '" class="connectedSortable">';
if ($this->selected != null && is_array($this->selected)) {
foreach ($this->selected as $k => $v) {
echo '<li class="ui-state-default ui-left" style="background: #ddd;">
<label>' . $v['post_type'] . '</label>
<input type="text" value="' . $v['name'] . '"/>
</li>';
}
}
echo "</ul></div>";
echo "
<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>";
echo "
</fieldset>
</div>";
}
public function processData() {
// Make sure that the correct variables are used
$this->selected = $this->decode_param($this->data);
$this->data = $this->encode_param($this->data);
$this->types = get_post_types(array(
"public" => true,
"_builtin" => false
), "objects", "OR");
foreach ($this->types as $k => $v) {
if (in_array($k, array(
"revision", "nav_menu_item", "attachment", "acf", "wpcf7_contact_form", "dslc_templates",
"acf-field", "acf-group", "acf-groups"
))) {
unset($this->types[$k]);
continue;
}
}
}
public final function getData() {
return $this->data;
}
public final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,132 @@
<?php
use WPDRMS\ASP\Query\SearchQuery;
use WPDRMS\ASP\Utils\Ajax;
if (!class_exists("wd_CPTSearchCallBack")) {
/**
* Class wd_CPTSearchCallBack
*
* Custom post type search for both post meta and user meta tables, which passes the results to a JS callback method
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_CPTSearchCallBack extends wpdreamsType {
private static $delimiter = '!!!CPTRES!!!';
private $post_title = '';
private $args = array(
'callback' => '', // javacsript function name in the windows scope | if empty, shows results
'placeholder' => 'Search in post types..',
'search_values' => 0,
'limit' => 10,
'delimiter' => '!!!CPTRES!!!',
'controls_position' => 'right',
'class' => ''
);
public function getType() {
parent::getType();
$this->processData();
$this->args['delimiter'] = self::$delimiter;
?>
<div class='wd_cpt_search<?php echo $this->args['class'] != '' ? ' '.$this->args['class'] : "";?>'
id='wd_cpt_search-<?php echo self::$_instancenumber; ?>'>
<label for='wd_cpt_search-input-<?php echo self::$_instancenumber; ?>'><?php echo $this->label; ?></label>
<?php if ($this->args['controls_position'] == 'left') $this->printControls(); ?>
<input type="search"
class="hiddend wd_cpt_search"
value=""
id='wd_cpt_search-input-<?php echo self::$_instancenumber; ?>'
placeholder="<?php echo $this->args['placeholder']; ?>"/>
<input type='hidden'
name="<?php echo $this->name; ?>"
isparam="1"
value="<?php echo (is_array($this->data) && isset($this->data['value'])) ? $this->data['value'] : $this->data; ?>">
<input type="hidden" class="wd_cpt_search_nonce" value="<?php echo wp_create_nonce( 'wd_cpt_search_nonce' ); ?>">
<input type='hidden' value="<?php echo base64_encode(json_encode($this->args)); ?>" class="wd_args">
<?php if ($this->args['controls_position'] != 'left') $this->printControls(); ?>
<div class="wd_cpt_search_res"></div>
<span class="wp_cpt_search_selected "><span class="fa fa-ban"></span><span><?php echo esc_html($this->post_title); ?></span></span>
</div>
<?php
}
private function printControls() {
?>
<span class="loading-small hiddend"></span>
<div class="wd_ts_close hiddend">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<polygon id="x-mark-icon" points="438.393,374.595 319.757,255.977 438.378,137.348 374.595,73.607 255.995,192.225 137.375,73.622 73.607,137.352 192.246,255.983 73.622,374.625 137.352,438.393 256.002,319.734 374.652,438.378 "></polygon>
</svg>
</div>
<?php
}
public static function searchCPT() {
global $wpdb;
if (
isset($_POST['wd_phrase'], $_POST['wd_cpt_search_nonce']) &&
( current_user_can( 'manage_options' ) || apply_filters('wpdrms/backend/options/ajax/user_role_override', false) ) &&
wp_verify_nonce( $_POST["wd_cpt_search_nonce"], 'wd_cpt_search_nonce' )
) {
$phrase = trim($_POST['wd_phrase']);
$data = json_decode(base64_decode($_POST['wd_args']), true);
$ptypes = get_post_types(array(
"public" => true,
"_builtin" => false
), "names", "OR");
$exclude = array("revision", "nav_menu_item", "attachment", 'peepso-post', 'peepso-comment', "acf",
"oembed_cache", "user_request", "wp_block", "shop_coupon", "avada_page_options",
"_pods_template", "_pods_pod", "_pods_field", "bp-email",
"lbmn_archive", "lbmn_footer", "mc4wp-form",
"elementor-front", "elementor-icon",
"fusion_template", "fusion_element", "wc_product_tab", "customize_changeset",
"wpcf7_contact_form", "dslc_templates", "acf-field", "acf-group", "acf-groups", "acf-field-group", "custom_css");
$ptypes = array_diff($ptypes, $exclude);
$asp_query = new SearchQuery(array(
"s" => $phrase,
"_ajax_search" => false,
'keyword_logic' => 'and',
'secondary_logic' => 'or',
"posts_per_page" => 20,
'post_type' => $ptypes,
'post_status' => array(),
'post_fields' => array(
'title', 'ids'
)
));
$results = $asp_query->posts;
Ajax::prepareHeaders();
print_r(self::$delimiter . json_encode($results) . self::$delimiter);
}
die();
}
public function processData() {
// Get the args first if exists
if ( is_array($this->data) && isset($this->data['args']) )
$this->args = array_merge($this->args, $this->data['args']);
if ( is_array($this->data) && isset($this->data['value']) ) {
// If called from back-end non-post context
$this->data = $this->data['value'];
$this->post_title = get_the_title($this->data) . " (" . get_post_type($this->data) . ")";
}
}
public final function getData() {
return $this->data;
}
}
}
if ( !has_action('wp_ajax_wd_search_cb_cpt') )
add_action('wp_ajax_wd_search_cb_cpt', 'wd_CPTSearchCallBack::searchCPT');

View File

@@ -0,0 +1,181 @@
<?php
use WPDRMS\ASP\Query\SearchQuery;
use WPDRMS\ASP\Utils\Ajax;
if (!class_exists("wd_CPTSelect")) {
/**
* Class wd_CPTSelect
*
* Post/page/cpt select and search class.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_CPTSelect extends wpdreamsType {
private $args = array(
'show_parent_checkbox' => 1
);
private $e_data;
public function getType() {
parent::getType();
$this->processData();
?>
<div class='wd_cpt_select' id='wd_cpt_select-<?php echo self::$_instancenumber; ?>'>
<fieldset>
<div style='margin:15px 30px;text-align: left; line-height: 45px;'>
<label>
<?php echo __('Search posts/pages/cpt:', 'ajax-search-pro'); ?>
<input type="hidden" class="wd_cpt_select_search_nonce" value="<?php echo wp_create_nonce( 'wd_cpt_select_search_nonce' ); ?>">
<input type="text" class="wd_cpt_search" placeholder="<?php echo __('Type title or ID here..', 'ajax-search-pro'); ?>"/>
</label>
</div>
<legend><?php echo $this->label; ?></legend>
<div class="draggablecontainer" id="sortablecontainer<?php echo self::$_instancenumber; ?>">
<div class="dragLoader hiddend"></div>
<p><?php echo __('Results', 'ajax-search-pro'); ?></p>
<ul id="sortable<?php echo self::$_instancenumber; ?>" class="connectedSortable wd_csortable<?php echo self::$_instancenumber; ?>">
<?php echo __('Use the search to look for posts', 'ajax-search-pro'); ?> :)
</ul>
</div>
<div class="sortablecontainer"><p><?php echo __('Drag here the ones you want to', 'ajax-search-pro'); ?> <span style="font-weight: bold;" class="tts_type"><?php echo $this->e_data['op_type']; ?></span>!</p>
<ul id="sortable_conn<?php echo self::$_instancenumber; ?>" class="connectedSortable wd_csortable<?php echo self::$_instancenumber; ?>">
<?php $this->printSelectedPosts(); ?>
</ul>
</div>
<input type='hidden' value="<?php echo base64_encode(json_encode($this->args)); ?>" class="wd_args">
<input isparam=1 type='hidden' value="<?php echo (is_array($this->data) && isset($this->data['value'])) ? $this->data['value'] : $this->data; ?>" name='<?php echo $this->name; ?>'>
</fieldset>
</div>
<?php
}
private function printSelectedPosts() {
if ( count($this->e_data['ids']) > 0 ) {
$ptypes = get_post_types(array(
"public" => true,
"_builtin" => false
), "names", "OR");
$ptypes = array_diff($ptypes, array(
"revision", "nav_menu_item", "attachment", "acf", "wpcf7_contact_form", "dslc_templates",
"acf-field", "acf-group", "acf-groups"
));
$items = get_posts(array(
'posts_per_page' => count($this->e_data['ids']),
'post_type' => $ptypes,
'post__in' => $this->e_data['ids'],
'post_status' => 'any'
));
foreach ($items as $p) {
if (empty($p) || is_wp_error($p))
continue;
$checkbox = "";
if ($this->args['show_parent_checkbox'] == 1 && $p->post_type == 'page')
$checkbox = '<div class="exclude_child">' . __('Exclude direct children too?', 'ajax-search-pro') . ' <input type="checkbox" value="' . $p->ID . '"
' . (in_array($p->ID, $this->e_data['parent_ids']) ? ' checked="checked"' : '') . '/></div>';
echo '
<li class="ui-state-default" post_id="' . $p->ID . '">' . $p->post_title . '
<span class="extra_info">[id: '.$p->ID.'] [' . $p->post_type . '] [' . $p->post_status . ']</span>
' . $checkbox . '
<a class="deleteIcon"></a></li>
';
}
}
}
public static function searchPosts() {
if (
isset($_POST['wd_phrase'], $_POST['wd_cpt_select_search_nonce']) &&
( current_user_can( 'manage_options' ) || apply_filters('wpdrms/backend/options/ajax/user_role_override', false) ) &&
wp_verify_nonce( $_POST["wd_cpt_select_search_nonce"], 'wd_cpt_select_search_nonce' )
) {
$phrase = trim($_POST['wd_phrase']);
$data = json_decode(base64_decode($_POST['wd_args']), true);
$ptypes = get_post_types(array(
"public" => true,
"_builtin" => false
), "names", "OR");
$exclude = array("revision", "nav_menu_item", 'peepso-post', 'peepso-comment', "acf",
"oembed_cache", "user_request", "wp_block", "shop_coupon", "avada_page_options",
"_pods_template", "_pods_pod", "_pods_field", "bp-email",
"lbmn_archive", "lbmn_footer", "mc4wp-form",
"elementor-front", "elementor-icon",
"fusion_template", "fusion_element", "wc_product_tab", "customize_changeset",
"wpcf7_contact_form", "dslc_templates", "acf-field", "acf-group", "acf-groups", "acf-field-group", "custom_css");
$ptypes = array_diff($ptypes, $exclude);
$asp_query = new SearchQuery(array(
"s" => $phrase,
"_ajax_search" => false,
'keyword_logic' => 'and',
'secondary_logic' => 'or',
"posts_per_page" => 20,
'post_type' => $ptypes,
'post_status' => array('publish', 'future', 'pending', 'private'),
'post_fields' => array(
'title', 'ids'
)
));
$results = $asp_query->posts;
Ajax::prepareHeaders();
if ( ! empty( $results ) ) {
echo "Results (".count($results)."): ";
foreach ( $results as $p ) {
$checkbox = "";
if ($data['show_parent_checkbox'] == 1 && $p->post_type == 'page')
$checkbox = '<div class="exclude_child">' . __('Exclude direct children too?', 'ajax-search-pro') . ' <input type="checkbox" value="' . $p->ID . '"/></div>';
echo '
<li class="ui-state-default" post_id="' . $p->ID . '">'. $p->post_title . '
<span class="extra_info">[id: '.$p->ID.'] ['.$p->post_type.'] ['.$p->post_status.']</span>
' . $checkbox . '
<a class="deleteIcon"></a></li>
';
}
} else {
echo __('No items found for term:', 'ajax-search-pro') . ' <b>' . esc_html($phrase) .'<b>';
}
}
die();
}
public function processData() {
// Get the args first if exists
if ( is_array($this->data) && isset($this->data['args']) )
$this->args = array_merge($this->args, $this->data['args']);
if ( is_array($this->data) && isset($this->data['value']) ) {
// If called from back-end non-post context
$this->e_data = $this->decode_param($this->data['value']);
$this->data = $this->encode_param($this->data['value']);
} else {
// POST method or something else
$this->e_data = $this->decode_param($this->data);
$this->data = $this->encode_param($this->data);
}
/**
* At this point the this->data variable surely contains the encoded data, no matter what.
*/
}
public final function getData() {
return $this->data;
}
public final function getSelected() {
return $this->e_data;
}
}
}
if ( !has_action('wp_ajax_wd_search_cpt') )
add_action('wp_ajax_wd_search_cpt', 'wd_CPTSelect::searchPosts');

View File

@@ -0,0 +1,177 @@
<?php
if (!class_exists("wd_DraggableFields")) {
/**
* Class wd_DraggableFields
*
* A new multi-purpose, flexible abstract field editor - witch checkboxes and display mode option
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_DraggableFields extends wpdreamsType {
private $e_data;
private $args = array(
"show_checkboxes" => 0, // Checkboxes for default states
"show_display_mode" => 0, // Display mode option
"show_labels" => 0, // Display inputs to edit the labels
"show_required" => 0,
/**
* It's more logical to add the fields via arguments, because it can be extended - as opposing to
* options, which are stored permanently after saving.
*/
'fields' => array(
/*'field1' => 'Field label 1',
'field2' => 'Field label 2'*/
),
'checked' => array() // true|array() Which ones are checked by default on drag?
);
private $default_options = array(
'display_mode' => 'checkboxes', // checkboxes, dropdown, radio
'selected' => array('exact', 'title', 'content', 'excerpt', 'comments'),
'required' => false,
'invalid_input_text' => 'Please select an option!',
'unselected' => array(),
/**
* This only contains the items from the selected array, for the front-end,
* because of the labels - as the $args is not available on the front-end,
* and somehow we need to display the labels, do we?
* (this is calculated every time, but a default value is needed)
*/
'labels' => array(
'field1' => 'Field label 1',
'field2' => 'Field label 2'
),
'checked' => array('exact', 'title', 'content', 'excerpt', 'comments')
);
public function getType() {
parent::getType();
$this->processData();
?>
<div class='wd_DraggableFields' id='wd_DraggableFields-<?php echo self::$_instancenumber; ?>'>
<fieldset>
<legend><?php echo $this->label; ?></legend>
<?php if ($this->args['show_display_mode']): ?>
<div class="wd_df_display_mode_container"><label>
<?php echo __('Display mode:', 'ajax-search-pro'); ?>
<select class="wd_df_display_mode" id="wd_df_display_mode-<?php echo self::$_instancenumber; ?>">
<option value="checkboxes"<?php echo $this->e_data['display_mode'] == 'checkboxes' ? ' selected="selected"' : '';?>>
<?php echo __('Checkboxes', 'ajax-search-pro'); ?>
</option>
<option value="dropdown"<?php echo $this->e_data['display_mode'] == 'dropdown' ? ' selected="selected"' : '';?>>
<?php echo __('Drop-down', 'ajax-search-pro'); ?>
</option>
<option value="radio"<?php echo $this->e_data['display_mode'] == 'radio' ? ' selected="selected"' : '';?>>
<?php echo __('Radio buttons', 'ajax-search-pro'); ?>
</option>
</select>
</label></div>
<?php endif; ?>
<?php if ($this->args['show_required']): ?>
<div class="wd_df_required_container">
<label>
<?php echo __('Required?', 'ajax-search-pro'); ?>
<input type="checkbox" class="wd_df_required" <?php echo $this->e_data['required'] ? " checked=checked" :''; ?>>
</label>
<label>
<?php echo __('Required popup text:', 'ajax-search-pro'); ?>
<input type="text" class="wd_df_invalid_input_text" value="<?php echo esc_attr($this->e_data['invalid_input_text']); ?>">
</label>
</div>
<?php endif; ?>
<div class="draggablecontainer" id="sortablecontainer<?php echo self::$_instancenumber; ?>">
<p>&nbsp;</p>
<ul style='text-align:left;' id="sortable<?php echo self::$_instancenumber; ?>" class="connectedSortable wd_csortable<?php echo self::$_instancenumber; ?>">
<?php $this->printAvailableFields(); ?>
</ul>
</div>
<div class="sortablecontainer"><p><?php echo __('Drag here the terms you want to include!', 'ajax-search-pro'); ?></p>
<ul style='text-align:left;' id="sortable_conn<?php echo self::$_instancenumber; ?>" class="connectedSortable wd_csortable<?php echo self::$_instancenumber; ?>">
<?php $this->printSelectedFields(); ?>
</ul>
</div>
<input type='hidden' value="<?php echo base64_encode(json_encode($this->args)); ?>" class="wd_args">
<input isparam=1 type='hidden' value="<?php echo (is_array($this->data) && isset($this->data['value'])) ? $this->data['value'] : $this->data; ?>" name='<?php echo $this->name; ?>'>
</fieldset>
</div>
<?php
}
public function printAvailableFields() {
foreach ($this->args['fields'] as $k=>$field) {
$checkbox = '';
if ($this->args['show_checkboxes'] == 1) {
if ( $this->args['checked'] === true || in_array($k, $this->args['checked']) )
$_c = ' checked="checked"';
else
$_c = '';
$checkbox = '<label class="wd_plain">' . __('Checked?', 'ajax-search-pro') . ' <input style="float:left;" type="checkbox" value="' . $k . '"'.$_c.'/></label>';
}
if ($this->args['show_labels'] == 1)
$input = '<label>'.$this->args['fields'][$k].'</label><input type="text" value="'.$this->args['fields'][$k].'"/>';
else
$input = $this->args['fields'][$k];
if ( in_array($k, $this->e_data['selected']) )
$disabled = ' ui-state-disabled';
else
$disabled = '';
echo '<li class="ui-state-default'.$disabled.'" field="'.$k.'">
<span class="wd_drag_visible">'.$this->args['fields'][$k].'</span>
'.$input.$checkbox.'
<a class="deleteIcon wd_icon_absolute"></a>
</li>';
}
}
public function printSelectedFields() {
foreach ($this->e_data['selected'] as $field) {
$checkbox = '';
if ($this->args['show_labels'] == 1)
$input = '<label>'.$this->args['fields'][$field].'</label><input type="text" value="'.$this->e_data['labels'][$field].'">';
else
$input = $this->args['fields'][$field];
if ($this->args['show_checkboxes'] == 1)
$checkbox = '<label class="wd_plain">' . __('Checked?', 'ajax-search-pro') . ' <input style="float:left;" type="checkbox" value="' . $field . '"
' . (in_array($field, $this->e_data['checked']) ? ' checked="checked"' : '') . '/></label>';
echo '<li class="ui-state-default" field="'.$field.'">
'.$input.$checkbox.'
<a class="deleteIcon wd_icon_absolute"></a>
</li>';
}
}
public function processData() {
// Get the args first if exists
if ( is_array($this->data) && isset($this->data['args']) )
$this->args = array_merge($this->args, $this->data['args']);
if ( is_array($this->data) && isset($this->data['value']) ) {
// If called from back-end non-post context
$this->e_data = $this->decode_param($this->data['value']);
$this->data = $this->encode_param($this->data['value']);
} else {
// POST method or something else
$this->e_data = $this->decode_param($this->data);
$this->data = $this->encode_param($this->data);
}
// All keys are strings in array, merge it with defaults to override
$this->e_data = array_merge($this->default_options, $this->e_data);
/**
* At this point the this->data variable surely contains the encoded data, no matter what.
*/
}
public final function getData() {
return $this->data;
}
public final function getSelected() {
return $this->e_data;
}
}
}

View File

@@ -0,0 +1,135 @@
<?php
abstract class WD_FrontFilters_Module_Abstract {
protected $name = 'abstract'; // Short module name - must be DISTINCTIVE, used in data manipulation
protected $title = 'Module label';
protected $icon = 'module.png';
protected $output = '';
protected $version = '1.0'; // Used in CSS and JS enqueue
protected $output_files = array(/*
'/../views/file1.php',
'/../views/file2.php',
...
*/);
protected $css_files = array(/*
array(
'handle' => 'script-handle-name',
'file' => 'file.js',
'dependencies' => array('jquery'),
'media' => 'all'
),
...
*/);
protected $js_files = array(/*
array(
'handle' => 'script-handle-name',
'file' => 'file.js',
'dependencies' => array('jquery'),
'in_footer' => true
),
...
*/);
/**
* const = FINAL in this case, DO NOT OVERRIDE IN INHERENT CLASSES
* This data is shared across all modules. It is merged into static::$default_data
*/
const DEFAULT_SHARED_DATA = array(
'option' => array(
'visibility' => array(
'desktop' => true,
'tablet' => true,
'mobile' => true
),
'required' => false,
'required_text' => 'Please select an option!',
'column' => 1,
'row' => 1, // Not used yet
'position' => 1 // Position within column -> row
)
);
protected static $default_data = array(
/*
'option' => array( -> 'option' key is REQUIRED
'items' => ...,
'option1' => ...,
),
'item' => array( ... )
...
*/
);
public final function __construct() {
if ( !empty($this->type) && $this->type != 'abstract' ) {
$this->loadAssets();
$this->loadOutput();
static::mergeSharedDefaultData();
} else {
throw new Exception(static::class . ': Module not loaded, name should be set.');
}
}
public final function getOutput() {
return $this->output;
}
public final function getType() {
return $this->type;
}
public final function getTitle() {
return $this->title;
}
public final function getIcon() {
return $this->icon;
}
public static function getData( $data = array(), $all = false ) {
// self = this class, static = inherent class where it is used
return array_merge(static::$default_data, $data);
}
public static function ajax() {
// Register ajax handlers here
}
protected final static function mergeSharedDefaultData() {
static::$default_data['option'] =
isset(static::$default_data['option']) ? static::$default_data['option'] : array();
static::$default_data['option'] = wd_array_merge_recursive_distinct(
static::$default_data['option'], self::DEFAULT_SHARED_DATA['option']
);
}
protected function loadAssets(){
foreach ( $this->css_files as $css ) {
$css = array_merge(array(
'dependencies' => array(),
'version' => 1,
'media' => 'all'
), $css);
wp_enqueue_style($css['handle'], $css['file'], $css['dependencies'], $this->version, $css['media']);
}
foreach ( $this->js_files as $js ) {
$js = array_merge(array(
'dependencies' => array('jquery', 'wd-ff-main-module'),
'version' => 1,
'in_footer' => true
), $js);
wp_enqueue_script($js['handle'], $js['file'], $js['dependencies'], $this->version, $js['in_footer']);
}
}
protected function loadOutput(){
if ( !empty($this->output_files) ) {
foreach ( $this->output_files as $file ) {
ob_start();
require_once(dirname(__FILE__) . $file);
$this->output .= ob_get_clean();
}
}
}
}

View File

@@ -0,0 +1,74 @@
<?php
defined( 'ABSPATH' ) or die( "You can't access this file directly." );
class WD_FrontFilters_Module_ContentType extends WD_FrontFilters_Module_Abstract {
protected $type = 'content_type';
protected $title = 'Content type filter module';
protected $icon = ASP_URL . 'backend/settings/assets/wd_frontfilters/img/generic.png';
protected $output_files = array(
'/../views/content_type.php'
);
protected $css_files = array(
array(
'handle' => 'wd-ff-content-type-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/css/content_type.css'
)
);
protected $js_files = array(
array(
'handle' => 'wd-ff-content-type-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/js/content_type.js',
'dependencies' => array('jquery', 'wd-ff-main-module')
)
);
protected static $default_data = array(
'option' => array(
'id' => false,
'label' => array(
'text' => 'Content type filters',
'visible' => true
),
'type' => '',
'display_mode' => 'checkboxes',
'items' => array()
),
'item' => array(
'label' => '',
'selected' => false,
'field' => -1, // Can be numeric, as well as a field name etc..
'level' => 0,
'default' => false
),
'choices' => array(
-1 => 'Choose One/Select all',
'cpt' => 'Custom post types',
'comments' => 'Comments',
'taxonomies' => 'Taxonomies',
'users' => 'Users',
'blogs' => 'Multisite blogs',
'buddypress' => 'BuddyPress content',
'attachments' => 'Attachments'
)
);
public static function getData( $data = array(), $all = false ) {
// Deep array merge, options in general first, then the individual selections
$return = array_merge( self::$default_data['option'], $data );
foreach ( $return['items'] as &$item ) {
$item = array_merge(self::$default_data['item'], $item);
}
if ( $all ) {
return array_merge( self::$default_data, array('option' => $return) );
} else {
return $return;
}
}
public static function getDataEncoded( $data = array(), $all = false ) {
return base64_encode( json_encode( static::getData($data, $all) ) );
}
}

View File

@@ -0,0 +1,121 @@
<?php
defined( 'ABSPATH' ) or die( "You can't access this file directly." );
class WD_FrontFilters_Module_Custom_Field extends WD_FrontFilters_Module_Abstract {
protected $type = 'custom_field';
protected $title = 'Custom field filter module';
protected $icon = ASP_URL . 'backend/settings/assets/wd_frontfilters/img/generic.png';
protected $output_files = array(
'/../views/custom_field.php'
);
protected $css_files = array(
array(
'handle' => 'wd-ff-custom_field-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/css/custom_field.css'
)
);
protected $js_files = array(
array(
'handle' => 'wd-ff-custom_field-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/js/custom_field.js',
'dependencies' => array('jquery', 'wd-ff-main-module')
)
);
protected static $default_data = array(
'option' => array(
'id' => false,
'label' => array(
'text' => 'Filter by Custom Field',
'visible' => true
),
'display_mode' => 'checkboxes',
'display_mode_args' => array(
'checkboxes' => array(
'logic' => 'OR', // OR, AND
'hide_children_on_unchecked' => true
),
'dropdown' => array(
'multi' => false,
'searchable' => false,
'placeholder' => '',
'logic' => 'OR', // OR, AND, ANDSE
'multiple' => false
),
'slider' => array(
'slider_prefix' => '-,',
'slider_suffix' => '.',
'slider_step' => 1,
'slider_from' => 1,
'slider_to' => 1000,
'slider_decimals' => 0,
'slider_t_separator' => ' ',
'operator' => 'let'
),
'range' => array(
'range_prefix' => '-,',
'range_suffix' => '.',
'range_step' => 1,
'range_from' => 1,
'range_to' => 1000,
'range_decimals' => 0,
'range_t_separator' => ' '
),
'datepicker' => array(
'placeholder' => '',
'date_format' => 'dd/mm/yy',
'date_store_format' => 'datetime' // datetime, acf, timestamp
)
),
'select_all' => array(
'enabled' => true,
'text' => 'Select all/one'
),
'value_display' => array(
'selects' => '||Choose one/Any**', // Select types: checkbox, dropdown, multiselect, multisearch etc..
'text' => '', // Textarea, input type text, input type hidden
'slider' => '',
'range1' => '',
'range2' => '',
'datepicker' => ''
),
'value' => '', // Defaults are shown, the values is copied here (hidden)
'field' => 'field_name',
'field_source' => 'postmeta', // postmeta, usermeta
'operator' => 'like',
'required' => false,
'required_text' => 'Please select an option!',
'allow_empty' => false, // allow results where the field is not associated with the post type object
'column' => 1,
'row' => 1, // Not used yet
'position' => 1 // Position within column -> row
)
);
public static function getData( $data = array(), $all = false ) {
// Deep array merge, options in general first, then the individual selections
$return = wd_array_merge_recursive_distinct( self::$default_data['option'], $data );
foreach ( $return['items'] as &$item ) {
$item = array_merge(self::$default_data['item'], $item);
}
if ( $all ) {
$return = array_merge( self::$default_data, array('option' => $return) );
}
return $return;
}
public static function getDataEncoded( $data = array(), $all = false ) {
return base64_encode( json_encode( static::getData($data, $all) ) );
}
public static function ajax() {
if ( !has_action('wp_ajax_wd_ff_get_taxonomy_terms') )
add_action('wp_ajax_wd_ff_get_taxonomy_terms', get_called_class().'::getTerms');
if ( !has_action('wp_ajax_wd_ff_get_selected_taxonomy_terms') )
add_action('wp_ajax_wd_ff_get_selected_taxonomy_terms', get_called_class().'::getSelectedTerms');
}
}

View File

@@ -0,0 +1,60 @@
<?php
defined( 'ABSPATH' ) or die( "You can't access this file directly." );
class WD_FrontFilters_Module_DateFrom extends WD_FrontFilters_Module_Abstract {
protected $type = 'date_from';
protected $title = 'After date filter module';
protected $icon = ASP_URL . 'backend/settings/assets/wd_frontfilters/img/generic.png';
protected $output_files = array(
'/../views/date_from.php'
);
protected $css_files = array(
array(
'handle' => 'wd-ff-date-from-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/css/date_from.css'
)
);
protected $js_files = array(
array(
'handle' => 'wd-ff-date-from-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/js/date_from.js',
'dependencies' => array('jquery', 'wd-ff-main-module')
)
);
protected static $default_data = array(
'option' => array(
'id' => false,
'label' => array(
'text' => 'Date filter',
'visible' => true
),
'type' => '',
'display_mode' => 'relative_date', // relative_date, date
'date' => '',
'relative_date' => array(
'year' => 0,
'month' => 0,
'day' => 0
),
'placeholder' => 'Choose a date',
'date_format' => 'dd-mm-yy',
)
);
public static function getData( $data = array(), $all = false ) {
// Deep array merge, options in general first, then the individual selections
$return = wd_array_merge_recursive_distinct( self::$default_data['option'], $data );
if ( $all ) {
return array_merge( self::$default_data, array('option' => $return) );
} else {
return $return;
}
}
public static function getDataEncoded( $data = array(), $all = false ) {
return base64_encode( json_encode( static::getData($data, $all) ) );
}
}

View File

@@ -0,0 +1,24 @@
<?php
defined( 'ABSPATH' ) or die( "You can't access this file directly." );
class WD_FrontFilters_Module_DateTo extends WD_FrontFilters_Module_DateFrom {
protected $type = 'date_to';
protected $title = 'Before date filter module';
protected $icon = ASP_URL . 'backend/settings/assets/wd_frontfilters/img/generic.png';
protected $output_files = array(
'/../views/date_to.php'
);
protected $css_files = array(
array(
'handle' => 'wd-ff-date-to-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/css/date_to.css'
)
);
protected $js_files = array(
array(
'handle' => 'wd-ff-date-to-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/js/date_to.js',
'dependencies' => array('jquery', 'wd-ff-main-module', 'wd-ff-date-from-module')
)
);
}

View File

@@ -0,0 +1,76 @@
<?php
defined( 'ABSPATH' ) or die( "You can't access this file directly." );
class WD_FrontFilters_Module_Generic extends WD_FrontFilters_Module_Abstract {
protected $type = 'generic';
protected $title = 'Generic filter module';
protected $icon = ASP_URL . 'backend/settings/assets/wd_frontfilters/img/generic.png';
protected $output_files = array(
'/../views/generic.php'
);
protected $css_files = array(
array(
'handle' => 'wd-ff-generic-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/css/generic.css'
)
);
protected $js_files = array(
array(
'handle' => 'wd-ff-generic-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/js/generic.js',
'dependencies' => array('jquery', 'wd-ff-main-module')
)
);
protected static $default_data = array(
'option' => array(
'id' => false,
'label' => array(
'text' => 'Generic filter',
'visible' => true
),
'type' => '',
'display_mode' => 'checkboxes',
'items' => array(),
'required' => false,
'required_text' => 'Please select an option!',
'column' => 1,
'row' => 1, // Not used yet
'position' => 1 // Position within column -> row
),
'item' => array(
'label' => '',
'selected' => false,
'field' => -1, // Can be numeric, as well as a field name etc..
'level' => 0,
'default' => false
),
'choices' => array(
-1 => 'Choose One/Select all',
'exact' => 'Exact matches only',
'title' => 'Search in title',
'content' => 'Search in content',
'excerpt' => 'Search in excerpt'
)
);
public static function getData( $data = array(), $all = false ) {
// Deep array merge, options in general first, then the individual selections
$return = wd_array_merge_recursive_distinct( self::$default_data['option'], $data );
foreach ( $return['items'] as &$item ) {
$item = array_merge(self::$default_data['item'], $item);
}
if ( $all ) {
return array_merge( self::$default_data, array('option' => $return) );
} else {
return $return;
}
}
public static function getDataEncoded( $data = array(), $all = false ) {
return base64_encode( json_encode( static::getData($data, $all) ) );
}
}

View File

@@ -0,0 +1,87 @@
<?php
defined( 'ABSPATH' ) or die( "You can't access this file directly." );
class WD_FrontFilters_Module_PostType extends WD_FrontFilters_Module_Abstract {
protected $type = 'post_type';
protected $title = 'Post type filter module';
protected $icon = ASP_URL . 'backend/settings/assets/wd_frontfilters/img/generic.png';
protected $output_files = array(
'/../views/post_type.php'
);
protected $css_files = array(
array(
'handle' => 'wd-ff-post-type-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/css/post_type.css'
)
);
protected $js_files = array(
array(
'handle' => 'wd-ff-post-type-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/js/post_type.js',
'dependencies' => array('jquery', 'wd-ff-main-module')
)
);
protected static $default_data = array(
'option' => array(
'id' => false,
'label' => array(
'text' => 'Post type filter',
'visible' => true
),
'type' => '',
'display_mode' => 'checkboxes',
'items' => array(),
'required' => false,
'required_text' => 'Please select an option!',
'column' => 1,
'row' => 1, // Not used yet
'position' => 1 // Position within column -> row
),
'item' => array(
'label' => '',
'selected' => false,
'field' => -1, // Can be numeric, as well as a field name etc..
'level' => 0,
'default' => false
),
'choices' => array(
-1 => 'Choose One/Select all'
)
);
public static function getData( $data = array(), $all = false ) {
// Deep array merge, options in general first, then the individual selections
$return = wd_array_merge_recursive_distinct( self::$default_data['option'], $data );
foreach ( $return['items'] as &$item ) {
$item = array_merge(self::$default_data['item'], $item);
}
if ( $all ) {
$types = get_post_types(array(
"public" => true,
"_builtin" => false
), "objects", "OR");
$post_types = array();
foreach ($types as $k => $v) {
if ( !in_array($k, wpdreamsType::NON_DISPLAYABLE_POST_TYPES) ) {
$post_types[$k] = $v->label;
}
}
$return = array_merge( self::$default_data, array('option' => $return) );
if ( count($post_types) > 0 ) {
$return['choices'] = array_merge($return['choices'], $post_types);
}
}
return $return;
}
public static function getDataEncoded( $data = array(), $all = false ) {
return base64_encode( json_encode( static::getData($data, $all) ) );
}
}

View File

@@ -0,0 +1,225 @@
<?php
use WPDRMS\ASP\Utils\Ajax;
defined( 'ABSPATH' ) or die( "You can't access this file directly." );
class WD_FrontFilters_Module_Taxonomy extends WD_FrontFilters_Module_Abstract {
protected $type = 'taxonomy';
protected $title = 'Taxonomy terms filter module';
protected $icon = ASP_URL . 'backend/settings/assets/wd_frontfilters/img/generic.png';
protected $output_files = array(
'/../views/taxonomy.php'
);
protected $css_files = array(
array(
'handle' => 'wd-ff-taxonomy-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/css/taxonomy.css'
)
);
protected $js_files = array(
array(
'handle' => 'wd-ff-taxonomy-module',
'file' => ASP_URL . 'backend/settings/assets/wd_frontfilters/js/taxonomy.js',
'dependencies' => array('jquery', 'wd-ff-main-module')
)
);
protected static $default_data = array(
'option' => array(
'id' => false,
'label' => array(
'text' => 'Filter by Categories',
'visible' => true
),
'display_mode' => 'checkboxes',
'display_mode_args' => array(
'checkboxes' => array(
'default_state' => 'unchecked', // checked, unchecked
'hide_children_on_unchecked' => true
),
'dropdown' => array(
'default' => 'first' // Select all (-1), first, last or a term ID
)
),
'select_all' => array(
'enabled' => true,
'text' => 'Select all/one'
),
'items' => array(),
'taxonomy' => 'select',
'mode' => 'exclude',
'required' => false,
'required_text' => 'Please select an option!',
'hide_empty' => false,
'maintain_hierarchy' => true,
'term_orderby' => 'name', //name, count, ID,
'term_order' => 'ASC', // ASC DESC,
'allow_empty' => false, // allow results where the terms are not associated with the post type object
'term_logic' => 'and', // and, or, andex
'column' => 1,
'row' => 1, // Not used yet
'position' => 1 // Position within column -> row
),
'item' => array(
'label' => '',
'selected' => true,
'field' => -1, // Can be numeric, as well as a field name etc..
'level' => 0,
'default' => false
),
'choices' => array()
);
public function getTaxonomiesList() {
$taxonomies = get_taxonomies(array(), 'objects');
$taxonomies_array = array();
foreach ( $taxonomies as $k => $taxonomy ) {
$taxonomies_array[$taxonomy->name] =
$taxonomy->name . ' - ' . $taxonomy->labels->name .
( isset($taxonomy->object_type[0]) ? ' [' . implode(', ', $taxonomy->object_type) . ']' : '' );
}
return $taxonomies_array;
}
public static function getData( $data = array(), $all = false ) {
// Deep array merge, options in general first, then the individual selections
$return = wd_array_merge_recursive_distinct( self::$default_data['option'], $data );
foreach ( $return['items'] as &$item ) {
$item = array_merge(self::$default_data['item'], $item);
}
if ( $all ) {
$return = array_merge( self::$default_data, array('option' => $return) );
}
return $return;
}
public static function getDataEncoded( $data = array(), $all = false ) {
return base64_encode( json_encode( static::getData($data, $all) ) );
}
public static function getSelectedTerms() {
$taxonomy = $_POST['wd_taxonomy'];
$items = $_POST['wd_items'];
$selected = self::$default_data['item'];
foreach($items as $k => &$t) {
if ( $t['id'] == -200 && $taxonomy == 'post_format' ) {
$t = apply_filters('asp_post_format_standard', $t);
$t['label'] = 'Standard';
} else {
$term = get_term($t['id'], $taxonomy);
if ( empty($term) || is_wp_error($term) ) {
unset($items[$k]);
continue;
}
$t['label'] = $term->name;
// WPML
$language_code = apply_filters( 'wpml_element_language_code', null, array( 'element_id'=> (int)$term->term_id, 'element_type'=> $term->taxonomy ) );
if ( defined('ICL_SITEPRESS_VERSION') && !empty($language_code) ) {
$t['label'] .= ' [' . $language_code . ']';
}
}
}
if ( isset($_POST['wd_selected']) ) {
$term = get_term($_POST['wd_selected'], $taxonomy);
if ( !empty($term) && !is_wp_error($term) ) {
$selected['label'] = $term->name;
$selected['id'] = $term->term_id;
// WPML
$language_code = apply_filters( 'wpml_element_language_code', null, array( 'element_id'=> (int)$term->term_id, 'element_type'=> $term->taxonomy ) );
if ( defined('ICL_SITEPRESS_VERSION') && !empty($language_code) ) {
$selected['label'] .= ' [' . $language_code . ']';
}
}
}
print_r("!!ASPSTART_HTML!!" . json_encode($items) . "!!ASPEND_HTML!!");
print_r("!!ASPSTART_SELECTED!!" . json_encode($selected) . "!!ASPEND_SELECTED!!");
die();
}
public static function getTerms() {
$ret = array();
$taxonomy = $_POST['wd_taxonomy'];
// WPMl?
$languages = apply_filters( 'wpml_active_languages', NULL, 'orderby=id&order=desc' );
$terms = array();
$args = array(
'taxonomy' => $taxonomy,
'hide_empty' => false
);
// This is a search too
if ( isset($_POST['wd_phrase']) ) {
$args = array_merge($args, array(
'search' => trim($_POST['wd_phrase']),
'number' => 15
));
}
if ( defined('ICL_SITEPRESS_VERSION') && !empty( $languages ) ) {
foreach( $languages as $l ) {
if ( isset($l['language_code']) ) {
do_action( 'wpml_switch_language', $l['language_code'] );
$gterms = get_terms($taxonomy, $args);
if ( !is_wp_error($gterms) && count($gterms) > 0 ) {
$terms = array_merge( $terms, $gterms );
foreach ( $gterms as &$term ) {
$term->name = $term->name . ' [' . $l['language_code'] . ']';
}
}
}
}
} else {
$terms = get_terms($taxonomy, $args);
}
if ( $taxonomy == 'post_format' && !is_wp_error($terms) && !empty($terms) ) {
$std_term = new stdClass();
$std_term->term_id = -200;
$std_term->taxonomy = 'post_format';
$std_term->children = array();
$std_term->name = 'Standard';
$std_term->label = 'Standard';
$std_term->parent = 0;
$std_term = apply_filters('asp_post_format_standard', $std_term);
array_unshift($terms, $std_term);
}
Ajax::prepareHeaders();
if ( !empty($terms) && is_array($terms) ) {
$termsHierarchical = array();
wd_sort_terms_hierarchicaly($terms, $termsHierarchical);
wd_flatten_hierarchical_terms($termsHierarchical, $terms);
foreach ( $terms as $term ) {
$ret[] = array_merge(self::$default_data['item'], array(
'id' => $term->term_id,
'label' => $term->name,
'level' => $term->level
));
}
}
print_r("!!ASPSTART_HTML!!" . json_encode($ret) . "!!ASPEND_HTML!!");
die();
}
public static function ajax() {
if ( !has_action('wp_ajax_wd_ff_get_taxonomy_terms') )
add_action('wp_ajax_wd_ff_get_taxonomy_terms', get_called_class().'::getTerms');
if ( !has_action('wp_ajax_wd_ff_get_selected_taxonomy_terms') )
add_action('wp_ajax_wd_ff_get_selected_taxonomy_terms', get_called_class().'::getSelectedTerms');
}
}

View File

@@ -0,0 +1,71 @@
<div class="content_type_filter_container">
<h1>Content Type Filter</h1>
<div class="content_type_filter_attributes">
<label for="taxonomy_filter_label" class="wd_ff_title_label">
<?php _e('Label', 'ajax-search-pro'); ?>
<input type="text" attr="label.text" maxlength="60">
<?php _e('is visible?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="label.visible">
</label>
<label for="content_type_filter_display_mode">
<?php _e('Display mode', 'ajax-search-pro'); ?>
<select attr="display_mode">
<option value="checkboxes"><?php _e('Checkboxes', 'ajax-search-pro'); ?></option>
<option value="dropdown"><?php _e('Dropdown', 'ajax-search-pro'); ?></option>
<option value="radio"><?php _e('Radio', 'ajax-search-pro'); ?></option>
</select>
</label>
</div>
<div class="content_type_filter_fields">
<div class="draggablecontainer">
<ul style='text-align:left;' class="connectedSortable" id="content_type_draggable">
<?php foreach ( $this::getData( array(), true )['choices'] as $field => $choice ): ?>
<li class="ui-state-default ui-draggable ui-draggable-handle" data-field="<?php echo $field; ?>">
<span class="wd_drag_visible"><?php echo $choice; ?></span>
<span class="wd_sort_visible">
<label><?php echo __($choice, 'ajax_search_pro'); ?></label>
<input type="text" attr="label" maxlength="100" value="<?php echo $choice; ?>">
<label class="wd_plain">
<?php _e('Checked?', 'ajax-search-pro'); ?> <input type="checkbox" attr="selected" value="content" checked="checked">
</label>
<a class="fa fa-minus-circle content_type_filter_remove"></a>
</span>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="sortablecontainer">
<ul style='text-align:left;' class="connectedSortable" id="content_type_sortable">
</ul>
</div>
</div>
<div class="content_type_filter_other_attributes">
<fieldset>
<legend><?php _e('Visibility', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Desktop', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.desktop">
</label>
<label>
<?php _e('Tablet', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.tablet">
</label>
<label>
<?php _e('Mobile', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.mobile">
</label>
</fieldset>
<fieldset>
<legend><?php _e('Neccessity', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Is at least one selection required?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="required">
</label>
<label wd-disable-on="required:0">
<?php _e('Text:', 'ajax-search-pro'); ?>
<input type="text" attr="required_text">
</label>
</fieldset>
</div>
<div style="clear:both"></div>
</div>

View File

@@ -0,0 +1,105 @@
<div class="generic_filter_container">
<h1>Generic Filter</h1>
<div class="generic_filter_attributes">
<label class="wd_ff_title_label">
<?php _e('Label', 'ajax-search-pro'); ?>
<input type="text" attr="label.text" maxlength="60">
<?php _e('is visible?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="label.visible">
</label>
<label for="generic_filter_display_mode">
<?php _e('Display mode', 'ajax-search-pro'); ?>
<select attr="display_mode">
<option value="checkboxes"><?php _e('Checkboxes', 'ajax-search-pro'); ?></option>
<option value="dropdown"><?php _e('Dropdown', 'ajax-search-pro'); ?></option>
<option value="radio"><?php _e('Radio', 'ajax-search-pro'); ?></option>
<option value="text"><?php _e('Text', 'ajax-search-pro'); ?></option>
<option value="hidden"><?php _e('Hidden', 'ajax-search-pro'); ?></option>
<option value="slider"><?php _e('Slider', 'ajax-search-pro'); ?></option>
<option value="range"><?php _e('Range slider', 'ajax-search-pro'); ?></option>
<option value="datepicker"><?php _e('Date picker', 'ajax-search-pro'); ?></option>
</select>
</label>
<fieldset wd-show-on="display_mode:checkboxes,dropdown,radio">
<label>
<?php _e('Values', 'ajax-search-pro'); ?>
<textarea attr="value_display.selects"></textarea>
<?php echo sprintf( __('One item per line. Use the <strong>{get_values}</strong> variable to get custom field values automatically.
For more info see the
<a target="_blank" href="%s">documentation</a>.', 'ajax-search-pro'), 'https://documentation.ajaxsearchpro.com/frontend-search-settings/custom-field-selectors' );
?>
</label>
<label>
<?php _e('Operator', 'ajax-search-pro'); ?>
<select attr="operator">
<optgroup label="<?php _e('Numeric operators', 'ajax-search-pro'); ?>">
<option value="eq">EQUALS</option>
<option value="neq">NOT EQUALS</option>
<option value="lt">LESS THEN</option>
<option value="let">LESS OR EQUALS THEN</option>
<option value="gt">MORE THEN</option>
<option value="get">MORE OR EQUALS THEN</option>
</optgroup>
<optgroup label="String operators">
<option value="elike">EXACTLY LIKE</option>
<option value="like" selected="selected">LIKE</option>
<option value="not elike">NOT EXACTLY LIKE</option>
<option value="not like">NOT LIKE</option>
</optgroup>
</select>
</label>
</fieldset>
<fieldset wd-show-on="display_mode:dropdown">
<label>
<?php _e('Multiselect?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="display_mode_args.dropdown.multi">
</label>
<label>
<?php _e('Searchable?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="display_mode_args.dropdown.searchable">
<?php _e('placeholder', 'ajax-search-pro'); ?>
<input type="text" attr="display_mode_args.dropdown.placeholder">
</label>
<label>
<?php _e('Drop-down values logic', 'ajax-search-pro'); ?>
<select attr="display_mode_args.dropdown.logic">
<option value="OR"><?php _e('OR', 'ajax-search-pro'); ?></option>
<option value="AND"><?php _e('AND', 'ajax-search-pro'); ?></option>
<option value="ANDSE"><?php _e('AND in separate fields', 'ajax-search-pro'); ?></option>
</select>
</label>
</fieldset>
<fieldset wd-show-on="display_mode:text,hidden">
<textarea attr="value_display.text"></textarea>
</fieldset>
</div>
<div class="generic_filter_other_attributes">
<fieldset>
<legend><?php _e('Visibility', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Desktop', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.desktop">
</label>
<label>
<?php _e('Tablet', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.tablet">
</label>
<label>
<?php _e('Mobile', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.mobile">
</label>
</fieldset>
<fieldset>
<legend><?php _e('Neccessity', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Is at least one selection required?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="required">
</label>
<label wd-disable-on="required:0">
<?php _e('Text:', 'ajax-search-pro'); ?>
<input type="text" attr="required_text">
</label>
</fieldset>
</div>
<div style="clear:both"></div>
</div>

View File

@@ -0,0 +1,80 @@
<div class="date_from_filter_container">
<h1><?php _e('After date Filter', 'ajax-search-pro'); ?></h1>
<div class="date_from_filter_attributes">
<label class="wd_ff_title_label">
<?php _e('Label', 'ajax-search-pro'); ?>
<input type="text" attr="label.text" maxlength="60">
<?php _e('is visible?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="label.visible">
</label>
<label for="date_from_filter_display_mode">
<?php _e('Mode', 'ajax-search-pro'); ?>
<select attr="display_mode" attr="display_mode">
<option value="relative_date"><?php _e('Relative Date', 'ajax-search-pro'); ?></option>
<option value="date"><?php _e('Date', 'ajax-search-pro'); ?></option>
</select>
</label>
<div class="date_from_filter_rel_date" wd-show-on="display_mode:relative_date">
<?php _e('Relative', 'ajax-search-pro'); ?>
<input attr="relative_date.year" aria-label="Years" type="number" class="threedigit" value=""><?php _e('years', 'ajax-search-pro'); ?>&nbsp;
<input attr="relative_date.month" aria-label="Months" type="number" class="threedigit" value=""><?php _e('months', 'ajax-search-pro'); ?>&nbsp;
<input attr="relative_date.day" aria-label="Days before current date" type="number" class="threedigit" value="">&nbsp; <?php _e('days before current date', 'ajax-search-pro'); ?>
<p class="wd_ff_desc_right">
<?php _e('It is possible to use negative values as well.', 'ajax-search-pro'); ?>
</p>
</div>
<div class="date_from_filter_date" wd-show-on="display_mode:date">
<label>
<?php _e('Date', 'ajax-search-pro'); ?>
<input type="text" attr="date" value="">
</label>
<p class="wd_ff_desc_right">
<?php _e('Empty value can be used, in that case the placeholder text will appear.', 'ajax-search-pro'); ?>
</p>
</div>
<div class="date_from_filter_placeholder">
<label>
<?php _e('Placeholder text', 'ajax-search-pro'); ?>
<input type="text" attr="placeholder" value="">
</label>
</div>
<div class="date_from_filter_date_format">
<label>
<?php _e('Date format', 'ajax-search-pro'); ?>
<input type="text" attr="date_format" value="">
</label>
<p class="wd_ff_desc_right">
<?php echo sprintf( __('dd/mm/yy is the most popular format, <a href="%s" target="_blank">list of accepted params</a>', 'ajax-search-pro'), 'http://api.jqueryui.com/datepicker/#utility-formatDate' ); ?>
</p>
</div>
</div>
<div class="date_from_filter_other_attributes">
<fieldset>
<legend><?php _e('Visibility', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Desktop', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.desktop">
</label>
<label>
<?php _e('Tablet', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.tablet">
</label>
<label>
<?php _e('Mobile', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.mobile">
</label>
</fieldset>
<fieldset>
<legend><?php _e('Neccessity', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Is at least one selection required?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="required">
</label>
<label wd-disable-on="required:0">
<?php _e('Text:', 'ajax-search-pro'); ?>
<input type="text" attr="required_text">
</label>
</fieldset>
</div>
<div style="clear:both"></div>
</div>

View File

@@ -0,0 +1,80 @@
<div class="date_to_filter_container">
<h1><?php _e('Before date Filter', 'ajax-search-pro'); ?></h1>
<div class="date_to_filter_attributes">
<label class="wd_ff_title_label">
<?php _e('Label', 'ajax-search-pro'); ?>
<input type="text" attr="label.text" maxlength="60">
<?php _e('is visible?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="label.visible">
</label>
<label for="date_to_filter_display_mode">
<?php _e('Mode', 'ajax-search-pro'); ?>
<select attr="display_mode" attr="display_mode">
<option value="relative_date"><?php _e('Relative Date', 'ajax-search-pro'); ?></option>
<option value="date"><?php _e('Date', 'ajax-search-pro'); ?></option>
</select>
</label>
<div class="date_to_filter_rel_date" wd-show-on="display_mode:relative_date">
<?php _e('Relative', 'ajax-search-pro'); ?>
<input attr="relative_date.year" aria-label="Years" type="number" class="threedigit" value=""><?php _e('years', 'ajax-search-pro'); ?>&nbsp;
<input attr="relative_date.month" aria-label="Months" type="number" class="threedigit" value=""><?php _e('months', 'ajax-search-pro'); ?>&nbsp;
<input attr="relative_date.day" aria-label="Days before current date" type="number" class="threedigit" value="">&nbsp; <?php _e('days before current date', 'ajax-search-pro'); ?>
<p class="wd_ff_desc_right">
<?php _e('It is possible to use negative values as well.', 'ajax-search-pro'); ?>
</p>
</div>
<div class="date_to_filter_date" wd-show-on="display_mode:date">
<label>
<?php _e('Date', 'ajax-search-pro'); ?>
<input type="text" attr="date" value="">
</label>
<p class="wd_ff_desc_right">
<?php _e('Empty value can be used, in that case the placeholder text will appear.', 'ajax-search-pro'); ?>
</p>
</div>
<div class="date_to_filter_placeholder">
<label>
<?php _e('Placeholder text', 'ajax-search-pro'); ?>
<input type="text" attr="placeholder" value="">
</label>
</div>
<div class="date_to_filter_date_format">
<label>
<?php _e('Date format', 'ajax-search-pro'); ?>
<input type="text" attr="date_format" value="">
</label>
<p class="wd_ff_desc_right">
<?php echo sprintf( __('dd/mm/yy is the most popular format, <a href="%s" target="_blank">list of accepted params</a>', 'ajax-search-pro'), 'http://api.jqueryui.com/datepicker/#utility-formatDate' ); ?>
</p>
</div>
</div>
<div class="date_to_filter_other_attributes">
<fieldset>
<legend><?php _e('Visibility', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Desktop', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.desktop">
</label>
<label>
<?php _e('Tablet', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.tablet">
</label>
<label>
<?php _e('Mobile', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.mobile">
</label>
</fieldset>
<fieldset>
<legend><?php _e('Neccessity', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Is at least one selection required?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="required">
</label>
<label wd-disable-on="required:0">
<?php _e('Text:', 'ajax-search-pro'); ?>
<input type="text" attr="required_text">
</label>
</fieldset>
</div>
<div style="clear:both"></div>
</div>

View File

@@ -0,0 +1,71 @@
<div class="generic_filter_container">
<h1>Generic Filter</h1>
<div class="generic_filter_attributes">
<label class="wd_ff_title_label">
<?php _e('Label', 'ajax-search-pro'); ?>
<input type="text" attr="label.text" maxlength="60">
<?php _e('is visible?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="label.visible">
</label>
<label for="generic_filter_display_mode">
<?php _e('Display mode', 'ajax-search-pro'); ?>
<select attr="display_mode">
<option value="checkboxes"><?php _e('Checkboxes', 'ajax-search-pro'); ?></option>
<option value="dropdown"><?php _e('Dropdown', 'ajax-search-pro'); ?></option>
<option value="radio"><?php _e('Radio', 'ajax-search-pro'); ?></option>
</select>
</label>
</div>
<div class="generic_filter_fields">
<div class="draggablecontainer">
<ul style='text-align:left;' class="connectedSortable" id="generic_draggable">
<?php foreach ( $this::getData( array(), true )['choices'] as $field => $choice ): ?>
<li class="ui-state-default ui-draggable ui-draggable-handle" data-field="<?php echo $field; ?>">
<span class="wd_drag_visible"><?php echo $choice; ?></span>
<span class="wd_sort_visible">
<label><?php echo __($choice, 'ajax_search_pro'); ?></label>
<input type="text" attr="label" maxlength="100" value="<?php echo $choice; ?>">
<label class="wd_plain">
<?php _e('Checked?', 'ajax-search-pro'); ?> <input type="checkbox" attr="selected" value="content" checked="checked">
</label>
<a class="fa fa-minus-circle generic_filter_remove"></a>
</span>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="sortablecontainer">
<ul style='text-align:left;' class="connectedSortable" id="generic_sortable">
</ul>
</div>
</div>
<div class="generic_filter_other_attributes">
<fieldset>
<legend><?php _e('Visibility', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Desktop', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.desktop">
</label>
<label>
<?php _e('Tablet', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.tablet">
</label>
<label>
<?php _e('Mobile', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.mobile">
</label>
</fieldset>
<fieldset>
<legend><?php _e('Neccessity', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Is at least one selection required?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="required">
</label>
<label wd-disable-on="required:0">
<?php _e('Text:', 'ajax-search-pro'); ?>
<input type="text" attr="required_text">
</label>
</fieldset>
</div>
<div style="clear:both"></div>
</div>

View File

@@ -0,0 +1,71 @@
<div class="post_type_filter_container">
<h1>Content Type Filter</h1>
<div class="post_type_filter_attributes">
<label class="wd_ff_title_label">
<?php _e('Label', 'ajax-search-pro'); ?>
<input type="text" attr="label.text" maxlength="60">
<?php _e('is visible?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="label.visible">
</label>
<label for="post_type_filter_display_mode">
<?php _e('Display mode', 'ajax-search-pro'); ?>
<select attr="display_mode">
<option value="checkboxes"><?php _e('Checkboxes', 'ajax-search-pro'); ?></option>
<option value="dropdown"><?php _e('Dropdown', 'ajax-search-pro'); ?></option>
<option value="radio"><?php _e('Radio', 'ajax-search-pro'); ?></option>
</select>
</label>
</div>
<div class="post_type_filter_fields">
<div class="draggablecontainer">
<ul style='text-align:left;' class="connectedSortable" id="post_type_draggable">
<?php foreach ( $this::getData( array(), true )['choices'] as $field => $choice ): ?>
<li class="ui-state-default ui-draggable ui-draggable-handle" data-field="<?php echo $field; ?>">
<span class="wd_drag_visible"><?php echo $choice; ?></span>
<span class="wd_sort_visible">
<label><?php echo __($choice, 'ajax_search_pro'); ?></label>
<input type="text" attr="label" maxlength="100" value="<?php echo $choice; ?>">
<label class="wd_plain">
<?php _e('Checked?', 'ajax-search-pro'); ?> <input type="checkbox" attr="selected" value="content" checked="checked">
</label>
<a class="fa fa-minus-circle post_type_filter_remove"></a>
</span>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="sortablecontainer">
<ul style='text-align:left;' class="connectedSortable" id="post_type_sortable">
</ul>
</div>
</div>
<div class="post_type_filter_other_attributes">
<fieldset>
<legend><?php _e('Visibility', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Desktop', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.desktop">
</label>
<label>
<?php _e('Tablet', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.tablet">
</label>
<label>
<?php _e('Mobile', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.mobile">
</label>
</fieldset>
<fieldset>
<legend><?php _e('Neccessity', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Is at least one selection required?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="required">
</label>
<label wd-disable-on="required:0">
<?php _e('Text:', 'ajax-search-pro'); ?>
<input type="text" attr="required_text">
</label>
</fieldset>
</div>
<div style="clear:both"></div>
</div>

View File

@@ -0,0 +1,191 @@
<div class="taxonomy_filter_container" id="taxonomy_filter_container">
<h1><?php _e('Taxonomy Filter', 'ajax-search-pro'); ?></h1>
<div class="taxonomy_filter_attributes">
<label class="wd_ff_title_label" wd-disable-on="taxonomy:,select">
<?php _e('Label', 'ajax-search-pro'); ?>
<input type="text" attr="label.text" maxlength="60">
<?php _e('is visible?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="label.visible">
</label>
<label for="taxonomy_filter_display_mode" wd-disable-on="taxonomy:,select">
<?php _e('Display mode', 'ajax-search-pro'); ?>
<select attr="display_mode">
<option value="checkboxes"><?php _e('Checkboxes', 'ajax-search-pro'); ?></option>
<option value="dropdown"><?php _e('Dropdown', 'ajax-search-pro'); ?></option>
<option value="dropdownsearch"><?php _e('Dropdown with search', 'ajax-search-pro'); ?></option>
<option value="multisearch"><?php _e('Multiselect with search', 'ajax-search-pro'); ?></option>
<option value="radio"><?php _e('Radio', 'ajax-search-pro'); ?></option>
</select>
</label>
<label for="taxonomy_filter_taxonomy">
<?php _e('Taxonomy', 'ajax-search-pro'); ?>
<select attr="taxonomy">
<option value="select" selected="selected" disabled><?php _e('Select a taxonomy', 'ajax-search-pro'); ?></option>
<?php foreach ( $this->getTaxonomiesList() as $taxonomy => $label ): ?>
<option value="<?php echo $taxonomy; ?>"><?php echo $label; ?></option>
<?php endforeach; ?>
</select>
</label>
<label for="taxonomy_filter_mode" wd-disable-on="taxonomy:,select">
<?php _e('Mode', 'ajax-search-pro'); ?>
<select attr="mode">
<option value="exclude"><?php _e('Display all, exclude selected', 'ajax-search-pro'); ?></option>
<option value="include"><?php _e('Exclude all, display selected', 'ajax-search-pro'); ?></option>
</select>
</label>
</div>
<div class="taxonomy_filter_fields" wd-disable-on="taxonomy:,select">
<div class="draggablecontainer">
<ul style='text-align:left;' class="connectedSortable" id="taxonomy_draggable">
<label class="taxonomy_draggable_search hiddend">
<span class="fa fa-search"></span>
<input type="text" placeholder="<?php _e('Type term name & press Enter', 'ajax-search-pro'); ?>">
</label>
<span>Select a taxonomy to list terms here</span>
</ul>
</div>
<div class="sortablecontainer">
<ul style='text-align:left;' class="connectedSortable" id="taxonomy_sortable">
<span class="taxonomy_filter_mode_label_excluded"><?php _e('Excluded terms:', 'ajax-search-pro'); ?></span>
<span class="taxonomy_filter_mode_label_included"><?php _e('Included terms:', 'ajax-search-pro'); ?></span>
</ul>
</div>
</div>
<div class="taxonomy_filter_other_attributes" wd-disable-on="taxonomy:,select">
<fieldset class="taxonomy_filter_layout_options">
<legend><?php _e('Layout & Functionality Options', 'ajax-search-pro'); ?></legend>
<div>
<label>
<?php _e('Hide empty terms?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="hide_empty">
</label>
<p class="wd_ff_desc_left">
<?php echo __('Automatically hides terms, that have no posts or any CPT assigned to them.', 'ajax-search-pro'); ?>
</p>
</div>
<div wd-hide-on="display_mode:multisearch">
<label>
<?php _e('Display "select all/one" option', 'ajax-search-pro'); ?>
<input type="checkbox" attr="select_all.enabled">
</label>
<label wd-disable-on="select_all.enabled:0">
<?php _e('text', 'ajax-search-pro'); ?>
<input type="text" attr="select_all.text">
</label>
</div>
<div wd-show-on="display_mode:checkboxes">
<label>
<?php _e('Checkboxes default state', 'ajax-search-pro'); ?>
<select attr="display_mode_args.checkboxes.default_state">
<option value="checked"><?php _e('Checked', 'ajax-search-pro'); ?></option>
<option value="unchecked"><?php _e('Un-Checked', 'ajax-search-pro'); ?></option>
</select>
</label>
<label>
<?php _e('Hide (collapse) child terms, where the parent checkbox is unchecked?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="display_mode_args.checkboxes.hide_children_on_unchecked">
</label>
<p class="wd_ff_desc_left">
<?php echo __('Automatically hides the checkbox options, where the parent terms are unchecked.', 'ajax-search-pro'); ?>
</p>
</div>
<div wd-hide-on="display_mode:checkboxes" class="taxonomy_filter_dm">
<label>
<?php _e('Default selected', 'ajax-search-pro'); ?>
<input class="taxonomy_filter_search" type="text" placeholder="<?php _e('Search for terms here', 'ajax-search-pro'); ?>">
<span class="taxonomy_filter_search_nores hiddend"><?php _e('No results for this phrase!', 'ajax-search-pro'); ?></span>
<input type="hidden" attr="display_mode_args.dropdown.default">
</label>
<span class="taxonomy_filter_selected hiddend"><span class="fa fa-ban"></span><span class="taxonomy_filter_selected_name"></span></span>
<div class="taxonomy_filter_search_res">
<ul>
<li key="-1"><?php _e('Select All/One option', 'ajax-search-pro'); ?></li>
<li key="first"><?php _e('First option', 'ajax-search-pro'); ?></li>
<li key="last"><?php _e('Last option', 'ajax-search-pro'); ?></li>
</ul>
</div>
</div>
<div wd-hide-on="mode:include" class="taxonomy_filter_dm">
<label>
<?php _e('Maintain term hierarchy', 'ajax-search-pro'); ?>
<input type="checkbox" attr="maintain_hierarchy">
</label>
<p class="wd_ff_desc_left">
<?php echo __('Shows child terms hierarchically under their parents with padding. Supports multiple term levels.', 'ajax-search-pro'); ?>
</p>
<label>
<?php _e('Default term order', 'ajax-search-pro'); ?>
<select attr="term_orderby">
<option value="name"><?php _e('Name', 'ajax-search-pro'); ?></option>
<option value="count"><?php _e('Item count', 'ajax-search-pro'); ?></option>
<option value="id"><?php _e('ID', 'ajax-search-pro'); ?></option>
</select>
<select attr="term_order">
<option value="ASC"><?php _e('Ascending', 'ajax-search-pro'); ?></option>
<option value="DESC"><?php _e('Descending', 'ajax-search-pro'); ?></option>
</select>
</label>
</div>
<div class="taxonomy_filter_dm">
<label>
<?php _e('Allow results with missing terms', 'ajax-search-pro'); ?>
<input type="checkbox" attr="allow_empty">
</label>
<p class="wd_ff_desc_left">
<?php _e('This decides what happens if the posts does not have any terms from the selected taxonomies. For example posts with no categories, when using a category filter.', 'ajax-search-pro'); ?>
</p>
</div>
<div class="taxonomy_filter_dm" wd-show-on="display_mode:checkboxes,multisearch">
<label>
<?php _e('Taxonomy terms checkbox/multiselect connection logic', 'ajax-search-pro'); ?>
<select attr="term_logic">
<option value="or"><?php _e('At least one selected terms should match', 'ajax-search-pro'); ?></option>
<option value="and" selected="selected"><?php _e('All of the selected terms must match, exclude unselected (default)', 'ajax-search-pro'); ?></option>
<option value="andex"><?php _e('All of the selected terms must match EXACTLY, but unselected ones are not excluded.', 'ajax-search-pro'); ?></option>
</select>
</label>
</div>
</fieldset>
<fieldset>
<legend><?php _e('Visibility', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Desktop', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.desktop">
</label>
<label>
<?php _e('Tablet', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.tablet">
</label>
<label>
<?php _e('Mobile', 'ajax-search-pro'); ?>
<input type="checkbox" attr="visibility.mobile">
</label>
</fieldset>
<fieldset>
<legend><?php _e('Neccessity', 'ajax-search-pro'); ?></legend>
<label>
<?php _e('Is at least one selection required?', 'ajax-search-pro'); ?>
<input type="checkbox" attr="required">
</label>
<label wd-disable-on="required:0">
<?php _e('Text:', 'ajax-search-pro'); ?>
<input type="text" attr="required_text">
</label>
</fieldset>
</div>
<div style="clear:both"></div>
<div class="taxonomy_filter_sample" style="display: none !important;">
<li class="ui-state-default ui-draggable ui-draggable-handle" term_level="0" data-id="123">
<span class="wd_sort_visible">
<label class="wd_plain">
<input type="checkbox" attr="selected" value="content" checked="checked">
</label>
<a class="fa fa-minus-circle taxonomy_filter_remove"></a>
</span>
<input type="hidden" attr="id" value="">
<input type="hidden" attr="level" value="">
<span attr="label">Aside</span>
</li>
</div>
<div class="taxonomy_filter_loader hiddend"></div>
</div>

View File

@@ -0,0 +1,109 @@
<div id="wd_frontfilters">
<div id="wd_frontfilters_header">
</div>
<div id="wd_frontfilters_body">
<!-- New Filter popup -->
<div id="wd_frontfilters_new_filter_container">
<div id="wd_frontfilters_new_filter">
<h1>Choose a filter type</h1>
<div class="wd_frontfilters_2_column">
<?php foreach ( $this->getModules() as $module ): ?>
<!-- Print module boxes -->
<div
data-moduletype="<?php echo $module->getType(); ?>"
class="wd_frontfilters_new_filter wd_frontfilters_new_<?php echo $module->getType(); ?>">
<img src="<?php echo $module->getIcon(); ?>">
<span><?php echo $module->getTitle(); ?></span>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<!-- ///////// -->
<!-- Module boxes with options popup/editor popup -->
<div id="wd_frontfilters_modules_container">
<div id="wd_frontfilters_modules">
<?php foreach ( $this->getModules() as $module ): ?>
<div
data-moduledefaults="<?php echo $module::getDataEncoded(array()); ?>"
data-moduletype="<?php echo $module->getType(); ?>"
class="wd_frontfilters_module wd_frontfilters_module_<?php echo $module->getType(); ?>">
<?php echo $module->getOutput(); ?>
</div>
<?php endforeach; ?>
<div class="wd_frontfilters_modules_buttons">
<input name="wd_frontfilters_cancel" class="wd_frontfilters_btn" type="button" value="Cancel">
<input name="wd_frontfilters_save" class="wd_frontfilters_btn wd_frontfilters_btn_blue" type="submit" value="Save Filter">
<input name="wd_frontfilters_delete"
class="wd_frontfilters_btn wd_frontfilters_btn_red"
style="float:right;"
type="button" value="DELETE">
</div>
</div>
</div>
<!-- ///////// -->
<div id="wd_frontfilters_options">
<label>
Columns count
<select name="wd_frontfilters_columns_count">
<option value="auto">Auto</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3" selected="selected">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
</label>
<span class="wd_frontfilters_btn wd_frontfilters_btn_blue">More Options</span>
</div>
<div id="wd_frontfilters_more_options">
More options :)
</div>
<div id="wd_frontfilter_columns">
<div class="wd_frontfilters_column" data-id="1">
<div class="wd_frontfilters_add_filter">New Filter</div>
</div>
<div class="wd_frontfilters_column" data-id="2">
<div class="wd_frontfilters_add_filter">New Filter</div>
</div>
<div class="wd_frontfilters_column" data-id="3">
<div class="wd_frontfilters_add_filter">New Filter</div>
</div>
<div class="wd_frontfilters_column" data-id="4">
<div class="wd_frontfilters_add_filter">New Filter</div>
</div>
<div class="wd_frontfilters_column" data-id="5">
<div class="wd_frontfilters_add_filter">New Filter</div>
</div>
<div class="wd_frontfilters_column" data-id="6">
<div class="wd_frontfilters_add_filter">New Filter</div>
</div>
<div class="wd_frontfilters_column" data-id="7">
<div class="wd_frontfilters_add_filter">New Filter</div>
</div>
<div class="wd_frontfilters_column" data-id="8">
<div class="wd_frontfilters_add_filter">New Filter</div>
</div>
</div>
</div>
<div id="wd_frontfilters_footer">
</div>
<div id="wd_frontfilters_footer_sample_data" style="display:none !important;">
<div class="wd_frontfilters_filter"><span class="fa fa-edit"></span><span class="wd_ff_filter_title">Fitler Name</span></div>
</div>
<input isparam="1" type="hidden" name="<?php echo $this->name; ?>" value="<?php echo $this->data ?>" />
</div>
<?php
/*
foreach ( $this->getModules() as $module ) {
print $module->getOutput();
}
*/

View File

@@ -0,0 +1,50 @@
<?php
if (!class_exists("wd_imageRadio")) {
/**
* Class wpdreamsImageRadio
*
* Displays selectable images like radio buttons.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_imageRadio extends wpdreamsType {
private $selects, $selected;
public function getType() {
parent::getType();
$this->processData();
echo "<div class='wd_imageRadio'>";
echo "<label class='image_radio'>" . $this->label . "</label>";
$i = 1;
foreach ($this->selects as $k => $image) {
$image = trim($image);
$selected = !(strpos($k, $this->selected) === false);
echo "
<img num='" . $i . "' sel = '".$k."' src='" . plugins_url() . $image . "' class='image_radio" . (($selected) ? ' selected' : '') . "'/>
";
$i++;
}
echo "<input isparam=1 type='hidden' class='realvalue' value='" . $this->selected . "' name='" . $this->name . "'>";
echo "<div class='triggerer'></div>
</div>";
}
function processData() {
$this->selects = $this->defaultData['images'];
$this->selected = $this->data['value'];
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}

View File

@@ -0,0 +1,82 @@
<?php
defined('ABSPATH') or die("You can't access this file directly.");
if (!class_exists("wd_MimeTypeSelect")) {
/**
* Class wd_MimeTypeSelect
*
* Selection field for mime types
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://codecanyon.net/user/wpdreams/portfolio
* @copyright Copyright (c) 2022, Ernest Marcinko
*/
class wd_MimeTypeSelect extends wpdreamsType {
public function getType() {
parent::getType();
$this->processData();
?>
<div class="wd_MimeTypeSelect">
<div class="file_mime_types_input hiddend">
<label class='wd_textarea_expandable'
for='wd_textareae_<?php echo self::$_instancenumber; ?>'><?php echo __($this->label, 'ajax-search-pro'); ?>
<textarea rows='1' data-min-rows='1'
class='wd_textarea_expandable'
id='wd_textareae_<?php echo self::$_instancenumber; ?>'
name='<?php echo $this->name; ?>'><?php echo stripslashes(esc_html($this->data)); ?></textarea>
</label>
<span class="mime_input_hide"><?php echo __('>> Simplified view <<', 'ajax-search-pro'); ?></span>
</div>
<div class="file_mime_types_list">
<label>
<?php echo __($this->label, 'ajax-search-pro'); ?>
<select multiple attr="multi_attachment_mime_types_<?php echo self::$_instancenumber; ?>"
id="multi_attachment_mime_types">
<option value="pdf">PDF</option>
<option value="text">Text</option>
<option value="richtext">Rich Text (rtf etc..)</option>
<option value="mso_word">Office Word</option>
<option value="mso_excel">Office Excel</option>
<option value="mso_powerpoint">Office PowerPoint</option>
<option value="image">Image</option>
<option value="video">Video</option>
<option value="audio">Audio</option>
</select>
</label>
<span class="mime_list_hide"><?php echo __('>> Enter manually <<', 'ajax-search-pro'); ?></span>
</div>
</div>
<?php
}
function processData() {
if ( $this->isBase64Encoded($this->data) ) {
$this->data = base64_decode($this->data);
}
}
function isBase64Encoded( $s ){
if ((bool) preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $s) === false) {
return false;
}
$decoded = base64_decode($s, true);
if ($decoded === false) {
return false;
}
if ( function_exists('mb_detect_encoding') ) {
$encoding = mb_detect_encoding($decoded);
if ( !in_array($encoding, ['UTF-8', 'ASCII'], true) ) {
return false;
}
}
return $decoded !== false && base64_encode($decoded) === $s;
}
}
}
wp_register_script('wd_mime_select-js', ASP_URL_NP . 'backend/settings/assets/wd_mime_select/js/wd_mime_select.js', array('asp-backend-jquery-select2'), '1', true);
wp_enqueue_script('wd_mime_select-js');
wp_register_style('wd_mime_select-style', ASP_URL_NP . 'backend/settings/assets/wd_mime_select/css/wd_mime_select.css', false, 1);
wp_enqueue_style('wd_mime_select-style');

View File

@@ -0,0 +1,63 @@
<?php
use WPDRMS\ASP\Media\RemoteService\License;
if (!class_exists("wd_MSLicenseActivator")) {
class wd_MSLicenseActivator extends wpdreamsType {
private $stats = array();
public function getType() {
parent::getType();
$this->processData();
?>
<div class="wd_MSLicenseActivator">
<div class="ms_license_active<?php echo $this->data['active'] == 1 ? '' : ' hiddend'; ?>">
Your license key: <span class="ms_license_key"><?php echo esc_attr($this->data['license']);?></span>
<?php if ( $this->data['active'] == 1 && $this->stats['free'] ): ?>
&nbsp;|&nbsp;<span><?php echo __('FREE License tier', 'ajax-search-pro'); ?></span>
<?php endif; ?>
<button name="ms_license_deactivate" class="submit wd_button wd_button_red">
<i class="fa"></i><?php echo __('Deactivate', 'ajax-search-pro'); ?>
</button>
</div>
<div class="ms_license_inactive<?php echo $this->data['active'] == 1 ? ' hiddend' : ''; ?>">
<label for="ms_license_key">
<input type="text" name="ms_license_key" value="<?php echo esc_attr($this->data['license']);?>">
</label>
<button name="ms_license_activate" class="submit wd_button">
<i class="fa"></i><?php echo __('Activate', 'ajax-search-pro'); ?>
</button>
</div>
<div class="ms_license_log">
<p class="successMsg hiddend"><?php echo __('License successfully activated!', 'ajax-search-pro'); ?></p>
<p class="errorMsg<?php echo ( $this->data['active'] == 0 && $this->data['license'] != "" ) ? '' :' hiddend' ?>">
<?php echo __('The license is no longer active, please renew your subscription.', 'ajax-search-pro'); ?>
</p>
</div>
<?php if ( $this->data['active'] == 1 && count($this->stats) > 0 ): ?>
<div class="ms_license_usage">
<span><?php echo sprintf(__('Max. allowed file size: <strong>%sMB</strong>', 'ajax-search-pro'), $this->stats['max_filesize']); ?></span>&nbsp;|&nbsp;
<span><?php echo __('Usage: ', 'ajax-search-pro'); ?></span>
<span class="ms_license_usage_counter"><?php echo $this->stats['max_files_usage'] . "/" . $this->stats['max_files']; ?></span>
<span><?php
echo sprintf(__('(max files) for this period (renews at <strong>%s</strong>)', 'ajax-search-pro'), $this->stats['ends']);
?></span>
</div>
<?php endif; ?>
<input type="hidden" id="asp_mediaservice_request_nonce" value="<?php echo wp_create_nonce( 'asp_mediaservice_request_nonce' ); ?>">
<input type="hidden" name="ms_license_active" value="<?php echo $this->data['active'] ? 1 : 0; ?>">
</div>
<?php
}
public function processData() {
$this->data = License::getInstance()->getData();
$this->stats = $this->data['stats'];
}
}
}
wp_register_script('wd_ms_license_activator-js', ASP_URL_NP . 'backend/settings/assets/wd_ms_license_activator/js/wd_ms_license_activator.js', array('jquery'), '1', true);
wp_enqueue_script('wd_ms_license_activator-js');
wp_register_style('wd_ms_license_activator-style', ASP_URL_NP . 'backend/settings/assets/wd_ms_license_activator/css/wd_ms_license_activator.css', false, 1);
wp_enqueue_style('wd_ms_license_activator-style');

View File

@@ -0,0 +1,59 @@
<?php
if (!class_exists("wd_Post_Type_Sortalbe")) {
/**
* Class wd_Post_Type_Sortalbe
*
* A post type sortable based on jQuery UI
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_Post_Type_Sortalbe extends wpdreamsType {
private $types;
public function getType() {
parent::getType();
$this->processData();
echo "
<div class='wd_post_type_sortalbe' id='wd_post_type_sortalbe-" . self::$_instancenumber . "'>";
echo '<div class="sortablecontainer" style="float:right;"><p>'.$this->label.'</p><ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
if (is_array($this->types)) {
foreach ($this->types as $k => $v) {
echo '<li class="ui-state-default">' . $v . '</li>';
}
}
echo "
</ul></div>
<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>";
?>
</div>
<div class="clear"></div>
<?php
}
public function processData() {
$this->types = $this->decode_param($this->data);
$this->data = $this->encode_param($this->data);
$ptypes = get_post_types(array(
"public" => false,
"_builtin" => false
), "names", "OR");
foreach ( $ptypes as $type )
if ( !in_array($type, $this->types) )
$this->types[] = $type;
}
public final function getData() {
return $this->data;
}
public final function getSelected() {
return $this->types;
}
}
}

View File

@@ -0,0 +1,54 @@
<?php
if (!class_exists("wd_Sortable_Editable")) {
/**
* Class wd_Sortable_Editable
*
* A sortable based editable jQuery UI element
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_Sortable_Editable extends wpdreamsType {
private $e_data = array();
private $types;
public function getType() {
parent::getType();
$this->processData();
echo "
<fieldset>
<legend>".$this->label."</legend>
<div class='wd_sortable_editable' id='wd_sortable_editable-" . self::$_instancenumber . "'>";
echo '<div class="sortablecontainer" style="float:right;"><ul id="sortable' . self::$_instancenumber . '" class="connectedSortable">';
foreach ($this->e_data as $k => $v) {
echo '<li class="ui-state-default ui-left">
<label>' . $k . '</label><input type="text" value="' . $v . '">
</li>';
}
echo "
</ul></div>
<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>";
?>
</div>
<div class="clear"></div>
</fieldset>
<?php
}
public function processData() {
$this->e_data = $this->decode_param($this->data);
$this->data = $this->encode_param($this->data);
}
public final function getData() {
return $this->data;
}
public final function getSelected() {
return $this->types;
}
}
}

View File

@@ -0,0 +1,438 @@
<?php
use WPDRMS\ASP\Utils\Ajax;
if (!class_exists("wd_TaxonomyTermSelect")) {
/**
* Class wd_TaxonomyTermSelect
*
* A new multi-purpose, flexible taxonomy-term selector class that includes built-in types as well.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_TaxonomyTermSelect extends wpdreamsType {
private $args = array(
"show_type" => 0,
"show_checkboxes" => 0, // Checkboxes for default states
"show_display_mode" => 0, // Display mode option
"show_more_options" => 0, // More options for exclusions, default states
'show_taxonomy_all' => 1, // Display the 'Use all from taxonomy' when searching
"built_in" => true, // display only built in taxonomy terms
"exclude_taxonomies" => array()
);
private $default_options = array(
"op_type" => "include", // include|exclude
/**
* 0 => array(
* "id" => 1, // -1 if whole taxonomy
* "level" => 0,
* "taxonomy" => "product_cat",
* (optional) "ex_ids" => array(1, 2, 3,) // array of excluded terms, if id=-1
* ), ...
*/
"terms" => array(),
"un_checked" => array(), // ids of unchecked terms
/**
* "taxonomy_name" => array(
* "type" => "checkbox",
* "default" => "checked",
* "select_all" => 0,
* "select_all_text" => "Choose One",
* "box_header_text" => "Filter by Taxonomy"
* ), ...
*/
"display_mode" => array()
);
private $labels = array(
'product_visibility' => 'Product visibility',
'product_type' => 'Product type'
);
private $term_data = array(); // Temporary storage for term data
private $types, $e_data;
public function getType() {
parent::getType();
$this->processData();
$this->types = $this->getAllTaxonomies();
$types_copy = $this->types;
if (!isset($this->e_data['display_mode']))
$this->e_data['display_mode'] = array();
?>
<div class='wd_TaxonomyTermSelect' id='wd_TaxonomyTermSelect-<?php echo self::$_instancenumber; ?>'>
<fieldset>
<div style='margin:15px 30px;text-align: left; line-height: 45px;'>
<label><?php echo __('Select the taxonomy:', 'ajax-search-pro'); ?> </label>
<select class='wd_tts_ajax_selector' id='tax_ajax_selector_<?php echo self::$_instancenumber; ?>'>
<option name="_select_one_yo" selected="selected" disabled><?php echo __('Select a taxonomy', 'ajax-search-pro'); ?></option>
<?php
foreach ($this->types as $taxonomy) {
$custom_post_type = "";
if ( isset($taxonomy->object_type[0]) )
$custom_post_type = $taxonomy->object_type[0] . " - ";
if ( isset($this->labels[$taxonomy->name]) )
$label = $this->labels[$taxonomy->name];
else
$label = $taxonomy->labels->name;
echo "<option value='" . $taxonomy->name . "' taxonomy='" . $taxonomy->name . "'>" . $custom_post_type .''. $taxonomy->name .' ('.$label. ")</option>";
}
?>
</select>
<label<?php echo ($this->args["show_type"] == 1) ? '' : ' class="hiddend"'; ?>><?php echo __('Operation:', 'ajax-search-pro'); ?>
<select class="tts_operation">
<option value="include"<?php echo $this->e_data['op_type'] == "include" ? ' selected="selected"' : ''; ?>>
<?php echo __('Include the selected', 'ajax-search-pro'); ?>
</option>
<option value="exclude"<?php echo $this->e_data['op_type'] == "exclude" ? ' selected="selected"' : ''; ?>>
<?php echo __('Exclude the selected', 'ajax-search-pro'); ?>
</option>
</select>
</label>
<?php if ($this->args["show_display_mode"] == 1): ?>
<input type="button" class="wd_tts_display_mode" value="<?php echo __('Change display mode', 'ajax-search-pro'); ?>"><br>
<div class="wd_tts_disp_m_popup hiddend">
<div class="wd_tts_m_popup_content">
<?php foreach ($types_copy as $tax): ?>
<?php
$custom_post_type = "";
if ( isset($tax->object_type[0]) )
$custom_post_type = $tax->object_type[0] . " - ";
if ( isset($this->labels[$tax->name]) )
$label = $custom_post_type . $this->labels[$tax->name];
else
$label = $custom_post_type . $tax->labels->name;
?>
<fieldset taxonomy="<?php echo $tax->name; ?>">
<legend><?php echo __('Terms from', 'ajax-search-pro'); ?> <b><?php echo $label; ?></b> (<?php echo $tax->name; ?>)</legend>
<?php echo __('Box header:', 'ajax-search-pro'); ?> <input type="text" class="wd_tts_box_header_text" value="<?php echo ($tax->name != "all") ? __('Filter by ', 'ajax-search-pro').$tax->labels->name : __('Filter by terms', 'ajax-search-pro'); ?>"><br>
<?php echo __('Display as', 'ajax-search-pro'); ?> <select class="tts_display_as">
<option value="checkboxes"><?php echo __('Checkboxes', 'ajax-search-pro'); ?></option>
<option value="dropdown"><?php echo __('Drop-down', 'ajax-search-pro'); ?></option>
<option value="dropdownsearch"><?php echo __('Drop-down with search', 'ajax-search-pro'); ?></option>
<option value="multisearch"><?php echo __('Multiselect with search', 'ajax-search-pro'); ?></option>
<option value="radio"><?php echo __('Radio', 'ajax-search-pro'); ?></option>
</select><span class="tts_d_defaults"> <?php echo __('default', 'ajax-search-pro'); ?> <select class="tts_d_checkboxes">
<option value="checked"><?php echo __('Checked', 'ajax-search-pro'); ?></option>
<option value="unchecked"><?php echo __('Un-checked', 'ajax-search-pro'); ?></option>
</select>
<select class="tts_d_dropdown">
<option value='all'><?php echo __('"Choose one/Any" option', 'ajax-search-pro'); ?></option>
<option value='first'><?php echo __('First item', 'ajax-search-pro'); ?></option>
<option value='last'><?php echo __('Last item', 'ajax-search-pro'); ?></option>
<?php if ($tax->name != "all"): ?>
<option value='0'><?php echo __('As defined:', 'ajax-search-pro'); ?></option>
<?php endif; ?>
</select></span>
<div class="wd_tts_as_defined">
<span class="loading-small hiddend"></span>
<div class="wd_ts_close hiddend">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<polygon id="x-mark-icon" points="438.393,374.595 319.757,255.977 438.378,137.348 374.595,73.607 255.995,192.225 137.375,73.622 73.607,137.352 192.246,255.983 73.622,374.625 137.352,438.393 256.002,319.734 374.652,438.378 "></polygon>
</svg>
</div>
<input type="text" class="wd_tts_search" placeholder="<?php echo __('Search terms..', 'ajax-search-pro'); ?>">
<div class="wd_tts_defined"><?php
if (
isset($this->e_data['display_mode'][$tax->name]['default']) &&
(int)$this->e_data['display_mode'][$tax->name]['default'] > 0
) {
$tt = get_term($this->e_data['display_mode'][$tax->name]['default'], $tax->name);
if ( !is_wp_error($tt) && isset($tt->term_id) )
echo "<span term_id='".$tt->term_id."'>".$tt->name."</span>";
else
echo __('No selected term.', 'ajax-search-pro');
} else {
echo __('No selected term.', 'ajax-search-pro');
}
?></div>
<div class="wd_tts_res"></div>
</div>
<div class="wd_tts_selectall">
<input type="checkbox" class="wd_tts_select_all" value="checked"><?php echo __('Display the', 'ajax-search-pro'); ?><span class="wd_tts_select_all_label"><?php echo __('"Select all option"?', 'ajax-search-pro'); ?></span><br>
<?php echo __('Text:', 'ajax-search-pro'); ?> <input type="text" value="Select all" class="wd_tts_select_all_text">
</div>
<div class="wd_tts_placeholder">
<?php echo __('Placeholder:', 'ajax-search-pro'); ?> <input type="text" value="<?php echo __('Select options..', 'ajax-search-pro'); ?>" class="wd_tts_placeholder_text">
</div>
<div class="wd_tts_required">
<input type="checkbox" class="wd_tts_required" value="checked"><span class="wd_tts_required_label"><?php echo __('Required?', 'ajax-search-pro'); ?></span><br>
<?php echo __('Required popup text:', 'ajax-search-pro'); ?> <input type="text" value="This field is required!" class="wd_tts_required_text">
</div>
</fieldset>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<label><?php echo __('Show parent categories only', 'ajax-search-pro'); ?> <input class='hide-children' type='checkbox'></label>
</div>
<legend><?php echo $this->label; ?></legend>
<div class="draggablecontainer" id="sortablecontainer<?php echo self::$_instancenumber; ?>">
<div class="dragLoader hiddend"></div>
<p><?php echo __('Available terms for the selected taxonomy', 'ajax-search-pro'); ?></p>
<ul id="sortable<?php echo self::$_instancenumber; ?>" class="connectedSortable wd_csortable<?php echo self::$_instancenumber; ?>">
</ul>
</div>
<div class="sortablecontainer">
<p>
<?php _e('Drag here the terms you want to', 'ajax-search-pro'); ?><span style="font-weight: bold;" class="tts_type">
<?php if ( $this->e_data['op_type'] == 'include' ): ?>
<?php echo __('include', 'ajax-search-pro'); ?>
<?php else: ?>
<?php echo __('exclude', 'ajax-search-pro'); ?>
<?php endif; ?>
</span>!
</p>
<ul id="sortable_conn<?php echo self::$_instancenumber; ?>" class="connectedSortable wd_csortable<?php echo self::$_instancenumber; ?>">
<?php $this->printSelectedTerms(); ?>
</ul>
<div class="wd_tts_ex_container hiddend">
<h3>Title</h3>
<input type="text" class="wd_tts_all_text" placeholder="<?php echo __('Search terms..', 'ajax-search-pro'); ?>">
<span class="loading-small hiddend"></span>
<div class="wd_ts_close hiddend">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<polygon id="x-mark-icon" points="438.393,374.595 319.757,255.977 438.378,137.348 374.595,73.607 255.995,192.225 137.375,73.622 73.607,137.352 192.246,255.983 73.622,374.625 137.352,438.393 256.002,319.734 374.652,438.378 "></polygon>
</svg>
</div>
<div class="wd_tts_res"></div>
<h3><?php echo __('Excluded terms from displaying:', 'ajax-search-pro'); ?></h3>
<div class="wd_tts_excluded_t"></div>
</div>
</div>
<input type='hidden' value="<?php echo base64_encode(json_encode($this->term_data)); ?>" class="wd_term_data">
<input type='hidden' value="<?php echo base64_encode(json_encode($this->args)); ?>" class="wd_args">
<input type="hidden" class="wd_taxonomy_search_nonce" value="<?php echo wp_create_nonce( 'wd_taxonomy_search_nonce' ); ?>">
<input isparam=1 type='hidden' value="<?php echo (is_array($this->data) && isset($this->data['value'])) ? $this->data['value'] : $this->data; ?>" name='<?php echo $this->name; ?>'>
</fieldset>
</div>
<?php
}
public function getAllTaxonomies() {
if ( $this->args['built_in'] == false ) {
$args = array('_builtin' => false);
} else {
$args = array();
}
$taxonomies = get_taxonomies( $args, 'objects' );
if ( !empty($this->args["exclude_taxonomies"]) ) {
foreach ($taxonomies as $k => $v) {
if ( in_array($v->name, $this->args["exclude_taxonomies"]) )
unset($taxonomies[$k]);
}
}
return $taxonomies;
}
private function printSelectedTerms() {
foreach($this->e_data['terms'] as $t) {
if ( $t['id'] == -1 ) {
// Excluded ids for this taxonomy to temporary storage to use in JS
if ( taxonomy_exists($t['taxonomy']) ) {
if (!empty($t['ex_ids'])) {
$this->term_data[$t['taxonomy']] = wpd_get_terms(array(
'taxonomy' => $t['taxonomy'],
'include' => $t['ex_ids'],
'fields' => 'id=>name',
'hide_empty' => false
));
if (is_wp_error($this->term_data))
$this->term_data = array();
}
$showmore = ($this->args['show_more_options']) ? "<br><a class='wd_tts_showmore'>+ " . __('Show more options', 'ajax-search-pro') . "</a>" : "";
echo '<li class="ui-state-default termlevel-0" term_id="-1" taxonomy="' . $t['taxonomy'] . '">' . __('Use all from', 'ajax-search-pro') . ' <b>' . $t['taxonomy'] . '</b><a class="deleteIcon"></a>' . $showmore . '</li>';
}
} else if ( $t['id'] == -200 && $t['taxonomy'] == 'post_format' ) {
$term = new stdClass();
$term->term_id = -200;
$term->taxonomy = 'post_format';
$term->children = array();
$term->name = 'Standard';
$term->label = 'Standard';
$term->parent = 0;
$term = apply_filters('asp_post_format_standard', $term);
$checkbox = "";
if ($this->args['show_checkboxes'] == 1)
$checkbox = '<input style="float:left;" type="checkbox" value="' . $term->term_id . '"
' . (!in_array($term->term_id, $this->e_data['un_checked']) ? ' checked="checked"' : '') . '/>';
echo '
<li class="ui-state-default termlevel-' . $t['level'] . '" term_level="' . $t['level'] . '" term_id="' . $term->term_id . '" taxonomy="' . $term->taxonomy . '">' . $term->name . '
' . $checkbox . '
<a class="deleteIcon"></a></li>
';
} else {
$term = get_term($t['id'], $t['taxonomy']);
if (empty($term) || is_wp_error($term))
continue;
$checkbox = "";
if ($this->args['show_checkboxes'] == 1)
$checkbox = '<input style="float:left;" type="checkbox" value="' . $term->term_id . '"
' . (!in_array($term->term_id, $this->e_data['un_checked']) ? ' checked="checked"' : '') . '/>';
// WPML
$language_code = apply_filters( 'wpml_element_language_code', null, array( 'element_id'=> (int)$term->term_id, 'element_type'=> $term->taxonomy ) );
if ( defined('ICL_SITEPRESS_VERSION') && !empty($language_code) ) {
$term->name .= ' [' . $language_code . ']';
}
echo '
<li class="ui-state-default termlevel-' . $t['level'] . '" term_level="' . $t['level'] . '" term_id="' . $term->term_id . '" taxonomy="' . $term->taxonomy . '">' . $term->name . '
' . $checkbox . '
<a class="deleteIcon"></a></li>
';
}
}
}
public static function searchTerms() {
if (
isset($_POST['wd_taxonomy'], $_POST['wd_taxonomy_search_nonce']) &&
( current_user_can( 'manage_options' ) || apply_filters('wpdrms/backend/options/ajax/user_role_override', false) ) &&
wp_verify_nonce( $_POST["wd_taxonomy_search_nonce"], 'wd_taxonomy_search_nonce' )
) {
$taxonomy = $_POST['wd_taxonomy'];
$terms = get_terms($taxonomy, array(
'taxonomy' => $taxonomy,
'hide_empty' => false,
'fields' => 'id=>name',
'search' => trim($_POST['wd_s']),
'number' => 15
));
Ajax::prepareHeaders();
if ( !is_wp_error($terms) && count($terms) > 0) {
foreach ($terms as $k => $term)
print "<span term_id='".$k."'>".$term."</span><br>";
} else {
print "No results for <b>" .$_POST['wd_s'] . "</b>";
}
}
die();
}
public static function printTerms() {
if (
isset($_POST['wd_taxonomy'], $_POST['wd_taxonomy_search_nonce']) &&
( current_user_can( 'manage_options' ) || apply_filters('wpdrms/backend/options/ajax/user_role_override', false) ) &&
wp_verify_nonce( $_POST["wd_taxonomy_search_nonce"], 'wd_taxonomy_search_nonce' )
) {
$taxonomy = $_POST['wd_taxonomy'];
$data = json_decode(base64_decode($_POST['wd_args']), true);
// WPMl?
$languages = apply_filters( 'wpml_active_languages', NULL, 'orderby=id&order=desc' );
$terms = array();
if ( defined('ICL_SITEPRESS_VERSION') && !empty( $languages ) ) {
foreach( $languages as $l ) {
if ( isset($l['language_code']) ) {
do_action( 'wpml_switch_language', $l['language_code'] );
$gterms = get_terms($taxonomy, array(
'taxonomy' => $taxonomy,
'hide_empty' => false
));
if ( !is_wp_error($gterms) && count($gterms) > 0 ) {
$terms = array_merge( $terms, $gterms );
foreach ( $gterms as &$term ) {
$term->name = $term->name . ' [' . $l['language_code'] . ']';
}
}
}
}
} else {
$terms = get_terms($taxonomy, array(
'taxonomy' => $taxonomy,
'hide_empty' => false
));
}
if ( $taxonomy == 'post_format' && !is_wp_error($terms) && !empty($terms) ) {
$std_term = new stdClass();
$std_term->term_id = -200;
$std_term->taxonomy = 'post_format';
$std_term->children = array();
$std_term->name = 'Standard';
$std_term->label = 'Standard';
$std_term->parent = 0;
$std_term = apply_filters('asp_post_format_standard', $std_term);
array_unshift($terms, $std_term);
}
Ajax::prepareHeaders();
$showmore = ( $data['show_more_options'] ) ? "<br><a class='wd_tts_showmore'>+ Show more options</a>" : "";
if ( $data['show_taxonomy_all'] )
echo '
<li class="ui-state-default termlevel-0" term_id="-1" taxonomy="' . esc_attr($taxonomy) . '">' . __('Use all from', 'ajax-search-pro') . ' <b>'.esc_attr($taxonomy).'</b><a class="deleteIcon"></a>'.$showmore.'</li>
..or select terms..
';
if (!empty($terms) && is_array($terms)) {
$termsHierarchical = array();
wd_sort_terms_hierarchicaly($terms, $termsHierarchical);
self::printTermsRecursive($termsHierarchical, 0, $data);
} else {
print "No terms to display in this taxonomy.";
}
}
die();
}
private static function printTermsRecursive ($terms, $level, $data) {
foreach ($terms as $term) {
$checkbox = "";
if ($data['show_checkboxes'] == 1)
$checkbox = '<input style="float:left;" type="checkbox" value="' . $term->term_id . '" checked="checked"/>';
echo '
<li class="ui-state-default termlevel-'.$level.'" term_level="'.$level.'" term_id="' . $term->term_id . '" taxonomy="' . $term->taxonomy . '">' . $term->name . '
'.$checkbox.'
<a class="deleteIcon"></a></li>
';
if (is_array($term->children) && count($term->children) >0 )
self::printTermsRecursive($term->children, ($level + 1), $data);
}
}
public function processData() {
// Get the args first if exists
if ( is_array($this->data) && isset($this->data['args']) )
$this->args = array_merge($this->args, $this->data['args']);
if ( is_array($this->data) && isset($this->data['value']) ) {
// If called from back-end non-post context
$this->e_data = $this->decode_param($this->data['value']);
$this->data = $this->encode_param($this->data['value']);
} else {
// POST method or something else
$this->e_data = $this->decode_param($this->data);
$this->data = $this->encode_param($this->data);
}
// All keys are srings in array, merge it with defaults to override
$this->e_data = array_merge($this->default_options, $this->e_data);
/**
* At this point the this->data variable surely contains the encoded data, no matter what.
*/
}
public final function getData() {
return $this->data;
}
public final function getSelected() {
return $this->e_data;
}
}
}
// Ajax action for the back-end
if ( !has_action('wp_ajax_wd_print_taxonomy_terms') )
add_action('wp_ajax_wd_print_taxonomy_terms', 'wd_TaxonomyTermSelect::printTerms');
if ( !has_action('wp_ajax_wd_search_taxonomy_terms') )
add_action('wp_ajax_wd_search_taxonomy_terms', 'wd_TaxonomyTermSelect::searchTerms');

View File

@@ -0,0 +1,145 @@
<?php
use WPDRMS\ASP\Utils\Ajax;
if (!class_exists("wd_TaxTermSearchCallBack")) {
/**
* Class wd_TaxTermSearchCallBack
*
* Custom field search for both post meta and user meta tables, which passes the results to a JS callback method
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2018, Ernest Marcinko
*/
class wd_TaxTermSearchCallBack extends wpdreamsType {
private static $delimiter = '!!!TTRES!!!';
private $args = array(
'callback' => '', // javacsript function name in the windows scope | if empty, shows results
'placeholder' => 'Search terms..',
'built_in' => true,
'search_values' => 0,
'limit' => 10,
'delimiter' => '!!!TTRES!!!',
'controls_position' => 'right',
'class' => '',
'usermeta' => 0
);
private $types;
private $labels = array(
'product_visibility' => 'Product visibility',
'product_type' => 'Product type'
);
public function getType() {
parent::getType();
$this->processData();
$this->args['delimiter'] = self::$delimiter;
$this->types = $this->getAllTaxonomies();
?>
<div class='wd_taxterm_search<?php echo $this->args['class'] != '' ? ' '.$this->args['class'] : "";?>'
id='wd_taxterm_search-<?php echo self::$_instancenumber; ?>'>
<?php if ( $this->label != '' ): ?>
<label class="wd_taxterm_label"><?php echo $this->label; ?></label>
<?php endif; ?>
<select class='wd_taxterm_tax' id='tax_ajax_selector_<?php echo self::$_instancenumber; ?>'>
<?php
foreach ($this->types as $taxonomy) {
$custom_post_type = "";
if ( isset($taxonomy->object_type[0]) )
$custom_post_type = $taxonomy->object_type[0] . " - ";
if ( isset($this->labels[$taxonomy->name]) )
$label = $this->labels[$taxonomy->name];
else
$label = $taxonomy->labels->name;
echo "<option value='" . $taxonomy->name . "' taxonomy='" . $taxonomy->name . "'>" . $custom_post_type .''. $taxonomy->name .' ('.$label. ")</option>";
}
?>
</select>
<?php if ($this->args['controls_position'] == 'left') $this->printControls(); ?>
<input type="hidden" class="wd_taxonomy_search_cb_nonce" value="<?php echo wp_create_nonce( 'wd_taxonomy_search_cb_nonce' ); ?>">
<input type="search" name="<?php echo $this->name; ?>"
class="wd_taxterm_search"
value="<?php echo (is_array($this->data) && isset($this->data['value'])) ? $this->data['value'] : $this->data; ?>"
placeholder="<?php echo $this->args['placeholder']; ?>"/>
<input type='hidden' value="<?php echo base64_encode(json_encode($this->args)); ?>" class="wd_args">
<?php if ($this->args['controls_position'] != 'left') $this->printControls(); ?>
<div class="wd_taxterm_search_res"></div>
</div>
<?php
}
private function printControls() {
?>
<span class="loading-small hiddend"></span>
<div class="wd_ts_close hiddend">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<polygon id="x-mark-icon" points="438.393,374.595 319.757,255.977 438.378,137.348 374.595,73.607 255.995,192.225 137.375,73.622 73.607,137.352 192.246,255.983 73.622,374.625 137.352,438.393 256.002,319.734 374.652,438.378 "></polygon>
</svg>
</div>
<?php
}
public function getAllTaxonomies() {
if ( $this->args['built_in'] == false ) {
$args = array('_builtin' => false);
} else {
$args = array();
}
$taxonomies = get_taxonomies( $args, 'objects' );
if ( !empty($this->args["exclude_taxonomies"]) ) {
foreach ($taxonomies as $k => $v) {
if ( in_array($v->name, $this->args["exclude_taxonomies"]) )
unset($taxonomies[$k]);
}
}
return $taxonomies;
}
public static function searchTaxTerm() {
if (
isset($_POST['wd_taxonomy'], $_POST['wd_taxonomy_search_cb_nonce']) &&
( current_user_can( 'manage_options' ) || apply_filters('wpdrms/backend/options/ajax/user_role_override', false) ) &&
wp_verify_nonce( $_POST["wd_taxonomy_search_cb_nonce"], 'wd_taxonomy_search_cb_nonce' )
) {
$taxonomy = $_POST['wd_taxonomy'];
$data = json_decode(base64_decode($_POST['wd_args']), true);
$terms = get_terms($taxonomy, array(
'taxonomy' => $taxonomy,
'hide_empty' => false,
'fields' => 'all',
'search' => trim($_POST['wd_phrase']),
'number' => $data['limit']
));
Ajax::prepareHeaders();
if ( !is_wp_error($terms) ) {
print_r(self::$delimiter . json_encode($terms) . self::$delimiter);;
} else {
print 1;
}
}
die();
}
public function processData() {
// Get the args first if exists
if ( is_array($this->data) && isset($this->data['args']) )
$this->args = array_merge($this->args, $this->data['args']);
if ( is_array($this->data) && isset($this->data['value']) ) {
// If called from back-end non-post context
$this->data = $this->data['value'];
}
}
public final function getData() {
return $this->data;
}
}
}
if ( !has_action('wp_ajax_wd_search_taxterm') )
add_action('wp_ajax_wd_search_taxterm', 'wd_TaxTermSearchCallBack::searchTaxTerm');

View File

@@ -0,0 +1,30 @@
<?php
if (!class_exists("wd_Textarea_B64")) {
/**
* Class wd_Textarea_B64
*
* A simple textarea field.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wd_Textarea_B64 extends wpdreamsType {
private $ddata, $pdata;
public function getType() {
parent::getType();
$this->pdata = "";
$this->processData();
echo "<label style='vertical-align: top;' for='wpdreamstextarea_" . self::$_instancenumber . "'>" . $this->label . "</label>";
echo "<input type='hidden' name='" . $this->name . "' value='".$this->data."' />";
echo "<textarea class='wd_textarea_b64' id='wd_textarea_b64_" . self::$_instancenumber . "'>" . stripcslashes($this->ddata) . "</textarea>";
}
public function processData() {
$this->ddata = base64_decode($this->data);
}
}
}

View File

@@ -0,0 +1,166 @@
<?php
use WPDRMS\ASP\Utils\Ajax;
if (!class_exists("wd_UserSelect")) {
/**
* Class wd_UserSelect
*
* A new multi-purpose, flexible user-select class that includes built-in types as well.
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2016, Ernest Marcinko
*/
class wd_UserSelect extends wpdreamsType {
private $args = array(
"show_type" => 0,
"show_checkboxes" => 0,
"show_all_users_option" => 1
);
private $e_data;
public function getType() {
parent::getType();
$this->processData();
?>
<div class='wd_userselect' id='wd_userselect-<?php echo self::$_instancenumber; ?>'>
<fieldset>
<div style='margin:15px 30px;text-align: left; line-height: 45px;'>
<label>
<?php echo __('Search users:', 'ajax-search-pro'); ?>
<input type="text" class="wd_user_search" placeholder="<?php echo __('Type here..', 'ajax-search-pro'); ?>"/>
</label>
<label<?php echo ($this->args["show_type"] == 1) ? '' : ' class="hiddend"'; ?>>
<?php echo __('Operation:', 'ajax-search-pro'); ?>
<select class="tts_operation">
<option value="include"<?php echo $this->e_data['op_type'] == "include" ? ' selected="selected"' : ''; ?>><?php echo __('Include', 'ajax-search-pro'); ?></option>
<option value="exclude"<?php echo $this->e_data['op_type'] == "exclude" ? ' selected="selected"' : ''; ?>><?php echo __('Exclude', 'ajax-search-pro'); ?></option>
</select>
</label>
</div>
<legend><?php echo $this->label; ?></legend>
<div class="draggablecontainer" id="sortablecontainer<?php echo self::$_instancenumber; ?>">
<div class="dragLoader hiddend"></div>
<p><?php echo __('User Results', 'ajax-search-pro'); ?></p>
<ul id="sortable<?php echo self::$_instancenumber; ?>" class="connectedSortable wd_csortable<?php echo self::$_instancenumber; ?>">
<?php if ($this->args['show_all_users_option'] == 1): ?>
<li class="ui-state-default" user_id="-1"><?php echo __('All users', 'ajax-search-pro'); ?><a class="deleteIcon"></a></li>
<?php endif; ?>
<li class="ui-state-default" user_id="0"><?php echo __('Anonymous user (no user)', 'ajax-search-pro'); ?><a class="deleteIcon"></a></li>
<li class="ui-state-default" user_id="-2"><?php echo __('Current logged in user', 'ajax-search-pro'); ?><a class="deleteIcon"></a></li>
<?php echo __('Use the search to look for users :)', 'ajax-search-pro'); ?>
</ul>
</div>
<div class="sortablecontainer"><p><?php echo __('Drag here the ones you want to', 'ajax-search-pro'); ?> <span style="font-weight: bold;" class="tts_type"><?php echo $this->e_data['op_type']; ?></span>!</p>
<ul id="sortable_conn<?php echo self::$_instancenumber; ?>" class="connectedSortable wd_csortable<?php echo self::$_instancenumber; ?>">
<?php $this->printSelectedUsers(); ?>
</ul>
</div>
<input type="hidden" class="wd_user_select_nonce" value="<?php echo wp_create_nonce( 'wd_user_select_nonce' ); ?>">
<input type='hidden' value="<?php echo base64_encode(json_encode($this->args)); ?>" class="wd_args">
<input isparam=1 type='hidden' value="<?php echo (is_array($this->data) && isset($this->data['value'])) ? $this->data['value'] : $this->data; ?>" name='<?php echo $this->name; ?>'>
</fieldset>
</div>
<?php
}
private function printSelectedUsers() {
foreach($this->e_data['users'] as $u) {
switch ($u) {
case -1:
echo '<li class="ui-state-default termlevel-0" user_id="-1">' . __('All users', 'ajax-search-pro') . '</b><a class="deleteIcon"></a></li>';
break;
case 0:
echo '<li class="ui-state-default" user_id="0">' . __('Anonymous user (no user)', 'ajax-search-pro') . '</b><a class="deleteIcon"></a></li>';
break;
case -2:
echo '<li class="ui-state-default" user_id="-2">' . __('Current logged in user', 'ajax-search-pro') . '</b><a class="deleteIcon"></a></li>';
break;
default:
$user = get_user_by("ID", $u);
if (empty($user) || is_wp_error($user))
break;
$checkbox = "";
if ($this->args['show_checkboxes'] == 1)
$checkbox = '<input style="float:left;" type="checkbox" value="' . $user->ID . '"
' . (!in_array($user->ID, $this->e_data['un_checked']) ? ' checked="checked"' : '') . '/>';
echo '
<li class="ui-state-default" user_id="' . $user->ID . '">' . $user->user_login . ' ('.$user->display_name.')
' . $checkbox . '
<a class="deleteIcon"></a></li>';
break;
}
}
}
public static function searchUsers() {
if (
isset($_POST['wd_phrase'], $_POST['wd_user_select_nonce']) &&
( current_user_can( 'manage_options' ) || apply_filters('wpdrms/backend/options/ajax/user_role_override', false) ) &&
wp_verify_nonce( $_POST["wd_user_select_nonce"], 'wd_user_select_nonce' )
) {
$phrase = trim($_POST['wd_phrase']);
$data = json_decode(base64_decode($_POST['wd_args']), true);
$user_query = new WP_User_Query( array( 'search' => "*" . $phrase . "*", "number" => 100 ) );
Ajax::prepareHeaders();
if ( $data['show_all_users_option'] == 1 )
echo '<li class="ui-state-default termlevel-0" user_id="-1">' . __('All users', 'ajax-search-pro') . '</b><a class="deleteIcon"></a></li>';
echo '<li class="ui-state-default" user_id="0">' . __('Anonymous user (no user)', 'ajax-search-pro') . '</b><a class="deleteIcon"></a></li>
<li class="ui-state-default" user_id="-2">' . __('Current logged in user', 'ajax-search-pro') . '</b><a class="deleteIcon"></a></li>';
// User Loop
$user_results = $user_query->get_results();
if ( ! empty( $user_results ) ) {
echo "Or select users:";
foreach ( $user_results as $user ) {
$checkbox = "";
if ($data['show_checkboxes'] == 1)
$checkbox = '<input style="float:left;" type="checkbox" value="' . $user->ID . '" checked="checked"/>';
echo '
<li class="ui-state-default" user_id="' . $user->ID . '">' . $user->user_login . ' ('.$user->display_name.')
'.$checkbox.'
<a class="deleteIcon"></a></li>
';
}
} else {
echo __('No users found for term:', 'ajax-search-pro') . ' <b>' . esc_html($phrase) .'</b>';
}
}
die();
}
public function processData() {
// Get the args first if exists
if ( is_array($this->data) && isset($this->data['args']) )
$this->args = array_merge($this->args, $this->data['args']);
if ( is_array($this->data) && isset($this->data['value']) ) {
// If called from back-end non-post context
$this->e_data = $this->decode_param($this->data['value']);
$this->data = $this->encode_param($this->data['value']);
} else {
// POST method or something else
$this->e_data = $this->decode_param($this->data);
$this->data = $this->encode_param($this->data);
}
/**
* At this point the this->data variable surely contains the encoded data, no matter what.
*/
}
public final function getData() {
return $this->data;
}
public final function getSelected() {
return $this->e_data;
}
}
}
if ( !has_action('wp_ajax_wd_search_users') )
add_action('wp_ajax_wd_search_users', 'wd_UserSelect::searchUsers');

View File

@@ -0,0 +1,91 @@
<?php
if (!class_exists("wd_UserMeta")) {
/**
* Class wd_UserMeta
*
* User meta search and select element
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/wpdreams/portfolio
* @copyright Copyright (c) 2017, Ernest Marcinko
*/
class wd_UserMeta extends wpdreamsType {
private $args = array();
private $e_data;
function getType()
{
parent::getType();
$this->processData();
$inst = self::$_instancenumber; // Need this, as the static variable is overwritten when the callback is created
?>
<div class='wd_UserMeta' id="wd_UserMeta-<?php echo $inst; ?>">
<fieldset>
<legend><?php echo $this->label; ?></legend>
<div class="draggablecontainer" id="draggablecontainer<?php echo $inst; ?>">
<div class="arrow-all-left"></div>
<div class="arrow-all-right"></div><div style="margin: -3px 0 5px -5px;">
<?php
new wd_CFSearchCallBack('wdcfs_' . $inst, '',
array(
'value' => '',
'args' => array(
'callback' => 'wd_um_ajax_callback',
'limit' => 20,
'usermeta' => 1
)
)
);
?>
</div><ul id="sortable<?php echo $inst; ?>" class="connectedSortable">
<?php echo __('Use the search bar above to look for user meta fields', 'ajax-search-pro'); ?> :)
</ul></div>
<div class="sortablecontainer">
<p><?php echo __('Drag here the user meta fields you want to use!', 'ajax-search-pro'); ?></p>
<ul id="sortable_conn<?php echo $inst; ?>" class="connectedSortable">
<?php
if ($this->e_data != null && is_array($this->e_data)) {
foreach ($this->e_data as $k => $v) {
echo '<li class="ui-state-default" cf_name="' . $v . '">' . $v . '<a class="deleteIcon"></a></li>';
}
}
?>
</ul></div>
<input type='hidden' value="<?php echo base64_encode(json_encode($this->args)); ?>" class="wd_args">
<input isparam=1 type='hidden' value="<?php echo (is_array($this->data) && isset($this->data['value'])) ? $this->data['value'] : $this->data; ?>" name="<?php echo $this->name; ?>">
</fieldset>
</div>
<?php
}
public function processData() {
// Get the args first if exists
if ( is_array($this->data) && isset($this->data['args']) )
$this->args = array_merge($this->args, $this->data['args']);
if ( is_array($this->data) && isset($this->data['value']) ) {
// If called from back-end non-post context
$this->e_data = $this->decode_param($this->data['value']);
$this->data = $this->encode_param($this->data['value']);
} else {
// POST method or something else
$this->e_data = $this->decode_param($this->data);
$this->data = $this->encode_param($this->data);
}
/**
* At this point the this->data variable surely contains the encoded data, no matter what.
*/
}
public final function getData() {
return $this->data;
}
public final function getSelected() {
return $this->e_data;
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
if (!class_exists("wpdreamsYesNo")) {
/**
* Class wpdreamsYesNo
*
* Displays an ON-OFF switch UI element
*
* @package WPDreams/OptionsFramework/Classes
* @category Class
* @author Ernest Marcinko <ernest.marcinko@wp-dreams.com>
* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2014, Ernest Marcinko
*/
class wpdreamsYesNo extends wpdreamsType {
function getType() {
parent::getType();
echo "<div class='wpdreamsYesNo" . (($this->data == 1) ? " active" : "") . "'>";
echo "<label for='wpdreamstext_" . self::$_instancenumber . "'>" . $this->label . "</label>";
echo "<input isparam=1 type='hidden' value='" . $this->data . "' name='" . $this->name . "'>";
echo "<div class='wpdreamsYesNoInner'></div>";
echo "<div class='triggerer'></div>";
echo "</div>";
}
}
}