PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.25
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.25
1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 All 172 releases
userswp / includes / class-uwp-compatibility.php

class-uwp-compatibility.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.25, at includes/class-uwp-compatibility.php

122 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Compatibility functions for third party plugins.
4 *
5 * @since 1.2.2.32
6 * @package userswp
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly
11 }
12
13
14 class UsersWP_Compatibility {
15
16 public function __construct(){
17 if( defined( 'ELEMENTOR_VERSION' ) ){
18 add_action('uwp_bypass_users_list_item_template_content', array($this,'users_list_item_content_elementor'), 10, 3);
19
20 // Elementor 3
21 if ( version_compare( ELEMENTOR_VERSION, '3.0.0', '>=' ) ) {
22 add_filter( 'elementor/elements/categories_registered', array( __CLASS__,'add_elementor_widget_categories' ), 1, 1 );
23 add_filter( 'elementor/editor/localize_settings', array( __CLASS__,'alter_widget_config' ), 5, 1 );
24 }
25 }
26 }
27
28 /**
29 * Allow to filter the archive item template content if being edited by elementor.
30 *
31 * @param $content
32 * @param $original_content
33 * @param $page_id
34 *
35 * @return mixed
36 */
37 public function users_list_item_content_elementor($content, $original_content, $page_id){
38 if ( ! $original_content && $page_id && self::is_elementor( $page_id ) ) {
39 $original_content = $content = \Elementor\Plugin::$instance->frontend->get_builder_content_for_display( $page_id );
40 } else {
41 $original_content = $content;
42 }
43
44 return $original_content;
45 }
46
47 /**
48 * Get the elementor document by page ID.
49 *
50 * @since 1.2.20
51 *
52 * @param int $post_id The current post ID.
53 * @return object Elementor document.
54 */
55 public static function get_elementor_document( $post_id ) {
56 if ( defined( 'ELEMENTOR_VERSION' ) && class_exists( '\Elementor\Plugin' ) ) {
57 $document = \Elementor\Plugin::$instance->documents->get( (int) $post_id );
58 } else {
59 $document = null;
60 }
61
62 return $document;
63 }
64
65 /**
66 * Check if a page is being edited by elementor.
67 *
68 * @return bool
69 */
70 public static function is_elementor( $post_id ) {
71 $document = self::get_elementor_document( $post_id );
72
73 if ( empty( $document ) ) {
74 return false;
75 }
76
77 return $document->is_built_with_elementor();
78 }
79
80 /**
81 * Add our own Category.
82 *
83 * @param $elements_manager
84 */
85 public static function add_elementor_widget_categories( $elements_manager ) {
86
87 $elements_manager->add_category(
88 'userswp',
89 [
90 'title' => esc_html__( 'UsersWP', 'userswp' ),
91 'icon' => 'fa fa-plug',
92 ]
93 );
94
95 }
96
97 /**
98 * Force our widget to show for search and to be in our own category.
99 *
100 * @param $config
101 *
102 * @return mixed
103 */
104 public static function alter_widget_config( $config ){
105
106 if ( ! empty( $config['initial_document']['widgets'] ) ) {
107 foreach( $config['initial_document']['widgets'] as $key => $widget){
108 if(substr( $key, 0, 14 ) === "wp-widget-uwp_"){
109 $config['initial_document']['widgets'][$key]['categories'][] = 'userswp';
110 $config['initial_document']['widgets'][$key]['hide_on_search'] = false;
111 $config['initial_document']['widgets'][$key]['icon'] = 'eicon-user-circle-o'; //@todo if no icons use on page then font-awesome is not loaded, wif we can fifure out how to force load we can use icons. <i class="fas fa-globe-americas"></i><i class="fa-solid fa-earth-americas"></i>
112 }
113 }
114 }
115
116
117
118 return $config;
119 }
120 }
121
122 new UsersWP_Compatibility();