Sindbad~EG File Manager
<?php
namespace RealPress;
use Thim_EL_Kit\SingletonTrait;
use Thim_EL_Kit\Custom_Post_Type;
use RealPress\Modules\SingleProperty\Init as SingleProperty;
use RealPress\Modules\ArchiveProperty\Init as ArchiveProperty;
class Elementor {
use SingletonTrait;
const CATEGORY_ARCHIVE_PROPERTY = 'thim_ekit_archive_property';
const CATEGORY_SINGLE_PROPERTY = 'thim_ekit_single_property';
const CATEGORY_RECOMMENDED = 'thim_ekit_recommended';
const WIDGETS = array(
'archive-property' => array(
'property-archive',
),
'single-property' => array(
'property-map',
'property-content',
'property-feature',
'property-nearby',
'property-walkscore',
'property-floor-plan',
'property-review-comment',
'property-thumb',
'property-video',
'property-contact-agent',
'property-schedule',
'property-mortgage',
'property-similar'
),
'loop-item' => array(
'property-verified',
'property-location',
'property-price',
'property-status',
'property-review-rating',
'property-wishlist',
'property-compare',
'property-detail'
),
);
public function __construct() {
$this->includes();
add_filter( 'thim_ekit/elementor/widgets/list', array( $this, 'add_widgets' ), 20 );
add_filter( 'thim_ekit/elementor/widget/file_path', array( $this, 'change_widget_path' ), 10, 2 );
add_filter( 'thim_ekit_elementor_category', array( $this, 'add_categories' ) );
add_filter( 'thim_ekit/elementor/documents/preview_item', array( $this, 'change_documents_preview_item' ), 10, 2 );
add_filter(
'thim_ekit/admin/enqueue/localize',
function( $localize ) {
$localize['loop_item']['post_type'][] = array(
'label' => 'Properties',
'value' => REALPRESS_PROPERTY_CPT,
);
return $localize;
},10,1
);
}
public function includes() {
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
require_once REALPRESS_DIR . 'app/Elementor/modules/archive-property/class-init.php';
require_once REALPRESS_DIR . 'app/Elementor/modules/single-property/class-init.php';
require_once REALPRESS_DIR . 'app/Elementor/modules/archive-property/class-rest-api.php';
require_once REALPRESS_DIR . 'app/Elementor/modules/group-control-global-el.php';
}
public function add_widgets( $widget_default ) {
$widgets = self::WIDGETS;
global $post;
// Only register archive-post, post-title in Elementor Editor only template.
if ( $post && \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
$type = get_post_meta( $post->ID, Custom_Post_Type::TYPE, true );
if ( $type !== 'archive-property' ) {
unset( $widgets['archive-property'] );
}
if ( $type !== 'single-property' ) {
unset( $widgets['single-property'] );
}
}
$widgets = array_merge_recursive( $widget_default, $widgets );
return $widgets;
}
public function change_documents_preview_item( $preview, $type ) {
if ( $type == SingleProperty::instance()->tab ) {
$preview = REALPRESS_PROPERTY_CPT;
}
if ( get_the_ID() && $type === 'loop_item' ) {
$preview = get_post_meta( get_the_ID(), 'thim_loop_item_post_type', true );
}
return $preview;
}
public function change_widget_path( $path, $widget ) {
foreach ( self::WIDGETS as $key => $widgets ) {
if ( in_array( $widget, $widgets ) ) {
$path = REALPRESS_DIR . 'app/Elementor/widgets/' . $key . '/' . $widget . '.php';
}
}
return $path;
}
public function add_categories( $categories ) {
return array(
self::CATEGORY_ARCHIVE_PROPERTY => array(
'title' => esc_html__( 'Thim Archive Property', 'realpress' ),
'icon' => 'fa fa-plug',
),
self::CATEGORY_SINGLE_PROPERTY => array(
'title' => esc_html__( 'Thim Single Property', 'realpress' ),
'icon' => 'fa fa-plug',
),
) + $categories;
}
}
Elementor::instance();
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists