PluginProbe
CF7 Submissions – Securely Store Contact Form 7 Data and Attachments, Reply to the Sender and more / 0.9
CF7 Submissions – Securely Store Contact Form 7 Data and Attachments, Reply to the Sender and more v0.9
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.9, at cf7-submissions.php

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