| 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.20 |
| 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'] = '5.6'; |
| 133 |
$this->plugin['min_wp'] = '4.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 |
|
| 138 |
/** |
| 139 |
* Hooks |
| 140 |
* |
| 141 |
* @access private |
| 142 |
* |
| 143 |
* Executes main plugin features |
| 144 |
* |
| 145 |
* To add an action, use $instance->action() |
| 146 |
* To apply a filter, use $instance->filter() |
| 147 |
* To register a shortcode, use $instance->register() |
| 148 |
* To add a hook for logged in users, use $instance->priv() |
| 149 |
* To add a hook for non-logged in users, use $instance->nopriv() |
| 150 |
* |
| 151 |
* @return void |
| 152 |
*/ |
| 153 |
private function hook() { |
| 154 |
|
| 155 |
if( is_admin() ) : |
| 156 |
|
| 157 |
/** |
| 158 |
* Admin facing hooks |
| 159 |
*/ |
| 160 |
$admin = new App\Admin( $this->plugin ); |
| 161 |
$admin->action( 'admin_footer', 'modal' ); |
| 162 |
$admin->action( 'init', 'i18n' ); |
| 163 |
$admin->action( 'admin_enqueue_scripts', 'enqueue_scripts' ); |
| 164 |
$admin->filter( "plugin_action_links_contact-form-7/wp-contact-form-7.php", 'action_links' ); |
| 165 |
$admin->filter( "plugin_action_links_{$this->plugin['basename']}", 'action_links' ); |
| 166 |
$admin->action( 'admin_footer_text', 'footer_text' ); |
| 167 |
$admin->filter( 'manage_toplevel_page_wpcf7_columns', 'add_table_column', 11 ); |
| 168 |
$admin->filter( 'cx-plugin_table_row_class', 'table_row_class', 10, 2 ); |
| 169 |
$admin->action( 'cx-plugin_tablenav', 'filter_buttons', 10, 2 ); |
| 170 |
$admin->action( 'admin_menu', 'admin_menu' ); |
| 171 |
$admin->action( 'admin_init', 'download' ); |
| 172 |
|
| 173 |
/** |
| 174 |
* Renders different notices |
| 175 |
* |
| 176 |
* @package Codexpert\Plugin |
| 177 |
* |
| 178 |
* @author Codexpert <hi@codexpert.io> |
| 179 |
*/ |
| 180 |
$notice = new Notice( $this->plugin ); |
| 181 |
|
| 182 |
/** |
| 183 |
* Marketing Modules |
| 184 |
* |
| 185 |
* @package Pluggable\Marketing |
| 186 |
* |
| 187 |
* @author Pluggable <hi@pluggable.io> |
| 188 |
*/ |
| 189 |
new Feature( $this->plugin, [ 'reserved' => [] ] ); |
| 190 |
new Survey( $this->plugin ); |
| 191 |
new Deactivator( $this->plugin ); |
| 192 |
|
| 193 |
else : // ! is_admin() ? |
| 194 |
|
| 195 |
/** |
| 196 |
* Front facing hooks |
| 197 |
*/ |
| 198 |
$front = new App\Front( $this->plugin ); |
| 199 |
$front->action( 'wp_head', 'head' ); |
| 200 |
$front->action( 'wp_footer', 'modal' ); |
| 201 |
$front->action( 'wp_enqueue_scripts', 'enqueue_scripts' ); |
| 202 |
$front->filter( 'wpcf7_form_hidden_fields', 'show_user_id' ); |
| 203 |
|
| 204 |
endif; |
| 205 |
|
| 206 |
/** |
| 207 |
* Installer facing hooks |
| 208 |
*/ |
| 209 |
$installer = new App\Installer( $this->plugin ); |
| 210 |
$installer->activate( 'install' ); |
| 211 |
$installer->deactivate( 'uninstall' ); |
| 212 |
|
| 213 |
/** |
| 214 |
* Submission hooks |
| 215 |
* |
| 216 |
* Executes on both the admin area and front area |
| 217 |
*/ |
| 218 |
$submission = new App\Submission( $this->plugin ); |
| 219 |
$submission->action( 'wpcf7_mail_sent', 'store' ); |
| 220 |
$submission->action( 'admin_init', 'delete' ); |
| 221 |
$submission->action( 'admin_init', 'read_unread' ); |
| 222 |
$submission->action( 'admin_init', 'bulk_action' ); |
| 223 |
|
| 224 |
/** |
| 225 |
* AJAX related hooks |
| 226 |
*/ |
| 227 |
$ajax = new App\AJAX( $this->plugin ); |
| 228 |
$ajax->priv( 'cf7s-contact', 'contact' ); |
| 229 |
} |
| 230 |
|
| 231 |
/** |
| 232 |
* Cloning is forbidden. |
| 233 |
* |
| 234 |
* @access public |
| 235 |
*/ |
| 236 |
public function __clone() { } |
| 237 |
|
| 238 |
/** |
| 239 |
* Unserializing instances of this class is forbidden. |
| 240 |
* |
| 241 |
* @access public |
| 242 |
*/ |
| 243 |
public function __wakeup() { } |
| 244 |
|
| 245 |
/** |
| 246 |
* Instantiate the plugin |
| 247 |
* |
| 248 |
* @access public |
| 249 |
* |
| 250 |
* @return $_instance |
| 251 |
*/ |
| 252 |
public static function instance() { |
| 253 |
if ( is_null( self::$_instance ) ) { |
| 254 |
self::$_instance = new self(); |
| 255 |
} |
| 256 |
return self::$_instance; |
| 257 |
} |
| 258 |
} |
| 259 |
|
| 260 |
Plugin::instance(); |