PluginProbe
CF7 Submissions – Securely Store Contact Form 7 Data and Attachments, Reply to the Sender and more / 0.26
CF7 Submissions – Securely Store Contact Form 7 Data and Attachments, Reply to the Sender and more v0.26
trunk 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.20 0.22 0.23 0.24 0.25 0.26 0.27 0.9
cf7-submissions / cf7-submissions.php

cf7-submissions.php in CF7 Submissions – Securely Store Contact Form 7 Data and Attachments, Reply to the Sender and more 0.26, at cf7-submissions.php

264 lines 6.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: CF7 Submissions
4 * Plugin URI: https://pluggable.io/plugin/cf7-submissions
5 * Description: Securely Store and Manage Contact Form 7 Submissions Hassle-Free
6 * Version: 0.26
7 * Requires at least: 6.0
8 * Requires PHP: 7.4
9 * Author: Codexpert, Inc
10 * Author URI: https://codexpert.io
11 * License: GPLv2 or later
12 * License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
13 * Text Domain: cf7-submissions
14 * Domain Path: /languages
15 */
16
17 /**
18 * CF7 Submissions is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * any later version.
22 *
23 * CF7 Submissions is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 */
28
29 namespace Codexpert\CF7_Submissions;
30
31 use Codexpert\Plugin\Notice;
32 use Pluggable\Marketing\Survey;
33 use Pluggable\Marketing\Feature;
34 use Pluggable\Marketing\Deactivator;
35
36 /**
37 * if accessed directly, exit.
38 */
39 if ( ! defined( 'ABSPATH' ) ) {
40 exit;
41 }
42
43 /**
44 * Main class for the plugin
45 * @package Plugin
46 * @author Codexpert <hi@codexpert.io>
47 */
48 final class Plugin {
49
50 public $plugin;
51
52 /**
53 * Plugin instance
54 *
55 * @access private
56 *
57 * @var Plugin
58 */
59 private static $_instance;
60
61 /**
62 * The constructor method
63 *
64 * @access private
65 *
66 * @since 0.9
67 */
68 private function __construct() {
69
70 /**
71 * Includes required files
72 */
73 $this->include();
74
75 /**
76 * Defines contants
77 */
78 $this->define();
79
80 /**
81 * Runs actual hooks
82 */
83 $this->hook();
84 }
85
86 /**
87 * Includes files
88 *
89 * @access private
90 *
91 * @uses composer
92 * @uses psr-4
93 */
94 private function include() {
95 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
96 require_once( ABSPATH . 'wp-includes/PHPMailer/PHPMailer.php' );
97 require_once( ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php' );
98 require_once( ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php' );
99 require_once( dirname( __FILE__ ) . '/vendor/autoload.php' );
100 }
101
102 /**
103 * Define variables and constants
104 *
105 * @access private
106 *
107 * @uses get_plugin_data
108 * @uses plugin_basename
109 */
110 private function define() {
111
112 /**
113 * Define some constants
114 *
115 * @since 0.9
116 */
117 define( 'CF7S', __FILE__ );
118 define( 'CF7S_DIR', dirname( CF7S ) );
119 define( 'CF7S_ASSET', plugins_url( 'assets', CF7S ) );
120 define( 'CF7S_DEBUG', apply_filters( 'cf7-submissions_debug', true ) );
121
122 /**
123 * The plugin data
124 *
125 * @since 0.9
126 * @var $plugin
127 */
128 $this->plugin = get_plugin_data( CF7S, true, false );
129 $this->plugin['basename'] = plugin_basename( CF7S );
130 $this->plugin['file'] = CF7S;
131 $this->plugin['server'] = apply_filters( 'cf7-submissions_server', 'https://codexpert.io/dashboard' );
132 $this->plugin['min_php'] = '7.4';
133 $this->plugin['min_wp'] = '6.0';
134 $this->plugin['icon'] = CF7S_ASSET . '/img/icon.png';
135 $this->plugin['depends'] = [ 'contact-form-7/wp-contact-form-7.php' => 'Contact Form 7' ];
136
137 $this->plugin['hash_deactivator'] = 'fd149c48-25af-4612-8e6e-06496e983099';
138 $this->plugin['hash_survey'] = '680b0b59-8acf-4c44-a020-ff106ba4c2df';
139 $this->plugin['hash_wizard'] = '193060fe-c1f6-42ed-92f7-2b652bd75b0c';
140 }
141
142 /**
143 * Hooks
144 *
145 * @access private
146 *
147 * Executes main plugin features
148 *
149 * To add an action, use $instance->action()
150 * To apply a filter, use $instance->filter()
151 * To register a shortcode, use $instance->register()
152 * To add a hook for logged in users, use $instance->priv()
153 * To add a hook for non-logged in users, use $instance->nopriv()
154 *
155 * @return void
156 */
157 private function hook() {
158
159 if( is_admin() ) :
160
161 /**
162 * Admin facing hooks
163 */
164 $admin = new App\Admin( $this->plugin );
165 $admin->action( 'admin_footer', 'modal' );
166 $admin->action( 'init', 'i18n' );
167 $admin->action( 'admin_enqueue_scripts', 'enqueue_scripts' );
168 $admin->filter( "plugin_action_links_contact-form-7/wp-contact-form-7.php", 'action_links' );
169 $admin->filter( "plugin_action_links_{$this->plugin['basename']}", 'action_links' );
170 $admin->action( 'admin_footer_text', 'footer_text' );
171 $admin->filter( 'manage_toplevel_page_wpcf7_columns', 'add_table_column', 11 );
172 $admin->filter( 'cx-plugin_table_row_class', 'table_row_class', 10, 2 );
173 $admin->action( 'cx-plugin_tablenav', 'filter_buttons', 10, 2 );
174 $admin->action( 'admin_menu', 'admin_menu' );
175 $admin->action( 'admin_init', 'download' );
176
177 /**
178 * Renders different notices
179 *
180 * @package Codexpert\Plugin
181 *
182 * @author Codexpert <hi@codexpert.io>
183 */
184 $notice = new Notice( $this->plugin );
185
186 /**
187 * Marketing Modules
188 *
189 * @package Pluggable\Marketing
190 *
191 * @author Pluggable <hi@pluggable.io>
192 */
193 // new Feature( $this->plugin, [ 'reserved' => [] ] );
194 new Survey( $this->plugin );
195 new Deactivator( $this->plugin );
196
197 else : // ! is_admin() ?
198
199 /**
200 * Front facing hooks
201 */
202 $front = new App\Front( $this->plugin );
203 $front->action( 'wp_head', 'head' );
204 $front->action( 'wp_footer', 'modal' );
205 $front->action( 'wp_enqueue_scripts', 'enqueue_scripts' );
206 $front->filter( 'wpcf7_form_hidden_fields', 'show_user_id' );
207
208 endif;
209
210 /**
211 * Installer facing hooks
212 */
213 $installer = new App\Installer( $this->plugin );
214 $installer->activate( 'install' );
215 $installer->deactivate( 'uninstall' );
216
217 /**
218 * Submission hooks
219 *
220 * Executes on both the admin area and front area
221 */
222 $submission = new App\Submission( $this->plugin );
223 $submission->action( 'wpcf7_mail_sent', 'store' );
224 $submission->action( 'admin_init', 'delete' );
225 $submission->action( 'admin_init', 'read_unread' );
226 $submission->action( 'admin_init', 'bulk_action' );
227
228 /**
229 * AJAX related hooks
230 */
231 $ajax = new App\AJAX( $this->plugin );
232 $ajax->priv( 'cf7s-contact', 'contact' );
233 }
234
235 /**
236 * Cloning is forbidden.
237 *
238 * @access public
239 */
240 public function __clone() { }
241
242 /**
243 * Unserializing instances of this class is forbidden.
244 *
245 * @access public
246 */
247 public function __wakeup() { }
248
249 /**
250 * Instantiate the plugin
251 *
252 * @access public
253 *
254 * @return $_instance
255 */
256 public static function instance() {
257 if ( is_null( self::$_instance ) ) {
258 self::$_instance = new self();
259 }
260 return self::$_instance;
261 }
262 }
263
264 Plugin::instance();