PluginProbe
WP Directory Kit / 1.5.4
WP Directory Kit v1.5.4
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / actions.php

actions.php in WP Directory Kit 1.5.4, at actions.php

135 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly.
5 }
6
7 require_once WPDIRECTORYKIT_PATH . 'extensions/wdk-dependfields.php';
8 new \Wdk\Extensions\WdkDependfields();
9
10
11 if(file_exists(WPDIRECTORYKIT_PATH . 'extensions/wdk-cached-users.php')) {
12 require_once WPDIRECTORYKIT_PATH . 'extensions/wdk-cached-users.php';
13 new \Wdk\Extensions\WdkCachedUsers();
14 }
15
16 if(file_exists(WPDIRECTORYKIT_PATH . 'extensions/wdk-cached-user-editor.php')) {
17 require_once WPDIRECTORYKIT_PATH . 'extensions/wdk-cached-user-editor.php';
18 new \Wdk\Extensions\WdkCachedUserEditor();
19 }
20
21 if(file_exists(WPDIRECTORYKIT_PATH . 'extensions/wdk-autosuggestion-fields.php')) {
22 require_once WPDIRECTORYKIT_PATH . 'extensions/wdk-autosuggestion-fields.php';
23 new \Wdk\Extensions\WdkAutosuggestionFields();
24 }
25
26 /* remove wdk data on remove user */
27 add_action('delete_user', function($user_id ){
28 if(!empty($user_id)) {
29 global $Winter_MVC_WDK;
30 $Winter_MVC_WDK->model('user_m');
31 $Winter_MVC_WDK->user_m->remove_user_data(intval($user_id));
32 }
33 });
34
35 /* home, results page, dash/login, menu for hamburger */
36 add_action('wp_footer', function(){
37 if(wdk_get_option('wdk_mobile_bottom_navbar_enable')) {
38 wp_enqueue_style( 'dashicons' );
39 ?>
40 <div class="wdk_mobile_footer_menu">
41 <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr__('Home','wpdirectorykit' ); ?>"><span class="dashicons dashicons-admin-home"></span></a>
42 <?php if(wdk_get_option('wdk_results_page')):?>
43 <a href="<?php echo esc_url(get_permalink(wdk_get_option('wdk_results_page'))); ?>" title="<?php echo esc_attr__('Search','wpdirectorykit' ); ?>"><span class="dashicons dashicons-search"></span></a>
44 <?php endif;?>
45 <?php if (!is_user_logged_in()): ?>
46 <a href="<?php echo (get_option('wdk_membership_login_page')) ? esc_url(get_permalink(wdk_get_option('wdk_membership_login_page'))) : esc_url(wp_login_url());?>" class="sign_in sign-btn"><i class="fas fa-user" aria-hidden="true"></i></a>
47 <?php else:?>
48 <?php
49 $dash_url = get_admin_url() . "admin.php?page=wdk";
50 if(function_exists('wdk_dash_url') && get_option('wdk_membership_dash_page') && wdk_dash_url()){
51 $dash_url = wdk_dash_url();
52 }
53 ?>
54 <a href="<?php echo esc_url($dash_url);?>" class="sign_in dash-btn" title="<?php echo esc_attr__('Dash','wpdirectorykit' ); ?>" class="wdk-element-button logout">
55 <i aria-hidden="true" class="fas fa-tachometer-alt"></i>
56 </a>
57 <a href="<?php echo esc_url(wp_logout_url( get_permalink() )); ?>" class="sign_in sign-btn" title="<?php echo esc_attr__('Log Out','wpdirectorykit' ); ?>"><i class="fas fa-user-times" aria-hidden="true"></i></a>
58 <?php endif;?>
59
60
61 <?php if(!wdk_get_option('wdk_mobile_bottom_show_menu_disable')):?>
62 <div class="wdk-footer-menu">
63 <?php
64 $menus = wp_get_nav_menus();
65
66 $available_menus = [];
67 foreach ($menus as $menu) {
68 $available_menus[$menu->slug] = $menu->name;
69 }
70
71 ?>
72
73 <input id="wdk_mobile_footer_menu_gumb" type="checkbox" class="wdk_mobile_footer_menu_gumb">
74
75 <?php if(!empty($available_menus)):?>
76 <label for="wdk_mobile_footer_menu_gumb" class="wdk_mobile_footer_menu_gumb-open">
77 <span class="dashicons dashicons-menu"></span>
78 </label>
79 <?php endif;?>
80
81 <div class="menu__box">
82 <?php echo wp_nav_menu( array(
83 'menu' => array_keys($available_menus)[0],
84 'menu_class' => 'wl-nav-menu wl-nav-menu',
85 'menu_id' => 'menu-' . array_keys($available_menus)[0] . '-wdk-bottom-menu',
86 'fallback_cb' => '__return_empty_string',
87 ));?>
88 </div>
89 </div>
90 <?php endif;?>
91 </div>
92 <?php
93 }
94 });
95
96 add_filter( 'intermediate_image_sizes_advanced', function( $sizes ){
97 if(get_option('wdk_install_images_sizes_disable') == 1) {
98 return array();
99 }
100 return $sizes;
101 } );
102
103 /* update edit log */
104 add_action('wdk-membership/listing/saved', function($post_id = NULL, $old_listing_date = NULL){
105 global $Winter_MVC_WDK;
106 $Winter_MVC_WDK->model('editlog_m');
107 $Winter_MVC_WDK->editlog_m->insert(array(
108 'user_id' => get_current_user_id(),
109 'post_id' => $post_id,
110 'date' => date('Y-m-d H:i:s'),
111 'ip' => $_SERVER['REMOTE_ADDR']
112 ));
113 });
114
115
116 add_filter('posts_clauses', function($clauses, $query) {
117 global $wpdb;
118
119 if (
120 !defined('REST_REQUEST') || !REST_REQUEST ||
121 empty($query->query_vars['post_type']) ||
122 $query->query_vars['post_type'] !== 'wdk-listing'
123 ) {
124 return $clauses;
125 }
126
127 // Join your custom table `wdk_listings`
128 $clauses['join'] .= " INNER JOIN {$wpdb->prefix}wdk_listings AS wdk_tbl ON {$wpdb->posts}.ID = wdk_tbl.post_id";
129
130 // Add condition for activation
131 $clauses['where'] .= " AND wdk_tbl.is_activated = 1";
132
133 return $clauses;
134 }, 10, 2);
135 ?>