rebase from live enviornment
This commit is contained in:
72
wp/plugins/search-filter-divi/README.txt
Normal file
72
wp/plugins/search-filter-divi/README.txt
Normal file
@@ -0,0 +1,72 @@
|
||||
=== Search & Filter Pro - Divi Extension ===
|
||||
Contributors: CodeAmp
|
||||
Donate link:
|
||||
Tags: posts, custom posts, products, category, filter, taxonomy, post meta, custom fields, search, wordpress, post type, post date, author
|
||||
Requires at least: 4.0
|
||||
Tested up to: 5.4
|
||||
Stable tag: 1.0.7
|
||||
|
||||
A bridge Plugin enabling easy integration of the Divi Blog, Portfolio and Shop modules with Search & Filter Pro
|
||||
|
||||
== Description ==
|
||||
|
||||
A bridge Plugin enabling easy integration of the Divi Blog, Portfolio and Shop modules with Search & Filter Pro
|
||||
|
||||
|
||||
== Installation ==
|
||||
|
||||
|
||||
= Uploading in WordPress Dashboard =
|
||||
|
||||
1. Navigate to the 'Add New' in the plugins dashboard
|
||||
2. Navigate to the 'Upload' area
|
||||
3. Select `search-filter-divi.zip` from your computer
|
||||
4. Click 'Install Now'
|
||||
5. Activate the plugin in the Plugin dashboard
|
||||
|
||||
|
||||
= Using FTP =
|
||||
|
||||
1. Download `search-filter-divi.zip`
|
||||
2. Extract the `search-filter-divi` directory to your computer
|
||||
3. Upload the `search-filter-divi` directory to the `/wp-content/plugins/` directory
|
||||
4. Activate the plugin in the Plugin dashboard
|
||||
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.0.7 =
|
||||
* Fix - an with our search form no longer showing up in the Divi Builder
|
||||
|
||||
= 1.0.6 =
|
||||
* Fix - a PHP issue with paramater order
|
||||
|
||||
= 1.0.5 =
|
||||
* Fix - an issue with pagination not working properly when using modules + filtering on the homepage
|
||||
* Fix - a PHP 8 issue
|
||||
* Add support for wp pagenavi plugin
|
||||
* Add hooks before/after the posts module
|
||||
|
||||
= 1.0.4 =
|
||||
* Fix - an with our query for fetching search forms not being handled correctly in certain situations
|
||||
|
||||
= 1.0.3 =
|
||||
* Fix an issue with custom CSS classes being lost with S&F results/modules
|
||||
|
||||
= 1.0.2 =
|
||||
* Fix an issue with an option disappearing from the Blog module
|
||||
|
||||
= 1.0.1 =
|
||||
* Fix an issue with the Shop module not being filtered
|
||||
|
||||
= 1.0.0 =
|
||||
* Initial release
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
14
wp/plugins/search-filter-divi/includes/loader.php
Normal file
14
wp/plugins/search-filter-divi/includes/loader.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
if ( ! class_exists( 'ET_Builder_Element' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$module_files = glob( __DIR__ . '/modules/*/*.php' );
|
||||
|
||||
// Load custom Divi Builder modules
|
||||
foreach ( (array) $module_files as $module_file ) {
|
||||
if ( $module_file && preg_match( "/\/modules\/\b([^\/]+)\/\\1\.php$/", $module_file ) ) {
|
||||
require_once $module_file;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
class SFDIVI_SearchForm extends ET_Builder_Module {
|
||||
|
||||
public $slug = 'sfdivi_search_filter_form';
|
||||
public $vb_support = 'on';
|
||||
public $search_form_options;
|
||||
|
||||
protected $module_credits = array(
|
||||
'module_uri' => 'https://searchandfilter.com/',
|
||||
'author' => 'Code Amp',
|
||||
'author_uri' => 'https://codeamp.com/',
|
||||
);
|
||||
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Search & Filter Form', 'search-filter-divi' );
|
||||
/*$this->whitelisted_fields = array(
|
||||
'search_form',
|
||||
);*/
|
||||
$this->advanced_fields = array(
|
||||
'fonts' => array(
|
||||
'search_form' => array(
|
||||
'label' => __('Search & Filter Form', "search-filter-divi"),
|
||||
'css' => array(
|
||||
'main' => "%%order_class%% .sf_divi_select_text",
|
||||
),
|
||||
'line_height' => array('default' => '1em',),
|
||||
'font_size' => array('default' => '14px',),
|
||||
),
|
||||
),
|
||||
);
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
'toggles' => array(
|
||||
'sg1' => __('Search & Filter Settings', "search-filter-divi"),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
|
||||
$search_form_options = $this->get_search_form_options();
|
||||
|
||||
return array(
|
||||
'search_form' => array(
|
||||
'label' => esc_html__( 'Choose a Search Form', 'sfdivi-search-filter-divi' ),
|
||||
'type' => 'select',
|
||||
'option_category' => 'basic_option',
|
||||
'description' => __('Display your Search Form.', "sfdivi-search-filter-divi"),
|
||||
'toggle_slug' => 'sg1',
|
||||
|
||||
'options' => array_merge(array('' => 'Choose a Search Form'), $search_form_options),
|
||||
//'options' => $search_form_options,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_search_form_options()
|
||||
{
|
||||
if(empty($this->search_form_options)){
|
||||
|
||||
$custom_posts = new WP_Query('post_type=search-filter-widget&post_status=publish&posts_per_page=-1');
|
||||
|
||||
$this->search_form_options = array();
|
||||
foreach($custom_posts->posts as $post){
|
||||
$this->search_form_options['search-filter-id-'.$post->ID] = get_the_title($post->ID);
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
}
|
||||
|
||||
return $this->search_form_options;
|
||||
}
|
||||
|
||||
public function render( $attrs, $content, $render_slug ) {
|
||||
$search_filter_id = intval(str_replace("search-filter-id-", "", $this->props['search_form']));
|
||||
return do_shortcode('[searchandfilter id="'.$search_filter_id.'"]');
|
||||
}
|
||||
}
|
||||
|
||||
new SFDIVI_SearchForm;
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
class SIMP_SimpleHeader extends ET_Builder_Module {
|
||||
|
||||
public $slug = 'simp_simple_header';
|
||||
public $vb_support = 'on';
|
||||
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Simple Header', 'simp-simple-extension' );
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function render( $unprocessed_props, $content, $render_slug ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
new SIMP_SimpleHeader;
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class Search_Filter_Divi_Extension extends DiviExtension {
|
||||
|
||||
/**
|
||||
* The gettext domain for the extension's translations.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gettext_domain = 'sfdivi-search-filter-divi';
|
||||
|
||||
/**
|
||||
* The extension's WP Plugin name.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name = 'search-filter-divi';
|
||||
|
||||
/**
|
||||
* The extension's version
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $version = '1.0.7';
|
||||
|
||||
/**
|
||||
* Search_Filter_Divi_Extension constructor.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $args
|
||||
*/
|
||||
public function __construct( $name = 'search-filter-divi', $args = array() ) {
|
||||
$this->plugin_dir = plugin_dir_path( __FILE__ );
|
||||
$this->plugin_dir_url = plugin_dir_url( $this->plugin_dir );
|
||||
|
||||
parent::__construct( $name, $args );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
new Search_Filter_Divi_Extension;
|
||||
@@ -0,0 +1,356 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Search_Filter_Divi_Query {
|
||||
|
||||
protected static $instance = null;
|
||||
|
||||
private $search_form_options = array();
|
||||
private $active_query_id = 0;
|
||||
|
||||
private $current_query = 0;
|
||||
|
||||
public static function get_instance() {
|
||||
|
||||
// If the single instance hasn't been set, set it now.
|
||||
if ( null == self::$instance ) {
|
||||
self::$instance = new self;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
|
||||
public function __construct() {
|
||||
|
||||
$this->init();
|
||||
|
||||
}
|
||||
public function init(){
|
||||
|
||||
// add S&F option to portoflio and blog module settings
|
||||
add_filter( 'et_pb_all_fields_unprocessed_et_pb_portfolio', array($this, 'render_settings_field') );
|
||||
add_filter( 'et_pb_all_fields_unprocessed_et_pb_blog', array($this, 'render_settings_field'));
|
||||
add_filter( 'et_pb_all_fields_unprocessed_et_pb_shop', array($this, 'render_settings_field'), 1000 );
|
||||
|
||||
//we used to do it a different way for shop, but lets unify all for consistent experience
|
||||
//add_filter( 'et_pb_all_fields_unprocessed_et_pb_shop', array($this, 'render_shop_settings_field'), 1000 );
|
||||
|
||||
//add S&F class to portfolio and blog modules, attach pre_get_posts
|
||||
add_filter( 'et_pb_module_shortcode_attributes', array($this, 'module_attributes'), 1000, 3 );
|
||||
add_filter( 'et_pb_module_shortcode_attributes', array($this, 'module_shop_attributes'), 1000, 3 );
|
||||
|
||||
//remove pre_get_posts and add hooks for content above / below the blog module
|
||||
add_filter( 'et_module_shortcode_output', array($this, 'shortcode_output'), 1000, 3 );
|
||||
|
||||
//add Divi option to `display method` in S&F settings
|
||||
add_filter( 'search_filter_admin_option_display_results', array($this, 'search_filter_admin_option_display_results'), 10, 2 );
|
||||
|
||||
//override the ajax container, and pagination selectors in search form attributes
|
||||
add_filter( 'search_filter_form_attributes', array($this, 'search_filter_form_attributes'), 10, 2 );
|
||||
|
||||
// retrieving wp_query information from this action
|
||||
add_filter( 'et_builder_blog_query', array($this, 'get_blog_query'), 10, 2 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function filter_query($query){
|
||||
|
||||
|
||||
//attach S&F to the query
|
||||
if( 0 !== $this->active_query_id ) {
|
||||
$query->set( "search_filter_id", $this->active_query_id );
|
||||
|
||||
// pagination stops working on the homepage, so we have to set these vars again
|
||||
if ( is_front_page() || is_home() ) {
|
||||
$sfpaged = 1;
|
||||
if( isset( $_GET['sf_paged'] ) ) {
|
||||
$sfpaged = intval( $_GET[ 'sf_paged' ] );
|
||||
global $paged;
|
||||
$paged = $sfpaged;
|
||||
set_query_var( "paged", $paged ); //some plugins / themes use `get_query_var`, they often shouldn't
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$this->active_query_id = 0;
|
||||
}
|
||||
|
||||
public function shortcode_output($output, $render_slug, $module){
|
||||
|
||||
if( ('et_pb_portfolio' !== $render_slug) && ('et_pb_blog' !== $render_slug) && ('et_pb_shop' !== $render_slug) ){
|
||||
return $output;
|
||||
}
|
||||
|
||||
if ( is_array( $output ) ) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
// shortcode output means the query has been run, so remove pre_get_posts
|
||||
remove_action( 'pre_get_posts', array( $this, 'filter_query' ), 1000 );
|
||||
remove_filter( 'woocommerce_shortcode_products_query', array($this, 'woocommerce_shortcode_cache_breaker'), 1000 );
|
||||
|
||||
// now allow actions to insert content
|
||||
ob_start();
|
||||
do_action( 'search_filter_divi_module_start_render', $this->current_query );
|
||||
$pre_render_html = ob_get_clean();
|
||||
|
||||
ob_start();
|
||||
do_action( 'search_filter_divi_module_end_render', $this->current_query );
|
||||
$after_render_html = ob_get_clean();
|
||||
|
||||
// injecting the pre_render_html inside the ajax container
|
||||
$output = preg_replace( '~<div class="et_pb_ajax_pagination_container">~', $pre_render_html . '<div class="et_pb_ajax_pagination_container">', $output );
|
||||
|
||||
// find the last closing div
|
||||
$closing_div = '</div>';
|
||||
$last_div_pos = strrpos( $output, $closing_div );
|
||||
if( $last_div_pos !== false ) {
|
||||
//and insert html just before
|
||||
$output = substr_replace( $output, $after_render_html . $closing_div, $last_div_pos, strlen( $closing_div ));
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function get_blog_query( $wp_query ){
|
||||
$this->current_query = $wp_query;
|
||||
return $wp_query;
|
||||
}
|
||||
|
||||
public function module_attributes($props, $attrs, $render_slug){
|
||||
|
||||
if( ('et_pb_portfolio' !== $render_slug) && ('et_pb_blog' !== $render_slug) ){
|
||||
return $props;
|
||||
}
|
||||
|
||||
if((!isset($props['search_filter_link']))||(!isset($props['search_filter_id']))){
|
||||
return $props;
|
||||
}
|
||||
|
||||
if("yes" !== $props['search_filter_link']){
|
||||
return $props;
|
||||
}
|
||||
|
||||
//the value of search_filter_id will be something like `search-filter-id-X` where X is the ID
|
||||
$search_filter_id = intval(str_replace("search-filter-id-", "", $props['search_filter_id']));
|
||||
$search_filter_results_class = 'search-filter-results-'.$search_filter_id;
|
||||
|
||||
// if the class is not already there, add it
|
||||
if ( strpos( $props['module_class'], $search_filter_results_class ) === false) {
|
||||
$props['module_class'] .= ' ' . $search_filter_results_class . ' '; //add a class for easy Ajax integration
|
||||
}
|
||||
|
||||
$this->active_query_id = $search_filter_id;
|
||||
add_action( 'pre_get_posts', array($this, 'filter_query'), 1000 );
|
||||
|
||||
return $props;
|
||||
}
|
||||
|
||||
public function products_shortcode_attributes($out, $pairs, $atts) {
|
||||
|
||||
//remove products shortcode caching
|
||||
$out['cache'] = false;
|
||||
remove_filter( 'shortcode_atts_products', array($this, 'products_shortcode_attributes'), 1000, 3 );
|
||||
return $out;
|
||||
}
|
||||
public function module_shop_attributes($props, $attrs, $render_slug) {
|
||||
|
||||
if( ('et_pb_shop' !== $render_slug) ){
|
||||
return $props;
|
||||
}
|
||||
|
||||
if((!isset($props['search_filter_link']))||(!isset($props['search_filter_id']))){
|
||||
return $props;
|
||||
}
|
||||
|
||||
if("yes" !== $props['search_filter_link']){
|
||||
return $props;
|
||||
}
|
||||
|
||||
//the value of search_filter_id will be something like `search-filter-id-X` where X is the ID
|
||||
$search_filter_id = intval( str_replace( "search-filter-id-", "", $props['search_filter_id'] ) );
|
||||
$props['module_class'] = " search-filter-results-".$search_filter_id." "; //add a class for easy Ajax integration
|
||||
$this->active_query_id = $search_filter_id;
|
||||
|
||||
//filter the query
|
||||
add_action( 'pre_get_posts', array($this, 'filter_query'), 1000 );
|
||||
|
||||
//add cache=false to `products` shortcode
|
||||
add_filter( 'shortcode_atts_products', array($this, 'products_shortcode_attributes'), 1000, 3 );
|
||||
|
||||
return $props;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attach S&F settings to portfolio and blog modules (search form choice)
|
||||
*/
|
||||
public function render_settings_field( $field_unprocessed ){
|
||||
|
||||
$show_if = array(
|
||||
'search_filter_link' => 'yes',
|
||||
);
|
||||
|
||||
$fields = array(
|
||||
'search_filter_link' => array(
|
||||
'label' => __('Link with a Search & Filter Form?', 'search-filter-divi'),
|
||||
'type' => 'select',
|
||||
'default' => 'no',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'no' => 'No',
|
||||
'yes' => 'Yes',
|
||||
),
|
||||
'toggle_slug' => 'main_content',
|
||||
'affects' => array('search_filter_id'), //,'posts_number','include_categories',
|
||||
'vb_support' => true,
|
||||
),
|
||||
'search_filter_id' => array(
|
||||
'label' => __('Choose a Search Form', 'search-filter-divi'),
|
||||
'type' => 'select',
|
||||
'default' => '0',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array_merge(array('' => 'Choose a Search Form'), $this->get_search_form_options()),
|
||||
//'show_if' => $show_if,
|
||||
'depends_show_if_not' => 'no',
|
||||
'toggle_slug' => 'main_content',
|
||||
'vb_support' => true,
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
//hide query related options unless S&F query is off
|
||||
//editing existing dependencies doesn't really seem to work anymore
|
||||
/*$show_if_value = "no";
|
||||
$show_if = array(
|
||||
'search_filter_link' => $show_if_value,
|
||||
);
|
||||
|
||||
$field_unprocessed['posts_number']['depends_show_if_not'] = 'no';
|
||||
$field_unprocessed['include_categories']['depends_show_if_not'] = 'no';
|
||||
$field_unprocessed['post_type']['show_if']['search_filter_link'] = 'off';*/
|
||||
|
||||
//return $field_unprocessed + $fields;
|
||||
|
||||
return array_merge($fields, $field_unprocessed);
|
||||
}
|
||||
public function render_shop_settings_field($field_unprocessed){
|
||||
|
||||
$show_if = array(
|
||||
'type' => 'search_filter',
|
||||
);
|
||||
|
||||
if(isset($field_unprocessed['type'])){
|
||||
|
||||
if(isset($field_unprocessed['type']['options'])){
|
||||
if(is_array($field_unprocessed['type']['options'])){
|
||||
$field_unprocessed['type']['options']['search_filter'] = 'Search & Filter Results';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'search_filter_id' => array(
|
||||
'label' => __('Choose a Search Form', 'search-filter-divi'),
|
||||
'type' => 'select',
|
||||
'default' => '1',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array_merge(array('' => 'Choose a Search Form'), $this->get_search_form_options()),
|
||||
'show_if' => $show_if,
|
||||
'toggle_slug' => 'main_content',
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
//hide query related options unless S&F query is off
|
||||
//doesn't work so well anymore
|
||||
/*$show_if = array(
|
||||
'search_filter_link' => 'no',
|
||||
);
|
||||
$field_unprocessed['posts_number']['show_if'] = $show_if;
|
||||
$field_unprocessed['include_categories']['show_if'] = $show_if;*/
|
||||
|
||||
return $fields + $field_unprocessed;
|
||||
}
|
||||
/*
|
||||
* Override the settings for the ajax container and pagination
|
||||
*/
|
||||
public function search_filter_form_attributes($attributes, $sfid){
|
||||
|
||||
if(isset($attributes['data-display-result-method']))
|
||||
{
|
||||
if($attributes['data-display-result-method']=="divi_post_module" && ! function_exists('wp_pagenavi') )
|
||||
{
|
||||
$attributes['data-ajax-target'] = '.search-filter-results-'.$sfid;
|
||||
$attributes['data-ajax-links-selector'] = '.pagination a';
|
||||
}
|
||||
else if ($attributes['data-display-result-method']=="divi_post_module" && function_exists('wp_pagenavi') ) {
|
||||
$attributes['data-ajax-target'] = '.search-filter-results-'.$sfid;
|
||||
$attributes['data-ajax-links-selector'] = '.wp-pagenavi a';
|
||||
}
|
||||
else if($attributes['data-display-result-method']=="divi_shop_module")
|
||||
{
|
||||
$attributes['data-ajax-target'] = '.search-filter-results-'.$sfid;
|
||||
$attributes['data-ajax-links-selector'] = '.page-numbers a';
|
||||
}
|
||||
else if($attributes['data-display-result-method']=="custom_woocommerce_store")
|
||||
{
|
||||
$attributes['data-ajax-target'] = '.search-filter-results-'.$sfid;
|
||||
$attributes['data-ajax-links-selector'] = '.page-numbers a';
|
||||
}
|
||||
else if($attributes['data-display-result-method']=="post_type_archive")
|
||||
{
|
||||
$attributes['data-ajax-target'] = '.search-filter-results-'.$sfid;
|
||||
$attributes['data-ajax-links-selector'] = '.pagination a';
|
||||
}
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a `display result` method for divi
|
||||
*/
|
||||
public function search_filter_admin_option_display_results($display_results_options){
|
||||
|
||||
$display_results_options['divi_post_module'] = array(
|
||||
'label' => __('Divi Blog / Portfolio Module'),
|
||||
'description' =>
|
||||
'<p>'.__('Search Results will displayed using a Divi Blog or Portfolio.', 'search-filter-divi').'</p>'.
|
||||
'<p>'.__('Remember to update the setting in your module to use the Search & Filter Query.', 'search-filter-divi').'</p>',
|
||||
'base' => 'shortcode'
|
||||
);
|
||||
$display_results_options['divi_shop_module'] = array(
|
||||
'label' => __('Divi Shop Module'),
|
||||
'description' =>
|
||||
'<p>'.__('Search Results will displayed using a Divi Shop Module.', 'search-filter-divi').'</p>'.
|
||||
'<p>'.__('Remember to update the setting in your module to use the Search & Filter Query.', 'search-filter-divi').'</p>',
|
||||
'base' => 'shortcode'
|
||||
);
|
||||
|
||||
return $display_results_options;
|
||||
}
|
||||
/*
|
||||
* Get available search forms as key => label array, for populating a `select`
|
||||
*/
|
||||
private function get_search_form_options() {
|
||||
|
||||
if(empty($this->search_form_options)){
|
||||
|
||||
$custom_posts = new WP_Query('post_type=search-filter-widget&post_status=publish&posts_per_page=-1');
|
||||
|
||||
if( $custom_posts->post_count > 0 ) {
|
||||
foreach ($custom_posts->posts as $post){
|
||||
$this->search_form_options[ 'search-filter-id-' . $post->ID ] = get_post_field( 'post_name', $post->ID );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->search_form_options;
|
||||
}
|
||||
}
|
||||
|
||||
new Search_Filter_Divi_Query();
|
||||
1
wp/plugins/search-filter-divi/scripts/builder-bundle.min.js
vendored
Normal file
1
wp/plugins/search-filter-divi/scripts/builder-bundle.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r(r.s=1)}([function(e,t){},function(e,t,r){r(2),e.exports=r(3)},function(e,t,r){"use strict"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),o=r.n(n),i=r(5);o()(window).on("et_builder_api_ready",function(e,t){t.registerModules(i.a)})},function(e,t){e.exports=jQuery},function(e,t,r){"use strict";var n=r(6);t.a=[n.a]},function(e,t,r){"use strict";var n=r(7),o=r.n(n),i=r(8),u=r.n(i),c=r(0);r.n(c);function a(e){return(a="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){return t&&l(e.prototype,t),r&&l(e,r),e}function p(e,t){return!t||"object"!==a(t)&&"function"!==typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function h(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var m=window.jQuery,y=window.SF_LDATA,d=function(e){function t(e){var r;return f(this,t),(r=p(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))).state={error:null,sform:null},r.$el=null,r.el=null,r}return h(t,n["Component"]),s(t,[{key:"fetchSearchForm",value:function(e){var t=this,r="?sfid="+parseInt(e)+"&sf_action=get_data&sf_data=form",n=y.home_url+r;fetch(n).then(function(e){return e.json()}).then(function(e){t.setState({sform:e.form})},function(e){t.setState({error:e})})}},{key:"initSearchAndFilter",value:function(){this.el=u.a.findDOMNode(this),this.$el=m(this.el).find("form"),this.$el.off(),this.$el.searchAndFilter()}},{key:"componentDidUpdate",value:function(){this.initSearchAndFilter()}},{key:"componentWillReceiveProps",value:function(e){if(e.search_form!==this.props.search_form&&"undefined"!==typeof e.search_form){var t=e.search_form.replace("search-filter-id-","");this.fetchSearchForm(t)}}},{key:"componentDidMount",value:function(){if("undefined"!==typeof this.props.search_form){var e=this.props.search_form.replace("search-filter-id-","");this.fetchSearchForm(e)}}},{key:"render",value:function(){var e=this.state,t=e.error,r=e.sform;return t?o.a.createElement("div",null,"Error: ",t.message):o.a.createElement(n.Fragment,null,o.a.createElement(_,{html:r}))}}]),t}();Object.defineProperty(d,"slug",{configurable:!0,enumerable:!0,writable:!0,value:"sfdivi_search_filter_form"});var _=function(e){function t(){return f(this,t),p(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return h(t,o.a.Component),s(t,[{key:"render",value:function(){return o.a.createElement("div",{dangerouslySetInnerHTML:{__html:this.props.html}})}}]),t}();t.a=d},function(e,t){e.exports=React},function(e,t){e.exports=ReactDOM}]);
|
||||
1
wp/plugins/search-filter-divi/scripts/frontend-bundle.min.js
vendored
Normal file
1
wp/plugins/search-filter-divi/scripts/frontend-bundle.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(n){var t={};function r(e){if(t[e])return t[e].exports;var o=t[e]={i:e,l:!1,exports:{}};return n[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=n,r.c=t,r.d=function(n,t,e){r.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:e})},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,"a",t),t},r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.p="/",r(r.s=9)}({0:function(n,t){},9:function(n,t,r){n.exports=r(0)}});
|
||||
40
wp/plugins/search-filter-divi/scripts/search-filter-divi.js
Normal file
40
wp/plugins/search-filter-divi/scripts/search-filter-divi.js
Normal file
@@ -0,0 +1,40 @@
|
||||
// This script is loaded both on the frontend page and in the Visual Builder.
|
||||
|
||||
(function ( $ ) {
|
||||
"use strict";
|
||||
|
||||
var removeDiviPaginationEvents = false;
|
||||
|
||||
$(document).on("sf:init", ".searchandfilter", function(e, data){3
|
||||
|
||||
var searchForm = {};
|
||||
searchForm = data.object;
|
||||
|
||||
//check to see if there is a divi search form
|
||||
if(searchForm.display_result_method == "divi_post_module"){
|
||||
//check to see if there is a divi results module
|
||||
if($(data.targetSelector).length>0){
|
||||
//if yes, then its likely this page is a results page for S&F, so remove the DIVI events
|
||||
removeDiviPaginationEvents = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready( function(){
|
||||
if(removeDiviPaginationEvents){
|
||||
//this is the only way to remove those events
|
||||
$( 'body' ).off( 'click', '.et_pb_ajax_pagination_container .wp-pagenavi a, .et_pb_ajax_pagination_container .pagination a');
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("sf:ajaxfinish", ".searchandfilter", function(e, searchForm){
|
||||
if( (searchForm.object.display_result_method == "divi_post_module") || (searchForm.object.display_result_method == "post_type_archive") ){
|
||||
var $grids = $( searchForm.targetSelector + ' .et_pb_salvattore_content' );
|
||||
if( $grids.length > 0 ){
|
||||
salvattore['register_grid']($grids.get(0));
|
||||
salvattore['recreate_columns']($grids.get(0));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,572 @@
|
||||
<?php
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
/**
|
||||
* Allows plugins to use their own update API.
|
||||
*
|
||||
* @author Easy Digital Downloads
|
||||
* @version 1.6.18
|
||||
*/
|
||||
class Search_Filter_Divi_Plugin_Updater {
|
||||
|
||||
private $api_url = '';
|
||||
private $api_data = array();
|
||||
private $name = '';
|
||||
private $slug = '';
|
||||
private $version = '';
|
||||
private $wp_override = false;
|
||||
private $cache_key = '';
|
||||
|
||||
private $health_check_timeout = 5;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @uses plugin_basename()
|
||||
* @uses hook()
|
||||
*
|
||||
* @param string $_api_url The URL pointing to the custom API endpoint.
|
||||
* @param string $_plugin_file Path to the plugin file.
|
||||
* @param array $_api_data Optional data to send with API calls.
|
||||
*/
|
||||
public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
|
||||
|
||||
global $edd_plugin_data;
|
||||
|
||||
$this->api_url = trailingslashit( $_api_url );
|
||||
$this->api_data = $_api_data;
|
||||
$this->name = plugin_basename( $_plugin_file );
|
||||
$this->slug = basename( $_plugin_file, '.php' );
|
||||
$this->version = $_api_data['version'];
|
||||
$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
|
||||
$this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
|
||||
$this->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
|
||||
|
||||
$edd_plugin_data[ $this->slug ] = $this->api_data;
|
||||
|
||||
/**
|
||||
* Fires after the $edd_plugin_data is setup.
|
||||
*
|
||||
* @since x.x.x
|
||||
*
|
||||
* @param array $edd_plugin_data Array of EDD SL plugin data.
|
||||
*/
|
||||
do_action( 'post_edd_sl_plugin_updater_setup', $edd_plugin_data );
|
||||
|
||||
// Set up hooks.
|
||||
$this->init();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up WordPress filters to hook into WP's update process.
|
||||
*
|
||||
* @uses add_filter()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
|
||||
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
||||
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
|
||||
remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
|
||||
add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
|
||||
add_action( 'admin_init', array( $this, 'show_changelog' ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for Updates at the defined API endpoint and modify the update array.
|
||||
*
|
||||
* This function dives into the update API just when WordPress creates its update array,
|
||||
* then adds a custom API call and injects the custom plugin data retrieved from the API.
|
||||
* It is reassembled from parts of the native WordPress plugin update code.
|
||||
* See wp-includes/update.php line 121 for the original wp_update_plugins() function.
|
||||
*
|
||||
* @uses api_request()
|
||||
*
|
||||
* @param array $_transient_data Update array build by WordPress.
|
||||
* @return array Modified update array with custom plugin data.
|
||||
*/
|
||||
public function check_update( $_transient_data ) {
|
||||
|
||||
global $pagenow;
|
||||
|
||||
if ( ! is_object( $_transient_data ) ) {
|
||||
$_transient_data = new stdClass;
|
||||
}
|
||||
|
||||
if ( 'plugins.php' == $pagenow && is_multisite() ) {
|
||||
return $_transient_data;
|
||||
}
|
||||
|
||||
if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
|
||||
return $_transient_data;
|
||||
}
|
||||
|
||||
$version_info = $this->get_cached_version_info();
|
||||
|
||||
if ( false === $version_info ) {
|
||||
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
|
||||
|
||||
$this->set_version_info_cache( $version_info );
|
||||
|
||||
}
|
||||
|
||||
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
|
||||
|
||||
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
||||
|
||||
$_transient_data->response[ $this->name ] = $version_info;
|
||||
|
||||
// Make sure the plugin property is set to the plugin's name/location. See issue 1463 on Software Licensing's GitHub repo.
|
||||
$_transient_data->response[ $this->name ]->plugin = $this->name;
|
||||
|
||||
}
|
||||
|
||||
$_transient_data->last_checked = time();
|
||||
$_transient_data->checked[ $this->name ] = $this->version;
|
||||
|
||||
}
|
||||
|
||||
return $_transient_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
|
||||
*
|
||||
* @param string $file
|
||||
* @param array $plugin
|
||||
*/
|
||||
public function show_update_notification( $file, $plugin ) {
|
||||
|
||||
if ( is_network_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! current_user_can( 'update_plugins' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! is_multisite() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $this->name != $file ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove our filter on the site transient
|
||||
remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
|
||||
|
||||
$update_cache = get_site_transient( 'update_plugins' );
|
||||
|
||||
$update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
|
||||
|
||||
if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
|
||||
|
||||
$version_info = $this->get_cached_version_info();
|
||||
|
||||
if ( false === $version_info ) {
|
||||
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
|
||||
|
||||
// Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
|
||||
if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
|
||||
$version_info->banners = $this->convert_object_to_array( $version_info->banners );
|
||||
}
|
||||
|
||||
if ( isset( $version_info->sections ) && ! is_array( $version_info->sections ) ) {
|
||||
$version_info->sections = $this->convert_object_to_array( $version_info->sections );
|
||||
}
|
||||
|
||||
if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) {
|
||||
$version_info->icons = $this->convert_object_to_array( $version_info->icons );
|
||||
}
|
||||
|
||||
$this->set_version_info_cache( $version_info );
|
||||
}
|
||||
|
||||
if ( ! is_object( $version_info ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
||||
|
||||
$update_cache->response[ $this->name ] = $version_info;
|
||||
|
||||
}
|
||||
|
||||
$update_cache->last_checked = time();
|
||||
$update_cache->checked[ $this->name ] = $this->version;
|
||||
|
||||
set_site_transient( 'update_plugins', $update_cache );
|
||||
|
||||
} else {
|
||||
|
||||
$version_info = $update_cache->response[ $this->name ];
|
||||
|
||||
}
|
||||
|
||||
// Restore our filter
|
||||
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
||||
|
||||
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
||||
|
||||
// build a plugin list row, with update notification
|
||||
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
|
||||
# <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
|
||||
echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
|
||||
echo '<td colspan="3" class="plugin-update colspanchange">';
|
||||
echo '<div class="update-message notice inline notice-warning notice-alt">';
|
||||
|
||||
$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
|
||||
|
||||
if ( empty( $version_info->download_link ) ) {
|
||||
printf(
|
||||
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
|
||||
esc_html( $version_info->name ),
|
||||
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
|
||||
esc_html( $version_info->new_version ),
|
||||
'</a>'
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
|
||||
esc_html( $version_info->name ),
|
||||
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
|
||||
esc_html( $version_info->new_version ),
|
||||
'</a>',
|
||||
'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
|
||||
'</a>'
|
||||
);
|
||||
}
|
||||
|
||||
do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
|
||||
|
||||
echo '</div></td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates information on the "View version x.x details" page with custom data.
|
||||
*
|
||||
* @uses api_request()
|
||||
*
|
||||
* @param mixed $_data
|
||||
* @param string $_action
|
||||
* @param object $_args
|
||||
* @return object $_data
|
||||
*/
|
||||
public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
|
||||
|
||||
if ( $_action != 'plugin_information' ) {
|
||||
|
||||
return $_data;
|
||||
|
||||
}
|
||||
|
||||
if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
|
||||
|
||||
return $_data;
|
||||
|
||||
}
|
||||
|
||||
$to_send = array(
|
||||
'slug' => $this->slug,
|
||||
'is_ssl' => is_ssl(),
|
||||
'fields' => array(
|
||||
'banners' => array(),
|
||||
'reviews' => false,
|
||||
'icons' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
|
||||
|
||||
// Get the transient where we store the api request for this plugin for 24 hours
|
||||
$edd_api_request_transient = $this->get_cached_version_info( $cache_key );
|
||||
|
||||
//If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
|
||||
if ( empty( $edd_api_request_transient ) ) {
|
||||
|
||||
$api_response = $this->api_request( 'plugin_information', $to_send );
|
||||
|
||||
// Expires in 3 hours
|
||||
$this->set_version_info_cache( $api_response, $cache_key );
|
||||
|
||||
if ( false !== $api_response ) {
|
||||
$_data = $api_response;
|
||||
}
|
||||
|
||||
} else {
|
||||
$_data = $edd_api_request_transient;
|
||||
}
|
||||
|
||||
// Convert sections into an associative array, since we're getting an object, but Core expects an array.
|
||||
if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
|
||||
$_data->sections = $this->convert_object_to_array( $_data->sections );
|
||||
}
|
||||
|
||||
// Convert banners into an associative array, since we're getting an object, but Core expects an array.
|
||||
if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
|
||||
$_data->banners = $this->convert_object_to_array( $_data->banners );
|
||||
}
|
||||
|
||||
// Convert icons into an associative array, since we're getting an object, but Core expects an array.
|
||||
if ( isset( $_data->icons ) && ! is_array( $_data->icons ) ) {
|
||||
$_data->icons = $this->convert_object_to_array( $_data->icons );
|
||||
}
|
||||
|
||||
if( ! isset( $_data->plugin ) ) {
|
||||
$_data->plugin = $this->name;
|
||||
}
|
||||
|
||||
return $_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert some objects to arrays when injecting data into the update API
|
||||
*
|
||||
* Some data like sections, banners, and icons are expected to be an associative array, however due to the JSON
|
||||
* decoding, they are objects. This method allows us to pass in the object and return an associative array.
|
||||
*
|
||||
* @since 3.6.5
|
||||
*
|
||||
* @param stdClass $data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function convert_object_to_array( $data ) {
|
||||
$new_data = array();
|
||||
foreach ( $data as $key => $value ) {
|
||||
$new_data[ $key ] = $value;
|
||||
}
|
||||
|
||||
return $new_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable SSL verification in order to prevent download update failures
|
||||
*
|
||||
* @param array $args
|
||||
* @param string $url
|
||||
* @return object $array
|
||||
*/
|
||||
public function http_request_args( $args, $url ) {
|
||||
|
||||
$verify_ssl = $this->verify_ssl();
|
||||
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
|
||||
$args['sslverify'] = $verify_ssl;
|
||||
}
|
||||
return $args;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the API and, if successfull, returns the object delivered by the API.
|
||||
*
|
||||
* @uses get_bloginfo()
|
||||
* @uses wp_remote_post()
|
||||
* @uses is_wp_error()
|
||||
*
|
||||
* @param string $_action The requested action.
|
||||
* @param array $_data Parameters for the API action.
|
||||
* @return false|object
|
||||
*/
|
||||
private function api_request( $_action, $_data ) {
|
||||
|
||||
global $wp_version, $edd_plugin_url_available;
|
||||
|
||||
$verify_ssl = $this->verify_ssl();
|
||||
|
||||
// Do a quick status check on this domain if we haven't already checked it.
|
||||
$store_hash = md5( $this->api_url );
|
||||
if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
|
||||
$test_url_parts = parse_url( $this->api_url );
|
||||
|
||||
$scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http';
|
||||
$host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : '';
|
||||
$port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : '';
|
||||
|
||||
if ( empty( $host ) ) {
|
||||
$edd_plugin_url_available[ $store_hash ] = false;
|
||||
} else {
|
||||
$test_url = $scheme . '://' . $host . $port;
|
||||
$response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => $verify_ssl ) );
|
||||
$edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( false === $edd_plugin_url_available[ $store_hash ] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = array_merge( $this->api_data, $_data );
|
||||
|
||||
if ( $data['slug'] != $this->slug ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( $this->api_url == trailingslashit ( home_url() ) ) {
|
||||
return false; // Don't allow a plugin to ping itself
|
||||
}
|
||||
|
||||
$api_params = array(
|
||||
'edd_action' => 'get_version',
|
||||
'license' => ! empty( $data['license'] ) ? $data['license'] : '',
|
||||
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
||||
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
||||
'version' => isset( $data['version'] ) ? $data['version'] : false,
|
||||
'slug' => $data['slug'],
|
||||
'author' => $data['author'],
|
||||
'url' => home_url(),
|
||||
'beta' => ! empty( $data['beta'] ),
|
||||
);
|
||||
|
||||
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
|
||||
|
||||
if ( ! is_wp_error( $request ) ) {
|
||||
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
||||
}
|
||||
|
||||
if ( $request && isset( $request->sections ) ) {
|
||||
$request->sections = maybe_unserialize( $request->sections );
|
||||
} else {
|
||||
$request = false;
|
||||
}
|
||||
|
||||
if ( $request && isset( $request->banners ) ) {
|
||||
$request->banners = maybe_unserialize( $request->banners );
|
||||
}
|
||||
|
||||
if ( $request && isset( $request->icons ) ) {
|
||||
$request->icons = maybe_unserialize( $request->icons );
|
||||
}
|
||||
|
||||
if( ! empty( $request->sections ) ) {
|
||||
foreach( $request->sections as $key => $section ) {
|
||||
$request->$key = (array) $section;
|
||||
}
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
public function show_changelog() {
|
||||
|
||||
global $edd_plugin_data;
|
||||
|
||||
if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( empty( $_REQUEST['plugin'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( empty( $_REQUEST['slug'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! current_user_can( 'update_plugins' ) ) {
|
||||
wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
||||
}
|
||||
|
||||
$data = $edd_plugin_data[ $_REQUEST['slug'] ];
|
||||
$beta = ! empty( $data['beta'] ) ? true : false;
|
||||
$cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
|
||||
$version_info = $this->get_cached_version_info( $cache_key );
|
||||
|
||||
if( false === $version_info ) {
|
||||
|
||||
$api_params = array(
|
||||
'edd_action' => 'get_version',
|
||||
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
||||
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
||||
'slug' => $_REQUEST['slug'],
|
||||
'author' => $data['author'],
|
||||
'url' => home_url(),
|
||||
'beta' => ! empty( $data['beta'] )
|
||||
);
|
||||
|
||||
$verify_ssl = $this->verify_ssl();
|
||||
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
|
||||
|
||||
if ( ! is_wp_error( $request ) ) {
|
||||
$version_info = json_decode( wp_remote_retrieve_body( $request ) );
|
||||
}
|
||||
|
||||
|
||||
if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
|
||||
$version_info->sections = maybe_unserialize( $version_info->sections );
|
||||
} else {
|
||||
$version_info = false;
|
||||
}
|
||||
|
||||
if( ! empty( $version_info ) ) {
|
||||
foreach( $version_info->sections as $key => $section ) {
|
||||
$version_info->$key = (array) $section;
|
||||
}
|
||||
}
|
||||
|
||||
$this->set_version_info_cache( $version_info, $cache_key );
|
||||
|
||||
}
|
||||
|
||||
if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
|
||||
echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public function get_cached_version_info( $cache_key = '' ) {
|
||||
|
||||
if( empty( $cache_key ) ) {
|
||||
$cache_key = $this->cache_key;
|
||||
}
|
||||
|
||||
$cache = get_option( $cache_key );
|
||||
|
||||
if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
|
||||
return false; // Cache is expired
|
||||
}
|
||||
|
||||
// We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
|
||||
$cache['value'] = json_decode( $cache['value'] );
|
||||
if ( ! empty( $cache['value']->icons ) ) {
|
||||
$cache['value']->icons = (array) $cache['value']->icons;
|
||||
}
|
||||
|
||||
return $cache['value'];
|
||||
|
||||
}
|
||||
|
||||
public function set_version_info_cache( $value = '', $cache_key = '' ) {
|
||||
|
||||
if( empty( $cache_key ) ) {
|
||||
$cache_key = $this->cache_key;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'timeout' => strtotime( '+3 hours', time() ),
|
||||
'value' => json_encode( $value )
|
||||
);
|
||||
|
||||
update_option( $cache_key, $data, 'no' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the SSL of the store should be verified.
|
||||
*
|
||||
* @since 1.6.13
|
||||
* @return bool
|
||||
*/
|
||||
private function verify_ssl() {
|
||||
return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
|
||||
}
|
||||
|
||||
}
|
||||
118
wp/plugins/search-filter-divi/search-filter-divi.php
Normal file
118
wp/plugins/search-filter-divi/search-filter-divi.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Search & Filter Pro - Divi Extension
|
||||
* Plugin URI: https://searchandfilter.com
|
||||
* Description: A bridge Plugin enabling easy integration of the Divi Blog, Portfolio and Shop modules with Search & Filter Pro
|
||||
* Version: 1.0.7
|
||||
* Author: Code Amp
|
||||
* Author URI: https://www.codeamp.com
|
||||
* Text Domain: search-filter-divi
|
||||
* License: GPL-2.0+
|
||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Domain Path: /languages
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* Public-Facing Functionality
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
add_action( 'plugins_loaded', array( 'Search_Filter_Divi', 'get_instance' ) );
|
||||
|
||||
|
||||
if ( ! defined( 'SEARCH_FILTER_DIVI_PATH' ) ) {
|
||||
define('SEARCH_FILTER_DIVI_PATH', plugin_dir_path(__FILE__));
|
||||
}
|
||||
if ( ! defined( 'SEARCH_FILTER_DIVI_URL' ) ) {
|
||||
define('SEARCH_FILTER_DIVI_URL', plugin_dir_url(__FILE__));
|
||||
}
|
||||
|
||||
Class Search_Filter_Divi {
|
||||
|
||||
const VERSION = '1.0.7';
|
||||
|
||||
const PLUGIN_UPDATE_URL = 'https://searchandfilter.com';
|
||||
const PLUGIN_UPDATE_ID = 197854;
|
||||
|
||||
protected static $instance = null;
|
||||
|
||||
public static function get_instance() {
|
||||
|
||||
// If the single instance hasn't been set, set it now.
|
||||
if ( null == self::$instance ) {
|
||||
self::$instance = new self;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
|
||||
private function __construct() {
|
||||
|
||||
// Init Divi extenion
|
||||
add_action( 'divi_extensions_init', array($this, 'initialise_divi_extension' ) );
|
||||
|
||||
// Scripts
|
||||
add_action('wp_enqueue_scripts', array($this, "enqueue_scripts"), 10);
|
||||
|
||||
// Plugin Updater
|
||||
add_action( 'admin_init', array($this, 'update_plugin_handler'), 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Scripts
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function enqueue_scripts(){
|
||||
|
||||
wp_register_script( 'search-filter-divi', plugins_url( 'scripts/search-filter-divi.js', __FILE__ ), array( 'jquery' ), "1.0.0" );
|
||||
wp_localize_script( 'search-filter-divi', 'SFE_DATA', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'home_url' => (home_url('/')) ));
|
||||
wp_enqueue_script( 'search-filter-divi' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Init Divi Extension
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function initialise_divi_extension() {
|
||||
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/search-filter-divi-extension.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle plugin updates
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function update_plugin_handler() {
|
||||
|
||||
// setup the updater
|
||||
$edd_updater = new Search_Filter_Divi_Plugin_Updater( self::PLUGIN_UPDATE_URL, __FILE__,
|
||||
array(
|
||||
'version' => self::VERSION,
|
||||
'license' => 'search-filter-extension-free',
|
||||
'item_id' => self::PLUGIN_UPDATE_ID, // ID of the product
|
||||
'author' => 'Search & Filter', // author of this plugin
|
||||
'beta' => false,
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( !class_exists( 'Search_Filter_Divi_Plugin_Updater' ) ) {
|
||||
// load our custom updater
|
||||
include( dirname( __FILE__ ) . '/search-filter-divi-plugin-updater.php' );
|
||||
}
|
||||
|
||||
if( !class_exists( 'Search_Filter_Divi_Query' ) ) {
|
||||
include( dirname( __FILE__ ) . '/includes/search-filter-divi-query.php' );
|
||||
}
|
||||
0
wp/plugins/search-filter-divi/styles/style-dbp.min.css
vendored
Normal file
0
wp/plugins/search-filter-divi/styles/style-dbp.min.css
vendored
Normal file
0
wp/plugins/search-filter-divi/styles/style.min.css
vendored
Normal file
0
wp/plugins/search-filter-divi/styles/style.min.css
vendored
Normal file
Reference in New Issue
Block a user