PluginProbe
User Private Files – WordPress File Sharing Plugin / 2.1.1
User Private Files – WordPress File Sharing Plugin v2.1.1
2.1.8 2.1.7 trunk 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 All 33 releases
user-private-files / user-private-files.php

user-private-files.php in User Private Files – WordPress File Sharing Plugin 2.1.1, at user-private-files.php

238 lines 7.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: User Private Files
4 * Description: This plugin allows users to manage their uploaded files and access to them.
5 * Version: 2.1.1
6 * Author: User Private Files
7 * Author URI: https://userprivatefiles.com/
8 * License: GPLv2 or later
9 * Text Domain: user-private-files
10 * Domain Path: /languages
11 */
12
13 // Exit if accessed directly
14 if ( ! defined('ABSPATH') ) {
15 exit;
16 }
17
18 include_once dirname( __FILE__ ) . '/upvf_actdeact.php';
19 register_activation_hook( __FILE__, array( 'Upvf_Actdeact', 'upvf_plugin_activate' ) );
20 register_deactivation_hook( __FILE__, array( 'Upvf_Actdeact', 'upvf_plugin_deactivate') );
21
22 add_action( 'admin_init', 'upvf_admin_init_plugin', 1 );
23 if (!function_exists('upvf_admin_init_plugin')) {
24 function upvf_admin_init_plugin(){
25 // check if htaccess is writable
26 $htaccess = ABSPATH.".htaccess";
27 if ( ! is_writeable( $htaccess ) ) {
28 add_action( 'admin_notices', function(){
29 $upload_dir = wp_upload_dir();
30 $manual_htcode = "RewriteRule ^".basename(content_url()) . "/" . wp_basename( $upload_dir['baseurl'] )."/upf-docs/(.*)$ ".home_url()."?file=$1 [QSA,L]";
31 echo '<div class="notice notice-warning is-dismissible">
32 <p>Your htaccess file is not writable. Please change permission and reactivate the plugin OR edit the htaccess file manually and enter this code at the bottom. Please ignore if already added!</p>
33 <p><code>'.$manual_htcode.'</code></p>
34 </div>';
35 } );
36 add_action('admin_head', function(){ ?>
37 <script>
38 let hta_access = 0;
39 jQuery(document).ready(function(){
40 jQuery('#deactivate-user-private-files').on('click', function(){
41 alert('Your htaccess file is not writable. Please check and remove the code from htaccess (if manually added)');
42 });
43 })
44 </script>
45 <?php });
46 }
47 // check if plugin created uploads folder or not
48 $upload_dir = wp_upload_dir();
49 $upf_dir_path = $upload_dir['basedir'] . "/upf-docs";
50 $created_dir = wp_mkdir_p($upf_dir_path);
51 if(!$created_dir){
52 add_action('admin_head', function(){
53 echo '<div class="notice notice-warning is-dismissible"><p>Plugin was unable to create directory in uploads. Please create a "upf-docs" directory/folder under your uploads directory</p></div>';
54 });
55 }
56 }
57 }
58
59 add_action( 'init', 'upvf_init_plugin', 1 );
60 if (!function_exists('upvf_init_plugin')) {
61 function upvf_init_plugin(){
62 define ( 'UPVF_PLUGIN_DIR', plugin_dir_path(__FILE__ ) );
63 global $upf_plugin_url;
64 $upf_plugin_url = plugin_dir_url( __FILE__ );
65 add_action( 'wp_enqueue_scripts', 'upf_styles_scripts' );
66 add_action( 'admin_enqueue_scripts', 'upfp_admin_script' );
67
68 // Including other functions
69 include(plugin_dir_path(__FILE__ ) . 'inc/classic-post-new.php');
70 include(plugin_dir_path(__FILE__ ) . 'inc/classic-render.php');
71 include(plugin_dir_path(__FILE__ ) . 'inc/classic-user-functions.php');
72
73 // PRO Design
74 include(plugin_dir_path(__FILE__ ) . 'admin/settings.php');
75 include(plugin_dir_path(__FILE__ ) . 'inc/class-upf-template-loader.php');
76 global $upvf_template_loader;
77 $upvf_template_loader = new UPF_Template_Loader();
78 include(plugin_dir_path(__FILE__ ) . 'inc/shortcodes.php');
79 include(plugin_dir_path(__FILE__ ) . 'inc/functions-file.php');
80 include(plugin_dir_path(__FILE__ ) . 'inc/functions-folder.php');
81 include(plugin_dir_path(__FILE__ ) . 'filters.php');
82 include(plugin_dir_path(__FILE__ ) . 'actions.php');
83
84 load_plugin_textdomain( 'user-private-files', false, 'user-private-files' );
85 }
86 }
87
88 // Include file permission functions
89 add_filter( 'template_include', 'upvf_check_perm' );
90 if (!function_exists('upvf_check_perm')) {
91 function upvf_check_perm( $original_template ) {
92 if(isset($_GET[ 'file' ])){
93 $template = dirname( __FILE__ ) . '/dl-file.php';
94 if ( file_exists( $template ) ) {
95 include $template;
96 }
97 return $template;
98 } else {
99 return $original_template;
100 }
101 }
102 }
103
104 // Back-end assets
105 if (!function_exists('upfp_admin_script')) {
106 function upfp_admin_script(){
107 wp_enqueue_style(
108 'upf-admin-style',
109 plugin_dir_url( __FILE__ ) . 'css/admin/admin_free.css'
110 );
111 wp_enqueue_script(
112 'upf-admin-script',
113 plugins_url('js/admin/admin-upf_free.js',__FILE__ ),
114 array('jquery')
115 );
116 wp_enqueue_style(
117 'upf-multiple_choose-style',
118 "https://cdn.rawgit.com/harvesthq/chosen/gh-pages/chosen.min.css"
119 );
120 wp_enqueue_script(
121 'upf-multiple_choose-script2',
122 "https://cdn.rawgit.com/harvesthq/chosen/gh-pages/chosen.jquery.min.js",
123 array('jquery')
124 );
125 }
126 }
127
128 if (!function_exists('upf_styles_scripts')) {
129 function upf_styles_scripts(){
130
131 wp_register_style(
132 'upf-classic-style',
133 plugin_dir_url( __FILE__ ) . 'css/classic-style.css'
134 );
135 wp_register_script(
136 'upf-classic-script',
137 plugins_url('js/classic-main.js',__FILE__ ),
138 array('jquery')
139 );
140 wp_localize_script(
141 'upf-classic-script',
142 'ajax_upf_classic_obj',
143 array(
144 'ajaxurl' => admin_url( 'admin-ajax.php' ),
145 'upvf_plugin_url' => plugin_dir_url( __FILE__ ),
146 'nonce' => wp_create_nonce('upf_classic_ajax_nonce')
147 )
148 );
149
150 wp_register_style(
151 'upf-style',
152 plugin_dir_url( __FILE__ ) . 'css/style.css'
153 );
154
155 // FA local since kit is limited to views per month
156 wp_register_style(
157 'upf-font-awesome',
158 plugin_dir_url(__FILE__) . 'css/fa.min.css'
159 );
160
161 wp_register_style(
162 'upf-google-font',
163 'https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,300;1,400;1,500;1,600;1,700;1,800&display=swap',
164 array(),
165 'null'
166 );
167
168 wp_register_script(
169 'upf-waitforimages-script',
170 plugins_url('js/waitforimages.min.js',__FILE__ ),
171 array('jquery')
172 );
173 wp_register_script(
174 'upf-script',
175 plugins_url('js/file.js',__FILE__ ),
176 array('jquery')
177 );
178 wp_register_script(
179 'upvf-frnt-script',
180 plugins_url('js/folder.js',__FILE__ ),
181 array('jquery')
182 );
183 wp_register_script(
184 'upvf-bulk-script',
185 plugins_url('js/bulk-action.js',__FILE__ ),
186 array('jquery')
187 );
188
189 wp_localize_script(
190 'upf-script',
191 'ajax_upf_obj',
192 array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),
193 'upvf_plugin_url' => plugin_dir_url( __FILE__ ),
194 'nonce' => wp_create_nonce('upfp_ajax_nonce'),
195 'max_upload_size' => wp_max_upload_size(),
196 'max_err' => __("Uploaded file exceeds the maximum upload size for this site", "user-private-files")
197 )
198 );
199 wp_localize_script(
200 'upvf-frnt-script',
201 'ajax_upvf_frnt_obj',
202 array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),
203 'upvf_plugin_url' => plugin_dir_url( __FILE__ ),
204 'nonce' => wp_create_nonce('upfp_ajax_nonce')
205 )
206 );
207 wp_localize_script(
208 'upvf-bulk-script',
209 'ajax_upvf_bulk_obj',
210 array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),
211 'nonce' => wp_create_nonce('upfp_ajax_nonce')
212 )
213 );
214
215
216
217
218
219 }
220 }
221
222 if(is_admin()){
223 // Plugin Configuration Page
224 add_action( 'plugins_loaded', 'upvf_set_admin_menu' );
225 if (!function_exists('upvf_set_admin_menu')) {
226 function upvf_set_admin_menu(){
227 add_action('admin_menu', 'upvf_admin_config', 999);
228 }
229 }
230
231 if (!function_exists('upvf_admin_config')) {
232 function upvf_admin_config() {
233 add_menu_page('User Private Files', 'User Private Files', 'manage_options', 'upvf-free', 'upvf_config_callback', 'dashicons-superhero');
234 add_submenu_page('upvf-free', 'Settings', 'Settings', 'manage_options', 'upvf-free', 'upvf_config_callback', 1);
235 }
236 }
237 }
238