PluginProbe
File Upload For WPForms – Filenzo / trunk
File Upload For WPForms – Filenzo vtrunk
1.1.2 1.1.1 trunk 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0
file-upload-for-wpforms / file-upload-for-wpforms.php

file-upload-for-wpforms.php in File Upload For WPForms – Filenzo trunk, at file-upload-for-wpforms.php

109 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: File Upload For WPForms - Filenzo
4 Description: Adds a file upload field to WPForms.
5 Version: 1.1.1
6 Author: WPDebugLog
7 License: GPL v2 or later
8 License URI: https://www.gnu.org/licenses/gpl-2.0.html
9 Requires at least: 6.6
10 Requires PHP: 7.0
11 Text Domain: file-upload-for-wpforms
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) exit;
15
16 add_action('wpforms_loaded', 'fileupfo_wpform_upload_input', 99);
17 function fileupfo_wpform_upload_input(){
18 require plugin_dir_path( __FILE__ ) . '/upload.php';
19 require plugin_dir_path( __FILE__ ) . '/move-queue.php';
20 }
21
22
23 function fileupfo_wpform_upload_on_activate(){
24 global $wp_filesystem;
25
26 $upload_dir = wp_upload_dir();
27 $dirpath = $upload_dir['basedir'].'/wpxform-uploads';
28 if ( ! file_exists( $dirpath ) ) {
29 wp_mkdir_p( $dirpath );
30 if ( ! function_exists( 'WP_Filesystem' ) ) {
31 require_once ABSPATH . 'wp-admin/includes/file.php';
32 }
33 WP_Filesystem();
34 $wp_filesystem->put_contents( $dirpath.'/index.php', '<?php //Silence is golden.', FS_CHMOD_FILE );
35 }
36 }
37 register_activation_hook( __FILE__, 'fileupfo_wpform_upload_on_activate' );
38
39
40 add_action('admin_notices', 'fileupfo_check_wpforms_installed');
41 function fileupfo_check_wpforms_installed() {
42
43 if( function_exists('wpforms') )
44 return;
45
46 $error_message = sprintf(
47 /* translators: 1. open anchor tag, 2. close */
48 esc_html__( 'File Upload For WPForms requires %1$sWPForms%2$s installed & activated!' , 'file-upload-for-wpforms' ),
49 '<a target="_blank" href="https://wordpress.org/plugins/wpforms-lite/">',
50 '</a>',
51 );
52
53 $message = '<div class="error">';
54 $message .= sprintf( '<p>%s</p>', $error_message );
55 $message .= '</div>';
56
57 echo wp_kses_post( $message );
58 }
59
60
61 add_action( 'admin_notices', 'fileupfo_admin_notice' );
62 add_action('admin_init', 'fileupfo_view_ignore_notice' );
63
64 function fileupfo_admin_notice() {
65
66 $install_date = get_option( 'fileupfo_view_install_date', '');
67
68 if( empty( $install_date ) ){
69 $install_date = date('Y-m-d G:i:s');
70 add_option( 'fileupfo_view_install_date', $install_date );
71 }
72
73 $install_date = date_create( $install_date );
74 $date_now = date_create( date('Y-m-d G:i:s') );
75 $date_diff = date_diff( $install_date, $date_now );
76
77 if ( $date_diff->format("%d") < 7 ) {
78
79 return false;
80 }
81
82 if ( ! get_option( 'fileupfo_view_ignore_notice' ) ) {
83
84 echo '<div class="updated"><p>';
85
86 printf(
87 __( 'Thanks for using <a href="https://wordpress.org/plugins/file-upload-for-wpforms/" target="_blank">File Upload For WPForms</a> for over a week! 🙌 Enjoying it? Please consider a <strong>5-star rating</strong> on WordPress. ⭐ <a href="%2$s" target="_blank">Yes, happy to!</a> | <a href="%1$s">Already did</a> | <a href="%1$s">Not yet</a>',
88 'file-upload-for-wpforms'
89 ),
90 add_query_arg('fileupfo-ignore-notice', 0, admin_url()),
91 'https://wordpress.org/support/plugin/file-upload-for-wpforms/reviews/'
92 );
93 echo "</p></div>";
94 }
95 }
96
97 function fileupfo_view_ignore_notice() {
98
99 if ( isset($_GET['fileupfo-ignore-notice']) && '0' == $_GET['fileupfo-ignore-notice'] ) {
100
101 update_option( 'fileupfo_view_ignore_notice', 'true' );
102 }
103 if ( !empty($_GET['fileupfo-ignore-field-notice'])) {
104
105 update_option( 'fileupfo_view_ignore_field_notice', 'true' );
106 }
107 }
108
109