Version Description
- Fix preview of checkbox fields on leads list
- Fix nonce issues on extensions page
- Fix send file to api [{fieldname}-filename] [{fieldname}-base_64_file] [{fieldname}-path]
Download this release
Release Info
Developer | querysolutions |
Plugin | Contact Form 7 Redirection |
Version | 2.3.5 |
Comparing to | |
See all releases |
Code changes from version 2.3.4 to 2.3.5
- build/css/wpcf7-redirect-backend.css +9 -8
- build/js/wpcf7-redirect-backend-script.js +1 -2
- class-wpcf7-redirect.php +73 -73
- classes/actions/class-wpcf7r-action-firescript.php +83 -83
- classes/actions/class-wpcf7r-action-honeypot.php +163 -163
- classes/actions/class-wpcf7r-action-redirect.php +280 -280
- classes/actions/class-wpcf7r-action-save-lead.php +174 -168
- classes/actions/class-wpcf7r-action-send-to-api.php +409 -409
- classes/actions/class-wpcf7r-action-sendmail.php +197 -197
- classes/actions/html/html-action-redirect.php +13 -13
- classes/actions/html/html-action-send-to-email.php +13 -13
- classes/actions/html/html-page-settings.php +19 -19
- classes/actions/html/index.php +5 -5
- classes/actions/html/rule-title.php +23 -23
- classes/aff/class-ext-accessibe.php +631 -627
- classes/aff/templates/accesibie-content.php +165 -165
- classes/class-qs-api.php +320 -320
- classes/class-wpcf7r-action.php +919 -870
- classes/class-wpcf7r-actions-list.php +102 -102
- classes/class-wpcf7r-actions.php +111 -111
- classes/class-wpcf7r-extension.php +497 -497
- classes/class-wpcf7r-extensions.php +42 -42
- classes/class-wpcf7r-form-helper.php +668 -668
- classes/class-wpcf7r-form.php +652 -652
- classes/class-wpcf7r-html.php +302 -302
- classes/class-wpcf7r-lead.php +197 -197
- classes/class-wpcf7r-leads-manager.php +422 -422
- classes/class-wpcf7r-list-table.php +133 -133
- classes/class-wpcf7r-module.php +77 -77
- classes/class-wpcf7r-post-types.php +237 -221
- classes/class-wpcf7r-settings.php +296 -303
- classes/class-wpcf7r-submission.php +233 -233
- classes/class-wpcf7r-updates.php +146 -146
- classes/class-wpcf7r-user.php +117 -117
- classes/class-wpcf7r-utils.php +914 -914
- index.php +4 -4
- lang/index.php +4 -10
- modules/cf7-shortcode-password-field.php +224 -224
- modules/cf7r-shortcode-get-param-field.php +29 -29
- readme.txt +213 -204
- templates/banner.php +16 -16
- templates/block-html.php +8 -8
- templates/block-title.php +16 -16
- templates/default-settings.php +69 -69
- templates/extensions.php +26 -26
- templates/extensions/extension-promo-box.php +81 -81
- templates/extensions/extensions-table.php +23 -21
- templates/fields/field-button.php +18 -18
- templates/fields/field-checkbox.php +23 -23
- templates/fields/field-debug-log.php +28 -28
- templates/fields/field-download.php +29 -29
- templates/fields/field-editor.php +37 -37
- templates/fields/field-json-editor.php +22 -22
- templates/fields/field-leads-mapping.php +73 -73
- templates/fields/field-media.php +31 -31
- templates/fields/field-notice.php +17 -17
- templates/fields/field-number.php +25 -25
- templates/fields/field-page-select.php +35 -35
- templates/fields/field-password.php +28 -28
- templates/fields/field-post-author-select.php +25 -25
- templates/fields/field-post-type-select.php +28 -28
- templates/fields/field-preview.php +11 -11
- templates/fields/field-repeater.php +90 -90
- templates/fields/field-rule-blocks.php +38 -38
- templates/fields/field-tags-map.php +76 -76
- templates/fields/field-taxonomy.php +26 -26
- templates/fields/field-text.php +41 -41
- templates/fields/field-textarea.php +33 -33
- templates/fields/field-upload.php +31 -31
- templates/fields/field-url.php +23 -23
- templates/fields/index.php +2 -2
- templates/fields/section.php +32 -32
- templates/index.php +2 -2
- templates/popup-api-test.php +74 -74
- templates/save-form.php +21 -21
- templates/settings.php +28 -28
- wpcf7-redirect.php +83 -83
- wpcf7r-functions.php +808 -800
build/css/wpcf7-redirect-backend.css
CHANGED
@@ -851,17 +851,18 @@ div#wpcf7r_leads .field-wrap label {
|
|
851 |
display: block;
|
852 |
}
|
853 |
|
854 |
-
#steps-panel .check-column,
|
855 |
-
#extensions-panel .check-column,
|
856 |
-
#leads-panel .check-column,
|
857 |
-
#redirect-panel .check-column {
|
858 |
padding: 10px;
|
|
|
859 |
}
|
860 |
|
861 |
-
#steps-panel .check-column .handle,
|
862 |
-
#extensions-panel .check-column .handle,
|
863 |
-
#leads-panel .check-column .handle,
|
864 |
-
#redirect-panel .check-column .handle {
|
865 |
cursor: pointer;
|
866 |
}
|
867 |
|
851 |
display: block;
|
852 |
}
|
853 |
|
854 |
+
#steps-panel .cf7r-check-column,
|
855 |
+
#extensions-panel .cf7r-check-column,
|
856 |
+
#leads-panel .cf7r-check-column,
|
857 |
+
#redirect-panel .cf7r-check-column {
|
858 |
padding: 10px;
|
859 |
+
width: 45px;
|
860 |
}
|
861 |
|
862 |
+
#steps-panel .cf7r-check-column .handle,
|
863 |
+
#extensions-panel .cf7r-check-column .handle,
|
864 |
+
#leads-panel .cf7r-check-column .handle,
|
865 |
+
#redirect-panel .cf7r-check-column .handle {
|
866 |
cursor: pointer;
|
867 |
}
|
868 |
|
build/js/wpcf7-redirect-backend-script.js
CHANGED
@@ -210,7 +210,6 @@ var wpcf7_redirect_admin;
|
|
210 |
this.notice_dismiss_selector = '.wpcf7r-notice .notice-dismiss';
|
211 |
this.mail_tags_toggle = '.mail-tags-title';
|
212 |
this.validate_salesforce_app_details = '.wpcf7-redirect-validate_connection-fields';
|
213 |
-
this.debug_import_button_selector = '.reacreate-from-debug';
|
214 |
this.debug_send_button_selector = '.send-debug-info'
|
215 |
|
216 |
}
|
@@ -1248,7 +1247,7 @@ var wpcf7_redirect_admin;
|
|
1248 |
})(jQuery);
|
1249 |
|
1250 |
function wpcf_get_nonce() {
|
1251 |
-
return jQuery('[name=actions-nonce]').val();
|
1252 |
}
|
1253 |
jQuery(document).ready(function () {
|
1254 |
set_event_listeneres();
|
210 |
this.notice_dismiss_selector = '.wpcf7r-notice .notice-dismiss';
|
211 |
this.mail_tags_toggle = '.mail-tags-title';
|
212 |
this.validate_salesforce_app_details = '.wpcf7-redirect-validate_connection-fields';
|
|
|
213 |
this.debug_send_button_selector = '.send-debug-info'
|
214 |
|
215 |
}
|
1247 |
})(jQuery);
|
1248 |
|
1249 |
function wpcf_get_nonce() {
|
1250 |
+
return jQuery('[name=actions-nonce]').val() ? jQuery('[name=actions-nonce]').val() : jQuery('[name=_wpcf7nonce]').val();
|
1251 |
}
|
1252 |
jQuery(document).ready(function () {
|
1253 |
set_event_listeneres();
|
class-wpcf7-redirect.php
CHANGED
@@ -1,73 +1,73 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Main Contact Form 7 Redirect Class
|
4 |
-
*/
|
5 |
-
class Wpcf7_Redirect {
|
6 |
-
public function init() {
|
7 |
-
$this->define();
|
8 |
-
$this->load_dependencies();
|
9 |
-
$this->cf7_redirect_base = new WPCF7R_Base();
|
10 |
-
|
11 |
-
add_action( 'plugins_loaded', array( $this, 'notice_to_remove_old_plugin' ) );
|
12 |
-
}
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Load dependencies
|
16 |
-
*/
|
17 |
-
public function load_dependencies() {
|
18 |
-
// Load all actions
|
19 |
-
foreach ( glob( WPCF7_PRO_REDIRECT_BASE_PATH . 'modules/*.php' ) as $filename ) {
|
20 |
-
require_once( $filename );
|
21 |
-
}
|
22 |
-
require_once( WPCF7_PRO_REDIRECT_CLASSES_PATH . 'class-wpcf7r-base.php' );
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Notice to remove old plugin
|
27 |
-
*/
|
28 |
-
public function notice_to_remove_old_plugin() {
|
29 |
-
if ( ! function_exists( 'is_plugin_active' ) ) {
|
30 |
-
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
31 |
-
}
|
32 |
-
if ( is_plugin_active( 'cf7-to-api/cf7-to-api.php' ) ) {
|
33 |
-
add_action( 'admin_notices', 'wpcf7_remove_contact_form_7_to_api' );
|
34 |
-
}
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Defines
|
39 |
-
*/
|
40 |
-
public function define() {
|
41 |
-
$base_url = 'https://redirection-for-contact-form7.com/';
|
42 |
-
|
43 |
-
define( 'WPCF7_PRO_REDIRECT_PLUGIN_PAGE_URL', $base_url );
|
44 |
-
define( 'WPCF7_PRO_REDIRECT_DEBUG_URL', $base_url . 'wp-json/api-v1/debug' );
|
45 |
-
define( 'WPCF7_PRO_REDIRECT_PLUGIN_ACTIVATION_URL', $base_url . 'wp-admin/admin-ajax.php' );
|
46 |
-
define( 'WPCF7_PRO_REDIRECT_PLUGIN_CHANGELOG_URL', $base_url . 'wp-json/api-v1/get_changelog/' );
|
47 |
-
define( 'WPCF7_PRO_REDIRECT_PLUGIN_UPDATES', $base_url . 'wp-json/api-v1/check-for-updates/' );
|
48 |
-
define( 'WPCF7_PRO_REDIRECT_EXTENSION_UPDATES', $base_url . 'wp-json/api-v1/get-extension-update/' );
|
49 |
-
define( 'WPCF7_PRO_REDIRECT_PLUGIN_EXTENSIONS_LIST_URL', $base_url . 'wp-json/api-v1/extensions_list/' );
|
50 |
-
define( 'WPCF7_PRO_REDIRECT_PLUGIN_PROMOTIONS_URL', $base_url . 'wp-json/api-v1/promotions/' );
|
51 |
-
define( 'ACCESSIBE_API_URI', $base_url . 'wp-json/accesibe-api/activate' );
|
52 |
-
|
53 |
-
define( 'WPCF7_PRO_REDIRECT_WP_REQUIRES', '5.3' );
|
54 |
-
define( 'WPCF7_PRO_REDIRECT_WP_TESTED', '5.6' );
|
55 |
-
define( 'WPCF7_PRO_REDIRECT_PLUGIN_ID', '6XpU046EOVs7v6O' );
|
56 |
-
define( 'WPCF7_PRO_REDIRECT_PLUGIN_SKU', 'wpcfr-pro' );
|
57 |
-
define( 'WPCF7_PRO_REDIRECT_BASE_NAME', plugin_basename( __FILE__ ) );
|
58 |
-
define( 'WPCF7_PRO_REDIRECT_BASE_PATH', plugin_dir_path( __FILE__ ) );
|
59 |
-
define( 'WPCF7_PRO_REDIRECT_BASE_URL', plugin_dir_url( __FILE__ ) );
|
60 |
-
define( 'WPCF7_PRO_REDIRECT_PLUGINS_PATH', plugin_dir_path( dirname( __FILE__ ) ) );
|
61 |
-
define( 'WPCF7_PRO_REDIRECT_TEMPLATE_PATH', WPCF7_PRO_REDIRECT_BASE_PATH . 'templates/' );
|
62 |
-
define( 'WPCF7_PRO_REDIRECT_ACTIONS_TEMPLATE_PATH', WPCF7_PRO_REDIRECT_CLASSES_PATH . 'actions/html/' );
|
63 |
-
define( 'WPCF7_PRO_REDIRECT_ADDONS_PATH', WPCF7_PRO_REDIRECT_PLUGINS_PATH . 'wpcf7r-addons/' );
|
64 |
-
define( 'WPCF7_PRO_REDIRECT_ACTIONS_PATH', WPCF7_PRO_REDIRECT_CLASSES_PATH . 'actions/' );
|
65 |
-
define( 'WPCF7_PRO_REDIRECT_FIELDS_PATH', WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'fields/' );
|
66 |
-
define( 'WPCF7_PRO_REDIRECT_POPUP_TEMPLATES_PATH', WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'popups/' );
|
67 |
-
define( 'WPCF7_PRO_REDIRECT_POPUP_TEMPLATES_URL', WPCF7_PRO_REDIRECT_BASE_URL . '/templates/popups/' );
|
68 |
-
define( 'WPCF7_PRO_REDIRECT_ASSETS_PATH', WPCF7_PRO_REDIRECT_BASE_URL . 'assets/' );
|
69 |
-
define( 'WPCF7_PRO_REDIRECT_BUILD_PATH', WPCF7_PRO_REDIRECT_BASE_URL . 'build/' );
|
70 |
-
|
71 |
-
define( 'QFORM_BASE', WPCF7_PRO_REDIRECT_BASE_PATH . 'form/' );
|
72 |
-
}
|
73 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Main Contact Form 7 Redirect Class
|
4 |
+
*/
|
5 |
+
class Wpcf7_Redirect {
|
6 |
+
public function init() {
|
7 |
+
$this->define();
|
8 |
+
$this->load_dependencies();
|
9 |
+
$this->cf7_redirect_base = new WPCF7R_Base();
|
10 |
+
|
11 |
+
add_action( 'plugins_loaded', array( $this, 'notice_to_remove_old_plugin' ) );
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Load dependencies
|
16 |
+
*/
|
17 |
+
public function load_dependencies() {
|
18 |
+
// Load all actions
|
19 |
+
foreach ( glob( WPCF7_PRO_REDIRECT_BASE_PATH . 'modules/*.php' ) as $filename ) {
|
20 |
+
require_once( $filename );
|
21 |
+
}
|
22 |
+
require_once( WPCF7_PRO_REDIRECT_CLASSES_PATH . 'class-wpcf7r-base.php' );
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Notice to remove old plugin
|
27 |
+
*/
|
28 |
+
public function notice_to_remove_old_plugin() {
|
29 |
+
if ( ! function_exists( 'is_plugin_active' ) ) {
|
30 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
31 |
+
}
|
32 |
+
if ( is_plugin_active( 'cf7-to-api/cf7-to-api.php' ) ) {
|
33 |
+
add_action( 'admin_notices', 'wpcf7_remove_contact_form_7_to_api' );
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Defines
|
39 |
+
*/
|
40 |
+
public function define() {
|
41 |
+
$base_url = 'https://redirection-for-contact-form7.com/';
|
42 |
+
|
43 |
+
define( 'WPCF7_PRO_REDIRECT_PLUGIN_PAGE_URL', $base_url );
|
44 |
+
define( 'WPCF7_PRO_REDIRECT_DEBUG_URL', $base_url . 'wp-json/api-v1/debug' );
|
45 |
+
define( 'WPCF7_PRO_REDIRECT_PLUGIN_ACTIVATION_URL', $base_url . 'wp-admin/admin-ajax.php' );
|
46 |
+
define( 'WPCF7_PRO_REDIRECT_PLUGIN_CHANGELOG_URL', $base_url . 'wp-json/api-v1/get_changelog/' );
|
47 |
+
define( 'WPCF7_PRO_REDIRECT_PLUGIN_UPDATES', $base_url . 'wp-json/api-v1/check-for-updates/' );
|
48 |
+
define( 'WPCF7_PRO_REDIRECT_EXTENSION_UPDATES', $base_url . 'wp-json/api-v1/get-extension-update/' );
|
49 |
+
define( 'WPCF7_PRO_REDIRECT_PLUGIN_EXTENSIONS_LIST_URL', $base_url . 'wp-json/api-v1/extensions_list/' );
|
50 |
+
define( 'WPCF7_PRO_REDIRECT_PLUGIN_PROMOTIONS_URL', $base_url . 'wp-json/api-v1/promotions/' );
|
51 |
+
define( 'ACCESSIBE_API_URI', $base_url . 'wp-json/accesibe-api/activate' );
|
52 |
+
|
53 |
+
define( 'WPCF7_PRO_REDIRECT_WP_REQUIRES', '5.3' );
|
54 |
+
define( 'WPCF7_PRO_REDIRECT_WP_TESTED', '5.6' );
|
55 |
+
define( 'WPCF7_PRO_REDIRECT_PLUGIN_ID', '6XpU046EOVs7v6O' );
|
56 |
+
define( 'WPCF7_PRO_REDIRECT_PLUGIN_SKU', 'wpcfr-pro' );
|
57 |
+
define( 'WPCF7_PRO_REDIRECT_BASE_NAME', plugin_basename( __FILE__ ) );
|
58 |
+
define( 'WPCF7_PRO_REDIRECT_BASE_PATH', plugin_dir_path( __FILE__ ) );
|
59 |
+
define( 'WPCF7_PRO_REDIRECT_BASE_URL', plugin_dir_url( __FILE__ ) );
|
60 |
+
define( 'WPCF7_PRO_REDIRECT_PLUGINS_PATH', plugin_dir_path( dirname( __FILE__ ) ) );
|
61 |
+
define( 'WPCF7_PRO_REDIRECT_TEMPLATE_PATH', WPCF7_PRO_REDIRECT_BASE_PATH . 'templates/' );
|
62 |
+
define( 'WPCF7_PRO_REDIRECT_ACTIONS_TEMPLATE_PATH', WPCF7_PRO_REDIRECT_CLASSES_PATH . 'actions/html/' );
|
63 |
+
define( 'WPCF7_PRO_REDIRECT_ADDONS_PATH', WPCF7_PRO_REDIRECT_PLUGINS_PATH . 'wpcf7r-addons/' );
|
64 |
+
define( 'WPCF7_PRO_REDIRECT_ACTIONS_PATH', WPCF7_PRO_REDIRECT_CLASSES_PATH . 'actions/' );
|
65 |
+
define( 'WPCF7_PRO_REDIRECT_FIELDS_PATH', WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'fields/' );
|
66 |
+
define( 'WPCF7_PRO_REDIRECT_POPUP_TEMPLATES_PATH', WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'popups/' );
|
67 |
+
define( 'WPCF7_PRO_REDIRECT_POPUP_TEMPLATES_URL', WPCF7_PRO_REDIRECT_BASE_URL . '/templates/popups/' );
|
68 |
+
define( 'WPCF7_PRO_REDIRECT_ASSETS_PATH', WPCF7_PRO_REDIRECT_BASE_URL . 'assets/' );
|
69 |
+
define( 'WPCF7_PRO_REDIRECT_BUILD_PATH', WPCF7_PRO_REDIRECT_BASE_URL . 'build/' );
|
70 |
+
|
71 |
+
define( 'QFORM_BASE', WPCF7_PRO_REDIRECT_BASE_PATH . 'form/' );
|
72 |
+
}
|
73 |
+
}
|
classes/actions/class-wpcf7r-action-firescript.php
CHANGED
@@ -1,83 +1,83 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Action_FireScript file - handles JavaScript actions
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
register_wpcf7r_actions(
|
9 |
-
'FireScript',
|
10 |
-
__( 'Fire JavaScript', 'wpcf7-redirect' ),
|
11 |
-
'WPCF7R_Action_FireScript',
|
12 |
-
2
|
13 |
-
);
|
14 |
-
|
15 |
-
class WPCF7R_Action_FireScript extends WPCF7R_Action {
|
16 |
-
|
17 |
-
public function __construct( $post ) {
|
18 |
-
parent::__construct( $post );
|
19 |
-
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Get the fields relevant for this action
|
24 |
-
*/
|
25 |
-
public function get_action_fields() {
|
26 |
-
return array_merge(
|
27 |
-
array(
|
28 |
-
'script' => array(
|
29 |
-
'name' => 'script',
|
30 |
-
'type' => 'textarea',
|
31 |
-
'label' => __( 'Paste your JavaScript here.', 'wpcf7-redirect' ),
|
32 |
-
'sub_title' => esc_html( __( '(Don\'t use <script> tags)', 'wpcf7-redirect' ) ),
|
33 |
-
'placeholder' => __( 'Paste your JavaScript here', 'wpcf7-redirect' ),
|
34 |
-
'value' => $this->get( 'script' ),
|
35 |
-
),
|
36 |
-
'short-tags-usage' => array(
|
37 |
-
'name' => 'general-alert',
|
38 |
-
'type' => 'notice',
|
39 |
-
'label' => __( 'Notice!', 'wpcf7-redirect' ),
|
40 |
-
/* Translators: available mail tags */
|
41 |
-
'sub_title' => sprintf( __( 'You can use the following tags.<div>%s</div>', 'wpcf7-redirect' ), $this->get_formatted_mail_tags() ),
|
42 |
-
'placeholder' => '',
|
43 |
-
'class' => 'field-notice-alert',
|
44 |
-
'show_selector' => '',
|
45 |
-
),
|
46 |
-
'general-alert' => array(
|
47 |
-
'name' => 'general-alert',
|
48 |
-
'type' => 'notice',
|
49 |
-
'label' => __( 'Warning!', 'wpcf7-redirect' ),
|
50 |
-
'sub_title' => __(
|
51 |
-
'This option is for developers only - use with caution. If the plugin does not redirect after you have added scripts,
|
52 |
-
it means you have a problem with your script. Either fix the script, or remove it.',
|
53 |
-
'wpcf7-redirect'
|
54 |
-
),
|
55 |
-
'placeholder' => '',
|
56 |
-
'class' => 'field-warning-alert',
|
57 |
-
'show_selector' => '',
|
58 |
-
),
|
59 |
-
),
|
60 |
-
parent::get_default_fields()
|
61 |
-
);
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Get settings page
|
66 |
-
*/
|
67 |
-
public function get_action_settings() {
|
68 |
-
$this->get_settings_template( 'html-action-send-to-email.php' );
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Handle a simple redirect rule
|
73 |
-
*/
|
74 |
-
public function process( $submission ) {
|
75 |
-
|
76 |
-
$script = $this->get( 'script' );
|
77 |
-
|
78 |
-
$script = $this->replace_tags( $script, array() );
|
79 |
-
|
80 |
-
return $script;
|
81 |
-
}
|
82 |
-
|
83 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Action_FireScript file - handles JavaScript actions
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
register_wpcf7r_actions(
|
9 |
+
'FireScript',
|
10 |
+
__( 'Fire JavaScript', 'wpcf7-redirect' ),
|
11 |
+
'WPCF7R_Action_FireScript',
|
12 |
+
2
|
13 |
+
);
|
14 |
+
|
15 |
+
class WPCF7R_Action_FireScript extends WPCF7R_Action {
|
16 |
+
|
17 |
+
public function __construct( $post ) {
|
18 |
+
parent::__construct( $post );
|
19 |
+
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Get the fields relevant for this action
|
24 |
+
*/
|
25 |
+
public function get_action_fields() {
|
26 |
+
return array_merge(
|
27 |
+
array(
|
28 |
+
'script' => array(
|
29 |
+
'name' => 'script',
|
30 |
+
'type' => 'textarea',
|
31 |
+
'label' => __( 'Paste your JavaScript here.', 'wpcf7-redirect' ),
|
32 |
+
'sub_title' => esc_html( __( '(Don\'t use <script> tags)', 'wpcf7-redirect' ) ),
|
33 |
+
'placeholder' => __( 'Paste your JavaScript here', 'wpcf7-redirect' ),
|
34 |
+
'value' => $this->get( 'script' ),
|
35 |
+
),
|
36 |
+
'short-tags-usage' => array(
|
37 |
+
'name' => 'general-alert',
|
38 |
+
'type' => 'notice',
|
39 |
+
'label' => __( 'Notice!', 'wpcf7-redirect' ),
|
40 |
+
/* Translators: available mail tags */
|
41 |
+
'sub_title' => sprintf( __( 'You can use the following tags.<div>%s</div>', 'wpcf7-redirect' ), $this->get_formatted_mail_tags() ),
|
42 |
+
'placeholder' => '',
|
43 |
+
'class' => 'field-notice-alert',
|
44 |
+
'show_selector' => '',
|
45 |
+
),
|
46 |
+
'general-alert' => array(
|
47 |
+
'name' => 'general-alert',
|
48 |
+
'type' => 'notice',
|
49 |
+
'label' => __( 'Warning!', 'wpcf7-redirect' ),
|
50 |
+
'sub_title' => __(
|
51 |
+
'This option is for developers only - use with caution. If the plugin does not redirect after you have added scripts,
|
52 |
+
it means you have a problem with your script. Either fix the script, or remove it.',
|
53 |
+
'wpcf7-redirect'
|
54 |
+
),
|
55 |
+
'placeholder' => '',
|
56 |
+
'class' => 'field-warning-alert',
|
57 |
+
'show_selector' => '',
|
58 |
+
),
|
59 |
+
),
|
60 |
+
parent::get_default_fields()
|
61 |
+
);
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Get settings page
|
66 |
+
*/
|
67 |
+
public function get_action_settings() {
|
68 |
+
$this->get_settings_template( 'html-action-send-to-email.php' );
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Handle a simple redirect rule
|
73 |
+
*/
|
74 |
+
public function process( $submission ) {
|
75 |
+
|
76 |
+
$script = $this->get( 'script' );
|
77 |
+
|
78 |
+
$script = $this->replace_tags( $script, array() );
|
79 |
+
|
80 |
+
return $script;
|
81 |
+
}
|
82 |
+
|
83 |
+
}
|
classes/actions/class-wpcf7r-action-honeypot.php
CHANGED
@@ -1,163 +1,163 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Action_Honeypot
|
4 |
-
* A Class that handles javascript actions
|
5 |
-
*/
|
6 |
-
|
7 |
-
defined( 'ABSPATH' ) || exit;
|
8 |
-
|
9 |
-
register_wpcf7r_actions(
|
10 |
-
'honeypot',
|
11 |
-
__( 'Honeypot', 'wpcf7-redirect' ),
|
12 |
-
'WPCF7R_Action_Honeypot',
|
13 |
-
5
|
14 |
-
);
|
15 |
-
|
16 |
-
class WPCF7R_Action_Honeypot extends WPCF7R_Action {
|
17 |
-
public function __construct( $post ) {
|
18 |
-
parent::__construct( $post );
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Get the fields relevant for this action
|
23 |
-
*/
|
24 |
-
public function get_action_fields() {
|
25 |
-
return array_merge(
|
26 |
-
array(
|
27 |
-
'general-alert' => array(
|
28 |
-
'name' => 'general-alert',
|
29 |
-
'type' => 'notice',
|
30 |
-
'label' => __( 'Notice!', 'wpcf7-redirect' ),
|
31 |
-
'sub_title' => __(
|
32 |
-
'Honeypot creates a random number of anti-spam fields on your form. If a robot fills out one of these fields the submission is marked as spam.<br/>
|
33 |
-
<a href="https://en.wikipedia.org/wiki/Honeypot_(computing)" target="_blank">Learn More</a>',
|
34 |
-
'wpcf7-redirect'
|
35 |
-
),
|
36 |
-
'placeholder' => '',
|
37 |
-
'class' => 'field-warning-notice',
|
38 |
-
'show_selector' => '',
|
39 |
-
),
|
40 |
-
),
|
41 |
-
parent::get_default_fields()
|
42 |
-
);
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Create the honeypot field names
|
47 |
-
*
|
48 |
-
* @param integer $length
|
49 |
-
*/
|
50 |
-
function readable_random_string( $length = 6 ) {
|
51 |
-
$string = '';
|
52 |
-
$vowels = array( 'a', 'e', 'i', 'o', 'u' );
|
53 |
-
$consonants = array(
|
54 |
-
'b',
|
55 |
-
'c',
|
56 |
-
'd',
|
57 |
-
'f',
|
58 |
-
'g',
|
59 |
-
'h',
|
60 |
-
'j',
|
61 |
-
'k',
|
62 |
-
'l',
|
63 |
-
'm',
|
64 |
-
'n',
|
65 |
-
'p',
|
66 |
-
'r',
|
67 |
-
's',
|
68 |
-
't',
|
69 |
-
'v',
|
70 |
-
'w',
|
71 |
-
'x',
|
72 |
-
'y',
|
73 |
-
'z',
|
74 |
-
);
|
75 |
-
$max = $length / 2;
|
76 |
-
|
77 |
-
for ( $i = 1; $i <= $max; $i++ ) {
|
78 |
-
$string .= $consonants[ rand( 0, 19 ) ];
|
79 |
-
$string .= $vowels[ rand( 0, 4 ) ];
|
80 |
-
}
|
81 |
-
|
82 |
-
return $string;
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Get the honeypot fields names
|
87 |
-
*/
|
88 |
-
private function get_honeypot_names() {
|
89 |
-
return get_post_meta( $this->get_id(), 'honeypot_names', true );
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Render callback
|
94 |
-
*/
|
95 |
-
public function render_callback_once( $properties ) {
|
96 |
-
add_action(
|
97 |
-
'wp_footer',
|
98 |
-
function() {
|
99 |
-
$honeypot_names = $this->get_honeypot_names();
|
100 |
-
|
101 |
-
foreach ( $honeypot_names as $honeypot_name ) {
|
102 |
-
echo "<style>.{$honeypot_name}{transform:scale(0);position: absolute;z-index: -10;}</style>";
|
103 |
-
}
|
104 |
-
}
|
105 |
-
);
|
106 |
-
|
107 |
-
return $properties;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Render an element on the form frontend.
|
112 |
-
*
|
113 |
-
* @param array $properties
|
114 |
-
* @param object $form
|
115 |
-
*/
|
116 |
-
public function render_callback( $properties, $form ) {
|
117 |
-
$honeypot_names = $this->get_honeypot_names();
|
118 |
-
|
119 |
-
if ( ! $honeypot_names ) {
|
120 |
-
$rand = rand( 1, 4 );
|
121 |
-
$honeypot_names = array();
|
122 |
-
|
123 |
-
for ( $i = 1;$i <= $rand;$i++ ) {
|
124 |
-
$honeypot_names[] = $this->readable_random_string();
|
125 |
-
}
|
126 |
-
|
127 |
-
update_post_meta( $this->get_id(), 'honeypot_names', $honeypot_names );
|
128 |
-
}
|
129 |
-
|
130 |
-
if ( isset( $properties['form'] ) ) {
|
131 |
-
foreach ( $honeypot_names as $honeypot_name ) {
|
132 |
-
$properties['form'] .= "<p class='{$honeypot_name}'>[text {$honeypot_name}]</p>";
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
return $properties;
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Process the honeypot validations
|
141 |
-
*/
|
142 |
-
public function process_validation( $submission ) {
|
143 |
-
$response = array();
|
144 |
-
$posted_data = $submission->get_posted_data();
|
145 |
-
$honeypot_names = $this->get_honeypot_names();
|
146 |
-
|
147 |
-
if ( $honeypot_names ) {
|
148 |
-
foreach ( $honeypot_names as $honeypot_name ) {
|
149 |
-
if ( isset( $posted_data[ $honeypot_name ] ) && $posted_data[ $honeypot_name ] ) {
|
150 |
-
$error = array(
|
151 |
-
'tag' => $honeypot_name,
|
152 |
-
'error_message' => __( 'Something went wrong', 'wpcf7-redirect' ),
|
153 |
-
);
|
154 |
-
$response['invalid_tags'][] = new WP_error( 'tag_invalid', $error );
|
155 |
-
} else {
|
156 |
-
$response['ignored_tags'][] = $honeypot_name;
|
157 |
-
}
|
158 |
-
}
|
159 |
-
}
|
160 |
-
|
161 |
-
return $response;
|
162 |
-
}
|
163 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Action_Honeypot
|
4 |
+
* A Class that handles javascript actions
|
5 |
+
*/
|
6 |
+
|
7 |
+
defined( 'ABSPATH' ) || exit;
|
8 |
+
|
9 |
+
register_wpcf7r_actions(
|
10 |
+
'honeypot',
|
11 |
+
__( 'Honeypot', 'wpcf7-redirect' ),
|
12 |
+
'WPCF7R_Action_Honeypot',
|
13 |
+
5
|
14 |
+
);
|
15 |
+
|
16 |
+
class WPCF7R_Action_Honeypot extends WPCF7R_Action {
|
17 |
+
public function __construct( $post ) {
|
18 |
+
parent::__construct( $post );
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Get the fields relevant for this action
|
23 |
+
*/
|
24 |
+
public function get_action_fields() {
|
25 |
+
return array_merge(
|
26 |
+
array(
|
27 |
+
'general-alert' => array(
|
28 |
+
'name' => 'general-alert',
|
29 |
+
'type' => 'notice',
|
30 |
+
'label' => __( 'Notice!', 'wpcf7-redirect' ),
|
31 |
+
'sub_title' => __(
|
32 |
+
'Honeypot creates a random number of anti-spam fields on your form. If a robot fills out one of these fields the submission is marked as spam.<br/>
|
33 |
+
<a href="https://en.wikipedia.org/wiki/Honeypot_(computing)" target="_blank">Learn More</a>',
|
34 |
+
'wpcf7-redirect'
|
35 |
+
),
|
36 |
+
'placeholder' => '',
|
37 |
+
'class' => 'field-warning-notice',
|
38 |
+
'show_selector' => '',
|
39 |
+
),
|
40 |
+
),
|
41 |
+
parent::get_default_fields()
|
42 |
+
);
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Create the honeypot field names
|
47 |
+
*
|
48 |
+
* @param integer $length
|
49 |
+
*/
|
50 |
+
function readable_random_string( $length = 6 ) {
|
51 |
+
$string = '';
|
52 |
+
$vowels = array( 'a', 'e', 'i', 'o', 'u' );
|
53 |
+
$consonants = array(
|
54 |
+
'b',
|
55 |
+
'c',
|
56 |
+
'd',
|
57 |
+
'f',
|
58 |
+
'g',
|
59 |
+
'h',
|
60 |
+
'j',
|
61 |
+
'k',
|
62 |
+
'l',
|
63 |
+
'm',
|
64 |
+
'n',
|
65 |
+
'p',
|
66 |
+
'r',
|
67 |
+
's',
|
68 |
+
't',
|
69 |
+
'v',
|
70 |
+
'w',
|
71 |
+
'x',
|
72 |
+
'y',
|
73 |
+
'z',
|
74 |
+
);
|
75 |
+
$max = $length / 2;
|
76 |
+
|
77 |
+
for ( $i = 1; $i <= $max; $i++ ) {
|
78 |
+
$string .= $consonants[ rand( 0, 19 ) ];
|
79 |
+
$string .= $vowels[ rand( 0, 4 ) ];
|
80 |
+
}
|
81 |
+
|
82 |
+
return $string;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Get the honeypot fields names
|
87 |
+
*/
|
88 |
+
private function get_honeypot_names() {
|
89 |
+
return get_post_meta( $this->get_id(), 'honeypot_names', true );
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Render callback
|
94 |
+
*/
|
95 |
+
public function render_callback_once( $properties ) {
|
96 |
+
add_action(
|
97 |
+
'wp_footer',
|
98 |
+
function() {
|
99 |
+
$honeypot_names = $this->get_honeypot_names();
|
100 |
+
|
101 |
+
foreach ( $honeypot_names as $honeypot_name ) {
|
102 |
+
echo "<style>.{$honeypot_name}{transform:scale(0);position: absolute;z-index: -10;}</style>";
|
103 |
+
}
|
104 |
+
}
|
105 |
+
);
|
106 |
+
|
107 |
+
return $properties;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Render an element on the form frontend.
|
112 |
+
*
|
113 |
+
* @param array $properties
|
114 |
+
* @param object $form
|
115 |
+
*/
|
116 |
+
public function render_callback( $properties, $form ) {
|
117 |
+
$honeypot_names = $this->get_honeypot_names();
|
118 |
+
|
119 |
+
if ( ! $honeypot_names ) {
|
120 |
+
$rand = rand( 1, 4 );
|
121 |
+
$honeypot_names = array();
|
122 |
+
|
123 |
+
for ( $i = 1;$i <= $rand;$i++ ) {
|
124 |
+
$honeypot_names[] = $this->readable_random_string();
|
125 |
+
}
|
126 |
+
|
127 |
+
update_post_meta( $this->get_id(), 'honeypot_names', $honeypot_names );
|
128 |
+
}
|
129 |
+
|
130 |
+
if ( isset( $properties['form'] ) ) {
|
131 |
+
foreach ( $honeypot_names as $honeypot_name ) {
|
132 |
+
$properties['form'] .= "<p class='{$honeypot_name}'>[text {$honeypot_name}]</p>";
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
return $properties;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Process the honeypot validations
|
141 |
+
*/
|
142 |
+
public function process_validation( $submission ) {
|
143 |
+
$response = array();
|
144 |
+
$posted_data = $submission->get_posted_data();
|
145 |
+
$honeypot_names = $this->get_honeypot_names();
|
146 |
+
|
147 |
+
if ( $honeypot_names ) {
|
148 |
+
foreach ( $honeypot_names as $honeypot_name ) {
|
149 |
+
if ( isset( $posted_data[ $honeypot_name ] ) && $posted_data[ $honeypot_name ] ) {
|
150 |
+
$error = array(
|
151 |
+
'tag' => $honeypot_name,
|
152 |
+
'error_message' => __( 'Something went wrong', 'wpcf7-redirect' ),
|
153 |
+
);
|
154 |
+
$response['invalid_tags'][] = new WP_error( 'tag_invalid', $error );
|
155 |
+
} else {
|
156 |
+
$response['ignored_tags'][] = $honeypot_name;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
return $response;
|
162 |
+
}
|
163 |
+
}
|
classes/actions/class-wpcf7r-action-redirect.php
CHANGED
@@ -1,280 +1,280 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Action_Redirect file.
|
4 |
-
*/
|
5 |
-
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
-
exit;
|
8 |
-
}
|
9 |
-
|
10 |
-
register_wpcf7r_actions(
|
11 |
-
'redirect',
|
12 |
-
__( 'Redirect', 'wpcf7-redirect' ),
|
13 |
-
'WPCF7R_Action_Redirect',
|
14 |
-
1
|
15 |
-
);
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Class WPCF7R_Action_Redirect
|
19 |
-
* A Class that handles redirect actions
|
20 |
-
*/
|
21 |
-
class WPCF7R_Action_Redirect extends WPCF7R_Action {
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Init the parent action class
|
25 |
-
*
|
26 |
-
* @param $post
|
27 |
-
*/
|
28 |
-
public function __construct( $post ) {
|
29 |
-
parent::__construct( $post );
|
30 |
-
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Get the action admin fields
|
35 |
-
*/
|
36 |
-
public function get_action_fields() {
|
37 |
-
|
38 |
-
$parent_fields = parent::get_default_fields();
|
39 |
-
|
40 |
-
unset( $parent_fields['action_status'] );
|
41 |
-
|
42 |
-
return array_merge(
|
43 |
-
array(
|
44 |
-
array(
|
45 |
-
'name' => 'use_external_url',
|
46 |
-
'type' => 'checkbox',
|
47 |
-
'label' => __( 'Use custom URL', 'wpcf7-redirect' ),
|
48 |
-
'sub_title' => '',
|
49 |
-
'placeholder' => '',
|
50 |
-
'show_selector' => '.field-wrap-external_url,.field-wrap-page_id',
|
51 |
-
'value' => $this->get( 'use_external_url' ),
|
52 |
-
),
|
53 |
-
array(
|
54 |
-
'name' => 'page_id',
|
55 |
-
'type' => 'page_select',
|
56 |
-
'label' => __( 'Select a page', 'wpcf7-redirect' ),
|
57 |
-
'placeholder' => __( 'Select a page', 'wpcf7-redirect' ),
|
58 |
-
'value' => $this->get( 'page_id' ),
|
59 |
-
'class' => $this->get( 'use_external_url' ) ? 'field-hidden' : '',
|
60 |
-
),
|
61 |
-
array(
|
62 |
-
'name' => 'external_url',
|
63 |
-
'type' => 'text',
|
64 |
-
'label' => __( 'Use external URL', 'wpcf7-redirect' ),
|
65 |
-
'placeholder' => __( 'Use external URL', 'wpcf7-redirect' ),
|
66 |
-
'tooltip' => __( 'You can build a custom url like this https://example.com/[your-name]?[your-email]&[your-tel]', 'wpcf7-redirect' ),
|
67 |
-
'footer' => '<div>' . $this->get_formatted_mail_tags() . '</div><div class="wpcf7-redirect-butify-wrap"></div>',
|
68 |
-
'value' => $this->get( 'external_url' ),
|
69 |
-
'class' => $this->get( 'use_external_url' ) ? '' : 'field-hidden',
|
70 |
-
),
|
71 |
-
array(
|
72 |
-
'name' => 'redirect_as_x_form_encoded_url',
|
73 |
-
'type' => 'checkbox',
|
74 |
-
'label' => __( 'Redirect as X-WWW-FORM-URLENCODED (Form Post)', 'wpcf7-redirect' ),
|
75 |
-
'sub_title' => '',
|
76 |
-
'placeholder' => '',
|
77 |
-
'value' => $this->get( 'redirect_as_x_form_encoded_url' ),
|
78 |
-
),
|
79 |
-
array(
|
80 |
-
'name' => 'open_in_new_tab',
|
81 |
-
'type' => 'checkbox',
|
82 |
-
'label' => __( 'Open page in a new tab', 'wpcf7-redirect' ),
|
83 |
-
'sub_title' => '',
|
84 |
-
'placeholder' => '',
|
85 |
-
'show_selector' => '.field-wrap-open_in_new_tab_notice',
|
86 |
-
'value' => $this->get( 'open_in_new_tab' ),
|
87 |
-
),
|
88 |
-
array(
|
89 |
-
'name' => 'open_in_new_tab_notice',
|
90 |
-
'type' => 'notice',
|
91 |
-
'label' => '<strong>' . __( 'Notice!', 'wpcf7-redirect' ) . '</strong>',
|
92 |
-
'sub_title' => __( 'This option might not work as expected, since browsers often block popup windows. This option depends on the browser settings.', 'wpcf7-redirect' ),
|
93 |
-
'placeholder' => '',
|
94 |
-
'class' => $this->get( 'open_in_new_tab' ) ? 'field-notice-alert' : 'field-hidden field-notice-alert',
|
95 |
-
'show_selector' => '',
|
96 |
-
),
|
97 |
-
array(
|
98 |
-
'name' => 'http_build_query',
|
99 |
-
'type' => 'checkbox',
|
100 |
-
'label' => __( 'Pass all the fields from the form as URL query parameters', 'wpcf7-redirect' ),
|
101 |
-
'sub_title' => '',
|
102 |
-
'placeholder' => '',
|
103 |
-
'show_selector' => '.field-wrap-get_param_shortcode',
|
104 |
-
'value' => $this->get( 'http_build_query' ),
|
105 |
-
),
|
106 |
-
array(
|
107 |
-
'name' => 'http_build_query_selectively',
|
108 |
-
'type' => 'checkbox',
|
109 |
-
'label' => __( 'Pass specific fields from the form as URL query parameters', 'wpcf7-redirect' ),
|
110 |
-
'sub_title' => '',
|
111 |
-
'placeholder' => '',
|
112 |
-
'show_selector' => '.field-wrap-http_build_query_selectively_fields,.field-wrap-get_param_shortcode',
|
113 |
-
'value' => $this->get( 'http_build_query_selectively' ),
|
114 |
-
),
|
115 |
-
array(
|
116 |
-
'name' => 'url_encode',
|
117 |
-
'type' => 'checkbox',
|
118 |
-
'label' => __( 'Encode passed query parameters', 'wpcf7-redirect' ),
|
119 |
-
'sub_title' => '',
|
120 |
-
'placeholder' => '',
|
121 |
-
'value' => $this->get( 'url_encode' ),
|
122 |
-
),
|
123 |
-
array(
|
124 |
-
'name' => 'http_build_query_selectively_fields',
|
125 |
-
'type' => 'text',
|
126 |
-
'label' => __( 'Fields to pass as URL query parameters, separated by commas:', 'wpcf7-redirect' ),
|
127 |
-
'footer' => '<div>' . $this->get_formatted_mail_tags( true ) . '</div><div class="wpcf7-redirect-butify-wrap"></div>',
|
128 |
-
'placeholder' => '',
|
129 |
-
'value' => $this->get( 'http_build_query_selectively_fields' ),
|
130 |
-
'class' => $this->get( 'http_build_query_selectively' ) ? '' : 'field-hidden',
|
131 |
-
),
|
132 |
-
array(
|
133 |
-
'name' => 'get_param_shortcode',
|
134 |
-
'type' => 'notice',
|
135 |
-
'label' => '<strong>' . __( '[get_param]!', 'wpcf7-redirect' ) . '</strong>',
|
136 |
-
'sub_title' => __( 'You can use this tag on the target page to collect the data transerred [get_param param="your-name"].', 'wpcf7-redirect' ),
|
137 |
-
'placeholder' => '',
|
138 |
-
'class' => $this->get( 'http_build_query_selectively' ) ? 'field-notice-alert' : 'field-hidden field-notice-alert',
|
139 |
-
'show_selector' => '',
|
140 |
-
),
|
141 |
-
array(
|
142 |
-
'name' => 'delay_redirect_seconds',
|
143 |
-
'type' => 'number',
|
144 |
-
'label' => __( 'How many seconds to delay', 'wpcf7-redirect' ),
|
145 |
-
'placeholder' => __( 'Number of seconds', 'wpcf7-redirect' ),
|
146 |
-
'value' => $this->get( 'delay_redirect_seconds' ),
|
147 |
-
'class' => '',
|
148 |
-
),
|
149 |
-
'action_status' => array(
|
150 |
-
'name' => 'action_status',
|
151 |
-
'type' => 'checkbox',
|
152 |
-
'label' => $this->get_action_status_label(),
|
153 |
-
'sub_title' => __( 'if this is off the rule will not be applied', 'wpcf7-redirect' ),
|
154 |
-
'placeholder' => '',
|
155 |
-
'show_selector' => '.field-wrap-disable_default_email',
|
156 |
-
'toggle-label' => json_encode(
|
157 |
-
array(
|
158 |
-
'.field-wrap-action_status .checkbox-label,.column-status a' => array(
|
159 |
-
__( 'Enabled', 'wpcf7-redirect' ),
|
160 |
-
__( 'Disabled', 'wpcf7-redirect' ),
|
161 |
-
),
|
162 |
-
)
|
163 |
-
),
|
164 |
-
'value' => $this->get( 'action_status' ),
|
165 |
-
),
|
166 |
-
'disable_default_email' => array(
|
167 |
-
'name' => 'disable_default_email',
|
168 |
-
'type' => 'notice',
|
169 |
-
'label' => __( '<strong>NOTICE!</strong><br/>', 'wpcf7-redirect' ),
|
170 |
-
'sub_title' => __( 'Redirection will always be the last action regardless of the actions order.', 'wpcf7-redirect' ),
|
171 |
-
'placeholder' => '',
|
172 |
-
'class' => $this->get( 'action_status' ) ? 'field-notice-alert' : 'field-hidden field-notice-alert',
|
173 |
-
'show_selector' => '',
|
174 |
-
),
|
175 |
-
),
|
176 |
-
$parent_fields
|
177 |
-
);
|
178 |
-
}
|
179 |
-
|
180 |
-
/**
|
181 |
-
* Get an HTML of the
|
182 |
-
*/
|
183 |
-
public function get_action_settings() {
|
184 |
-
$this->get_settings_template( 'html-action-redirect.php' );
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Handle a simple redirect rule
|
189 |
-
*
|
190 |
-
* @param $submission
|
191 |
-
*/
|
192 |
-
public function process( $submission ) {
|
193 |
-
$response = array();
|
194 |
-
|
195 |
-
$this->posted_data = $submission->get_posted_data();
|
196 |
-
|
197 |
-
foreach ( $this->posted_data as $posted_data_key => $posted_data_value ) {
|
198 |
-
if ( is_array( $posted_data_value ) ) {
|
199 |
-
$this->posted_data[ $posted_data_key ] = implode( ',', $posted_data_value );
|
200 |
-
} elseif ( $this->get( 'url_encode' ) ) {
|
201 |
-
$this->posted_data[ $posted_data_key ] = rawurlencode( $posted_data_value );
|
202 |
-
}
|
203 |
-
}
|
204 |
-
|
205 |
-
if ( $this->get( 'use_external_url' ) === 'on' && $this->get( 'external_url' ) ) {
|
206 |
-
$response = array(
|
207 |
-
'type' => 'redirect',
|
208 |
-
'redirect_url' => $this->replace_tags( $this->get( 'external_url' ) ),
|
209 |
-
'delay' => $this->get( 'delay_redirect_seconds' ) ? (int) $this->get( 'delay_redirect_seconds' ) : 0,
|
210 |
-
);
|
211 |
-
} elseif ( $this->get( 'page_id' ) ) {
|
212 |
-
$response = array(
|
213 |
-
'type' => 'redirect',
|
214 |
-
'redirect_url' => get_permalink( $this->get( 'page_id' ) ),
|
215 |
-
'delay' => $this->get( 'delay_redirect_seconds' ) ? (int) $this->get( 'delay_redirect_seconds' ) : 0,
|
216 |
-
);
|
217 |
-
}
|
218 |
-
|
219 |
-
if ( $this->get( 'redirect_as_x_form_encoded_url' ) && isset( $response['redirect_url'] ) && $response['redirect_url'] ) {
|
220 |
-
|
221 |
-
ob_start();
|
222 |
-
|
223 |
-
$params = parse_url( $response['redirect_url'] );
|
224 |
-
|
225 |
-
parse_str( $params['query'], $fields );
|
226 |
-
|
227 |
-
if ( isset( $fields['sum'] ) && isset( $fields['qty'] ) ) {
|
228 |
-
$fields['sum'] = $fields['sum'] * $fields['qty'];
|
229 |
-
}
|
230 |
-
|
231 |
-
if ( $this->get( 'http_build_query_selectively' ) === 'on' ) {
|
232 |
-
$fields_to_add = explode( ',', $this->get( 'http_build_query_selectively_fields' ) );
|
233 |
-
|
234 |
-
foreach ( $fields_to_add as $field_to_add ) {
|
235 |
-
$field_to_add = trim( $field_to_add );
|
236 |
-
$fields[ $field_to_add ] = isset( $this->posted_data[ $field_to_add ] ) ? $this->posted_data[ $field_to_add ] : '';
|
237 |
-
}
|
238 |
-
} elseif ( $this->get( 'http_build_query' ) === 'on' ) {
|
239 |
-
$fields = array_merge( $this->posted_data, $fields );
|
240 |
-
}
|
241 |
-
|
242 |
-
?>
|
243 |
-
<form id="cf7r-result-form" action="<?php echo $response['redirect_url']; ?>" method="post">
|
244 |
-
<?php foreach ( $fields as $field_key => $field_value ) : ?>
|
245 |
-
<input type="hidden" name="<?php echo $field_key; ?>" value="<?php echo $field_value; ?>">
|
246 |
-
<?php endforeach; ?>
|
247 |
-
</form>
|
248 |
-
<?php
|
249 |
-
$response['form'] = ob_get_clean();
|
250 |
-
|
251 |
-
} elseif ( $this->get( 'http_build_query' ) === 'on' ) {
|
252 |
-
|
253 |
-
$response['http_build_query'] = true;
|
254 |
-
|
255 |
-
$response['redirect_url'] = add_query_arg( $this->posted_data, $response['redirect_url'] );
|
256 |
-
|
257 |
-
} elseif ( $this->get( 'http_build_query_selectively' ) === 'on' ) {
|
258 |
-
|
259 |
-
$fields_to_add = explode( ',', $this->get( 'http_build_query_selectively_fields' ) );
|
260 |
-
$fields_to_add_args = array();
|
261 |
-
|
262 |
-
foreach ( $fields_to_add as $field_to_add ) {
|
263 |
-
$field_to_add = trim( $field_to_add );
|
264 |
-
$fields_to_add_args[ $field_to_add ] = isset( $this->posted_data[ $field_to_add ] ) ? $this->posted_data[ $field_to_add ] : '';
|
265 |
-
}
|
266 |
-
|
267 |
-
$response['redirect_url'] = add_query_arg( $fields_to_add_args, $response['redirect_url'] );
|
268 |
-
}
|
269 |
-
|
270 |
-
if ( $this->get( 'after_sent_script' ) ) {
|
271 |
-
$response['after_sent_script'] = $this->get( 'after_sent_script' );
|
272 |
-
}
|
273 |
-
|
274 |
-
if ( $this->get( 'open_in_new_tab' ) === 'on' ) {
|
275 |
-
$response['type'] = 'new_tab';
|
276 |
-
}
|
277 |
-
|
278 |
-
return $response;
|
279 |
-
}
|
280 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Action_Redirect file.
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit;
|
8 |
+
}
|
9 |
+
|
10 |
+
register_wpcf7r_actions(
|
11 |
+
'redirect',
|
12 |
+
__( 'Redirect', 'wpcf7-redirect' ),
|
13 |
+
'WPCF7R_Action_Redirect',
|
14 |
+
1
|
15 |
+
);
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Class WPCF7R_Action_Redirect
|
19 |
+
* A Class that handles redirect actions
|
20 |
+
*/
|
21 |
+
class WPCF7R_Action_Redirect extends WPCF7R_Action {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Init the parent action class
|
25 |
+
*
|
26 |
+
* @param $post
|
27 |
+
*/
|
28 |
+
public function __construct( $post ) {
|
29 |
+
parent::__construct( $post );
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Get the action admin fields
|
35 |
+
*/
|
36 |
+
public function get_action_fields() {
|
37 |
+
|
38 |
+
$parent_fields = parent::get_default_fields();
|
39 |
+
|
40 |
+
unset( $parent_fields['action_status'] );
|
41 |
+
|
42 |
+
return array_merge(
|
43 |
+
array(
|
44 |
+
array(
|
45 |
+
'name' => 'use_external_url',
|
46 |
+
'type' => 'checkbox',
|
47 |
+
'label' => __( 'Use custom URL', 'wpcf7-redirect' ),
|
48 |
+
'sub_title' => '',
|
49 |
+
'placeholder' => '',
|
50 |
+
'show_selector' => '.field-wrap-external_url,.field-wrap-page_id',
|
51 |
+
'value' => $this->get( 'use_external_url' ),
|
52 |
+
),
|
53 |
+
array(
|
54 |
+
'name' => 'page_id',
|
55 |
+
'type' => 'page_select',
|
56 |
+
'label' => __( 'Select a page', 'wpcf7-redirect' ),
|
57 |
+
'placeholder' => __( 'Select a page', 'wpcf7-redirect' ),
|
58 |
+
'value' => $this->get( 'page_id' ),
|
59 |
+
'class' => $this->get( 'use_external_url' ) ? 'field-hidden' : '',
|
60 |
+
),
|
61 |
+
array(
|
62 |
+
'name' => 'external_url',
|
63 |
+
'type' => 'text',
|
64 |
+
'label' => __( 'Use external URL', 'wpcf7-redirect' ),
|
65 |
+
'placeholder' => __( 'Use external URL', 'wpcf7-redirect' ),
|
66 |
+
'tooltip' => __( 'You can build a custom url like this https://example.com/[your-name]?[your-email]&[your-tel]', 'wpcf7-redirect' ),
|
67 |
+
'footer' => '<div>' . $this->get_formatted_mail_tags() . '</div><div class="wpcf7-redirect-butify-wrap"></div>',
|
68 |
+
'value' => $this->get( 'external_url' ),
|
69 |
+
'class' => $this->get( 'use_external_url' ) ? '' : 'field-hidden',
|
70 |
+
),
|
71 |
+
array(
|
72 |
+
'name' => 'redirect_as_x_form_encoded_url',
|
73 |
+
'type' => 'checkbox',
|
74 |
+
'label' => __( 'Redirect as X-WWW-FORM-URLENCODED (Form Post)', 'wpcf7-redirect' ),
|
75 |
+
'sub_title' => '',
|
76 |
+
'placeholder' => '',
|
77 |
+
'value' => $this->get( 'redirect_as_x_form_encoded_url' ),
|
78 |
+
),
|
79 |
+
array(
|
80 |
+
'name' => 'open_in_new_tab',
|
81 |
+
'type' => 'checkbox',
|
82 |
+
'label' => __( 'Open page in a new tab', 'wpcf7-redirect' ),
|
83 |
+
'sub_title' => '',
|
84 |
+
'placeholder' => '',
|
85 |
+
'show_selector' => '.field-wrap-open_in_new_tab_notice',
|
86 |
+
'value' => $this->get( 'open_in_new_tab' ),
|
87 |
+
),
|
88 |
+
array(
|
89 |
+
'name' => 'open_in_new_tab_notice',
|
90 |
+
'type' => 'notice',
|
91 |
+
'label' => '<strong>' . __( 'Notice!', 'wpcf7-redirect' ) . '</strong>',
|
92 |
+
'sub_title' => __( 'This option might not work as expected, since browsers often block popup windows. This option depends on the browser settings.', 'wpcf7-redirect' ),
|
93 |
+
'placeholder' => '',
|
94 |
+
'class' => $this->get( 'open_in_new_tab' ) ? 'field-notice-alert' : 'field-hidden field-notice-alert',
|
95 |
+
'show_selector' => '',
|
96 |
+
),
|
97 |
+
array(
|
98 |
+
'name' => 'http_build_query',
|
99 |
+
'type' => 'checkbox',
|
100 |
+
'label' => __( 'Pass all the fields from the form as URL query parameters', 'wpcf7-redirect' ),
|
101 |
+
'sub_title' => '',
|
102 |
+
'placeholder' => '',
|
103 |
+
'show_selector' => '.field-wrap-get_param_shortcode',
|
104 |
+
'value' => $this->get( 'http_build_query' ),
|
105 |
+
),
|
106 |
+
array(
|
107 |
+
'name' => 'http_build_query_selectively',
|
108 |
+
'type' => 'checkbox',
|
109 |
+
'label' => __( 'Pass specific fields from the form as URL query parameters', 'wpcf7-redirect' ),
|
110 |
+
'sub_title' => '',
|
111 |
+
'placeholder' => '',
|
112 |
+
'show_selector' => '.field-wrap-http_build_query_selectively_fields,.field-wrap-get_param_shortcode',
|
113 |
+
'value' => $this->get( 'http_build_query_selectively' ),
|
114 |
+
),
|
115 |
+
array(
|
116 |
+
'name' => 'url_encode',
|
117 |
+
'type' => 'checkbox',
|
118 |
+
'label' => __( 'Encode passed query parameters', 'wpcf7-redirect' ),
|
119 |
+
'sub_title' => '',
|
120 |
+
'placeholder' => '',
|
121 |
+
'value' => $this->get( 'url_encode' ),
|
122 |
+
),
|
123 |
+
array(
|
124 |
+
'name' => 'http_build_query_selectively_fields',
|
125 |
+
'type' => 'text',
|
126 |
+
'label' => __( 'Fields to pass as URL query parameters, separated by commas:', 'wpcf7-redirect' ),
|
127 |
+
'footer' => '<div>' . $this->get_formatted_mail_tags( true ) . '</div><div class="wpcf7-redirect-butify-wrap"></div>',
|
128 |
+
'placeholder' => '',
|
129 |
+
'value' => $this->get( 'http_build_query_selectively_fields' ),
|
130 |
+
'class' => $this->get( 'http_build_query_selectively' ) ? '' : 'field-hidden',
|
131 |
+
),
|
132 |
+
array(
|
133 |
+
'name' => 'get_param_shortcode',
|
134 |
+
'type' => 'notice',
|
135 |
+
'label' => '<strong>' . __( '[get_param]!', 'wpcf7-redirect' ) . '</strong>',
|
136 |
+
'sub_title' => __( 'You can use this tag on the target page to collect the data transerred [get_param param="your-name"].', 'wpcf7-redirect' ),
|
137 |
+
'placeholder' => '',
|
138 |
+
'class' => $this->get( 'http_build_query_selectively' ) ? 'field-notice-alert' : 'field-hidden field-notice-alert',
|
139 |
+
'show_selector' => '',
|
140 |
+
),
|
141 |
+
array(
|
142 |
+
'name' => 'delay_redirect_seconds',
|
143 |
+
'type' => 'number',
|
144 |
+
'label' => __( 'How many seconds to delay', 'wpcf7-redirect' ),
|
145 |
+
'placeholder' => __( 'Number of seconds', 'wpcf7-redirect' ),
|
146 |
+
'value' => $this->get( 'delay_redirect_seconds' ),
|
147 |
+
'class' => '',
|
148 |
+
),
|
149 |
+
'action_status' => array(
|
150 |
+
'name' => 'action_status',
|
151 |
+
'type' => 'checkbox',
|
152 |
+
'label' => $this->get_action_status_label(),
|
153 |
+
'sub_title' => __( 'if this is off the rule will not be applied', 'wpcf7-redirect' ),
|
154 |
+
'placeholder' => '',
|
155 |
+
'show_selector' => '.field-wrap-disable_default_email',
|
156 |
+
'toggle-label' => json_encode(
|
157 |
+
array(
|
158 |
+
'.field-wrap-action_status .checkbox-label,.column-status a' => array(
|
159 |
+
__( 'Enabled', 'wpcf7-redirect' ),
|
160 |
+
__( 'Disabled', 'wpcf7-redirect' ),
|
161 |
+
),
|
162 |
+
)
|
163 |
+
),
|
164 |
+
'value' => $this->get( 'action_status' ),
|
165 |
+
),
|
166 |
+
'disable_default_email' => array(
|
167 |
+
'name' => 'disable_default_email',
|
168 |
+
'type' => 'notice',
|
169 |
+
'label' => __( '<strong>NOTICE!</strong><br/>', 'wpcf7-redirect' ),
|
170 |
+
'sub_title' => __( 'Redirection will always be the last action regardless of the actions order.', 'wpcf7-redirect' ),
|
171 |
+
'placeholder' => '',
|
172 |
+
'class' => $this->get( 'action_status' ) ? 'field-notice-alert' : 'field-hidden field-notice-alert',
|
173 |
+
'show_selector' => '',
|
174 |
+
),
|
175 |
+
),
|
176 |
+
$parent_fields
|
177 |
+
);
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Get an HTML of the
|
182 |
+
*/
|
183 |
+
public function get_action_settings() {
|
184 |
+
$this->get_settings_template( 'html-action-redirect.php' );
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Handle a simple redirect rule
|
189 |
+
*
|
190 |
+
* @param $submission
|
191 |
+
*/
|
192 |
+
public function process( $submission ) {
|
193 |
+
$response = array();
|
194 |
+
|
195 |
+
$this->posted_data = $submission->get_posted_data();
|
196 |
+
|
197 |
+
foreach ( $this->posted_data as $posted_data_key => $posted_data_value ) {
|
198 |
+
if ( is_array( $posted_data_value ) ) {
|
199 |
+
$this->posted_data[ $posted_data_key ] = implode( ',', $posted_data_value );
|
200 |
+
} elseif ( $this->get( 'url_encode' ) ) {
|
201 |
+
$this->posted_data[ $posted_data_key ] = rawurlencode( $posted_data_value );
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
if ( $this->get( 'use_external_url' ) === 'on' && $this->get( 'external_url' ) ) {
|
206 |
+
$response = array(
|
207 |
+
'type' => 'redirect',
|
208 |
+
'redirect_url' => $this->replace_tags( $this->get( 'external_url' ) ),
|
209 |
+
'delay' => $this->get( 'delay_redirect_seconds' ) ? (int) $this->get( 'delay_redirect_seconds' ) : 0,
|
210 |
+
);
|
211 |
+
} elseif ( $this->get( 'page_id' ) ) {
|
212 |
+
$response = array(
|
213 |
+
'type' => 'redirect',
|
214 |
+
'redirect_url' => get_permalink( $this->get( 'page_id' ) ),
|
215 |
+
'delay' => $this->get( 'delay_redirect_seconds' ) ? (int) $this->get( 'delay_redirect_seconds' ) : 0,
|
216 |
+
);
|
217 |
+
}
|
218 |
+
|
219 |
+
if ( $this->get( 'redirect_as_x_form_encoded_url' ) && isset( $response['redirect_url'] ) && $response['redirect_url'] ) {
|
220 |
+
|
221 |
+
ob_start();
|
222 |
+
|
223 |
+
$params = parse_url( $response['redirect_url'] );
|
224 |
+
|
225 |
+
parse_str( $params['query'], $fields );
|
226 |
+
|
227 |
+
if ( isset( $fields['sum'] ) && isset( $fields['qty'] ) ) {
|
228 |
+
$fields['sum'] = $fields['sum'] * $fields['qty'];
|
229 |
+
}
|
230 |
+
|
231 |
+
if ( $this->get( 'http_build_query_selectively' ) === 'on' ) {
|
232 |
+
$fields_to_add = explode( ',', $this->get( 'http_build_query_selectively_fields' ) );
|
233 |
+
|
234 |
+
foreach ( $fields_to_add as $field_to_add ) {
|
235 |
+
$field_to_add = trim( $field_to_add );
|
236 |
+
$fields[ $field_to_add ] = isset( $this->posted_data[ $field_to_add ] ) ? $this->posted_data[ $field_to_add ] : '';
|
237 |
+
}
|
238 |
+
} elseif ( $this->get( 'http_build_query' ) === 'on' ) {
|
239 |
+
$fields = array_merge( $this->posted_data, $fields );
|
240 |
+
}
|
241 |
+
|
242 |
+
?>
|
243 |
+
<form id="cf7r-result-form" action="<?php echo $response['redirect_url']; ?>" method="post">
|
244 |
+
<?php foreach ( $fields as $field_key => $field_value ) : ?>
|
245 |
+
<input type="hidden" name="<?php echo $field_key; ?>" value="<?php echo $field_value; ?>">
|
246 |
+
<?php endforeach; ?>
|
247 |
+
</form>
|
248 |
+
<?php
|
249 |
+
$response['form'] = ob_get_clean();
|
250 |
+
|
251 |
+
} elseif ( $this->get( 'http_build_query' ) === 'on' ) {
|
252 |
+
|
253 |
+
$response['http_build_query'] = true;
|
254 |
+
|
255 |
+
$response['redirect_url'] = add_query_arg( $this->posted_data, $response['redirect_url'] );
|
256 |
+
|
257 |
+
} elseif ( $this->get( 'http_build_query_selectively' ) === 'on' ) {
|
258 |
+
|
259 |
+
$fields_to_add = explode( ',', $this->get( 'http_build_query_selectively_fields' ) );
|
260 |
+
$fields_to_add_args = array();
|
261 |
+
|
262 |
+
foreach ( $fields_to_add as $field_to_add ) {
|
263 |
+
$field_to_add = trim( $field_to_add );
|
264 |
+
$fields_to_add_args[ $field_to_add ] = isset( $this->posted_data[ $field_to_add ] ) ? $this->posted_data[ $field_to_add ] : '';
|
265 |
+
}
|
266 |
+
|
267 |
+
$response['redirect_url'] = add_query_arg( $fields_to_add_args, $response['redirect_url'] );
|
268 |
+
}
|
269 |
+
|
270 |
+
if ( $this->get( 'after_sent_script' ) ) {
|
271 |
+
$response['after_sent_script'] = $this->get( 'after_sent_script' );
|
272 |
+
}
|
273 |
+
|
274 |
+
if ( $this->get( 'open_in_new_tab' ) === 'on' ) {
|
275 |
+
$response['type'] = 'new_tab';
|
276 |
+
}
|
277 |
+
|
278 |
+
return $response;
|
279 |
+
}
|
280 |
+
}
|
classes/actions/class-wpcf7r-action-save-lead.php
CHANGED
@@ -1,168 +1,174 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Action_Save_Lead file - handles send send to api process
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
register_wpcf7r_actions( 'save_lead', __( 'Save Lead', 'wpcf7-redirect' ), 'WPCF7R_Action_Save_Lead', 3 );
|
9 |
-
|
10 |
-
class WPCF7R_Action_Save_Lead extends WPCF7R_Action {
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Init the parent action class
|
14 |
-
*/
|
15 |
-
public function __construct( $post ) {
|
16 |
-
parent::__construct( $post );
|
17 |
-
$this->priority = 1;
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Get the action admin fields
|
22 |
-
*/
|
23 |
-
public function get_action_fields() {
|
24 |
-
|
25 |
-
$parent_fields = parent::get_default_fields();
|
26 |
-
|
27 |
-
unset( $parent_fields['action_status'] );
|
28 |
-
|
29 |
-
return array_merge(
|
30 |
-
array(
|
31 |
-
'tags_map_mapping_section' => array(
|
32 |
-
'name' => 'tags_map_mapping_section',
|
33 |
-
'type' => 'section',
|
34 |
-
'title' => __( 'Tags mapping', 'wpcf7-redirect' ),
|
35 |
-
'fields' => array(
|
36 |
-
array(
|
37 |
-
'name' => 'leads_map',
|
38 |
-
'type' => 'leads_map',
|
39 |
-
'label' => '',
|
40 |
-
'sub_title' => '',
|
41 |
-
'placeholder' => '',
|
42 |
-
'show_selector' => '',
|
43 |
-
'value' => maybe_unserialize( $this->get( 'leads_map' ) ),
|
44 |
-
'tags' => WPCF7R_Form::get_mail_tags(),
|
45 |
-
),
|
46 |
-
),
|
47 |
-
),
|
48 |
-
'action_status' => array(
|
49 |
-
'name' => 'action_status',
|
50 |
-
'type' => 'checkbox',
|
51 |
-
'label' => $this->get_action_status_label(),
|
52 |
-
'sub_title' => __( 'if this is off the rule will not be applied', 'wpcf7-redirect' ),
|
53 |
-
'placeholder' => '',
|
54 |
-
'show_selector' => '',
|
55 |
-
'toggle-label' => json_encode(
|
56 |
-
array(
|
57 |
-
'.field-wrap-action_status .checkbox-label,.column-status a' => array(
|
58 |
-
__( 'Enabled', 'wpcf7-redirect' ),
|
59 |
-
__( 'Disabled', 'wpcf7-redirect' ),
|
60 |
-
),
|
61 |
-
)
|
62 |
-
),
|
63 |
-
'value' => $this->get( 'action_status' ),
|
64 |
-
),
|
65 |
-
),
|
66 |
-
$parent_fields
|
67 |
-
);
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Get an HTML of the
|
72 |
-
*/
|
73 |
-
public function get_action_settings() {
|
74 |
-
|
75 |
-
$this->get_settings_template( 'html-action-redirect.php' );
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Connected to manage_columns hooks.
|
81 |
-
*
|
82 |
-
* @param [string] $column - key of the column.
|
83 |
-
* @param [int] $lead_id - the id of the relevant post.
|
84 |
-
* @return void
|
85 |
-
*/
|
86 |
-
public function display_action_column_content( $column, $lead_id ) {
|
87 |
-
switch ( $column ) {
|
88 |
-
case 'form':
|
89 |
-
echo $this->get_cf7_link_html();
|
90 |
-
break;
|
91 |
-
case 'data_preview':
|
92 |
-
echo $this->display_columns_values( $lead_id );
|
93 |
-
break;
|
94 |
-
}
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Display the values that were selected on the action.
|
99 |
-
*
|
100 |
-
* @return void
|
101 |
-
*/
|
102 |
-
private function display_columns_values( $lead_id ) {
|
103 |
-
$mapped_fields = maybe_unserialize( $this->get( 'leads_map' ) );
|
104 |
-
$none_selected = true;
|
105 |
-
if ( $mapped_fields ) {
|
106 |
-
foreach ( $mapped_fields as $field_key => $mapped_field ) {
|
107 |
-
if ( isset( $mapped_field['appear'] ) && $mapped_field['appear'] ) {
|
108 |
-
$label = $mapped_field['tag'] ? $mapped_field['tag'] : $field_key;
|
109 |
-
|
110 |
-
$
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Action_Save_Lead file - handles send send to api process
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
register_wpcf7r_actions( 'save_lead', __( 'Save Lead', 'wpcf7-redirect' ), 'WPCF7R_Action_Save_Lead', 3 );
|
9 |
+
|
10 |
+
class WPCF7R_Action_Save_Lead extends WPCF7R_Action {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Init the parent action class
|
14 |
+
*/
|
15 |
+
public function __construct( $post ) {
|
16 |
+
parent::__construct( $post );
|
17 |
+
$this->priority = 1;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Get the action admin fields
|
22 |
+
*/
|
23 |
+
public function get_action_fields() {
|
24 |
+
|
25 |
+
$parent_fields = parent::get_default_fields();
|
26 |
+
|
27 |
+
unset( $parent_fields['action_status'] );
|
28 |
+
|
29 |
+
return array_merge(
|
30 |
+
array(
|
31 |
+
'tags_map_mapping_section' => array(
|
32 |
+
'name' => 'tags_map_mapping_section',
|
33 |
+
'type' => 'section',
|
34 |
+
'title' => __( 'Tags mapping', 'wpcf7-redirect' ),
|
35 |
+
'fields' => array(
|
36 |
+
array(
|
37 |
+
'name' => 'leads_map',
|
38 |
+
'type' => 'leads_map',
|
39 |
+
'label' => '',
|
40 |
+
'sub_title' => '',
|
41 |
+
'placeholder' => '',
|
42 |
+
'show_selector' => '',
|
43 |
+
'value' => maybe_unserialize( $this->get( 'leads_map' ) ),
|
44 |
+
'tags' => WPCF7R_Form::get_mail_tags(),
|
45 |
+
),
|
46 |
+
),
|
47 |
+
),
|
48 |
+
'action_status' => array(
|
49 |
+
'name' => 'action_status',
|
50 |
+
'type' => 'checkbox',
|
51 |
+
'label' => $this->get_action_status_label(),
|
52 |
+
'sub_title' => __( 'if this is off the rule will not be applied', 'wpcf7-redirect' ),
|
53 |
+
'placeholder' => '',
|
54 |
+
'show_selector' => '',
|
55 |
+
'toggle-label' => json_encode(
|
56 |
+
array(
|
57 |
+
'.field-wrap-action_status .checkbox-label,.column-status a' => array(
|
58 |
+
__( 'Enabled', 'wpcf7-redirect' ),
|
59 |
+
__( 'Disabled', 'wpcf7-redirect' ),
|
60 |
+
),
|
61 |
+
)
|
62 |
+
),
|
63 |
+
'value' => $this->get( 'action_status' ),
|
64 |
+
),
|
65 |
+
),
|
66 |
+
$parent_fields
|
67 |
+
);
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Get an HTML of the
|
72 |
+
*/
|
73 |
+
public function get_action_settings() {
|
74 |
+
|
75 |
+
$this->get_settings_template( 'html-action-redirect.php' );
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Connected to manage_columns hooks.
|
81 |
+
*
|
82 |
+
* @param [string] $column - key of the column.
|
83 |
+
* @param [int] $lead_id - the id of the relevant post.
|
84 |
+
* @return void
|
85 |
+
*/
|
86 |
+
public function display_action_column_content( $column, $lead_id ) {
|
87 |
+
switch ( $column ) {
|
88 |
+
case 'form':
|
89 |
+
echo $this->get_cf7_link_html();
|
90 |
+
break;
|
91 |
+
case 'data_preview':
|
92 |
+
echo $this->display_columns_values( $lead_id );
|
93 |
+
break;
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Display the values that were selected on the action.
|
99 |
+
*
|
100 |
+
* @return void
|
101 |
+
*/
|
102 |
+
private function display_columns_values( $lead_id ) {
|
103 |
+
$mapped_fields = maybe_unserialize( $this->get( 'leads_map' ) );
|
104 |
+
$none_selected = true;
|
105 |
+
if ( $mapped_fields ) {
|
106 |
+
foreach ( $mapped_fields as $field_key => $mapped_field ) {
|
107 |
+
if ( isset( $mapped_field['appear'] ) && $mapped_field['appear'] ) {
|
108 |
+
$label = $mapped_field['tag'] ? $mapped_field['tag'] : $field_key;
|
109 |
+
|
110 |
+
$value = get_post_meta( $lead_id, $field_key, true );
|
111 |
+
|
112 |
+
if ( is_array( $value ) ) {
|
113 |
+
$value = implode( ',', $value );
|
114 |
+
}
|
115 |
+
|
116 |
+
$string = $label . ': ' . $value;
|
117 |
+
|
118 |
+
echo sprintf( "<div class='preview-data'>%s</div>", $string );
|
119 |
+
|
120 |
+
$none_selected = false;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
if ( $none_selected ) {
|
126 |
+
echo __( 'No preview defined', 'wpcf7-redirect' );
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Handle a simple redirect rule
|
132 |
+
*
|
133 |
+
* @param $submission
|
134 |
+
*/
|
135 |
+
public function process( $submission ) {
|
136 |
+
$contact_form = $submission->get_contact_form();
|
137 |
+
|
138 |
+
// insert the lead to the DB
|
139 |
+
$files = $submission->uploaded_files();
|
140 |
+
|
141 |
+
$submitted_files = array();
|
142 |
+
|
143 |
+
$posted_values = $submission->get_posted_data();
|
144 |
+
|
145 |
+
if ( $files ) {
|
146 |
+
foreach ( $files as $file_key => $file_path ) {
|
147 |
+
|
148 |
+
$type = pathinfo( $file_path, PATHINFO_EXTENSION );
|
149 |
+
|
150 |
+
$submitted_files[ $file_key ] = array(
|
151 |
+
'type' => $type,
|
152 |
+
'name' => basename( $file_path ),
|
153 |
+
'base64_file' => wpcf7r_base_64_file( $file_path ),
|
154 |
+
'path' => $file_path,
|
155 |
+
);
|
156 |
+
unset( $posted_values[ $file_key ] );
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
$lead = WPCF7R_Leads_Manager::insert_lead( $contact_form->id(), $posted_values, $submitted_files, 'contact', $this->get_id() );
|
161 |
+
|
162 |
+
self::set_lead_id( $lead->post_id );
|
163 |
+
|
164 |
+
$response = array(
|
165 |
+
'type' => 'save_lead',
|
166 |
+
'data' => array(
|
167 |
+
'lead_id' => $lead->post_id,
|
168 |
+
),
|
169 |
+
);
|
170 |
+
|
171 |
+
return $response;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
classes/actions/class-wpcf7r-action-send-to-api.php
CHANGED
@@ -1,409 +1,409 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Action_api_url_request file
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
class WPCF7R_Action_Send_To_Api extends WPCF7R_Action {
|
9 |
-
|
10 |
-
public function __construct( $post ) {
|
11 |
-
$this->action_id = $post->ID;
|
12 |
-
}
|
13 |
-
|
14 |
-
/**
|
15 |
-
* The handler that will send the data to the api
|
16 |
-
*
|
17 |
-
* @param $args
|
18 |
-
*/
|
19 |
-
public function qs_cf7_send_data_to_api( $args ) {
|
20 |
-
$this->defaults = $args['tags_defaults'];
|
21 |
-
$this->functions = $args['tags_functions'];
|
22 |
-
$this->headers = $args['api_headers'];
|
23 |
-
$this->headers = array_filter( $this->headers );
|
24 |
-
|
25 |
-
$tags_map = $args['tags'];
|
26 |
-
$record_type = $args['record_type'];
|
27 |
-
$input_type = $args['input_type'];
|
28 |
-
$base_url = $args['base_url'];
|
29 |
-
$submission = isset( $args['submission'] ) ? $args['submission'] : '';
|
30 |
-
$template = $args['request_template'];
|
31 |
-
|
32 |
-
if ( 'xml' === $record_type ) {
|
33 |
-
$this->headers['Content-Type'] = 'text/xml';
|
34 |
-
} elseif ( 'json' === $record_type ) {
|
35 |
-
$this->headers['Content-Type'] = 'application/json';
|
36 |
-
}
|
37 |
-
|
38 |
-
$submission = WPCF7_Submission::get_instance();
|
39 |
-
$wpcf7 = $submission->get_contact_form();
|
40 |
-
|
41 |
-
$this->post = $wpcf7;
|
42 |
-
$this->clear_error_log( $this->post->id() );
|
43 |
-
|
44 |
-
$submission_url = $submission->get_meta( 'url' );
|
45 |
-
|
46 |
-
//always save last call results for debugging
|
47 |
-
|
48 |
-
$record = $this->get_record( $submission, $tags_map, $record_type, $template );
|
49 |
-
$record['url'] = $base_url;
|
50 |
-
|
51 |
-
if ( isset( $record['url'] ) && $record['url'] ) {
|
52 |
-
do_action( 'qs_cf7_api_before_sent_to_api', $record );
|
53 |
-
$response = $this->send_lead( $record, true, $input_type, $record_type, $tags_map );
|
54 |
-
do_action( 'qs_cf7_api_after_sent_to_api', $record, $response );
|
55 |
-
|
56 |
-
} else {
|
57 |
-
$this->log_result( __( 'Missing url' ), '' );
|
58 |
-
}
|
59 |
-
|
60 |
-
return array( $response, $record );
|
61 |
-
}
|
62 |
-
|
63 |
-
public function log_result( $record, $response ) {
|
64 |
-
if ( isset( $record['url'] ) ) {
|
65 |
-
update_post_meta( $this->action_id, 'api_debug_url', $record['url'] );
|
66 |
-
}
|
67 |
-
|
68 |
-
if ( is_wp_error( $response ) || is_wp_error( $record ) ) {
|
69 |
-
update_post_meta( $this->action_id, 'api_debug_result', $response );
|
70 |
-
update_post_meta( $this->action_id, 'api_debug_params', $record );
|
71 |
-
} else {
|
72 |
-
update_post_meta( $this->action_id, 'api_debug_params', $record );
|
73 |
-
update_post_meta( $this->action_id, 'api_debug_result', $response );
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Clear error log
|
79 |
-
*/
|
80 |
-
function clear_error_log( $post_id ) {
|
81 |
-
delete_post_meta( $post_id, 'api_errors' );
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Convert the form keys to the API keys according to the mapping instructions
|
86 |
-
*
|
87 |
-
* @param $submission
|
88 |
-
* @param $tags_map
|
89 |
-
* @param string $type
|
90 |
-
* @param string $template
|
91 |
-
*/
|
92 |
-
function get_record( $submission, $tags_map, $type = 'params', $template = '' ) {
|
93 |
-
$submited_data = $submission->get_posted_data();
|
94 |
-
|
95 |
-
if ( 'xml' === $type || 'json' === $type ) {
|
96 |
-
$template = $this->replace_lead_id_tag( $template );
|
97 |
-
|
98 |
-
foreach ( $tags_map as $form_key => $qs_cf7_form_key ) {
|
99 |
-
if ( is_array( $qs_cf7_form_key ) ) {
|
100 |
-
|
101 |
-
//arrange checkbox arrays
|
102 |
-
if ( isset( $submited_data[ $form_key ] ) ) {
|
103 |
-
$value = apply_filters( 'set_record_value', $submited_data[ $form_key ], $qs_cf7_form_key, $form_key );
|
104 |
-
$value = is_array( $value ) ? implode( ',', $value ) : $value;
|
105 |
-
}
|
106 |
-
} else {
|
107 |
-
$value = isset( $submited_data[ $form_key ] ) ? $submited_data[ $form_key ] : '';
|
108 |
-
$value = apply_filters( 'set_record_value', $value, $qs_cf7_form_key, $form_key );
|
109 |
-
|
110 |
-
//flattan radio
|
111 |
-
if ( is_array( $value ) ) {
|
112 |
-
$value = reset( $value );
|
113 |
-
}
|
114 |
-
}
|
115 |
-
|
116 |
-
//set defaults
|
117 |
-
|
118 |
-
if ( ! $value ) {
|
119 |
-
if ( isset( $this->defaults[ $form_key ] ) ) {
|
120 |
-
if ( is_array( $this->defaults[ $form_key ] ) ) {
|
121 |
-
$value = array();
|
122 |
-
|
123 |
-
foreach ( $this->defaults[ $form_key ] as $key => $sub_value ) {
|
124 |
-
if ( isset( $this->functions[ $key ] ) && $this->functions[ $key ] ) {
|
125 |
-
$sub_value = $this->run_function( $this->functions[ $key ], $sub_value );
|
126 |
-
}
|
127 |
-
|
128 |
-
if ( $sub_value ) {
|
129 |
-
$value[] = $sub_value;
|
130 |
-
}
|
131 |
-
|
132 |
-
$template = str_replace( "[{$key}]", $sub_value, $template );
|
133 |
-
}
|
134 |
-
|
135 |
-
$value = implode( ',', $value );
|
136 |
-
|
137 |
-
} else {
|
138 |
-
$value = $this->defaults[ $form_key ];
|
139 |
-
}
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
if ( isset( $this->functions[ $form_key ] ) && $this->functions[ $form_key ] ) {
|
144 |
-
|
145 |
-
//dont call the function again on arrays (checkvoxes)
|
146 |
-
|
147 |
-
if ( ! is_array( $this->functions[ $form_key ] ) ) {
|
148 |
-
$value = $this->run_function( $this->functions[ $form_key ], $value );
|
149 |
-
}
|
150 |
-
}
|
151 |
-
|
152 |
-
$value = trim( preg_replace( '/(\r\n)|\n|\r/', '\\n', $value ) );
|
153 |
-
$template = str_replace( "[{$form_key}]", $value, $template );
|
154 |
-
}
|
155 |
-
|
156 |
-
//replace special mail tags
|
157 |
-
|
158 |
-
foreach ( WPCF7R_Form::get_special_mail_tags() as $mail_tag ) {
|
159 |
-
$special = apply_filters( 'wpcf7_special_mail_tags', null, $mail_tag->field_name(), $template, $mail_tag );
|
160 |
-
$template = str_replace( "[{$mail_tag->field_name()}]", $special, $template );
|
161 |
-
}
|
162 |
-
|
163 |
-
//clean unchanged tags
|
164 |
-
|
165 |
-
$template = $this->replace_tags( $template );
|
166 |
-
$record['fields'] = $template;
|
167 |
-
|
168 |
-
} else {
|
169 |
-
$record = $this->get_record_by_tag_map( $submited_data, $tags_map );
|
170 |
-
$record = $this->set_defaults_and_run_functions( $record, $tags_map );
|
171 |
-
}
|
172 |
-
|
173 |
-
$record = apply_filters( 'cf7api_create_record', $record, $submited_data, $tags_map, $type, $template );
|
174 |
-
|
175 |
-
return $record;
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Create a record object
|
180 |
-
*
|
181 |
-
* @param $submited_data
|
182 |
-
* @param $tags_map
|
183 |
-
*/
|
184 |
-
public function get_record_by_tag_map( $submited_data, $tags_map ) {
|
185 |
-
|
186 |
-
$record = array();
|
187 |
-
|
188 |
-
foreach ( $tags_map as $form_key => $qs_cf7_form_key ) {
|
189 |
-
if ( $qs_cf7_form_key ) {
|
190 |
-
if ( is_array( $qs_cf7_form_key ) ) {
|
191 |
-
|
192 |
-
//arrange checkbox arrays
|
193 |
-
foreach ( $submited_data[ $form_key ] as $value ) {
|
194 |
-
if ( $value ) {
|
195 |
-
if ( 'lead_id' === $form_key ) {
|
196 |
-
$record['fields'][ $qs_cf7_form_key[ $value ] ] = apply_filters( 'set_record_value', self::get_lead_id(), $qs_cf7_form_key );
|
197 |
-
} else {
|
198 |
-
$record['fields'][ $qs_cf7_form_key[ $value ] ] = apply_filters( 'set_record_value', $value, $qs_cf7_form_key );
|
199 |
-
}
|
200 |
-
}
|
201 |
-
}
|
202 |
-
} else {
|
203 |
-
$value = isset( $submited_data[ $form_key ] ) ? $submited_data[ $form_key ] : '';
|
204 |
-
|
205 |
-
//flattan radio
|
206 |
-
if ( is_array( $value ) && count( $value ) === 1 ) {
|
207 |
-
$value = reset( $value );
|
208 |
-
}
|
209 |
-
|
210 |
-
if ( 'lead_id' === $form_key ) {
|
211 |
-
$record['fields'][ $qs_cf7_form_key ] = apply_filters( 'set_record_value', self::get_lead_id(), $qs_cf7_form_key );
|
212 |
-
} else {
|
213 |
-
$record['fields'][ $qs_cf7_form_key ] = apply_filters( 'set_record_value', $value, $qs_cf7_form_key );
|
214 |
-
}
|
215 |
-
}
|
216 |
-
}
|
217 |
-
}
|
218 |
-
|
219 |
-
return $record;
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Set the fields defaults
|
224 |
-
*/
|
225 |
-
public function set_defaults_and_run_functions( $record, $tags_map ) {
|
226 |
-
|
227 |
-
//set default values
|
228 |
-
|
229 |
-
if ( $this->defaults && array_values( $this->defaults ) ) {
|
230 |
-
foreach ( $this->defaults as $default_field_key => $default_value ) {
|
231 |
-
if ( $default_value ) {
|
232 |
-
$api_key = $tags_map[ $default_field_key ];
|
233 |
-
$record['fields'][ $api_key ] = isset( $record['fields'][ $api_key ] ) && $record['fields'][ $api_key ] ? $record['fields'][ $api_key ] : $default_value;
|
234 |
-
}
|
235 |
-
}
|
236 |
-
}
|
237 |
-
|
238 |
-
//run functions on values
|
239 |
-
|
240 |
-
if ( $this->functions && array_values( $this->functions ) ) {
|
241 |
-
foreach ( $this->functions as $field_key => $function ) {
|
242 |
-
$api_key = $tags_map[ $field_key ];
|
243 |
-
$field_value = $record['fields'][ $api_key ];
|
244 |
-
|
245 |
-
if ( $function && $field_value ) {
|
246 |
-
$record['fields'][ $api_key ] = $this->run_function( $function, $field_value );
|
247 |
-
}
|
248 |
-
}
|
249 |
-
}
|
250 |
-
|
251 |
-
return $record;
|
252 |
-
}
|
253 |
-
|
254 |
-
/**
|
255 |
-
* Run custom functions on user submission
|
256 |
-
*
|
257 |
-
* @param $function
|
258 |
-
* @param $field_value
|
259 |
-
*/
|
260 |
-
public function run_function( $function, $field_value ) {
|
261 |
-
|
262 |
-
$function = WPCF7r_Utils::get_available_text_functions( $function, 'all' );
|
263 |
-
|
264 |
-
if ( $function ) {
|
265 |
-
$class = $function[0];
|
266 |
-
$method = $function[1];
|
267 |
-
|
268 |
-
return call_user_func( array( $class, $method ), $field_value );
|
269 |
-
}
|
270 |
-
|
271 |
-
return $field_value;
|
272 |
-
}
|
273 |
-
|
274 |
-
/**
|
275 |
-
* Send the lead using wp_remote
|
276 |
-
*
|
277 |
-
* @param $record
|
278 |
-
* @param boolean $debug
|
279 |
-
* @param string $method
|
280 |
-
* @param string $record_type
|
281 |
-
*/
|
282 |
-
private function send_lead( $record, $debug = false, $method = 'GET', $record_type = 'params' ) {
|
283 |
-
|
284 |
-
global $wp_version;
|
285 |
-
|
286 |
-
$lead = $record['fields'];
|
287 |
-
$url = $record['url'];
|
288 |
-
|
289 |
-
if ( ( 'get' === $method || 'GET' === $method ) && ( 'params' === $record_type || 'json' === $record_type ) ) {
|
290 |
-
$args = array(
|
291 |
-
'timeout' => 100,
|
292 |
-
'redirection' => 5,
|
293 |
-
'httpversion' => '1.0',
|
294 |
-
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url(),
|
295 |
-
'blocking' => true,
|
296 |
-
'headers' => $this->headers,
|
297 |
-
'cookies' => array(),
|
298 |
-
'body' => null,
|
299 |
-
'compress' => false,
|
300 |
-
'decompress' => true,
|
301 |
-
'sslverify' => true,
|
302 |
-
'stream' => false,
|
303 |
-
'filename' => null,
|
304 |
-
);
|
305 |
-
|
306 |
-
if ( 'xml' === $record_type ) {
|
307 |
-
$xml = $this->get_xml( $lead );
|
308 |
-
if ( is_wp_error( $xml ) ) {
|
309 |
-
return $xml;
|
310 |
-
}
|
311 |
-
|
312 |
-
$args['body'] = $xml->asXML();
|
313 |
-
} elseif ( 'json' === $record_type ) {
|
314 |
-
$json = wp_json_encode( $lead );
|
315 |
-
if ( is_wp_error( $json ) ) {
|
316 |
-
return $json;
|
317 |
-
} else {
|
318 |
-
$args['body'] = $json;
|
319 |
-
}
|
320 |
-
} else {
|
321 |
-
$lead_string = http_build_query( $lead );
|
322 |
-
$url = strpos( '?', $url ) ? $url . '&' . $lead_string : $url . '?' . $lead_string;
|
323 |
-
}
|
324 |
-
|
325 |
-
$args = apply_filters( 'qs_cf7_api_get_args', $args );
|
326 |
-
$url = apply_filters( 'qs_cf7_api_get_url', $url, $record );
|
327 |
-
$url = $this->replace_tags( $url );
|
328 |
-
|
329 |
-
$result = wp_remote_get( $url, $args );
|
330 |
-
} else {
|
331 |
-
$args = array(
|
332 |
-
'timeout' => 100,
|
333 |
-
'redirection' => 5,
|
334 |
-
'method' => strtoupper( $method ),
|
335 |
-
'httpversion' => '1.0',
|
336 |
-
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url(),
|
337 |
-
'blocking' => true,
|
338 |
-
'headers' => $this->headers,
|
339 |
-
'cookies' => array(),
|
340 |
-
'body' => $lead,
|
341 |
-
'compress' => false,
|
342 |
-
'decompress' => true,
|
343 |
-
'sslverify' => true,
|
344 |
-
'stream' => false,
|
345 |
-
'filename' => null,
|
346 |
-
);
|
347 |
-
|
348 |
-
if ( 'xml' === $record_type ) {
|
349 |
-
$xml = $this->get_xml( $lead );
|
350 |
-
|
351 |
-
if ( is_wp_error( $xml ) ) {
|
352 |
-
return $xml;
|
353 |
-
}
|
354 |
-
|
355 |
-
$args['body'] = $xml->asXML();
|
356 |
-
} elseif ( 'json' === $record_type ) {
|
357 |
-
$json = wp_json_encode( json_decode( $lead ) );
|
358 |
-
if ( is_wp_error( $json ) ) {
|
359 |
-
return $json;
|
360 |
-
} else {
|
361 |
-
$args['body'] = $json;
|
362 |
-
}
|
363 |
-
}
|
364 |
-
|
365 |
-
$args = apply_filters( 'qs_cf7_api_get_args', $args );
|
366 |
-
$url = apply_filters( 'qs_cf7_api_post_url', $url );
|
367 |
-
$url = $this->replace_tags( $url );
|
368 |
-
|
369 |
-
$result = wp_remote_request( $url, $args );
|
370 |
-
}
|
371 |
-
|
372 |
-
$this->log_result( $args, $result );
|
373 |
-
|
374 |
-
do_action( 'after_qs_cf7_api_send_lead', $result, $record, $args );
|
375 |
-
|
376 |
-
if ( ! is_wp_error( $result ) ) {
|
377 |
-
$results['response_raw'] = $result;
|
378 |
-
$results['response'] = wp_remote_retrieve_body( $result );
|
379 |
-
}
|
380 |
-
|
381 |
-
return $result;
|
382 |
-
}
|
383 |
-
|
384 |
-
/**
|
385 |
-
* Get XML
|
386 |
-
*
|
387 |
-
* @param $lead
|
388 |
-
*/
|
389 |
-
private function get_xml( $lead ) {
|
390 |
-
|
391 |
-
$xml = '';
|
392 |
-
|
393 |
-
if ( function_exists( 'simplexml_load_string' ) ) {
|
394 |
-
libxml_use_internal_errors( true );
|
395 |
-
$xml = simplexml_load_string( $lead );
|
396 |
-
|
397 |
-
if ( false === $xml ) {
|
398 |
-
$xml = new WP_Error(
|
399 |
-
'xml',
|
400 |
-
__( 'XML Structure is incorrect', 'wpcf7-redirect' )
|
401 |
-
);
|
402 |
-
|
403 |
-
}
|
404 |
-
}
|
405 |
-
|
406 |
-
return $xml;
|
407 |
-
}
|
408 |
-
}
|
409 |
-
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Action_api_url_request file
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
class WPCF7R_Action_Send_To_Api extends WPCF7R_Action {
|
9 |
+
|
10 |
+
public function __construct( $post ) {
|
11 |
+
$this->action_id = $post->ID;
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* The handler that will send the data to the api
|
16 |
+
*
|
17 |
+
* @param $args
|
18 |
+
*/
|
19 |
+
public function qs_cf7_send_data_to_api( $args ) {
|
20 |
+
$this->defaults = $args['tags_defaults'];
|
21 |
+
$this->functions = $args['tags_functions'];
|
22 |
+
$this->headers = $args['api_headers'];
|
23 |
+
$this->headers = array_filter( $this->headers );
|
24 |
+
|
25 |
+
$tags_map = $args['tags'];
|
26 |
+
$record_type = $args['record_type'];
|
27 |
+
$input_type = $args['input_type'];
|
28 |
+
$base_url = $args['base_url'];
|
29 |
+
$submission = isset( $args['submission'] ) ? $args['submission'] : '';
|
30 |
+
$template = $args['request_template'];
|
31 |
+
|
32 |
+
if ( 'xml' === $record_type ) {
|
33 |
+
$this->headers['Content-Type'] = 'text/xml';
|
34 |
+
} elseif ( 'json' === $record_type ) {
|
35 |
+
$this->headers['Content-Type'] = 'application/json';
|
36 |
+
}
|
37 |
+
|
38 |
+
$submission = WPCF7_Submission::get_instance();
|
39 |
+
$wpcf7 = $submission->get_contact_form();
|
40 |
+
|
41 |
+
$this->post = $wpcf7;
|
42 |
+
$this->clear_error_log( $this->post->id() );
|
43 |
+
|
44 |
+
$submission_url = $submission->get_meta( 'url' );
|
45 |
+
|
46 |
+
//always save last call results for debugging
|
47 |
+
|
48 |
+
$record = $this->get_record( $submission, $tags_map, $record_type, $template );
|
49 |
+
$record['url'] = $base_url;
|
50 |
+
|
51 |
+
if ( isset( $record['url'] ) && $record['url'] ) {
|
52 |
+
do_action( 'qs_cf7_api_before_sent_to_api', $record );
|
53 |
+
$response = $this->send_lead( $record, true, $input_type, $record_type, $tags_map );
|
54 |
+
do_action( 'qs_cf7_api_after_sent_to_api', $record, $response );
|
55 |
+
|
56 |
+
} else {
|
57 |
+
$this->log_result( __( 'Missing url' ), '' );
|
58 |
+
}
|
59 |
+
|
60 |
+
return array( $response, $record );
|
61 |
+
}
|
62 |
+
|
63 |
+
public function log_result( $record, $response ) {
|
64 |
+
if ( isset( $record['url'] ) ) {
|
65 |
+
update_post_meta( $this->action_id, 'api_debug_url', $record['url'] );
|
66 |
+
}
|
67 |
+
|
68 |
+
if ( is_wp_error( $response ) || is_wp_error( $record ) ) {
|
69 |
+
update_post_meta( $this->action_id, 'api_debug_result', $response );
|
70 |
+
update_post_meta( $this->action_id, 'api_debug_params', $record );
|
71 |
+
} else {
|
72 |
+
update_post_meta( $this->action_id, 'api_debug_params', $record );
|
73 |
+
update_post_meta( $this->action_id, 'api_debug_result', $response );
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Clear error log
|
79 |
+
*/
|
80 |
+
function clear_error_log( $post_id ) {
|
81 |
+
delete_post_meta( $post_id, 'api_errors' );
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Convert the form keys to the API keys according to the mapping instructions
|
86 |
+
*
|
87 |
+
* @param $submission
|
88 |
+
* @param $tags_map
|
89 |
+
* @param string $type
|
90 |
+
* @param string $template
|
91 |
+
*/
|
92 |
+
function get_record( $submission, $tags_map, $type = 'params', $template = '' ) {
|
93 |
+
$submited_data = $submission->get_posted_data();
|
94 |
+
|
95 |
+
if ( 'xml' === $type || 'json' === $type ) {
|
96 |
+
$template = $this->replace_lead_id_tag( $template );
|
97 |
+
|
98 |
+
foreach ( $tags_map as $form_key => $qs_cf7_form_key ) {
|
99 |
+
if ( is_array( $qs_cf7_form_key ) ) {
|
100 |
+
|
101 |
+
//arrange checkbox arrays
|
102 |
+
if ( isset( $submited_data[ $form_key ] ) ) {
|
103 |
+
$value = apply_filters( 'set_record_value', $submited_data[ $form_key ], $qs_cf7_form_key, $form_key );
|
104 |
+
$value = is_array( $value ) ? implode( ',', $value ) : $value;
|
105 |
+
}
|
106 |
+
} else {
|
107 |
+
$value = isset( $submited_data[ $form_key ] ) ? $submited_data[ $form_key ] : '';
|
108 |
+
$value = apply_filters( 'set_record_value', $value, $qs_cf7_form_key, $form_key );
|
109 |
+
|
110 |
+
//flattan radio
|
111 |
+
if ( is_array( $value ) ) {
|
112 |
+
$value = reset( $value );
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
//set defaults
|
117 |
+
|
118 |
+
if ( ! $value ) {
|
119 |
+
if ( isset( $this->defaults[ $form_key ] ) ) {
|
120 |
+
if ( is_array( $this->defaults[ $form_key ] ) ) {
|
121 |
+
$value = array();
|
122 |
+
|
123 |
+
foreach ( $this->defaults[ $form_key ] as $key => $sub_value ) {
|
124 |
+
if ( isset( $this->functions[ $key ] ) && $this->functions[ $key ] ) {
|
125 |
+
$sub_value = $this->run_function( $this->functions[ $key ], $sub_value );
|
126 |
+
}
|
127 |
+
|
128 |
+
if ( $sub_value ) {
|
129 |
+
$value[] = $sub_value;
|
130 |
+
}
|
131 |
+
|
132 |
+
$template = str_replace( "[{$key}]", $sub_value, $template );
|
133 |
+
}
|
134 |
+
|
135 |
+
$value = implode( ',', $value );
|
136 |
+
|
137 |
+
} else {
|
138 |
+
$value = $this->defaults[ $form_key ];
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
if ( isset( $this->functions[ $form_key ] ) && $this->functions[ $form_key ] ) {
|
144 |
+
|
145 |
+
//dont call the function again on arrays (checkvoxes)
|
146 |
+
|
147 |
+
if ( ! is_array( $this->functions[ $form_key ] ) ) {
|
148 |
+
$value = $this->run_function( $this->functions[ $form_key ], $value );
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
$value = trim( preg_replace( '/(\r\n)|\n|\r/', '\\n', $value ) );
|
153 |
+
$template = str_replace( "[{$form_key}]", $value, $template );
|
154 |
+
}
|
155 |
+
|
156 |
+
//replace special mail tags
|
157 |
+
|
158 |
+
foreach ( WPCF7R_Form::get_special_mail_tags() as $mail_tag ) {
|
159 |
+
$special = apply_filters( 'wpcf7_special_mail_tags', null, $mail_tag->field_name(), $template, $mail_tag );
|
160 |
+
$template = str_replace( "[{$mail_tag->field_name()}]", $special, $template );
|
161 |
+
}
|
162 |
+
|
163 |
+
//clean unchanged tags
|
164 |
+
|
165 |
+
$template = $this->replace_tags( $template );
|
166 |
+
$record['fields'] = $template;
|
167 |
+
|
168 |
+
} else {
|
169 |
+
$record = $this->get_record_by_tag_map( $submited_data, $tags_map );
|
170 |
+
$record = $this->set_defaults_and_run_functions( $record, $tags_map );
|
171 |
+
}
|
172 |
+
|
173 |
+
$record = apply_filters( 'cf7api_create_record', $record, $submited_data, $tags_map, $type, $template );
|
174 |
+
|
175 |
+
return $record;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Create a record object
|
180 |
+
*
|
181 |
+
* @param $submited_data
|
182 |
+
* @param $tags_map
|
183 |
+
*/
|
184 |
+
public function get_record_by_tag_map( $submited_data, $tags_map ) {
|
185 |
+
|
186 |
+
$record = array();
|
187 |
+
|
188 |
+
foreach ( $tags_map as $form_key => $qs_cf7_form_key ) {
|
189 |
+
if ( $qs_cf7_form_key ) {
|
190 |
+
if ( is_array( $qs_cf7_form_key ) ) {
|
191 |
+
|
192 |
+
//arrange checkbox arrays
|
193 |
+
foreach ( $submited_data[ $form_key ] as $value ) {
|
194 |
+
if ( $value ) {
|
195 |
+
if ( 'lead_id' === $form_key ) {
|
196 |
+
$record['fields'][ $qs_cf7_form_key[ $value ] ] = apply_filters( 'set_record_value', self::get_lead_id(), $qs_cf7_form_key );
|
197 |
+
} else {
|
198 |
+
$record['fields'][ $qs_cf7_form_key[ $value ] ] = apply_filters( 'set_record_value', $value, $qs_cf7_form_key );
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
} else {
|
203 |
+
$value = isset( $submited_data[ $form_key ] ) ? $submited_data[ $form_key ] : '';
|
204 |
+
|
205 |
+
//flattan radio
|
206 |
+
if ( is_array( $value ) && count( $value ) === 1 ) {
|
207 |
+
$value = reset( $value );
|
208 |
+
}
|
209 |
+
|
210 |
+
if ( 'lead_id' === $form_key ) {
|
211 |
+
$record['fields'][ $qs_cf7_form_key ] = apply_filters( 'set_record_value', self::get_lead_id(), $qs_cf7_form_key );
|
212 |
+
} else {
|
213 |
+
$record['fields'][ $qs_cf7_form_key ] = apply_filters( 'set_record_value', $value, $qs_cf7_form_key );
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
return $record;
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Set the fields defaults
|
224 |
+
*/
|
225 |
+
public function set_defaults_and_run_functions( $record, $tags_map ) {
|
226 |
+
|
227 |
+
//set default values
|
228 |
+
|
229 |
+
if ( $this->defaults && array_values( $this->defaults ) ) {
|
230 |
+
foreach ( $this->defaults as $default_field_key => $default_value ) {
|
231 |
+
if ( $default_value ) {
|
232 |
+
$api_key = $tags_map[ $default_field_key ];
|
233 |
+
$record['fields'][ $api_key ] = isset( $record['fields'][ $api_key ] ) && $record['fields'][ $api_key ] ? $record['fields'][ $api_key ] : $default_value;
|
234 |
+
}
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
//run functions on values
|
239 |
+
|
240 |
+
if ( $this->functions && array_values( $this->functions ) ) {
|
241 |
+
foreach ( $this->functions as $field_key => $function ) {
|
242 |
+
$api_key = $tags_map[ $field_key ];
|
243 |
+
$field_value = $record['fields'][ $api_key ];
|
244 |
+
|
245 |
+
if ( $function && $field_value ) {
|
246 |
+
$record['fields'][ $api_key ] = $this->run_function( $function, $field_value );
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
return $record;
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Run custom functions on user submission
|
256 |
+
*
|
257 |
+
* @param $function
|
258 |
+
* @param $field_value
|
259 |
+
*/
|
260 |
+
public function run_function( $function, $field_value ) {
|
261 |
+
|
262 |
+
$function = WPCF7r_Utils::get_available_text_functions( $function, 'all' );
|
263 |
+
|
264 |
+
if ( $function ) {
|
265 |
+
$class = $function[0];
|
266 |
+
$method = $function[1];
|
267 |
+
|
268 |
+
return call_user_func( array( $class, $method ), $field_value );
|
269 |
+
}
|
270 |
+
|
271 |
+
return $field_value;
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Send the lead using wp_remote
|
276 |
+
*
|
277 |
+
* @param $record
|
278 |
+
* @param boolean $debug
|
279 |
+
* @param string $method
|
280 |
+
* @param string $record_type
|
281 |
+
*/
|
282 |
+
private function send_lead( $record, $debug = false, $method = 'GET', $record_type = 'params' ) {
|
283 |
+
|
284 |
+
global $wp_version;
|
285 |
+
|
286 |
+
$lead = $record['fields'];
|
287 |
+
$url = $record['url'];
|
288 |
+
|
289 |
+
if ( ( 'get' === $method || 'GET' === $method ) && ( 'params' === $record_type || 'json' === $record_type ) ) {
|
290 |
+
$args = array(
|
291 |
+
'timeout' => 100,
|
292 |
+
'redirection' => 5,
|
293 |
+
'httpversion' => '1.0',
|
294 |
+
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url(),
|
295 |
+
'blocking' => true,
|
296 |
+
'headers' => $this->headers,
|
297 |
+
'cookies' => array(),
|
298 |
+
'body' => null,
|
299 |
+
'compress' => false,
|
300 |
+
'decompress' => true,
|
301 |
+
'sslverify' => true,
|
302 |
+
'stream' => false,
|
303 |
+
'filename' => null,
|
304 |
+
);
|
305 |
+
|
306 |
+
if ( 'xml' === $record_type ) {
|
307 |
+
$xml = $this->get_xml( $lead );
|
308 |
+
if ( is_wp_error( $xml ) ) {
|
309 |
+
return $xml;
|
310 |
+
}
|
311 |
+
|
312 |
+
$args['body'] = $xml->asXML();
|
313 |
+
} elseif ( 'json' === $record_type ) {
|
314 |
+
$json = wp_json_encode( $lead );
|
315 |
+
if ( is_wp_error( $json ) ) {
|
316 |
+
return $json;
|
317 |
+
} else {
|
318 |
+
$args['body'] = $json;
|
319 |
+
}
|
320 |
+
} else {
|
321 |
+
$lead_string = http_build_query( $lead );
|
322 |
+
$url = strpos( '?', $url ) ? $url . '&' . $lead_string : $url . '?' . $lead_string;
|
323 |
+
}
|
324 |
+
|
325 |
+
$args = apply_filters( 'qs_cf7_api_get_args', $args );
|
326 |
+
$url = apply_filters( 'qs_cf7_api_get_url', $url, $record );
|
327 |
+
$url = $this->replace_tags( $url );
|
328 |
+
|
329 |
+
$result = wp_remote_get( $url, $args );
|
330 |
+
} else {
|
331 |
+
$args = array(
|
332 |
+
'timeout' => 100,
|
333 |
+
'redirection' => 5,
|
334 |
+
'method' => strtoupper( $method ),
|
335 |
+
'httpversion' => '1.0',
|
336 |
+
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url(),
|
337 |
+
'blocking' => true,
|
338 |
+
'headers' => $this->headers,
|
339 |
+
'cookies' => array(),
|
340 |
+
'body' => $lead,
|
341 |
+
'compress' => false,
|
342 |
+
'decompress' => true,
|
343 |
+
'sslverify' => true,
|
344 |
+
'stream' => false,
|
345 |
+
'filename' => null,
|
346 |
+
);
|
347 |
+
|
348 |
+
if ( 'xml' === $record_type ) {
|
349 |
+
$xml = $this->get_xml( $lead );
|
350 |
+
|
351 |
+
if ( is_wp_error( $xml ) ) {
|
352 |
+
return $xml;
|
353 |
+
}
|
354 |
+
|
355 |
+
$args['body'] = $xml->asXML();
|
356 |
+
} elseif ( 'json' === $record_type ) {
|
357 |
+
$json = wp_json_encode( json_decode( $lead ) );
|
358 |
+
if ( is_wp_error( $json ) ) {
|
359 |
+
return $json;
|
360 |
+
} else {
|
361 |
+
$args['body'] = $json;
|
362 |
+
}
|
363 |
+
}
|
364 |
+
|
365 |
+
$args = apply_filters( 'qs_cf7_api_get_args', $args );
|
366 |
+
$url = apply_filters( 'qs_cf7_api_post_url', $url );
|
367 |
+
$url = $this->replace_tags( $url );
|
368 |
+
|
369 |
+
$result = wp_remote_request( $url, $args );
|
370 |
+
}
|
371 |
+
|
372 |
+
$this->log_result( $args, $result );
|
373 |
+
|
374 |
+
do_action( 'after_qs_cf7_api_send_lead', $result, $record, $args );
|
375 |
+
|
376 |
+
if ( ! is_wp_error( $result ) ) {
|
377 |
+
$results['response_raw'] = $result;
|
378 |
+
$results['response'] = wp_remote_retrieve_body( $result );
|
379 |
+
}
|
380 |
+
|
381 |
+
return $result;
|
382 |
+
}
|
383 |
+
|
384 |
+
/**
|
385 |
+
* Get XML
|
386 |
+
*
|
387 |
+
* @param $lead
|
388 |
+
*/
|
389 |
+
private function get_xml( $lead ) {
|
390 |
+
|
391 |
+
$xml = '';
|
392 |
+
|
393 |
+
if ( function_exists( 'simplexml_load_string' ) ) {
|
394 |
+
libxml_use_internal_errors( true );
|
395 |
+
$xml = simplexml_load_string( $lead );
|
396 |
+
|
397 |
+
if ( false === $xml ) {
|
398 |
+
$xml = new WP_Error(
|
399 |
+
'xml',
|
400 |
+
__( 'XML Structure is incorrect', 'wpcf7-redirect' )
|
401 |
+
);
|
402 |
+
|
403 |
+
}
|
404 |
+
}
|
405 |
+
|
406 |
+
return $xml;
|
407 |
+
}
|
408 |
+
}
|
409 |
+
|
classes/actions/class-wpcf7r-action-sendmail.php
CHANGED
@@ -1,197 +1,197 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Action_SendMail file - handles send mail action
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
register_wpcf7r_actions(
|
9 |
-
'SendMail',
|
10 |
-
__( 'Send Email', 'wpcf7-redirect' ),
|
11 |
-
'WPCF7R_Action_SendMail',
|
12 |
-
4
|
13 |
-
);
|
14 |
-
|
15 |
-
class WPCF7R_Action_SendMail extends WPCF7R_Action {
|
16 |
-
public function __construct( $post ) {
|
17 |
-
parent::__construct( $post );
|
18 |
-
}
|
19 |
-
/**
|
20 |
-
* Get the fields relevant for this action
|
21 |
-
*/
|
22 |
-
public function get_action_fields() {
|
23 |
-
$parent_fields = parent::get_default_fields();
|
24 |
-
|
25 |
-
unset( $parent_fields['action_status'] );
|
26 |
-
|
27 |
-
$fields = array_merge(
|
28 |
-
array(
|
29 |
-
'send_to_emails_values' => array(
|
30 |
-
'name' => 'send_to_emails_values',
|
31 |
-
'type' => 'text',
|
32 |
-
'label' => __( 'To:', 'wpcf7-redirect' ),
|
33 |
-
'placeholder' => __( 'Email addresses seperated by comma (,)', 'wpcf7-redirect' ),
|
34 |
-
'value' => $this->get( 'send_to_emails_values' ),
|
35 |
-
),
|
36 |
-
'email_sender' => array(
|
37 |
-
'name' => 'email_sender',
|
38 |
-
'type' => 'text',
|
39 |
-
'label' => __( 'From:', 'wpcf7-redirect' ),
|
40 |
-
'placeholder' => __( 'name <address>', 'wpcf7-redirect' ),
|
41 |
-
'value' => $this->get( 'email_sender' ),
|
42 |
-
),
|
43 |
-
'email_subject' => array(
|
44 |
-
'name' => 'email_subject',
|
45 |
-
'type' => 'text',
|
46 |
-
'label' => __( 'Subject:', 'wpcf7-redirect' ),
|
47 |
-
'value' => $this->get( 'email_subject' ),
|
48 |
-
),
|
49 |
-
'email_format' => array(
|
50 |
-
'name' => 'email_format',
|
51 |
-
'type' => 'editor',
|
52 |
-
'label' => __( 'Email Format (use the same structure used on Contact Form 7)', 'wpcf7-redirect' ),
|
53 |
-
'footer' => $this->get_formatted_mail_tags(),
|
54 |
-
'value' => $this->get( 'email_format' ),
|
55 |
-
),
|
56 |
-
'email_attachments' => array(
|
57 |
-
'name' => 'email_attachments',
|
58 |
-
'type' => 'text',
|
59 |
-
'label' => __( 'Add your form attachments shortcodes here', 'wpcf7-redirect' ),
|
60 |
-
'value' => $this->get( 'email_attachments' ),
|
61 |
-
),
|
62 |
-
'plain_text' => array(
|
63 |
-
'name' => 'plain_text',
|
64 |
-
'type' => 'checkbox',
|
65 |
-
'label' => __( 'Use plain text email', 'wpcf7-redirect' ),
|
66 |
-
'placeholder' => '',
|
67 |
-
'show_selector' => '.field-wrap-plain_text',
|
68 |
-
'value' => $this->get( 'plain_text' ),
|
69 |
-
),
|
70 |
-
// 'disable_cf7_mail' => array(
|
71 |
-
// 'name' => 'disable_cf7_mail',
|
72 |
-
// 'type' => 'checkbox',
|
73 |
-
// 'label' => __( 'Disable contact form 7 default email', 'wpcf7-redirect' ),
|
74 |
-
// 'placeholder' => '',
|
75 |
-
// 'value' => $this->get( 'disable_cf7_mail' ),
|
76 |
-
// ),
|
77 |
-
'action_status' => array(
|
78 |
-
'name' => 'action_status',
|
79 |
-
'type' => 'checkbox',
|
80 |
-
'label' => $this->get_action_status_label(),
|
81 |
-
'sub_title' => __( 'if this is off the rule will not be applied', 'wpcf7-redirect' ),
|
82 |
-
'placeholder' => '',
|
83 |
-
'show_selector' => '.field-wrap-disable_default_email',
|
84 |
-
'toggle-label' => json_encode(
|
85 |
-
array(
|
86 |
-
'.field-wrap-action_status .checkbox-label,.column-status a' => array(
|
87 |
-
__( 'Enabled', 'wpcf7-redirect' ),
|
88 |
-
__( 'Disabled', 'wpcf7-redirect' ),
|
89 |
-
),
|
90 |
-
)
|
91 |
-
),
|
92 |
-
'value' => $this->get( 'action_status' ),
|
93 |
-
),
|
94 |
-
'disable_default_email' => array(
|
95 |
-
'name' => 'disable_default_email',
|
96 |
-
'type' => 'notice',
|
97 |
-
'label' => '<strong>' . __( 'Notice!', 'wpcf7-redirect' ) . '</strong>',
|
98 |
-
'sub_title' => __( 'When email action is enabled the default Contact Form 7 mailing feature will be disabled.', 'wpcf7-redirect' ),
|
99 |
-
'placeholder' => '',
|
100 |
-
'class' => $this->get( 'action_status' ) ? 'field-notice-alert' : 'field-hidden field-notice-alert',
|
101 |
-
'show_selector' => '',
|
102 |
-
),
|
103 |
-
),
|
104 |
-
$parent_fields
|
105 |
-
);
|
106 |
-
return $fields;
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Get settings page
|
111 |
-
*/
|
112 |
-
public function get_action_settings() {
|
113 |
-
$this->get_settings_template( 'html-action-send-to-email.php' );
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Handle a simple redirect rule
|
118 |
-
*
|
119 |
-
* @param $rules
|
120 |
-
* @param $response
|
121 |
-
*/
|
122 |
-
public function process( $submission ) {
|
123 |
-
$response = array();
|
124 |
-
$email_to = $this->get( 'send_to_emails_values' );
|
125 |
-
$email_sender = $this->get( 'email_sender' );
|
126 |
-
$email_format = $this->get( 'email_format' );
|
127 |
-
$email_subject = $this->get( 'email_subject' );
|
128 |
-
$email_attachments = $this->get( 'email_attachments' );
|
129 |
-
$plain_text = $this->get( 'plain_text' );
|
130 |
-
|
131 |
-
// set the email address to recipient
|
132 |
-
$mail_settings = $this->cf7r_form->cf7_post->get_properties( 'mail' );
|
133 |
-
|
134 |
-
if ( $email_to ) {
|
135 |
-
$mail_settings['mail']['recipient'] = $email_to;
|
136 |
-
}
|
137 |
-
|
138 |
-
if ( $email_sender ) {
|
139 |
-
$mail_settings['mail']['sender'] = $email_sender;
|
140 |
-
}
|
141 |
-
|
142 |
-
if ( $email_format ) {
|
143 |
-
$mail_settings['mail']['body'] = $email_format;
|
144 |
-
}
|
145 |
-
|
146 |
-
if ( $email_subject ) {
|
147 |
-
$mail_settings['mail']['subject'] = $email_subject;
|
148 |
-
}
|
149 |
-
|
150 |
-
if ( $email_attachments ) {
|
151 |
-
|
152 |
-
$mail_settings['mail']['attachments'] = $email_attachments;
|
153 |
-
|
154 |
-
//add pdfs
|
155 |
-
do_shortcode( $email_attachments );
|
156 |
-
}
|
157 |
-
|
158 |
-
$mail_settings['mail']['use_html'] = ! $plain_text;
|
159 |
-
|
160 |
-
$result = $this->send_mail( $mail_settings['mail'] );
|
161 |
-
|
162 |
-
return $result;
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Add pdf as attachment to email
|
167 |
-
*
|
168 |
-
* @return void
|
169 |
-
*/
|
170 |
-
public function add_pdf_to_email() {
|
171 |
-
|
172 |
-
}
|
173 |
-
/**
|
174 |
-
* Maybe perform actions before sending results to the user
|
175 |
-
*/
|
176 |
-
public function maybe_perform_pre_result_action() {
|
177 |
-
if ( $this->get( 'disable_cf7_mail' ) ) {
|
178 |
-
add_filter( 'wpcf7_skip_mail', '__return_false' );
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
|
183 |
-
/**
|
184 |
-
* Use contact form 7 function to send the email
|
185 |
-
*
|
186 |
-
* @param $mail
|
187 |
-
*/
|
188 |
-
public function send_mail( $mail ) {
|
189 |
-
do_action( 'wpcf7r_before_send_mail', $mail );
|
190 |
-
|
191 |
-
$result = WPCF7_Mail::send( $mail, 'mail' );
|
192 |
-
|
193 |
-
do_action( 'wpcf7r_after_send_mail', $mail, $result );
|
194 |
-
|
195 |
-
return $result;
|
196 |
-
}
|
197 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Action_SendMail file - handles send mail action
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
register_wpcf7r_actions(
|
9 |
+
'SendMail',
|
10 |
+
__( 'Send Email', 'wpcf7-redirect' ),
|
11 |
+
'WPCF7R_Action_SendMail',
|
12 |
+
4
|
13 |
+
);
|
14 |
+
|
15 |
+
class WPCF7R_Action_SendMail extends WPCF7R_Action {
|
16 |
+
public function __construct( $post ) {
|
17 |
+
parent::__construct( $post );
|
18 |
+
}
|
19 |
+
/**
|
20 |
+
* Get the fields relevant for this action
|
21 |
+
*/
|
22 |
+
public function get_action_fields() {
|
23 |
+
$parent_fields = parent::get_default_fields();
|
24 |
+
|
25 |
+
unset( $parent_fields['action_status'] );
|
26 |
+
|
27 |
+
$fields = array_merge(
|
28 |
+
array(
|
29 |
+
'send_to_emails_values' => array(
|
30 |
+
'name' => 'send_to_emails_values',
|
31 |
+
'type' => 'text',
|
32 |
+
'label' => __( 'To:', 'wpcf7-redirect' ),
|
33 |
+
'placeholder' => __( 'Email addresses seperated by comma (,)', 'wpcf7-redirect' ),
|
34 |
+
'value' => $this->get( 'send_to_emails_values' ),
|
35 |
+
),
|
36 |
+
'email_sender' => array(
|
37 |
+
'name' => 'email_sender',
|
38 |
+
'type' => 'text',
|
39 |
+
'label' => __( 'From:', 'wpcf7-redirect' ),
|
40 |
+
'placeholder' => __( 'name <address>', 'wpcf7-redirect' ),
|
41 |
+
'value' => $this->get( 'email_sender' ),
|
42 |
+
),
|
43 |
+
'email_subject' => array(
|
44 |
+
'name' => 'email_subject',
|
45 |
+
'type' => 'text',
|
46 |
+
'label' => __( 'Subject:', 'wpcf7-redirect' ),
|
47 |
+
'value' => $this->get( 'email_subject' ),
|
48 |
+
),
|
49 |
+
'email_format' => array(
|
50 |
+
'name' => 'email_format',
|
51 |
+
'type' => 'editor',
|
52 |
+
'label' => __( 'Email Format (use the same structure used on Contact Form 7)', 'wpcf7-redirect' ),
|
53 |
+
'footer' => $this->get_formatted_mail_tags(),
|
54 |
+
'value' => $this->get( 'email_format' ),
|
55 |
+
),
|
56 |
+
'email_attachments' => array(
|
57 |
+
'name' => 'email_attachments',
|
58 |
+
'type' => 'text',
|
59 |
+
'label' => __( 'Add your form attachments shortcodes here', 'wpcf7-redirect' ),
|
60 |
+
'value' => $this->get( 'email_attachments' ),
|
61 |
+
),
|
62 |
+
'plain_text' => array(
|
63 |
+
'name' => 'plain_text',
|
64 |
+
'type' => 'checkbox',
|
65 |
+
'label' => __( 'Use plain text email', 'wpcf7-redirect' ),
|
66 |
+
'placeholder' => '',
|
67 |
+
'show_selector' => '.field-wrap-plain_text',
|
68 |
+
'value' => $this->get( 'plain_text' ),
|
69 |
+
),
|
70 |
+
// 'disable_cf7_mail' => array(
|
71 |
+
// 'name' => 'disable_cf7_mail',
|
72 |
+
// 'type' => 'checkbox',
|
73 |
+
// 'label' => __( 'Disable contact form 7 default email', 'wpcf7-redirect' ),
|
74 |
+
// 'placeholder' => '',
|
75 |
+
// 'value' => $this->get( 'disable_cf7_mail' ),
|
76 |
+
// ),
|
77 |
+
'action_status' => array(
|
78 |
+
'name' => 'action_status',
|
79 |
+
'type' => 'checkbox',
|
80 |
+
'label' => $this->get_action_status_label(),
|
81 |
+
'sub_title' => __( 'if this is off the rule will not be applied', 'wpcf7-redirect' ),
|
82 |
+
'placeholder' => '',
|
83 |
+
'show_selector' => '.field-wrap-disable_default_email',
|
84 |
+
'toggle-label' => json_encode(
|
85 |
+
array(
|
86 |
+
'.field-wrap-action_status .checkbox-label,.column-status a' => array(
|
87 |
+
__( 'Enabled', 'wpcf7-redirect' ),
|
88 |
+
__( 'Disabled', 'wpcf7-redirect' ),
|
89 |
+
),
|
90 |
+
)
|
91 |
+
),
|
92 |
+
'value' => $this->get( 'action_status' ),
|
93 |
+
),
|
94 |
+
'disable_default_email' => array(
|
95 |
+
'name' => 'disable_default_email',
|
96 |
+
'type' => 'notice',
|
97 |
+
'label' => '<strong>' . __( 'Notice!', 'wpcf7-redirect' ) . '</strong>',
|
98 |
+
'sub_title' => __( 'When email action is enabled the default Contact Form 7 mailing feature will be disabled.', 'wpcf7-redirect' ),
|
99 |
+
'placeholder' => '',
|
100 |
+
'class' => $this->get( 'action_status' ) ? 'field-notice-alert' : 'field-hidden field-notice-alert',
|
101 |
+
'show_selector' => '',
|
102 |
+
),
|
103 |
+
),
|
104 |
+
$parent_fields
|
105 |
+
);
|
106 |
+
return $fields;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Get settings page
|
111 |
+
*/
|
112 |
+
public function get_action_settings() {
|
113 |
+
$this->get_settings_template( 'html-action-send-to-email.php' );
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Handle a simple redirect rule
|
118 |
+
*
|
119 |
+
* @param $rules
|
120 |
+
* @param $response
|
121 |
+
*/
|
122 |
+
public function process( $submission ) {
|
123 |
+
$response = array();
|
124 |
+
$email_to = $this->get( 'send_to_emails_values' );
|
125 |
+
$email_sender = $this->get( 'email_sender' );
|
126 |
+
$email_format = $this->get( 'email_format' );
|
127 |
+
$email_subject = $this->get( 'email_subject' );
|
128 |
+
$email_attachments = $this->get( 'email_attachments' );
|
129 |
+
$plain_text = $this->get( 'plain_text' );
|
130 |
+
|
131 |
+
// set the email address to recipient
|
132 |
+
$mail_settings = $this->cf7r_form->cf7_post->get_properties( 'mail' );
|
133 |
+
|
134 |
+
if ( $email_to ) {
|
135 |
+
$mail_settings['mail']['recipient'] = $email_to;
|
136 |
+
}
|
137 |
+
|
138 |
+
if ( $email_sender ) {
|
139 |
+
$mail_settings['mail']['sender'] = $email_sender;
|
140 |
+
}
|
141 |
+
|
142 |
+
if ( $email_format ) {
|
143 |
+
$mail_settings['mail']['body'] = $email_format;
|
144 |
+
}
|
145 |
+
|
146 |
+
if ( $email_subject ) {
|
147 |
+
$mail_settings['mail']['subject'] = $email_subject;
|
148 |
+
}
|
149 |
+
|
150 |
+
if ( $email_attachments ) {
|
151 |
+
|
152 |
+
$mail_settings['mail']['attachments'] = $email_attachments;
|
153 |
+
|
154 |
+
//add pdfs
|
155 |
+
do_shortcode( $email_attachments );
|
156 |
+
}
|
157 |
+
|
158 |
+
$mail_settings['mail']['use_html'] = ! $plain_text;
|
159 |
+
|
160 |
+
$result = $this->send_mail( $mail_settings['mail'] );
|
161 |
+
|
162 |
+
return $result;
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Add pdf as attachment to email
|
167 |
+
*
|
168 |
+
* @return void
|
169 |
+
*/
|
170 |
+
public function add_pdf_to_email() {
|
171 |
+
|
172 |
+
}
|
173 |
+
/**
|
174 |
+
* Maybe perform actions before sending results to the user
|
175 |
+
*/
|
176 |
+
public function maybe_perform_pre_result_action() {
|
177 |
+
if ( $this->get( 'disable_cf7_mail' ) ) {
|
178 |
+
add_filter( 'wpcf7_skip_mail', '__return_false' );
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Use contact form 7 function to send the email
|
185 |
+
*
|
186 |
+
* @param $mail
|
187 |
+
*/
|
188 |
+
public function send_mail( $mail ) {
|
189 |
+
do_action( 'wpcf7r_before_send_mail', $mail );
|
190 |
+
|
191 |
+
$result = WPCF7_Mail::send( $mail, 'mail' );
|
192 |
+
|
193 |
+
do_action( 'wpcf7r_after_send_mail', $mail, $result );
|
194 |
+
|
195 |
+
return $result;
|
196 |
+
}
|
197 |
+
}
|
classes/actions/html/html-action-redirect.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* HTML action redirect
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* HTML itterator to display redirect actions fields.
|
10 |
-
*/
|
11 |
-
foreach ( $this->get_action_fields() as $field ) {
|
12 |
-
$this->render_field( $field, $prefix );
|
13 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* HTML action redirect
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* HTML itterator to display redirect actions fields.
|
10 |
+
*/
|
11 |
+
foreach ( $this->get_action_fields() as $field ) {
|
12 |
+
$this->render_field( $field, $prefix );
|
13 |
+
}
|
classes/actions/html/html-action-send-to-email.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* html-action-send-to-email file.
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Send to mail action html fields
|
10 |
-
*/
|
11 |
-
foreach ( $this->get_action_fields() as $field ) {
|
12 |
-
$this->render_field( $field, $prefix );
|
13 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* html-action-send-to-email file.
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Send to mail action html fields
|
10 |
+
*/
|
11 |
+
foreach ( $this->get_action_fields() as $field ) {
|
12 |
+
$this->render_field( $field, $prefix );
|
13 |
+
}
|
classes/actions/html/html-page-settings.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* HTML action-send-to-email file.
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<section class="page-settings">
|
10 |
-
|
11 |
-
<?php
|
12 |
-
// Send to mail action html fields
|
13 |
-
foreach ( $this->get_action_fields() as $field ) {
|
14 |
-
$this->render_field( $field, $prefix );
|
15 |
-
}
|
16 |
-
?>
|
17 |
-
|
18 |
-
</section>
|
19 |
-
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* HTML action-send-to-email file.
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<section class="page-settings">
|
10 |
+
|
11 |
+
<?php
|
12 |
+
// Send to mail action html fields
|
13 |
+
foreach ( $this->get_action_fields() as $field ) {
|
14 |
+
$this->render_field( $field, $prefix );
|
15 |
+
}
|
16 |
+
?>
|
17 |
+
|
18 |
+
</section>
|
19 |
+
|
classes/actions/html/index.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
classes/actions/html/rule-title.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* rule-title.php file.
|
4 |
-
*
|
5 |
-
* @package cf7r
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit;
|
10 |
-
}
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Display the block title
|
14 |
-
*
|
15 |
-
* @version 1.0.0
|
16 |
-
*/
|
17 |
-
?>
|
18 |
-
<div class="field-wrap field-wrap-post-title">
|
19 |
-
<label for="wpcf7-redirect-post-title">
|
20 |
-
<strong><?php esc_html_e( 'Rule Title', 'wpcf7-redirect' );?></strong>
|
21 |
-
</label>
|
22 |
-
<input type="text" class="wpcf7-redirect-post-title-fields" placeholder="<?php esc_html_e( 'Rule title', 'wpcf7-redirect' );?>" name="wpcf7-redirect<?php echo $prefix;?>[post_title]" value="<?php echo $this->get_title();?>">
|
23 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* rule-title.php file.
|
4 |
+
*
|
5 |
+
* @package cf7r
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Display the block title
|
14 |
+
*
|
15 |
+
* @version 1.0.0
|
16 |
+
*/
|
17 |
+
?>
|
18 |
+
<div class="field-wrap field-wrap-post-title">
|
19 |
+
<label for="wpcf7-redirect-post-title">
|
20 |
+
<strong><?php esc_html_e( 'Rule Title', 'wpcf7-redirect' );?></strong>
|
21 |
+
</label>
|
22 |
+
<input type="text" class="wpcf7-redirect-post-title-fields" placeholder="<?php esc_html_e( 'Rule title', 'wpcf7-redirect' );?>" name="wpcf7-redirect<?php echo $prefix;?>[post_title]" value="<?php echo $this->get_title();?>">
|
23 |
+
</div>
|
classes/aff/class-ext-accessibe.php
CHANGED
@@ -1,627 +1,631 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Accesibe Extension Class
|
4 |
-
*
|
5 |
-
* @category Ext_Accessibe
|
6 |
-
* @package Ext_Accessibe
|
7 |
-
* @author Author <info@querysol.com>
|
8 |
-
* @license https://opensource.org/licenses/MIT MIT License
|
9 |
-
* @link http://querysol.com/
|
10 |
-
*/
|
11 |
-
class Ext_Accessibe extends WPCF7R_Action {
|
12 |
-
public $ver = '1.0';
|
13 |
-
private $api_url = ACCESSIBE_API_URI;
|
14 |
-
private $ext_name = 'accessibe';
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Class constructor
|
18 |
-
*/
|
19 |
-
public function __construct() {
|
20 |
-
if ( isset( $_GET['scan'] ) ) {
|
21 |
-
$this->reset_scan_results();
|
22 |
-
}
|
23 |
-
if ( is_admin() ) {
|
24 |
-
$this->admin_init();
|
25 |
-
}
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Get the extension name
|
30 |
-
*/
|
31 |
-
public function get_name() {
|
32 |
-
$name = $this->ext_name;
|
33 |
-
return $name;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Get the option key that will store the widget settings
|
38 |
-
*/
|
39 |
-
public function get_widget_option_key() {
|
40 |
-
$key = 'accesibe_widget_options';
|
41 |
-
if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
|
42 |
-
$key .= '_' . ICL_LANGUAGE_CODE;
|
43 |
-
}
|
44 |
-
return $key;
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Initiate admin scripts
|
49 |
-
*/
|
50 |
-
public function admin_init() {
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
if (
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
'
|
240 |
-
'
|
241 |
-
|
242 |
-
|
243 |
-
'
|
244 |
-
'
|
245 |
-
|
246 |
-
|
247 |
-
'
|
248 |
-
'
|
249 |
-
|
250 |
-
|
251 |
-
'
|
252 |
-
'
|
253 |
-
|
254 |
-
|
255 |
-
'
|
256 |
-
'
|
257 |
-
'
|
258 |
-
'
|
259 |
-
|
260 |
-
|
261 |
-
'
|
262 |
-
'
|
263 |
-
|
264 |
-
|
265 |
-
'
|
266 |
-
'
|
267 |
-
'
|
268 |
-
'
|
269 |
-
|
270 |
-
|
271 |
-
'
|
272 |
-
'
|
273 |
-
|
274 |
-
|
275 |
-
'
|
276 |
-
'
|
277 |
-
'
|
278 |
-
|
279 |
-
|
280 |
-
'
|
281 |
-
'
|
282 |
-
|
283 |
-
|
284 |
-
'
|
285 |
-
'
|
286 |
-
'
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
'
|
296 |
-
|
297 |
-
|
298 |
-
'
|
299 |
-
'
|
300 |
-
|
301 |
-
|
302 |
-
'
|
303 |
-
'
|
304 |
-
|
305 |
-
|
306 |
-
'
|
307 |
-
'
|
308 |
-
|
309 |
-
|
310 |
-
'
|
311 |
-
'
|
312 |
-
|
313 |
-
|
314 |
-
'
|
315 |
-
'
|
316 |
-
'
|
317 |
-
'
|
318 |
-
|
319 |
-
|
320 |
-
'
|
321 |
-
'
|
322 |
-
|
323 |
-
|
324 |
-
'
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
'
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
'
|
334 |
-
'
|
335 |
-
|
336 |
-
|
337 |
-
'
|
338 |
-
'
|
339 |
-
'
|
340 |
-
|
341 |
-
|
342 |
-
'
|
343 |
-
'
|
344 |
-
|
345 |
-
|
346 |
-
'
|
347 |
-
'
|
348 |
-
'
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
'
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
'
|
357 |
-
|
358 |
-
|
359 |
-
'
|
360 |
-
'
|
361 |
-
'
|
362 |
-
|
363 |
-
|
364 |
-
'
|
365 |
-
'
|
366 |
-
|
367 |
-
|
368 |
-
'
|
369 |
-
'
|
370 |
-
'
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
'
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
'
|
379 |
-
|
380 |
-
|
381 |
-
'
|
382 |
-
'
|
383 |
-
'
|
384 |
-
|
385 |
-
|
386 |
-
'
|
387 |
-
'
|
388 |
-
|
389 |
-
|
390 |
-
'
|
391 |
-
'
|
392 |
-
'
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
'
|
402 |
-
|
403 |
-
|
404 |
-
'
|
405 |
-
'
|
406 |
-
'
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
'
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
'
|
415 |
-
|
416 |
-
|
417 |
-
'
|
418 |
-
'
|
419 |
-
'
|
420 |
-
|
421 |
-
|
422 |
-
'
|
423 |
-
'
|
424 |
-
|
425 |
-
|
426 |
-
'
|
427 |
-
'
|
428 |
-
'
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
'
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
'
|
437 |
-
|
438 |
-
|
439 |
-
'
|
440 |
-
'
|
441 |
-
'
|
442 |
-
|
443 |
-
|
444 |
-
'
|
445 |
-
'
|
446 |
-
|
447 |
-
|
448 |
-
'
|
449 |
-
'
|
450 |
-
'
|
451 |
-
|
452 |
-
|
453 |
-
'
|
454 |
-
'
|
455 |
-
|
456 |
-
|
457 |
-
'
|
458 |
-
'
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
'
|
488 |
-
'
|
489 |
-
'
|
490 |
-
|
491 |
-
|
492 |
-
'
|
493 |
-
'
|
494 |
-
|
495 |
-
|
496 |
-
'
|
497 |
-
'
|
498 |
-
|
499 |
-
|
500 |
-
'
|
501 |
-
'
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
$
|
550 |
-
$
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
'
|
583 |
-
'
|
584 |
-
'
|
585 |
-
'
|
586 |
-
'
|
587 |
-
'
|
588 |
-
'
|
589 |
-
'
|
590 |
-
'
|
591 |
-
'
|
592 |
-
'
|
593 |
-
'
|
594 |
-
'
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
'
|
600 |
-
'
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
}
|
626 |
-
|
627 |
-
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Accesibe Extension Class
|
4 |
+
*
|
5 |
+
* @category Ext_Accessibe
|
6 |
+
* @package Ext_Accessibe
|
7 |
+
* @author Author <info@querysol.com>
|
8 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
9 |
+
* @link http://querysol.com/
|
10 |
+
*/
|
11 |
+
class Ext_Accessibe extends WPCF7R_Action {
|
12 |
+
public $ver = '1.0';
|
13 |
+
private $api_url = ACCESSIBE_API_URI;
|
14 |
+
private $ext_name = 'accessibe';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Class constructor
|
18 |
+
*/
|
19 |
+
public function __construct() {
|
20 |
+
if ( isset( $_GET['scan'] ) ) {
|
21 |
+
$this->reset_scan_results();
|
22 |
+
}
|
23 |
+
if ( is_admin() ) {
|
24 |
+
$this->admin_init();
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get the extension name
|
30 |
+
*/
|
31 |
+
public function get_name() {
|
32 |
+
$name = $this->ext_name;
|
33 |
+
return $name;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Get the option key that will store the widget settings
|
38 |
+
*/
|
39 |
+
public function get_widget_option_key() {
|
40 |
+
$key = 'accesibe_widget_options';
|
41 |
+
if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
|
42 |
+
$key .= '_' . ICL_LANGUAGE_CODE;
|
43 |
+
}
|
44 |
+
return $key;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Initiate admin scripts
|
49 |
+
*/
|
50 |
+
public function admin_init() {
|
51 |
+
|
52 |
+
if( current_user_can( 'wpcf7_edit_contact_form' ) ){
|
53 |
+
if ( isset( $_GET['page'] ) && qs_get_plugin_display_name() === $_GET['page'] ) {
|
54 |
+
$response = $this->acctivate_acccesbe_menu();
|
55 |
+
}
|
56 |
+
if ( isset( $_REQUEST['start-free-trial'] ) && qs_get_plugin_display_name() === $_REQUEST['start-free-trial'] ) {
|
57 |
+
$response = $this->mark_scan_completed();
|
58 |
+
}
|
59 |
+
if ( isset( $_POST['activate-accesibe'] ) && $_POST['activate-accesibe'] ) {
|
60 |
+
$response = $this->activate();
|
61 |
+
if ( is_wp_error( $response ) ) {
|
62 |
+
WPCF7r_Utils::add_admin_notice( 'alert', $response->get_error_message() );
|
63 |
+
} else {
|
64 |
+
WPCF7r_Utils::add_admin_notice( 'notice', __( 'Successfully activated' ) );
|
65 |
+
}
|
66 |
+
}
|
67 |
+
if ( isset( $_GET['deactivate'] ) && qs_get_plugin_display_name() === $_GET['deactivate'] ) {
|
68 |
+
$this->deactivate();
|
69 |
+
}
|
70 |
+
if ( isset( $_REQUEST['save_ext_settings'] ) && qs_get_plugin_display_name() === $_REQUEST['save_ext_settings'] ) {
|
71 |
+
$this->save();
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
$this->init();
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Save widget settings
|
80 |
+
*/
|
81 |
+
private function save() {
|
82 |
+
$name = $this->get_name();
|
83 |
+
$key = $this->get_widget_option_key();
|
84 |
+
if ( isset( $_REQUEST['wpcf7-redirect'][ $key ][ $name ] ) && $_REQUEST['wpcf7-redirect'][ $key ][ $name ] ) {
|
85 |
+
$data = $_REQUEST['wpcf7-redirect'][ $key ][ $name ];
|
86 |
+
update_option( $key, $data );
|
87 |
+
} elseif ( isset( $_REQUEST['save_ext_settings'] ) ) {
|
88 |
+
update_option( $key, array() );
|
89 |
+
}
|
90 |
+
$this->init();
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Get this extension settings page url
|
95 |
+
*/
|
96 |
+
public function get_settings_url() {
|
97 |
+
return admin_url( '/admin.php?page=' . qs_get_plugin_display_name() );
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* The link will reset the scan data to allow a new scan to process
|
102 |
+
*/
|
103 |
+
public function get_scan_link() {
|
104 |
+
$url = $this->get_settings_url();
|
105 |
+
$url = add_query_arg(
|
106 |
+
array(
|
107 |
+
'scan' => true,
|
108 |
+
)
|
109 |
+
);
|
110 |
+
return $url;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Check if scan was commited and saved
|
115 |
+
*/
|
116 |
+
public function get_scan_results() {
|
117 |
+
return get_option( 'accesibe_scan_results' );
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Get the widget settings
|
122 |
+
*/
|
123 |
+
public function get_widget_settings() {
|
124 |
+
$key = $this->get_widget_option_key();
|
125 |
+
return get_option( $key );
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Check if the plugin is active
|
130 |
+
*/
|
131 |
+
public function is_active() {
|
132 |
+
$settings = $this->get_settings();
|
133 |
+
return $settings ? true : false;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Check if the current screen is a registration form
|
138 |
+
* @return boolean
|
139 |
+
*/
|
140 |
+
public function is_registration_form() {
|
141 |
+
return ! $this->is_scan() && ! $this->is_active();
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Check if the plugin is active
|
146 |
+
*
|
147 |
+
* @return boolean
|
148 |
+
*/
|
149 |
+
public function is_scan() {
|
150 |
+
$results = $this->get_scan_results();
|
151 |
+
return $results ? false : true;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Set a flag that a scan was completed
|
156 |
+
*/
|
157 |
+
public function mark_scan_completed() {
|
158 |
+
update_option( 'accesibe_scan_results', true );
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Allow the user to rescan the website
|
163 |
+
*/
|
164 |
+
public function reset_scan_results() {
|
165 |
+
delete_option( 'accesibe_scan_results' );
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Init extension
|
170 |
+
*/
|
171 |
+
public function init() {
|
172 |
+
if ( ! get_option( 'hide_accessibie_menu' ) && get_option( 'show_accessibie_menu' ) ) {
|
173 |
+
add_action( 'admin_menu', array( $this, 'accessibie_menu' ) );
|
174 |
+
}
|
175 |
+
$this->accesibe_widget_options = $this->get_widget_settings();
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Deactivate the extension
|
180 |
+
*/
|
181 |
+
public function deactivate() {
|
182 |
+
delete_option( 'show_accessibie_menu' );
|
183 |
+
delete_option( 'accesibe_options' );
|
184 |
+
delete_option( 'accesibe_scan_results' );
|
185 |
+
update_option( 'hide_accessibie_menu', true );
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Get the value of a specific field
|
190 |
+
*/
|
191 |
+
public function get_field_value( $field ) {
|
192 |
+
if ( $this->accesibe_widget_options ) {
|
193 |
+
return isset( $this->accesibe_widget_options[ $field ] ) ? $this->accesibe_widget_options[ $field ] : '';
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Get the template to display on the admin field
|
199 |
+
*
|
200 |
+
* @param $template
|
201 |
+
*/
|
202 |
+
public function get_settings_template( $template ) {
|
203 |
+
$name = $this->get_name();
|
204 |
+
$prefix = "[accesibe_widget_options][{$name}]";
|
205 |
+
include WPCF7_PRO_REDIRECT_ACTIONS_TEMPLATE_PATH . $template;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* General function to retrieve meta
|
210 |
+
*
|
211 |
+
* @param $key
|
212 |
+
*/
|
213 |
+
public function get( $key ) {
|
214 |
+
return isset( $this->accesibe_widget_options[ $key ] ) ? $this->accesibe_widget_options[ $key ] : '';
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Get the accessibe settings form
|
219 |
+
*/
|
220 |
+
public function get_settings_form() {
|
221 |
+
$this->get_settings_template( 'html-page-settings.php' );
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Display settings fields for active users
|
226 |
+
*/
|
227 |
+
public function get_accesibe_settings() {
|
228 |
+
$this->html = new WPCF7R_html( '' );
|
229 |
+
include( WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'settings.php' );
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Get the fields relevant for this action
|
234 |
+
*/
|
235 |
+
public function get_action_fields() {
|
236 |
+
return
|
237 |
+
array(
|
238 |
+
array(
|
239 |
+
'name' => 'hideMobile',
|
240 |
+
'type' => 'checkbox',
|
241 |
+
'label' => __( 'Hide On Mobile', 'wpcf7-redirect' ),
|
242 |
+
'sub_title' => '',
|
243 |
+
'placeholder' => '',
|
244 |
+
'value' => $this->get( 'hideMobile' ),
|
245 |
+
),
|
246 |
+
array(
|
247 |
+
'name' => 'hideTrigger',
|
248 |
+
'type' => 'checkbox',
|
249 |
+
'label' => __( 'Hide Trigger', 'wpcf7-redirect' ),
|
250 |
+
'sub_title' => '',
|
251 |
+
'placeholder' => '',
|
252 |
+
'value' => $this->get( 'hideTrigger' ),
|
253 |
+
),
|
254 |
+
array(
|
255 |
+
'name' => 'leadColor',
|
256 |
+
'type' => 'text',
|
257 |
+
'input_class' => 'colorpicker',
|
258 |
+
'label' => __( 'Main Color', 'wpcf7-redirect' ),
|
259 |
+
'class' => 'qs-col qs-col-6',
|
260 |
+
'sub_title' => '',
|
261 |
+
'placeholder' => '',
|
262 |
+
'value' => $this->get( 'leadColor' ) ? $this->get( 'leadColor' ) : '#146FF8',
|
263 |
+
),
|
264 |
+
array(
|
265 |
+
'name' => 'triggerColor',
|
266 |
+
'type' => 'text',
|
267 |
+
'input_class' => 'colorpicker',
|
268 |
+
'label' => __( 'Trigger Color', 'wpcf7-redirect' ),
|
269 |
+
'class' => 'qs-col qs-col-6',
|
270 |
+
'sub_title' => '',
|
271 |
+
'placeholder' => '',
|
272 |
+
'value' => $this->get( 'triggerColor' ) ? $this->get( 'triggerColor' ) : '#146FF8',
|
273 |
+
),
|
274 |
+
array(
|
275 |
+
'name' => 'triggerIcon',
|
276 |
+
'type' => 'media',
|
277 |
+
'label' => __( 'Trigger Icon', 'wpcf7-redirect' ),
|
278 |
+
'class' => '',
|
279 |
+
'sub_title' => '',
|
280 |
+
'placeholder' => '',
|
281 |
+
'value' => $this->get( 'triggerIcon' ) ? $this->get( 'triggerIcon' ) : 'default',
|
282 |
+
),
|
283 |
+
array(
|
284 |
+
'name' => 'triggerSize',
|
285 |
+
'type' => 'select',
|
286 |
+
'label' => __( 'Trigger Size', 'wpcf7-redirect' ),
|
287 |
+
'class' => '',
|
288 |
+
'sub_title' => '',
|
289 |
+
'placeholder' => '',
|
290 |
+
'options' => array(
|
291 |
+
'small' => __( 'Small' ),
|
292 |
+
'medium' => __( 'Medium' ),
|
293 |
+
'large' => __( 'Large' ),
|
294 |
+
),
|
295 |
+
'value' => $this->get( 'triggerSize' ) ? $this->get( 'triggerSize' ) : 'medium',
|
296 |
+
),
|
297 |
+
array(
|
298 |
+
'name' => 'statementLink',
|
299 |
+
'type' => 'url',
|
300 |
+
'label' => __( 'Link To Statment', 'wpcf7-redirect' ),
|
301 |
+
'sub_title' => '',
|
302 |
+
'placeholder' => '',
|
303 |
+
'value' => $this->get( 'statementLink' ),
|
304 |
+
),
|
305 |
+
array(
|
306 |
+
'name' => 'feedbackLink',
|
307 |
+
'type' => 'url',
|
308 |
+
'label' => __( 'Link To Feedback', 'wpcf7-redirect' ),
|
309 |
+
'sub_title' => '',
|
310 |
+
'placeholder' => '',
|
311 |
+
'value' => $this->get( 'feedbackLink' ),
|
312 |
+
),
|
313 |
+
array(
|
314 |
+
'name' => 'language',
|
315 |
+
'type' => 'select',
|
316 |
+
'label' => __( 'Widget Language', 'wpcf7-redirect' ),
|
317 |
+
'class' => 'select2-field',
|
318 |
+
'sub_title' => '',
|
319 |
+
'placeholder' => '',
|
320 |
+
'options' => $this->get_available_languages(),
|
321 |
+
'value' => $this->get( 'language' ),
|
322 |
+
),
|
323 |
+
array(
|
324 |
+
'name' => 'position',
|
325 |
+
'type' => 'select',
|
326 |
+
'label' => __( 'Widget Position', 'wpcf7-redirect' ),
|
327 |
+
'class' => '',
|
328 |
+
'options' => array(
|
329 |
+
'right' => __( 'Right' ),
|
330 |
+
'left' => __( 'Left' ),
|
331 |
+
),
|
332 |
+
'sub_title' => '',
|
333 |
+
'placeholder' => '',
|
334 |
+
'value' => $this->get( 'position' ),
|
335 |
+
),
|
336 |
+
array(
|
337 |
+
'name' => 'triggerRadius',
|
338 |
+
'type' => 'number',
|
339 |
+
'label' => __( 'Trigger Border Radius (%)', 'wpcf7-redirect' ),
|
340 |
+
'class' => '',
|
341 |
+
'sub_title' => '',
|
342 |
+
'placeholder' => '',
|
343 |
+
'value' => $this->get( 'triggerRadius' ) ? $this->get( 'triggerRadius' ) : '50%',
|
344 |
+
),
|
345 |
+
array(
|
346 |
+
'name' => 'triggerPositionX',
|
347 |
+
'type' => 'select',
|
348 |
+
'label' => __( 'Trigger Position (X)', 'wpcf7-redirect' ),
|
349 |
+
'class' => '',
|
350 |
+
'sub_title' => '',
|
351 |
+
'placeholder' => '',
|
352 |
+
'options' => array(
|
353 |
+
'right' => __( 'Right' ),
|
354 |
+
'left' => __( 'Left' ),
|
355 |
+
),
|
356 |
+
'value' => $this->get( 'triggerPositionX' ) ? $this->get( 'triggerPositionX' ) : 'left',
|
357 |
+
),
|
358 |
+
array(
|
359 |
+
'name' => 'triggerOffsetX',
|
360 |
+
'type' => 'number',
|
361 |
+
'label' => __( 'Trigger Offset X (Pixels)', 'wpcf7-redirect' ),
|
362 |
+
'class' => '',
|
363 |
+
'sub_title' => '',
|
364 |
+
'placeholder' => '',
|
365 |
+
'value' => $this->get( 'triggerOffsetX' ) ? $this->get( 'triggerOffsetX' ) : 0,
|
366 |
+
),
|
367 |
+
array(
|
368 |
+
'name' => 'triggerPositionY',
|
369 |
+
'type' => 'select',
|
370 |
+
'label' => __( 'Trigger Position (X)', 'wpcf7-redirect' ),
|
371 |
+
'class' => '',
|
372 |
+
'sub_title' => '',
|
373 |
+
'placeholder' => '',
|
374 |
+
'options' => array(
|
375 |
+
'top' => __( 'Top' ),
|
376 |
+
'bottom' => __( 'Bottom' ),
|
377 |
+
),
|
378 |
+
'value' => $this->get( 'triggerPositionY' ) ? $this->get( 'triggerPositionY' ) : 'bottom',
|
379 |
+
),
|
380 |
+
array(
|
381 |
+
'name' => 'triggerOffsetY',
|
382 |
+
'type' => 'number',
|
383 |
+
'label' => __( 'Trigger Offset Y (Pixels)', 'wpcf7-redirect' ),
|
384 |
+
'class' => '',
|
385 |
+
'sub_title' => '',
|
386 |
+
'placeholder' => '',
|
387 |
+
'value' => $this->get( 'triggerOffsetY' ) ? $this->get( 'triggerOffsetY' ) : 0,
|
388 |
+
),
|
389 |
+
array(
|
390 |
+
'name' => 'triggerSizeMobile',
|
391 |
+
'type' => 'select',
|
392 |
+
'label' => __( 'Trigger Size Mobile', 'wpcf7-redirect' ),
|
393 |
+
'class' => '',
|
394 |
+
'sub_title' => '',
|
395 |
+
'placeholder' => '',
|
396 |
+
'options' => array(
|
397 |
+
'small' => __( 'Small' ),
|
398 |
+
'medium' => __( 'Medium' ),
|
399 |
+
'large' => __( 'Large' ),
|
400 |
+
),
|
401 |
+
'value' => $this->get( 'triggerSizeMobile' ) ? $this->get( 'triggerSizeMobile' ) : 'medium',
|
402 |
+
),
|
403 |
+
array(
|
404 |
+
'name' => 'triggerPositionXMobile',
|
405 |
+
'type' => 'select',
|
406 |
+
'label' => __( 'Trigger Position (X) Mobile', 'wpcf7-redirect' ),
|
407 |
+
'class' => '',
|
408 |
+
'sub_title' => '',
|
409 |
+
'placeholder' => '',
|
410 |
+
'options' => array(
|
411 |
+
'right' => __( 'Right' ),
|
412 |
+
'left' => __( 'Left' ),
|
413 |
+
),
|
414 |
+
'value' => $this->get( 'triggerPositionXMobile' ) ? $this->get( 'triggerPositionXMobile' ) : 'left',
|
415 |
+
),
|
416 |
+
array(
|
417 |
+
'name' => 'triggerOffsetXMobile',
|
418 |
+
'type' => 'number',
|
419 |
+
'label' => __( 'Trigger Offset X (Pixels) Mobile', 'wpcf7-redirect' ),
|
420 |
+
'class' => '',
|
421 |
+
'sub_title' => '',
|
422 |
+
'placeholder' => '',
|
423 |
+
'value' => $this->get( 'triggerOffsetXMobile' ) ? $this->get( 'triggerOffsetXMobile' ) : 0,
|
424 |
+
),
|
425 |
+
array(
|
426 |
+
'name' => 'triggerPositionYMobile',
|
427 |
+
'type' => 'select',
|
428 |
+
'label' => __( 'Trigger Position (X) Mobile', 'wpcf7-redirect' ),
|
429 |
+
'class' => '',
|
430 |
+
'sub_title' => '',
|
431 |
+
'placeholder' => '',
|
432 |
+
'options' => array(
|
433 |
+
'top' => __( 'Top' ),
|
434 |
+
'bottom' => __( 'Bottom' ),
|
435 |
+
),
|
436 |
+
'value' => $this->get( 'triggerPositionYMobile' ) ? $this->get( 'triggerPositionYMobile' ) : 'bottom',
|
437 |
+
),
|
438 |
+
array(
|
439 |
+
'name' => 'triggerOffsetYMobile',
|
440 |
+
'type' => 'number',
|
441 |
+
'label' => __( 'Trigger Offset Y (Pixels)', 'wpcf7-redirect' ),
|
442 |
+
'class' => '',
|
443 |
+
'sub_title' => '',
|
444 |
+
'placeholder' => '',
|
445 |
+
'value' => $this->get( 'triggerOffsetYMobile' ) ? $this->get( 'triggerOffsetYMobile' ) : 0,
|
446 |
+
),
|
447 |
+
array(
|
448 |
+
'name' => 'triggerRadiusMobile',
|
449 |
+
'type' => 'number',
|
450 |
+
'label' => __( 'Trigger Border Radius (%) Mobile', 'wpcf7-redirect' ),
|
451 |
+
'class' => '',
|
452 |
+
'sub_title' => '',
|
453 |
+
'placeholder' => '',
|
454 |
+
'value' => $this->get( 'triggerRadiusMobile' ) ? $this->get( 'triggerRadiusMobile' ) : '50%',
|
455 |
+
),
|
456 |
+
array(
|
457 |
+
'name' => 'footerHtml',
|
458 |
+
'type' => 'editor',
|
459 |
+
'label' => __( 'Footer Html', 'wpcf7-redirect' ),
|
460 |
+
'sub_title' => '',
|
461 |
+
'placeholder' => '',
|
462 |
+
'value' => $this->get( 'footerHtml' ),
|
463 |
+
),
|
464 |
+
);
|
465 |
+
}
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Get a list of available widget languages
|
469 |
+
*/
|
470 |
+
public function get_available_languages() {
|
471 |
+
return wpcf7_get_languages_list();
|
472 |
+
}
|
473 |
+
|
474 |
+
/**
|
475 |
+
* Display accesibe menu
|
476 |
+
*/
|
477 |
+
public function acctivate_acccesbe_menu() {
|
478 |
+
update_option( 'show_accessibie_menu', true );
|
479 |
+
delete_option( 'hide_accessibie_menu' );
|
480 |
+
}
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Activate the extension
|
484 |
+
*/
|
485 |
+
public function activate() {
|
486 |
+
$args = array(
|
487 |
+
'email' => sanitize_email( $_POST['email'] ),
|
488 |
+
'name' => sanitize_text_field( $_POST['fullname'] ),
|
489 |
+
'password' => sanitize_text_field( $_POST['password'] ),
|
490 |
+
'domain' => str_replace( array( 'http://', 'https://' ), '', home_url() ),
|
491 |
+
'ip_address' => $_SERVER['SERVER_ADDR'],
|
492 |
+
'contactCountry' => isset( $_POST['user-country'] ) ? sanitize_text_field( $_POST['user-country'] ) : '',
|
493 |
+
'contactPhone' => isset( $_POST['phone-number'] ) ? sanitize_text_field( $_POST['phone-number'] ) : '',
|
494 |
+
);
|
495 |
+
$post_args = array(
|
496 |
+
'method' => 'POST',
|
497 |
+
'timeout' => 45,
|
498 |
+
'redirection' => 5,
|
499 |
+
'httpversion' => '1.0',
|
500 |
+
'sslverify' => false,
|
501 |
+
'headers' => array(
|
502 |
+
'Content-Type' => 'application/json',
|
503 |
+
),
|
504 |
+
'body' => wp_json_encode( $args ),
|
505 |
+
'cookies' => array(),
|
506 |
+
);
|
507 |
+
$response = wp_remote_post( $this->api_url, $post_args );
|
508 |
+
|
509 |
+
if ( ! is_wp_error( $response ) ) {
|
510 |
+
$response = wp_remote_retrieve_body( $response );
|
511 |
+
$response = (object) json_decode( $response, true );
|
512 |
+
if ( 1 === $response->status ) {
|
513 |
+
$options_args = array(
|
514 |
+
'accessibe_plugin_active' => $this->ver,
|
515 |
+
'accessibe_plugin_domain' => $args['domain'],
|
516 |
+
'accessibe_plugin_dativation_date' => current_time( 'Ymd' ),
|
517 |
+
);
|
518 |
+
update_option( 'accesibe_options', $options_args );
|
519 |
+
} else {
|
520 |
+
$options_args = array(
|
521 |
+
'accessibe_plugin_active' => $this->ver,
|
522 |
+
'accessibe_plugin_domain' => $args['domain'],
|
523 |
+
'accessibe_plugin_dativation_date' => current_time( 'Ymd' ),
|
524 |
+
);
|
525 |
+
update_option( 'accesibe_options', $options_args );
|
526 |
+
$response = new WP_Error( 'activate', __( 'This Domain Is Already Registered' ) );
|
527 |
+
}
|
528 |
+
}
|
529 |
+
return $response;
|
530 |
+
}
|
531 |
+
|
532 |
+
/**
|
533 |
+
* Get accesibe options
|
534 |
+
*/
|
535 |
+
public function get_settings() {
|
536 |
+
return get_option( 'accesibe_options' );
|
537 |
+
}
|
538 |
+
|
539 |
+
/**
|
540 |
+
* Create Accesibie Menu
|
541 |
+
*/
|
542 |
+
public function accessibie_menu() {
|
543 |
+
// Add the menu item and page!
|
544 |
+
$page_title = qs_get_plugin_display_name();
|
545 |
+
$capability = 'manage_options';
|
546 |
+
$callback = array( $this, 'accesibie_settings_page_content' );
|
547 |
+
$icon = WPCF7_PRO_REDIRECT_BUILD_PATH . '/images/accesibie-logo.png';
|
548 |
+
add_menu_page(
|
549 |
+
$page_title,
|
550 |
+
$page_title,
|
551 |
+
$capability,
|
552 |
+
$page_title,
|
553 |
+
$callback,
|
554 |
+
$icon
|
555 |
+
);
|
556 |
+
}
|
557 |
+
|
558 |
+
/**
|
559 |
+
* Extension page Content
|
560 |
+
*/
|
561 |
+
public function accesibie_settings_page_content() {
|
562 |
+
do_action( 'before_settings_fields' );
|
563 |
+
?>
|
564 |
+
|
565 |
+
<div class="wrap wrap-accesibe">
|
566 |
+
<div class="postbox">
|
567 |
+
<div class="padbox">
|
568 |
+
<div class="content">
|
569 |
+
<?php include 'templates/accesibie-content.php'; ?>
|
570 |
+
</div>
|
571 |
+
</div>
|
572 |
+
</div>
|
573 |
+
</div>
|
574 |
+
<?php
|
575 |
+
}
|
576 |
+
|
577 |
+
/**
|
578 |
+
* Echo the script in the footer
|
579 |
+
*/
|
580 |
+
public function footer_script() {
|
581 |
+
$params = array(
|
582 |
+
'statementLink' => $this->get( 'statementLink' ),
|
583 |
+
'feedbackLink' => $this->get( 'feedbackLink' ),
|
584 |
+
'footerHtml' => $this->get( 'footerHtml' ),
|
585 |
+
'hideMobile' => $this->get( 'hideMobile' ),
|
586 |
+
'hideTrigger' => $this->get( 'hideTrigger' ),
|
587 |
+
'language' => $this->get( 'language' ) ? $this->get( 'language' ) : 'en',
|
588 |
+
'position' => $this->get( 'position' ) ? $this->get( 'position' ) : 'right',
|
589 |
+
'leadColor' => $this->get( 'leadColor' ) ? $this->get( 'leadColor' ) : '#146FF8',
|
590 |
+
'triggerColor' => $this->get( 'triggerColor' ) ? $this->get( 'triggerColor' ) : '#146FF8',
|
591 |
+
'triggerRadius' => $this->get( 'triggerRadius' ) ? $this->get( 'triggerRadius' ) : '50%',
|
592 |
+
'triggerPositionX' => $this->get( 'triggerPositionX' ) ? $this->get( 'triggerPositionX' ) : 'right',
|
593 |
+
'triggerPositionY' => $this->get( 'triggerPositionY' ) ? $this->get( 'triggerPositionY' ) : 'bottom',
|
594 |
+
'triggerIcon' => $this->get( 'triggerIcon' ) ? $this->get( 'triggerIcon' ) : 'default',
|
595 |
+
'triggerSize' => $this->get( 'triggerSize' ) ? $this->get( 'triggerSize' ) : 'medium',
|
596 |
+
'triggerOffsetX' => $this->get( 'triggerOffsetX' ) ? $this->get( 'triggerOffsetX' ) : 20,
|
597 |
+
'triggerOffsetY' => $this->get( 'triggerOffsetY' ) ? $this->get( 'triggerOffsetY' ) : 20,
|
598 |
+
'mobile' => (object) array(
|
599 |
+
'triggerSize' => $this->get( 'triggerSizeMobile' ) ? $this->get( 'triggerSizeMobile' ) : 'small',
|
600 |
+
'triggerPositionX' => $this->get( 'triggerPositionXMobile' ) ? $this->get( 'triggerPositionXMobile' ) : 'right',
|
601 |
+
'triggerPositionY' => $this->get( 'triggerPositionYMobile' ) ? $this->get( 'triggerPositionYMobile' ) : 'center',
|
602 |
+
'triggerOffsetX' => $this->get( 'triggerOffsetXMobile' ) ? $this->get( 'triggerOffsetXMobile' ) : 0,
|
603 |
+
'triggerOffsetY' => $this->get( 'triggerOffsetYMobile' ) ? $this->get( 'triggerOffsetYMobile' ) : 0,
|
604 |
+
'triggerRadius' => $this->get( 'triggerRadiusMobile' ) ? $this->get( 'triggerRadiusMobile' ) : '50%',
|
605 |
+
),
|
606 |
+
);
|
607 |
+
$options = json_encode( $params, JSON_UNESCAPED_UNICODE );
|
608 |
+
?>
|
609 |
+
<script>(function(){var s = document.createElement('script'),e = ! document.body ? document.querySelector('head') : document.body;s.src = 'https://acsbapp.com/apps/app/assets/js/acsb.js';s.async = s.defer = true;s.onload = function(){acsbJS.init(<?php echo $options; ?>);};e.appendChild(s);}());</script>
|
610 |
+
<?php
|
611 |
+
}
|
612 |
+
|
613 |
+
/**
|
614 |
+
* Enqueue script if the plugin is active
|
615 |
+
*/
|
616 |
+
public static function enqueue_script() {
|
617 |
+
if ( ! is_admin() ) {
|
618 |
+
$instance = new self();
|
619 |
+
$instance->init();
|
620 |
+
if ( $instance->is_active() ) {
|
621 |
+
add_action( 'wp_footer', array( $instance, 'footer_script' ) );
|
622 |
+
}
|
623 |
+
}
|
624 |
+
}
|
625 |
+
}
|
626 |
+
|
627 |
+
function qs_get_plugin_display_name() {
|
628 |
+
return apply_filters( 'qs_get_plugin_display_name', 'Accessibility' );
|
629 |
+
}
|
630 |
+
|
631 |
+
Ext_Accessibe::enqueue_script();
|
classes/aff/templates/accesibie-content.php
CHANGED
@@ -1,165 +1,165 @@
|
|
1 |
-
<?php defined( 'ABSPATH' ) || exit; ?>
|
2 |
-
|
3 |
-
<?php $user = wp_get_current_user(); ?>
|
4 |
-
|
5 |
-
<section class="home-hero hero-standard hero-standard-full">
|
6 |
-
<div class="wrapper flex <?php echo ! $this->is_scan() && ! $this->is_active() ? 'reg-form' : ''; ?> ">
|
7 |
-
<?php if ( ! $this->is_registration_form() ) : ?>
|
8 |
-
<div class="logo-row flex top-logo">
|
9 |
-
<div class="accessibe-logo">
|
10 |
-
<img class="hero-cover-image" data-lazyload-ignore="true" src="<?php echo WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/accessibe-full-logo.svg'; ?>" alt="Blind person hero image">
|
11 |
-
</div>
|
12 |
-
<?php if ( $this->is_scan() ) : ?>
|
13 |
-
<form action="<?php echo $this->get_settings_url(); ?>" method="post" class="accesibe-settings-form">
|
14 |
-
<button type="submit" class="site-button js-active site-button-animate site-button-right-icon site-button-full" data-element="signup-button">
|
15 |
-
<span class="align-middle">
|
16 |
-
<?php _e( 'Create a Free Account!', 'wpcf7-redirect' ); ?> <span class="dashicons dashicons-arrow-right-alt2"></span>
|
17 |
-
</span>
|
18 |
-
</button>
|
19 |
-
<input type="hidden" name="start-free-trial" value="<?php echo qs_get_plugin_display_name(); ?>" />
|
20 |
-
</form>
|
21 |
-
<?php endif; ?>
|
22 |
-
</div>
|
23 |
-
<?php endif; ?>
|
24 |
-
<?php
|
25 |
-
if ( $this->is_registration_form() ) :
|
26 |
-
?>
|
27 |
-
<div class="main-form-wrap">
|
28 |
-
<div class="home-hero-content hero-left">
|
29 |
-
<div class="hero-left-inner">
|
30 |
-
<h3 class="home-hero-title">The #1 <em>Fully</em> <em>Automated</em> <br> Web Accessibility Solution <br> for ADA & WCAG Compliance</h3>
|
31 |
-
<ul class="home-hero-checkmarks">
|
32 |
-
<li class="home-hero-checkmark">
|
33 |
-
<i class="icon icon-checkmark icon-pack-icomoon ">
|
34 |
-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
35 |
-
<title>checkmark</title>
|
36 |
-
<path d="M13.5 2l-7.5 7.5-3.5-3.5-2.5 2.5 6 6 10-10z"></path>
|
37 |
-
</svg>
|
38 |
-
</i>
|
39 |
-
<strong>Affordable.</strong> $49/month, free trial, no credit card required
|
40 |
-
</li>
|
41 |
-
<li class="home-hero-checkmark">
|
42 |
-
<i class="icon icon-checkmark icon-pack-icomoon ">
|
43 |
-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
44 |
-
<title>checkmark</title>
|
45 |
-
<path d="M13.5 2l-7.5 7.5-3.5-3.5-2.5 2.5 6 6 10-10z"></path>
|
46 |
-
</svg>
|
47 |
-
</i>
|
48 |
-
<strong>Effortless.</strong> Add a single line of code for 24/7 automated compliance
|
49 |
-
</li>
|
50 |
-
<li class="home-hero-checkmark">
|
51 |
-
<i class="icon icon-checkmark icon-pack-icomoon ">
|
52 |
-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
53 |
-
<title>checkmark</title>
|
54 |
-
<path d="M13.5 2l-7.5 7.5-3.5-3.5-2.5 2.5 6 6 10-10z"></path>
|
55 |
-
</svg>
|
56 |
-
</i>
|
57 |
-
<strong>Compliant.</strong> Accessibility statement and certificate of performance
|
58 |
-
</li>
|
59 |
-
</ul>
|
60 |
-
</div>
|
61 |
-
</div>
|
62 |
-
<div class="hero-right">
|
63 |
-
<div class="hero-right-inner">
|
64 |
-
<div class="accessibe-logo">
|
65 |
-
<img class="hero-cover-image" data-lazyload-ignore="true" src="<?php echo WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/accessibe-full-logo.svg'; ?>" alt="Blind person hero image">
|
66 |
-
</div>
|
67 |
-
<h4>Create A 30-Day Trial Account</h4>
|
68 |
-
<form name="accesibe-registration" action="" method="post" class="accesibe-registration-form-fields">
|
69 |
-
<div class="home-hero-cta">
|
70 |
-
<div class="field-wrap">
|
71 |
-
<label for="email"><?php _e( 'Your Email Address', 'wpcf7-redirect' ); ?></label>
|
72 |
-
<input type="email" name="email" value="<?php echo get_option( 'admin_email' ); ?>" required placeholder="example@example.com"/>
|
73 |
-
</div>
|
74 |
-
<div class="field-wrap">
|
75 |
-
<label for="fullname"><?php _e( 'Your Full Name', 'wpcf7-redirect' ); ?></label>
|
76 |
-
<input type="text" name="fullname" minlength="3" value="<?php echo $user->first_name . ' ' . $user->last_name; ?>" required placeholder="John Smith"/>
|
77 |
-
</div>
|
78 |
-
<div class="field-wrap">
|
79 |
-
<label for="password"><?php _e( 'Your Password', 'wpcf7-redirect' ); ?></label>
|
80 |
-
<input type="password" name="password" minlength="8" value="" required placeholder="<?php _e( '8+ Charachters', 'wpcf7-redirect' ); ?>"/>
|
81 |
-
</div>
|
82 |
-
|
83 |
-
<span class="loader-spinner-container spinner-light" data-loader="spinner">
|
84 |
-
<span class="loader-spinner"></span></span>
|
85 |
-
</button>
|
86 |
-
</div>
|
87 |
-
<div class="agreement">
|
88 |
-
<div class="highlight">
|
89 |
-
<input type="checkbox" name="tos" id="tos" checked="" data-activate-on-check="signup-button" required>
|
90 |
-
<label for="tos"><?php _e( 'By signing up you agree to our', 'wpcf7-redirect' ); ?> <a href="https://accessibe.com/terms-of-service" target="_blank"><?php _e( 'Terms of Service', 'wpcf7-redirect' ); ?></a></label>
|
91 |
-
</div>
|
92 |
-
</div>
|
93 |
-
<div class="field-wrap">
|
94 |
-
<button type="submit" class="site-button js-active site-button-animate site-button-right-icon site-button-full" data-element="signup-button">
|
95 |
-
<span class="align-middle">
|
96 |
-
<?php _e( 'Create a Free Account!', 'wpcf7-redirect' ); ?> <span class="dashicons dashicons-arrow-right-alt2"></span>
|
97 |
-
</span>
|
98 |
-
</button>
|
99 |
-
</div>
|
100 |
-
<input type="hidden" name="activate-accesibe" value="1" />
|
101 |
-
<div class="footer-wrap">
|
102 |
-
<a class=" align-middle" href="<?php echo admin_url( '?deactivate=' . qs_get_plugin_display_name() ); ?>">
|
103 |
-
<?php _e( 'Hide this special offer', 'wpcf7-redirect' ); ?>
|
104 |
-
</a>
|
105 |
-
<a href="<?php echo $this->get_scan_link(); ?>" class="scan-again"><?php _e( 'Scan my website again.', 'wpcf7-redirect' ); ?></a>
|
106 |
-
</div>
|
107 |
-
</form>
|
108 |
-
</div>
|
109 |
-
</div>
|
110 |
-
|
111 |
-
</div>
|
112 |
-
</form>
|
113 |
-
<?php elseif ( $this->is_scan() ) : ?>
|
114 |
-
<div class="qs-row">
|
115 |
-
<div class="qs-col">
|
116 |
-
<div class="scanning">
|
117 |
-
Please wait a few seconds while we process your website accessibility report.
|
118 |
-
</div>
|
119 |
-
<div class="scanning-tip">
|
120 |
-
<strong>Results guide:</strong> <strong>Compliant</strong> - You're all good. <strong>Semi/Not Compliant</strong> - We recommend you to install accessiBe
|
121 |
-
</div>
|
122 |
-
</div>
|
123 |
-
</div>
|
124 |
-
<?php $url = add_query_arg( 'accesibedomainscan', str_replace( 'http:', 'https:', home_url() ), 'https://querysol.com/scan' ); ?>
|
125 |
-
<iframe src="<?php echo $url; ?>" scrolling="no" style=" width: 100%; height: 100vh; overflow: hidden;" ></iframe>
|
126 |
-
<form action="<?php echo $this->get_settings_url(); ?>" method="post" class="accesibe-settings-form-footer">
|
127 |
-
<button type="submit" class="site-button js-active site-button-animate site-button-right-icon site-button-full" data-element="signup-button">
|
128 |
-
<span class="align-middle">
|
129 |
-
<?php _e( 'Create a Free Account!', 'wpcf7-redirect' ); ?> <span class="dashicons dashicons-arrow-right-alt2"></span>
|
130 |
-
</span>
|
131 |
-
</button>
|
132 |
-
<input type="hidden" name="start-free-trial" value="<?php echo qs_get_plugin_display_name(); ?>" />
|
133 |
-
</form>
|
134 |
-
<div class="footer-wrap">
|
135 |
-
<a class=" align-middle" href="<?php echo admin_url( '?deactivate=' . qs_get_plugin_display_name() ); ?>">
|
136 |
-
<?php _e( 'Hide This Special Offer', 'wpcf7-redirect' ); ?>
|
137 |
-
</a>
|
138 |
-
</div>
|
139 |
-
<?php else : ?>
|
140 |
-
<form name="accesibe-registration" action="<?php echo $this->get_settings_url(); ?>" method="post" class="accesibe-settings-form">
|
141 |
-
<div class="success-message">
|
142 |
-
<h3>
|
143 |
-
Thank you for installing accessibe!
|
144 |
-
</h3>
|
145 |
-
<div class="success-message-subtitle">
|
146 |
-
The plugin is now active on your website.
|
147 |
-
</div>
|
148 |
-
<div class="success-content">
|
149 |
-
If you want to customize the widget settings you can do it here: <br/>
|
150 |
-
To deactivate the plugin you can <a class=" align-middle" href="<?php echo admin_url( '?deactivate=' . qs_get_plugin_display_name() ); ?>">Click Here.</a>
|
151 |
-
</div>
|
152 |
-
</div>
|
153 |
-
<?php $this->get_settings_form(); ?>
|
154 |
-
|
155 |
-
<div class="qs-row">
|
156 |
-
<div class="qs-col">
|
157 |
-
<button type="submit" class="site-button js-active site-button-animate site-button-right-icon site-button-full" data-element="signup-button">
|
158 |
-
<span class="align-middle"><?php _e( 'Save', 'wpcf7-redirect' ); ?></span>
|
159 |
-
</button>
|
160 |
-
</div>
|
161 |
-
</div>
|
162 |
-
<input type="hidden" name="save_ext_settings" value="<?php echo qs_get_plugin_display_name(); ?>" />
|
163 |
-
</form>
|
164 |
-
<?php endif; ?>
|
165 |
-
</section>
|
1 |
+
<?php defined( 'ABSPATH' ) || exit; ?>
|
2 |
+
|
3 |
+
<?php $user = wp_get_current_user(); ?>
|
4 |
+
|
5 |
+
<section class="home-hero hero-standard hero-standard-full">
|
6 |
+
<div class="wrapper flex <?php echo ! $this->is_scan() && ! $this->is_active() ? 'reg-form' : ''; ?> ">
|
7 |
+
<?php if ( ! $this->is_registration_form() ) : ?>
|
8 |
+
<div class="logo-row flex top-logo">
|
9 |
+
<div class="accessibe-logo">
|
10 |
+
<img class="hero-cover-image" data-lazyload-ignore="true" src="<?php echo WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/accessibe-full-logo.svg'; ?>" alt="Blind person hero image">
|
11 |
+
</div>
|
12 |
+
<?php if ( $this->is_scan() ) : ?>
|
13 |
+
<form action="<?php echo $this->get_settings_url(); ?>" method="post" class="accesibe-settings-form">
|
14 |
+
<button type="submit" class="site-button js-active site-button-animate site-button-right-icon site-button-full" data-element="signup-button">
|
15 |
+
<span class="align-middle">
|
16 |
+
<?php _e( 'Create a Free Account!', 'wpcf7-redirect' ); ?> <span class="dashicons dashicons-arrow-right-alt2"></span>
|
17 |
+
</span>
|
18 |
+
</button>
|
19 |
+
<input type="hidden" name="start-free-trial" value="<?php echo qs_get_plugin_display_name(); ?>" />
|
20 |
+
</form>
|
21 |
+
<?php endif; ?>
|
22 |
+
</div>
|
23 |
+
<?php endif; ?>
|
24 |
+
<?php
|
25 |
+
if ( $this->is_registration_form() ) :
|
26 |
+
?>
|
27 |
+
<div class="main-form-wrap">
|
28 |
+
<div class="home-hero-content hero-left">
|
29 |
+
<div class="hero-left-inner">
|
30 |
+
<h3 class="home-hero-title">The #1 <em>Fully</em> <em>Automated</em> <br> Web Accessibility Solution <br> for ADA & WCAG Compliance</h3>
|
31 |
+
<ul class="home-hero-checkmarks">
|
32 |
+
<li class="home-hero-checkmark">
|
33 |
+
<i class="icon icon-checkmark icon-pack-icomoon ">
|
34 |
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
35 |
+
<title>checkmark</title>
|
36 |
+
<path d="M13.5 2l-7.5 7.5-3.5-3.5-2.5 2.5 6 6 10-10z"></path>
|
37 |
+
</svg>
|
38 |
+
</i>
|
39 |
+
<strong>Affordable.</strong> $49/month, free trial, no credit card required
|
40 |
+
</li>
|
41 |
+
<li class="home-hero-checkmark">
|
42 |
+
<i class="icon icon-checkmark icon-pack-icomoon ">
|
43 |
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
44 |
+
<title>checkmark</title>
|
45 |
+
<path d="M13.5 2l-7.5 7.5-3.5-3.5-2.5 2.5 6 6 10-10z"></path>
|
46 |
+
</svg>
|
47 |
+
</i>
|
48 |
+
<strong>Effortless.</strong> Add a single line of code for 24/7 automated compliance
|
49 |
+
</li>
|
50 |
+
<li class="home-hero-checkmark">
|
51 |
+
<i class="icon icon-checkmark icon-pack-icomoon ">
|
52 |
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
53 |
+
<title>checkmark</title>
|
54 |
+
<path d="M13.5 2l-7.5 7.5-3.5-3.5-2.5 2.5 6 6 10-10z"></path>
|
55 |
+
</svg>
|
56 |
+
</i>
|
57 |
+
<strong>Compliant.</strong> Accessibility statement and certificate of performance
|
58 |
+
</li>
|
59 |
+
</ul>
|
60 |
+
</div>
|
61 |
+
</div>
|
62 |
+
<div class="hero-right">
|
63 |
+
<div class="hero-right-inner">
|
64 |
+
<div class="accessibe-logo">
|
65 |
+
<img class="hero-cover-image" data-lazyload-ignore="true" src="<?php echo WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/accessibe-full-logo.svg'; ?>" alt="Blind person hero image">
|
66 |
+
</div>
|
67 |
+
<h4>Create A 30-Day Trial Account</h4>
|
68 |
+
<form name="accesibe-registration" action="" method="post" class="accesibe-registration-form-fields">
|
69 |
+
<div class="home-hero-cta">
|
70 |
+
<div class="field-wrap">
|
71 |
+
<label for="email"><?php _e( 'Your Email Address', 'wpcf7-redirect' ); ?></label>
|
72 |
+
<input type="email" name="email" value="<?php echo get_option( 'admin_email' ); ?>" required placeholder="example@example.com"/>
|
73 |
+
</div>
|
74 |
+
<div class="field-wrap">
|
75 |
+
<label for="fullname"><?php _e( 'Your Full Name', 'wpcf7-redirect' ); ?></label>
|
76 |
+
<input type="text" name="fullname" minlength="3" value="<?php echo $user->first_name . ' ' . $user->last_name; ?>" required placeholder="John Smith"/>
|
77 |
+
</div>
|
78 |
+
<div class="field-wrap">
|
79 |
+
<label for="password"><?php _e( 'Your Password', 'wpcf7-redirect' ); ?></label>
|
80 |
+
<input type="password" name="password" minlength="8" value="" required placeholder="<?php _e( '8+ Charachters', 'wpcf7-redirect' ); ?>"/>
|
81 |
+
</div>
|
82 |
+
|
83 |
+
<span class="loader-spinner-container spinner-light" data-loader="spinner">
|
84 |
+
<span class="loader-spinner"></span></span>
|
85 |
+
</button>
|
86 |
+
</div>
|
87 |
+
<div class="agreement">
|
88 |
+
<div class="highlight">
|
89 |
+
<input type="checkbox" name="tos" id="tos" checked="" data-activate-on-check="signup-button" required>
|
90 |
+
<label for="tos"><?php _e( 'By signing up you agree to our', 'wpcf7-redirect' ); ?> <a href="https://accessibe.com/terms-of-service" target="_blank"><?php _e( 'Terms of Service', 'wpcf7-redirect' ); ?></a></label>
|
91 |
+
</div>
|
92 |
+
</div>
|
93 |
+
<div class="field-wrap">
|
94 |
+
<button type="submit" class="site-button js-active site-button-animate site-button-right-icon site-button-full" data-element="signup-button">
|
95 |
+
<span class="align-middle">
|
96 |
+
<?php _e( 'Create a Free Account!', 'wpcf7-redirect' ); ?> <span class="dashicons dashicons-arrow-right-alt2"></span>
|
97 |
+
</span>
|
98 |
+
</button>
|
99 |
+
</div>
|
100 |
+
<input type="hidden" name="activate-accesibe" value="1" />
|
101 |
+
<div class="footer-wrap">
|
102 |
+
<a class=" align-middle" href="<?php echo admin_url( '?deactivate=' . qs_get_plugin_display_name() ); ?>">
|
103 |
+
<?php _e( 'Hide this special offer', 'wpcf7-redirect' ); ?>
|
104 |
+
</a>
|
105 |
+
<a href="<?php echo $this->get_scan_link(); ?>" class="scan-again"><?php _e( 'Scan my website again.', 'wpcf7-redirect' ); ?></a>
|
106 |
+
</div>
|
107 |
+
</form>
|
108 |
+
</div>
|
109 |
+
</div>
|
110 |
+
|
111 |
+
</div>
|
112 |
+
</form>
|
113 |
+
<?php elseif ( $this->is_scan() ) : ?>
|
114 |
+
<div class="qs-row">
|
115 |
+
<div class="qs-col">
|
116 |
+
<div class="scanning">
|
117 |
+
Please wait a few seconds while we process your website accessibility report.
|
118 |
+
</div>
|
119 |
+
<div class="scanning-tip">
|
120 |
+
<strong>Results guide:</strong> <strong>Compliant</strong> - You're all good. <strong>Semi/Not Compliant</strong> - We recommend you to install accessiBe
|
121 |
+
</div>
|
122 |
+
</div>
|
123 |
+
</div>
|
124 |
+
<?php $url = add_query_arg( 'accesibedomainscan', str_replace( 'http:', 'https:', home_url() ), 'https://querysol.com/scan' ); ?>
|
125 |
+
<iframe src="<?php echo $url; ?>" scrolling="no" style=" width: 100%; height: 100vh; overflow: hidden;" ></iframe>
|
126 |
+
<form action="<?php echo $this->get_settings_url(); ?>" method="post" class="accesibe-settings-form-footer">
|
127 |
+
<button type="submit" class="site-button js-active site-button-animate site-button-right-icon site-button-full" data-element="signup-button">
|
128 |
+
<span class="align-middle">
|
129 |
+
<?php _e( 'Create a Free Account!', 'wpcf7-redirect' ); ?> <span class="dashicons dashicons-arrow-right-alt2"></span>
|
130 |
+
</span>
|
131 |
+
</button>
|
132 |
+
<input type="hidden" name="start-free-trial" value="<?php echo qs_get_plugin_display_name(); ?>" />
|
133 |
+
</form>
|
134 |
+
<div class="footer-wrap">
|
135 |
+
<a class=" align-middle" href="<?php echo admin_url( '?deactivate=' . qs_get_plugin_display_name() ); ?>">
|
136 |
+
<?php _e( 'Hide This Special Offer', 'wpcf7-redirect' ); ?>
|
137 |
+
</a>
|
138 |
+
</div>
|
139 |
+
<?php else : ?>
|
140 |
+
<form name="accesibe-registration" action="<?php echo $this->get_settings_url(); ?>" method="post" class="accesibe-settings-form">
|
141 |
+
<div class="success-message">
|
142 |
+
<h3>
|
143 |
+
Thank you for installing accessibe!
|
144 |
+
</h3>
|
145 |
+
<div class="success-message-subtitle">
|
146 |
+
The plugin is now active on your website.
|
147 |
+
</div>
|
148 |
+
<div class="success-content">
|
149 |
+
If you want to customize the widget settings you can do it here: <br/>
|
150 |
+
To deactivate the plugin you can <a class=" align-middle" href="<?php echo admin_url( '?deactivate=' . qs_get_plugin_display_name() ); ?>">Click Here.</a>
|
151 |
+
</div>
|
152 |
+
</div>
|
153 |
+
<?php $this->get_settings_form(); ?>
|
154 |
+
|
155 |
+
<div class="qs-row">
|
156 |
+
<div class="qs-col">
|
157 |
+
<button type="submit" class="site-button js-active site-button-animate site-button-right-icon site-button-full" data-element="signup-button">
|
158 |
+
<span class="align-middle"><?php _e( 'Save', 'wpcf7-redirect' ); ?></span>
|
159 |
+
</button>
|
160 |
+
</div>
|
161 |
+
</div>
|
162 |
+
<input type="hidden" name="save_ext_settings" value="<?php echo qs_get_plugin_display_name(); ?>" />
|
163 |
+
</form>
|
164 |
+
<?php endif; ?>
|
165 |
+
</section>
|
classes/class-qs-api.php
CHANGED
@@ -1,320 +1,320 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class Qs_Api
|
4 |
-
* A class used for contacting Query Solutions API
|
5 |
-
*/
|
6 |
-
|
7 |
-
defined( 'ABSPATH' ) || exit;
|
8 |
-
|
9 |
-
class Qs_Api {
|
10 |
-
|
11 |
-
public function __construct() {
|
12 |
-
$this->activation_url = WPCF7_PRO_REDIRECT_PLUGIN_ACTIVATION_URL;
|
13 |
-
$this->changelog_url = WPCF7_PRO_REDIRECT_PLUGIN_CHANGELOG_URL;
|
14 |
-
$this->api_url = WPCF7_PRO_REDIRECT_PLUGIN_UPDATES;
|
15 |
-
$this->store_id = WPCF7_PRO_REDIRECT_PLUGIN_ID;
|
16 |
-
$this->sku = WPCF7_PRO_REDIRECT_PLUGIN_SKU;
|
17 |
-
$this->extensions_list_url = WPCF7_PRO_REDIRECT_PLUGIN_EXTENSIONS_LIST_URL;
|
18 |
-
$this->promotions_url = WPCF7_PRO_REDIRECT_PLUGIN_PROMOTIONS_URL;
|
19 |
-
}
|
20 |
-
|
21 |
-
public function extension_has_update( $extension ) {
|
22 |
-
$current_ver = $extension->get_extension_ver();
|
23 |
-
|
24 |
-
$params = array(
|
25 |
-
'action' => 'license_key_validate',
|
26 |
-
'store_code' => $this->store_id,
|
27 |
-
'license_key' => $extension->get_serial(),
|
28 |
-
'domain' => $this->get_current_domain(),
|
29 |
-
'sku' => $extension->get_name(),
|
30 |
-
'activation_id' => $extension->get_activation_id(),
|
31 |
-
);
|
32 |
-
|
33 |
-
$results = $this->api_call( $this->activation_url, $params );
|
34 |
-
|
35 |
-
if ( ! is_wp_error( $results ) && isset( $results->data->version ) ) {
|
36 |
-
return floatval( $results->data->version ) > floatval( $current_ver ) ? $results->data->version : '';
|
37 |
-
}
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Get action extension changelog
|
42 |
-
*/
|
43 |
-
public function get_action_changelog( $sku ) {
|
44 |
-
|
45 |
-
$params = array(
|
46 |
-
'ignore_unknown' => true,
|
47 |
-
);
|
48 |
-
|
49 |
-
$res = $this->api_call( $this->changelog_url . $sku, $params );
|
50 |
-
|
51 |
-
return $res;
|
52 |
-
}
|
53 |
-
/**
|
54 |
-
* Get a list of all extensions available on the server.
|
55 |
-
*
|
56 |
-
* @return void
|
57 |
-
*/
|
58 |
-
public function get_extensions_definitions() {
|
59 |
-
$params = array(
|
60 |
-
'ignore_unknown' => true,
|
61 |
-
);
|
62 |
-
|
63 |
-
if ( ! $this->update_extentions_list() ) {
|
64 |
-
return false;
|
65 |
-
}
|
66 |
-
|
67 |
-
$results = $this->api_call( $this->extensions_list_url, $params );
|
68 |
-
|
69 |
-
if ( ! is_wp_error( $results ) ) {
|
70 |
-
$extensions_list = (array) $results->response;
|
71 |
-
|
72 |
-
$extensions_list = array_map(
|
73 |
-
function( $extension_definition ) {
|
74 |
-
return (array) $extension_definition;
|
75 |
-
},
|
76 |
-
$extensions_list
|
77 |
-
);
|
78 |
-
|
79 |
-
update_option( 'wpcf7r-extensions-list', $extensions_list );
|
80 |
-
update_option( 'wpcf7r-extensions-list-updated', current_time( 'timestamp' ) );
|
81 |
-
}
|
82 |
-
|
83 |
-
return $extensions_list;
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Check id extensions list update is required.
|
88 |
-
* Get a list of extensions once a week.
|
89 |
-
*
|
90 |
-
* @return boolean - true - get the list.
|
91 |
-
*/
|
92 |
-
private function update_extentions_list() {
|
93 |
-
return isset( $_POST['extensions-updates-check'] ) && $_POST['extensions-updates-check'];
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Check if banner update is required.
|
98 |
-
*
|
99 |
-
* @return boolean - true - get the banner.
|
100 |
-
*/
|
101 |
-
private function update_promotions() {
|
102 |
-
return isset( $_POST['update-banner'] ) && $_POST['update-banner'];
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Get an updated promotion banner.
|
107 |
-
*
|
108 |
-
* @return array - the banner html anb version.
|
109 |
-
*/
|
110 |
-
public function get_promotion_banner() {
|
111 |
-
$params = array(
|
112 |
-
'ignore_unknown' => true,
|
113 |
-
);
|
114 |
-
|
115 |
-
if ( $this->update_promotions() ) {
|
116 |
-
$results = $this->api_call( $this->promotions_url, $params );
|
117 |
-
|
118 |
-
if ( ! is_wp_error( $results ) ) {
|
119 |
-
return $results;
|
120 |
-
}
|
121 |
-
}
|
122 |
-
|
123 |
-
return false;
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Make the API call
|
128 |
-
*/
|
129 |
-
public function api_call( $url, $params, $args = array() ) {
|
130 |
-
$defaults = array(
|
131 |
-
'timeout' => 100,
|
132 |
-
'redirection' => 5,
|
133 |
-
'httpversion' => '1.0',
|
134 |
-
'blocking' => true,
|
135 |
-
'headers' => array(),
|
136 |
-
'cookies' => array(),
|
137 |
-
'body' => $params,
|
138 |
-
'compress' => false,
|
139 |
-
'decompress' => true,
|
140 |
-
'sslverify' => false,
|
141 |
-
'stream' => false,
|
142 |
-
'filename' => null,
|
143 |
-
);
|
144 |
-
|
145 |
-
$args = wp_parse_args( $args, $defaults );
|
146 |
-
|
147 |
-
$results = wp_remote_post( $url, $args );
|
148 |
-
|
149 |
-
if ( ! is_wp_error( $results ) ) {
|
150 |
-
$body = wp_remote_retrieve_body( $results );
|
151 |
-
|
152 |
-
$results = json_decode( $body );
|
153 |
-
|
154 |
-
if ( is_wp_error( $results ) ) {
|
155 |
-
return $results;
|
156 |
-
}
|
157 |
-
|
158 |
-
if ( ! isset( $results->error ) && ! isset( $params['ignore_unknown'] ) ) {
|
159 |
-
return new WP_Error( $params['action'], 'Unknown error' );
|
160 |
-
}
|
161 |
-
|
162 |
-
if ( isset( $results->error ) && $results->error ) {
|
163 |
-
return new WP_Error( $params['action'], $results->errors );
|
164 |
-
}
|
165 |
-
|
166 |
-
if ( isset( $results->data ) ) {
|
167 |
-
$results->data->downloadable = '';
|
168 |
-
}
|
169 |
-
}
|
170 |
-
|
171 |
-
return $results;
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Get the domain where the plugin is intalled for authentication
|
176 |
-
*/
|
177 |
-
public function get_current_domain() {
|
178 |
-
return isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '';
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Check if the serial is valid
|
183 |
-
*
|
184 |
-
* @param $activation_id
|
185 |
-
* @param $serial
|
186 |
-
* @param $sku
|
187 |
-
*/
|
188 |
-
public function validate_serial( $activation_id, $serial, $sku = '' ) {
|
189 |
-
$params = array(
|
190 |
-
'action' => 'license_key_validate',
|
191 |
-
'store_code' => $this->store_id,
|
192 |
-
'license_key' => $serial,
|
193 |
-
'domain' => $this->get_current_domain(),
|
194 |
-
'sku' => $sku ? $sku : $this->sku,
|
195 |
-
'activation_id' => $activation_id,
|
196 |
-
);
|
197 |
-
|
198 |
-
$results = $this->api_call( $this->activation_url, $params );
|
199 |
-
|
200 |
-
return $results;
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Deactivate the specific activation serial
|
205 |
-
*
|
206 |
-
* @param $activation_id
|
207 |
-
* @param $serial
|
208 |
-
* @param string $sku
|
209 |
-
*/
|
210 |
-
public function deactivate_liscense( $activation_id, $serial, $sku = '' ) {
|
211 |
-
$params = array(
|
212 |
-
'action' => 'license_key_deactivate',
|
213 |
-
'store_code' => $this->store_id,
|
214 |
-
'license_key' => $serial,
|
215 |
-
'domain' => $this->get_current_domain(),
|
216 |
-
'sku' => $sku ? $sku : $this->sku,
|
217 |
-
'activation_id' => $activation_id,
|
218 |
-
);
|
219 |
-
|
220 |
-
$results = $this->api_call( $this->activation_url, $params );
|
221 |
-
|
222 |
-
return $results;
|
223 |
-
}
|
224 |
-
|
225 |
-
public function get_extension_download_url( $activation_data, $sku ) {
|
226 |
-
$params = array(
|
227 |
-
'action' => 'get_extension_file',
|
228 |
-
'store_code' => $this->store_id,
|
229 |
-
'license_key' => $activation_data->the_key,
|
230 |
-
'domain' => $this->get_current_domain(),
|
231 |
-
'sku' => $sku ? $sku : $this->sku,
|
232 |
-
'activation_id' => $activation_data->activation_id,
|
233 |
-
'sub_action' => 'download',
|
234 |
-
);
|
235 |
-
|
236 |
-
$url = add_query_arg( $params, $this->api_url );
|
237 |
-
|
238 |
-
$args = array(
|
239 |
-
'timeout' => 100,
|
240 |
-
'redirection' => 5,
|
241 |
-
'httpversion' => '1.0',
|
242 |
-
'blocking' => true,
|
243 |
-
'headers' => array(),
|
244 |
-
'cookies' => array(),
|
245 |
-
'body' => $params,
|
246 |
-
'compress' => false,
|
247 |
-
'decompress' => true,
|
248 |
-
'sslverify' => true,
|
249 |
-
'stream' => false,
|
250 |
-
'filename' => null,
|
251 |
-
);
|
252 |
-
|
253 |
-
$results = wp_remote_post( $url, $args );
|
254 |
-
|
255 |
-
if ( ! is_wp_error( $results ) && $results ) {
|
256 |
-
|
257 |
-
$results = wp_remote_retrieve_body( $results );
|
258 |
-
|
259 |
-
$results = json_decode( $results );
|
260 |
-
|
261 |
-
$results = $results->download_link;
|
262 |
-
} elseif ( ! $results ) {
|
263 |
-
$results = new WP_Error( 'get_extension_file', __( 'Cannot download the file', 'wpcf7-redirect' ) );
|
264 |
-
}
|
265 |
-
|
266 |
-
return $results;
|
267 |
-
}
|
268 |
-
|
269 |
-
public function get_extension_file( $activation_data, $sku ) {
|
270 |
-
|
271 |
-
$download_link = $this->get_extension_download_url( $activation_data, $sku );
|
272 |
-
|
273 |
-
if ( ! is_wp_error( $download_link ) ) {
|
274 |
-
$results = download_url( $download_link, 1000 );
|
275 |
-
}
|
276 |
-
|
277 |
-
return $results;
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Activate the serial
|
282 |
-
*
|
283 |
-
* @param $serial
|
284 |
-
* @param $sku
|
285 |
-
*/
|
286 |
-
public function activate_serial( $serial, $sku = '' ) {
|
287 |
-
$params = array(
|
288 |
-
'action' => 'license_key_activate',
|
289 |
-
'store_code' => $this->store_id,
|
290 |
-
'license_key' => $serial,
|
291 |
-
'domain' => $this->get_current_domain(),
|
292 |
-
'sku' => $sku ? $sku : $this->sku,
|
293 |
-
);
|
294 |
-
|
295 |
-
$results = $this->api_call( $this->activation_url, $params );
|
296 |
-
|
297 |
-
return $results;
|
298 |
-
}
|
299 |
-
|
300 |
-
/**
|
301 |
-
* Check if the API returned a vlid response
|
302 |
-
*
|
303 |
-
* @param $results
|
304 |
-
* @return boolean
|
305 |
-
*/
|
306 |
-
public function is_valid_response( $results ) {
|
307 |
-
if ( ! is_wp_error( $results ) ) {
|
308 |
-
if ( is_object( $results ) ) {
|
309 |
-
if ( isset( $results->error ) && ! $results->error ) {
|
310 |
-
return true;
|
311 |
-
}
|
312 |
-
} else {
|
313 |
-
if ( isset( $results['error'] ) && ! $results['error'] ) {
|
314 |
-
return true;
|
315 |
-
}
|
316 |
-
}
|
317 |
-
}
|
318 |
-
return false;
|
319 |
-
}
|
320 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Qs_Api
|
4 |
+
* A class used for contacting Query Solutions API
|
5 |
+
*/
|
6 |
+
|
7 |
+
defined( 'ABSPATH' ) || exit;
|
8 |
+
|
9 |
+
class Qs_Api {
|
10 |
+
|
11 |
+
public function __construct() {
|
12 |
+
$this->activation_url = WPCF7_PRO_REDIRECT_PLUGIN_ACTIVATION_URL;
|
13 |
+
$this->changelog_url = WPCF7_PRO_REDIRECT_PLUGIN_CHANGELOG_URL;
|
14 |
+
$this->api_url = WPCF7_PRO_REDIRECT_PLUGIN_UPDATES;
|
15 |
+
$this->store_id = WPCF7_PRO_REDIRECT_PLUGIN_ID;
|
16 |
+
$this->sku = WPCF7_PRO_REDIRECT_PLUGIN_SKU;
|
17 |
+
$this->extensions_list_url = WPCF7_PRO_REDIRECT_PLUGIN_EXTENSIONS_LIST_URL;
|
18 |
+
$this->promotions_url = WPCF7_PRO_REDIRECT_PLUGIN_PROMOTIONS_URL;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function extension_has_update( $extension ) {
|
22 |
+
$current_ver = $extension->get_extension_ver();
|
23 |
+
|
24 |
+
$params = array(
|
25 |
+
'action' => 'license_key_validate',
|
26 |
+
'store_code' => $this->store_id,
|
27 |
+
'license_key' => $extension->get_serial(),
|
28 |
+
'domain' => $this->get_current_domain(),
|
29 |
+
'sku' => $extension->get_name(),
|
30 |
+
'activation_id' => $extension->get_activation_id(),
|
31 |
+
);
|
32 |
+
|
33 |
+
$results = $this->api_call( $this->activation_url, $params );
|
34 |
+
|
35 |
+
if ( ! is_wp_error( $results ) && isset( $results->data->version ) ) {
|
36 |
+
return floatval( $results->data->version ) > floatval( $current_ver ) ? $results->data->version : '';
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get action extension changelog
|
42 |
+
*/
|
43 |
+
public function get_action_changelog( $sku ) {
|
44 |
+
|
45 |
+
$params = array(
|
46 |
+
'ignore_unknown' => true,
|
47 |
+
);
|
48 |
+
|
49 |
+
$res = $this->api_call( $this->changelog_url . $sku, $params );
|
50 |
+
|
51 |
+
return $res;
|
52 |
+
}
|
53 |
+
/**
|
54 |
+
* Get a list of all extensions available on the server.
|
55 |
+
*
|
56 |
+
* @return void
|
57 |
+
*/
|
58 |
+
public function get_extensions_definitions() {
|
59 |
+
$params = array(
|
60 |
+
'ignore_unknown' => true,
|
61 |
+
);
|
62 |
+
|
63 |
+
if ( ! $this->update_extentions_list() ) {
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
|
67 |
+
$results = $this->api_call( $this->extensions_list_url, $params );
|
68 |
+
|
69 |
+
if ( ! is_wp_error( $results ) ) {
|
70 |
+
$extensions_list = (array) $results->response;
|
71 |
+
|
72 |
+
$extensions_list = array_map(
|
73 |
+
function( $extension_definition ) {
|
74 |
+
return (array) $extension_definition;
|
75 |
+
},
|
76 |
+
$extensions_list
|
77 |
+
);
|
78 |
+
|
79 |
+
update_option( 'wpcf7r-extensions-list', $extensions_list );
|
80 |
+
update_option( 'wpcf7r-extensions-list-updated', current_time( 'timestamp' ) );
|
81 |
+
}
|
82 |
+
|
83 |
+
return $extensions_list;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Check id extensions list update is required.
|
88 |
+
* Get a list of extensions once a week.
|
89 |
+
*
|
90 |
+
* @return boolean - true - get the list.
|
91 |
+
*/
|
92 |
+
private function update_extentions_list() {
|
93 |
+
return isset( $_POST['extensions-updates-check'] ) && $_POST['extensions-updates-check'];
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Check if banner update is required.
|
98 |
+
*
|
99 |
+
* @return boolean - true - get the banner.
|
100 |
+
*/
|
101 |
+
private function update_promotions() {
|
102 |
+
return isset( $_POST['update-banner'] ) && $_POST['update-banner'];
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Get an updated promotion banner.
|
107 |
+
*
|
108 |
+
* @return array - the banner html anb version.
|
109 |
+
*/
|
110 |
+
public function get_promotion_banner() {
|
111 |
+
$params = array(
|
112 |
+
'ignore_unknown' => true,
|
113 |
+
);
|
114 |
+
|
115 |
+
if ( $this->update_promotions() ) {
|
116 |
+
$results = $this->api_call( $this->promotions_url, $params );
|
117 |
+
|
118 |
+
if ( ! is_wp_error( $results ) ) {
|
119 |
+
return $results;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
return false;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Make the API call
|
128 |
+
*/
|
129 |
+
public function api_call( $url, $params, $args = array() ) {
|
130 |
+
$defaults = array(
|
131 |
+
'timeout' => 100,
|
132 |
+
'redirection' => 5,
|
133 |
+
'httpversion' => '1.0',
|
134 |
+
'blocking' => true,
|
135 |
+
'headers' => array(),
|
136 |
+
'cookies' => array(),
|
137 |
+
'body' => $params,
|
138 |
+
'compress' => false,
|
139 |
+
'decompress' => true,
|
140 |
+
'sslverify' => false,
|
141 |
+
'stream' => false,
|
142 |
+
'filename' => null,
|
143 |
+
);
|
144 |
+
|
145 |
+
$args = wp_parse_args( $args, $defaults );
|
146 |
+
|
147 |
+
$results = wp_remote_post( $url, $args );
|
148 |
+
|
149 |
+
if ( ! is_wp_error( $results ) ) {
|
150 |
+
$body = wp_remote_retrieve_body( $results );
|
151 |
+
|
152 |
+
$results = json_decode( $body );
|
153 |
+
|
154 |
+
if ( is_wp_error( $results ) ) {
|
155 |
+
return $results;
|
156 |
+
}
|
157 |
+
|
158 |
+
if ( ! isset( $results->error ) && ! isset( $params['ignore_unknown'] ) ) {
|
159 |
+
return new WP_Error( $params['action'], 'Unknown error' );
|
160 |
+
}
|
161 |
+
|
162 |
+
if ( isset( $results->error ) && $results->error ) {
|
163 |
+
return new WP_Error( $params['action'], $results->errors );
|
164 |
+
}
|
165 |
+
|
166 |
+
if ( isset( $results->data ) ) {
|
167 |
+
$results->data->downloadable = '';
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
return $results;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Get the domain where the plugin is intalled for authentication
|
176 |
+
*/
|
177 |
+
public function get_current_domain() {
|
178 |
+
return isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '';
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Check if the serial is valid
|
183 |
+
*
|
184 |
+
* @param $activation_id
|
185 |
+
* @param $serial
|
186 |
+
* @param $sku
|
187 |
+
*/
|
188 |
+
public function validate_serial( $activation_id, $serial, $sku = '' ) {
|
189 |
+
$params = array(
|
190 |
+
'action' => 'license_key_validate',
|
191 |
+
'store_code' => $this->store_id,
|
192 |
+
'license_key' => $serial,
|
193 |
+
'domain' => $this->get_current_domain(),
|
194 |
+
'sku' => $sku ? $sku : $this->sku,
|
195 |
+
'activation_id' => $activation_id,
|
196 |
+
);
|
197 |
+
|
198 |
+
$results = $this->api_call( $this->activation_url, $params );
|
199 |
+
|
200 |
+
return $results;
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Deactivate the specific activation serial
|
205 |
+
*
|
206 |
+
* @param $activation_id
|
207 |
+
* @param $serial
|
208 |
+
* @param string $sku
|
209 |
+
*/
|
210 |
+
public function deactivate_liscense( $activation_id, $serial, $sku = '' ) {
|
211 |
+
$params = array(
|
212 |
+
'action' => 'license_key_deactivate',
|
213 |
+
'store_code' => $this->store_id,
|
214 |
+
'license_key' => $serial,
|
215 |
+
'domain' => $this->get_current_domain(),
|
216 |
+
'sku' => $sku ? $sku : $this->sku,
|
217 |
+
'activation_id' => $activation_id,
|
218 |
+
);
|
219 |
+
|
220 |
+
$results = $this->api_call( $this->activation_url, $params );
|
221 |
+
|
222 |
+
return $results;
|
223 |
+
}
|
224 |
+
|
225 |
+
public function get_extension_download_url( $activation_data, $sku ) {
|
226 |
+
$params = array(
|
227 |
+
'action' => 'get_extension_file',
|
228 |
+
'store_code' => $this->store_id,
|
229 |
+
'license_key' => $activation_data->the_key,
|
230 |
+
'domain' => $this->get_current_domain(),
|
231 |
+
'sku' => $sku ? $sku : $this->sku,
|
232 |
+
'activation_id' => $activation_data->activation_id,
|
233 |
+
'sub_action' => 'download',
|
234 |
+
);
|
235 |
+
|
236 |
+
$url = add_query_arg( $params, $this->api_url );
|
237 |
+
|
238 |
+
$args = array(
|
239 |
+
'timeout' => 100,
|
240 |
+
'redirection' => 5,
|
241 |
+
'httpversion' => '1.0',
|
242 |
+
'blocking' => true,
|
243 |
+
'headers' => array(),
|
244 |
+
'cookies' => array(),
|
245 |
+
'body' => $params,
|
246 |
+
'compress' => false,
|
247 |
+
'decompress' => true,
|
248 |
+
'sslverify' => true,
|
249 |
+
'stream' => false,
|
250 |
+
'filename' => null,
|
251 |
+
);
|
252 |
+
|
253 |
+
$results = wp_remote_post( $url, $args );
|
254 |
+
|
255 |
+
if ( ! is_wp_error( $results ) && $results ) {
|
256 |
+
|
257 |
+
$results = wp_remote_retrieve_body( $results );
|
258 |
+
|
259 |
+
$results = json_decode( $results );
|
260 |
+
|
261 |
+
$results = $results->download_link;
|
262 |
+
} elseif ( ! $results ) {
|
263 |
+
$results = new WP_Error( 'get_extension_file', __( 'Cannot download the file', 'wpcf7-redirect' ) );
|
264 |
+
}
|
265 |
+
|
266 |
+
return $results;
|
267 |
+
}
|
268 |
+
|
269 |
+
public function get_extension_file( $activation_data, $sku ) {
|
270 |
+
|
271 |
+
$download_link = $this->get_extension_download_url( $activation_data, $sku );
|
272 |
+
|
273 |
+
if ( ! is_wp_error( $download_link ) ) {
|
274 |
+
$results = download_url( $download_link, 1000 );
|
275 |
+
}
|
276 |
+
|
277 |
+
return $results;
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Activate the serial
|
282 |
+
*
|
283 |
+
* @param $serial
|
284 |
+
* @param $sku
|
285 |
+
*/
|
286 |
+
public function activate_serial( $serial, $sku = '' ) {
|
287 |
+
$params = array(
|
288 |
+
'action' => 'license_key_activate',
|
289 |
+
'store_code' => $this->store_id,
|
290 |
+
'license_key' => $serial,
|
291 |
+
'domain' => $this->get_current_domain(),
|
292 |
+
'sku' => $sku ? $sku : $this->sku,
|
293 |
+
);
|
294 |
+
|
295 |
+
$results = $this->api_call( $this->activation_url, $params );
|
296 |
+
|
297 |
+
return $results;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Check if the API returned a vlid response
|
302 |
+
*
|
303 |
+
* @param $results
|
304 |
+
* @return boolean
|
305 |
+
*/
|
306 |
+
public function is_valid_response( $results ) {
|
307 |
+
if ( ! is_wp_error( $results ) ) {
|
308 |
+
if ( is_object( $results ) ) {
|
309 |
+
if ( isset( $results->error ) && ! $results->error ) {
|
310 |
+
return true;
|
311 |
+
}
|
312 |
+
} else {
|
313 |
+
if ( isset( $results['error'] ) && ! $results['error'] ) {
|
314 |
+
return true;
|
315 |
+
}
|
316 |
+
}
|
317 |
+
}
|
318 |
+
return false;
|
319 |
+
}
|
320 |
+
}
|
classes/class-wpcf7r-action.php
CHANGED
@@ -1,870 +1,919 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Action - פarent class that handles all redirect actions.
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
class WPCF7R_Action {
|
9 |
-
// Save a reference to the lead id in case the save lead action is on.
|
10 |
-
public static $lead_id;
|
11 |
-
|
12 |
-
// Saved data from validation action to submission action.
|
13 |
-
public static $data;
|
14 |
-
|
15 |
-
// save refrence to global objects.
|
16 |
-
public static $global_options;
|
17 |
-
/**
|
18 |
-
* Class constructor
|
19 |
-
* Set required parameters
|
20 |
-
*
|
21 |
-
* @param string $post [description]
|
22 |
-
*/
|
23 |
-
public function __construct( $post =
|
24 |
-
$this->priority = 2;
|
25 |
-
|
26 |
-
if ( $post ) {
|
27 |
-
// save a refference to the action post.
|
28 |
-
$this->action_post = $post;
|
29 |
-
// set the action post ID.
|
30 |
-
$this->action_post_id = $post->ID;
|
31 |
-
// get the custom action fields.
|
32 |
-
$this->fields_values = get_post_custom( $this->action_post_id );
|
33 |
-
// get the contact form 7 post id.
|
34 |
-
$this->wpcf7_id = $this->get_action_wpcf7_id( $this->action_post_id );
|
35 |
-
// get the type of action.
|
36 |
-
$this->action = self::get_action_type( $this->action_post_id );
|
37 |
-
// get tje status of the action (is it active or not).
|
38 |
-
$this->action_status = $this->get_action_status( $this->action_post_id );
|
39 |
-
// get conditional logic blocks.
|
40 |
-
$this->logic_blocks = $this->get( 'blocks' );
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Returns an html for displaying a link to the form.
|
46 |
-
*
|
47 |
-
* @return [string] - a link to the form edit screen.
|
48 |
-
*/
|
49 |
-
public function get_cf7_link_html() {
|
50 |
-
return WPCF7r_Form_Helper::get_cf7_link_html( $this->wpcf7_id );
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Connected to manage_columns hooks.
|
55 |
-
*
|
56 |
-
* @param [string] $column - key of the column.
|
57 |
-
* @param [int] $post_id - the id of the relevant post.
|
58 |
-
* @return void
|
59 |
-
*/
|
60 |
-
public function display_action_column_content( $column, $post_id ) {
|
61 |
-
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Process validation action
|
66 |
-
* This function will be called on validation hook
|
67 |
-
*
|
68 |
-
* @param $submission
|
69 |
-
*/
|
70 |
-
public function process_validation( $submission ) { }
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Get action name
|
74 |
-
*/
|
75 |
-
public function get_name() {
|
76 |
-
return WPCF7r_Utils::get_action_name( $this->action );
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Adds a blank select option for select fields
|
81 |
-
*/
|
82 |
-
public function get_tags_optional() {
|
83 |
-
$tags = $this->get_mail_tags_array();
|
84 |
-
$tags_optional = array_merge( array( __( 'Select', 'wpcf7-redirect' ) ), $tags );
|
85 |
-
return $tags_optional;
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* save a reference to the lead id in case the save lead action is on
|
90 |
-
*
|
91 |
-
* @param $lead_id
|
92 |
-
*/
|
93 |
-
public function set_lead_id( $lead_id ) {
|
94 |
-
self::$lead_id = $lead_id;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* save a reference to a global feature
|
99 |
-
*
|
100 |
-
* @param $lead_id
|
101 |
-
*/
|
102 |
-
public function set_global_option( $key, $value ) {
|
103 |
-
self::$global_options[ $key ] = $value;
|
104 |
-
}
|
105 |
-
|
106 |
-
public function get_global_option( $key ) {
|
107 |
-
return isset( self::$global_options[ $key ] ) ? self::$global_options[ $key ] : '';
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Get all system user roles
|
112 |
-
*/
|
113 |
-
public function get_available_user_roles() {
|
114 |
-
return wp_roles()->get_names();
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Return the current lead id if it is availavle
|
119 |
-
*/
|
120 |
-
public static function get_lead_id() {
|
121 |
-
return isset( self::$lead_id ) ? self::$lead_id : '';
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* General function to retrieve meta
|
126 |
-
*
|
127 |
-
* @param $key
|
128 |
-
*/
|
129 |
-
public function get( $key ) {
|
130 |
-
return isset( $this->fields_values[ $key ][0] ) ? $this->fields_values[ $key ][0] : '';
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Get the contact form 7 related post id
|
135 |
-
*/
|
136 |
-
public function get_cf7_post_id() {
|
137 |
-
return isset( $this->wpcf7_id ) ? $this->wpcf7_id : '';
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Set action property
|
142 |
-
*
|
143 |
-
* @param $key
|
144 |
-
* @param $value
|
145 |
-
*/
|
146 |
-
public function set( $key, $value ) {
|
147 |
-
update_post_meta( $this->action_post_id, $key, $value );
|
148 |
-
$this->fields_values[ $key ][0] = $value;
|
149 |
-
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* Enqueue extension scripts and styles.
|
153 |
-
*
|
154 |
-
* @return void
|
155 |
-
*/
|
156 |
-
public static function enqueue_backend_scripts() {
|
157 |
-
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Enqueue extension scripts and styles.
|
162 |
-
*
|
163 |
-
* @return void
|
164 |
-
*/
|
165 |
-
public static function enqueue_frontend_scripts() {
|
166 |
-
|
167 |
-
}
|
168 |
-
/**
|
169 |
-
* Parent get action fields function
|
170 |
-
*/
|
171 |
-
public function get_action_fields() {
|
172 |
-
return array();
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Get a set of fields/specific field settings by key
|
177 |
-
*
|
178 |
-
* @param $fields_key
|
179 |
-
*/
|
180 |
-
public function get_fields_settings( $fields_key ) {
|
181 |
-
$fields = $this->get_action_fields();
|
182 |
-
|
183 |
-
return $fields[ $fields_key ];
|
184 |
-
}
|
185 |
-
|
186 |
-
/**
|
187 |
-
* Get the id of the rule
|
188 |
-
*/
|
189 |
-
public function get_rule_id() {
|
190 |
-
return $this->get( 'wpcf7_rule_id' );
|
191 |
-
}
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Get all fields values
|
195 |
-
*/
|
196 |
-
public function get_fields_values() {
|
197 |
-
$fields = $this->get_action_fields();
|
198 |
-
foreach ( $fields as $field ) {
|
199 |
-
$values[ $field['name'] ] = $this->get_field_value( $field );
|
200 |
-
}
|
201 |
-
return $values;
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* Get mail tags objects
|
206 |
-
*/
|
207 |
-
public function get_mail_tags() {
|
208 |
-
$mail_tags = WPCF7R_Form::get_mail_tags();
|
209 |
-
return $mail_tags;
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Get mail tags objects
|
214 |
-
*/
|
215 |
-
public function get_mail_tags_array() {
|
216 |
-
$mail_tags = WPCF7R_Form::get_mail_tags();
|
217 |
-
$mail_tags_array = array();
|
218 |
-
if ( $mail_tags ) {
|
219 |
-
foreach ( $mail_tags as $mail_tag ) {
|
220 |
-
$mail_tags_array[ $mail_tag->name ] = $mail_tag->name;
|
221 |
-
}
|
222 |
-
}
|
223 |
-
return $mail_tags_array;
|
224 |
-
}
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Get mail tags to display on the settings panel
|
228 |
-
*
|
229 |
-
* @param boolean $clean
|
230 |
-
*/
|
231 |
-
public function get_formatted_mail_tags( $clean = false ) {
|
232 |
-
$formatted_tags = array();
|
233 |
-
|
234 |
-
if ( ! is_array( WPCF7R_Form::get_mail_tags() ) ) {
|
235 |
-
return;
|
236 |
-
}
|
237 |
-
|
238 |
-
foreach ( WPCF7R_Form::get_mail_tags() as $mail_tag ) {
|
239 |
-
$formatted_tags[] = "<span class='mailtag code'>[{$mail_tag->name}]</span>";
|
240 |
-
}
|
241 |
-
|
242 |
-
// foreach( WPCF7R_Form::get_special_mail_tags() as $mail_tag ){
|
243 |
-
// $formatted_tags[] = "<br/><span class='mailtag code'>[".$mail_tag->field_name()."]</span>";
|
244 |
-
// }
|
245 |
-
|
246 |
-
$formatted_tags = implode( '', $formatted_tags );
|
247 |
-
if ( $clean ) {
|
248 |
-
$formatted_tags = str_replace( array( ']' ), ', ', $formatted_tags );
|
249 |
-
$formatted_tags = str_replace( array( '[' ), '', $formatted_tags );
|
250 |
-
}
|
251 |
-
|
252 |
-
ob_start();
|
253 |
-
?>
|
254 |
-
|
255 |
-
<div class="mail-tags-wrapper">
|
256 |
-
<div class="mail-tags-title" data-toggle=".mail-tags-wrapper-inner">
|
257 |
-
<strong><?php _e( 'Available mail tags', 'wpcf7-redirect' ); ?></strong> <span class="dashicons dashicons-arrow-down"></span>
|
258 |
-
</div>
|
259 |
-
<div class="mail-tags-wrapper-inner field-hidden">
|
260 |
-
<?php echo $formatted_tags; ?>
|
261 |
-
<div class="special-mail-tags">
|
262 |
-
<br/>
|
263 |
-
<a href="https://contactform7.com/special-mail-tags/"><?php _e( 'Special mail tags' ); ?></a>
|
264 |
-
<div><small><?php _e( 'These tags are available only inside the loop as described by the plugin author', 'wpcf7-redirect' ); ?></small></div>
|
265 |
-
</div>
|
266 |
-
</div>
|
267 |
-
</div>
|
268 |
-
<?php
|
269 |
-
return ob_get_clean();
|
270 |
-
}
|
271 |
-
|
272 |
-
/**
|
273 |
-
* Replace lead id from the lead manager
|
274 |
-
*
|
275 |
-
* @param $template
|
276 |
-
*/
|
277 |
-
public function replace_lead_id_tag( $template ) {
|
278 |
-
return str_replace( '[lead_id]', self::get_lead_id(), $template );
|
279 |
-
}
|
280 |
-
|
281 |
-
/**
|
282 |
-
* Replace all mail tags in a string
|
283 |
-
*
|
284 |
-
* @param $content
|
285 |
-
* @param $args
|
286 |
-
*/
|
287 |
-
public function replace_tags( $content, $args = '' ) {
|
288 |
-
if ( true === $args ) {
|
289 |
-
$args = array( 'html' => true );
|
290 |
-
}
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
'
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
$replaced_tags =
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
}
|
313 |
-
|
314 |
-
|
315 |
-
}
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
$
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
*
|
409 |
-
*
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
*
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
do_action( '
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
$
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
*
|
680 |
-
*
|
681 |
-
* @
|
682 |
-
*/
|
683 |
-
public function
|
684 |
-
|
685 |
-
}
|
686 |
-
|
687 |
-
/**
|
688 |
-
*
|
689 |
-
*/
|
690 |
-
public function
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
*
|
759 |
-
*/
|
760 |
-
|
761 |
-
$
|
762 |
-
$
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
}
|
784 |
-
}
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
$
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
}
|
836 |
-
}
|
837 |
-
return
|
838 |
-
}
|
839 |
-
|
840 |
-
/**
|
841 |
-
*
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
)
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Action - פarent class that handles all redirect actions.
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
class WPCF7R_Action {
|
9 |
+
// Save a reference to the lead id in case the save lead action is on.
|
10 |
+
public static $lead_id;
|
11 |
+
|
12 |
+
// Saved data from validation action to submission action.
|
13 |
+
public static $data;
|
14 |
+
|
15 |
+
// save refrence to global objects.
|
16 |
+
public static $global_options;
|
17 |
+
/**
|
18 |
+
* Class constructor
|
19 |
+
* Set required parameters
|
20 |
+
*
|
21 |
+
* @param string $post [description]
|
22 |
+
*/
|
23 |
+
public function __construct( $post = null ) {
|
24 |
+
$this->priority = 2;
|
25 |
+
|
26 |
+
if ( $post ) {
|
27 |
+
// save a refference to the action post.
|
28 |
+
$this->action_post = $post;
|
29 |
+
// set the action post ID.
|
30 |
+
$this->action_post_id = $post->ID;
|
31 |
+
// get the custom action fields.
|
32 |
+
$this->fields_values = get_post_custom( $this->action_post_id );
|
33 |
+
// get the contact form 7 post id.
|
34 |
+
$this->wpcf7_id = $this->get_action_wpcf7_id( $this->action_post_id );
|
35 |
+
// get the type of action.
|
36 |
+
$this->action = self::get_action_type( $this->action_post_id );
|
37 |
+
// get tje status of the action (is it active or not).
|
38 |
+
$this->action_status = $this->get_action_status( $this->action_post_id );
|
39 |
+
// get conditional logic blocks.
|
40 |
+
$this->logic_blocks = $this->get( 'blocks' );
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Returns an html for displaying a link to the form.
|
46 |
+
*
|
47 |
+
* @return [string] - a link to the form edit screen.
|
48 |
+
*/
|
49 |
+
public function get_cf7_link_html() {
|
50 |
+
return WPCF7r_Form_Helper::get_cf7_link_html( $this->wpcf7_id );
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Connected to manage_columns hooks.
|
55 |
+
*
|
56 |
+
* @param [string] $column - key of the column.
|
57 |
+
* @param [int] $post_id - the id of the relevant post.
|
58 |
+
* @return void
|
59 |
+
*/
|
60 |
+
public function display_action_column_content( $column, $post_id ) {
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Process validation action
|
66 |
+
* This function will be called on validation hook
|
67 |
+
*
|
68 |
+
* @param $submission
|
69 |
+
*/
|
70 |
+
public function process_validation( $submission ) { }
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Get action name
|
74 |
+
*/
|
75 |
+
public function get_name() {
|
76 |
+
return WPCF7r_Utils::get_action_name( $this->action );
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Adds a blank select option for select fields
|
81 |
+
*/
|
82 |
+
public function get_tags_optional() {
|
83 |
+
$tags = $this->get_mail_tags_array();
|
84 |
+
$tags_optional = array_merge( array( __( 'Select', 'wpcf7-redirect' ) ), $tags );
|
85 |
+
return $tags_optional;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* save a reference to the lead id in case the save lead action is on
|
90 |
+
*
|
91 |
+
* @param $lead_id
|
92 |
+
*/
|
93 |
+
public function set_lead_id( $lead_id ) {
|
94 |
+
self::$lead_id = $lead_id;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* save a reference to a global feature
|
99 |
+
*
|
100 |
+
* @param $lead_id
|
101 |
+
*/
|
102 |
+
public function set_global_option( $key, $value ) {
|
103 |
+
self::$global_options[ $key ] = $value;
|
104 |
+
}
|
105 |
+
|
106 |
+
public function get_global_option( $key ) {
|
107 |
+
return isset( self::$global_options[ $key ] ) ? self::$global_options[ $key ] : '';
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Get all system user roles
|
112 |
+
*/
|
113 |
+
public function get_available_user_roles() {
|
114 |
+
return wp_roles()->get_names();
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Return the current lead id if it is availavle
|
119 |
+
*/
|
120 |
+
public static function get_lead_id() {
|
121 |
+
return isset( self::$lead_id ) ? self::$lead_id : '';
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* General function to retrieve meta
|
126 |
+
*
|
127 |
+
* @param $key
|
128 |
+
*/
|
129 |
+
public function get( $key ) {
|
130 |
+
return isset( $this->fields_values[ $key ][0] ) ? $this->fields_values[ $key ][0] : '';
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Get the contact form 7 related post id
|
135 |
+
*/
|
136 |
+
public function get_cf7_post_id() {
|
137 |
+
return isset( $this->wpcf7_id ) ? $this->wpcf7_id : '';
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Set action property
|
142 |
+
*
|
143 |
+
* @param $key
|
144 |
+
* @param $value
|
145 |
+
*/
|
146 |
+
public function set( $key, $value ) {
|
147 |
+
update_post_meta( $this->action_post_id, $key, $value );
|
148 |
+
$this->fields_values[ $key ][0] = $value;
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Enqueue extension scripts and styles.
|
153 |
+
*
|
154 |
+
* @return void
|
155 |
+
*/
|
156 |
+
public static function enqueue_backend_scripts() {
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Enqueue extension scripts and styles.
|
162 |
+
*
|
163 |
+
* @return void
|
164 |
+
*/
|
165 |
+
public static function enqueue_frontend_scripts() {
|
166 |
+
|
167 |
+
}
|
168 |
+
/**
|
169 |
+
* Parent get action fields function
|
170 |
+
*/
|
171 |
+
public function get_action_fields() {
|
172 |
+
return array();
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Get a set of fields/specific field settings by key
|
177 |
+
*
|
178 |
+
* @param $fields_key
|
179 |
+
*/
|
180 |
+
public function get_fields_settings( $fields_key ) {
|
181 |
+
$fields = $this->get_action_fields();
|
182 |
+
|
183 |
+
return $fields[ $fields_key ];
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Get the id of the rule
|
188 |
+
*/
|
189 |
+
public function get_rule_id() {
|
190 |
+
return $this->get( 'wpcf7_rule_id' );
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Get all fields values
|
195 |
+
*/
|
196 |
+
public function get_fields_values() {
|
197 |
+
$fields = $this->get_action_fields();
|
198 |
+
foreach ( $fields as $field ) {
|
199 |
+
$values[ $field['name'] ] = $this->get_field_value( $field );
|
200 |
+
}
|
201 |
+
return $values;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Get mail tags objects
|
206 |
+
*/
|
207 |
+
public function get_mail_tags() {
|
208 |
+
$mail_tags = WPCF7R_Form::get_mail_tags();
|
209 |
+
return $mail_tags;
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Get mail tags objects
|
214 |
+
*/
|
215 |
+
public function get_mail_tags_array() {
|
216 |
+
$mail_tags = WPCF7R_Form::get_mail_tags();
|
217 |
+
$mail_tags_array = array();
|
218 |
+
if ( $mail_tags ) {
|
219 |
+
foreach ( $mail_tags as $mail_tag ) {
|
220 |
+
$mail_tags_array[ $mail_tag->name ] = $mail_tag->name;
|
221 |
+
}
|
222 |
+
}
|
223 |
+
return $mail_tags_array;
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Get mail tags to display on the settings panel
|
228 |
+
*
|
229 |
+
* @param boolean $clean
|
230 |
+
*/
|
231 |
+
public function get_formatted_mail_tags( $clean = false ) {
|
232 |
+
$formatted_tags = array();
|
233 |
+
|
234 |
+
if ( ! is_array( WPCF7R_Form::get_mail_tags() ) ) {
|
235 |
+
return;
|
236 |
+
}
|
237 |
+
|
238 |
+
foreach ( WPCF7R_Form::get_mail_tags() as $mail_tag ) {
|
239 |
+
$formatted_tags[] = "<span class='mailtag code'>[{$mail_tag->name}]</span>";
|
240 |
+
}
|
241 |
+
|
242 |
+
// foreach( WPCF7R_Form::get_special_mail_tags() as $mail_tag ){
|
243 |
+
// $formatted_tags[] = "<br/><span class='mailtag code'>[".$mail_tag->field_name()."]</span>";
|
244 |
+
// }
|
245 |
+
|
246 |
+
$formatted_tags = implode( '', $formatted_tags );
|
247 |
+
if ( $clean ) {
|
248 |
+
$formatted_tags = str_replace( array( ']' ), ', ', $formatted_tags );
|
249 |
+
$formatted_tags = str_replace( array( '[' ), '', $formatted_tags );
|
250 |
+
}
|
251 |
+
|
252 |
+
ob_start();
|
253 |
+
?>
|
254 |
+
|
255 |
+
<div class="mail-tags-wrapper">
|
256 |
+
<div class="mail-tags-title" data-toggle=".mail-tags-wrapper-inner">
|
257 |
+
<strong><?php _e( 'Available mail tags', 'wpcf7-redirect' ); ?></strong> <span class="dashicons dashicons-arrow-down"></span>
|
258 |
+
</div>
|
259 |
+
<div class="mail-tags-wrapper-inner field-hidden">
|
260 |
+
<?php echo $formatted_tags; ?>
|
261 |
+
<div class="special-mail-tags">
|
262 |
+
<br/>
|
263 |
+
<a href="https://contactform7.com/special-mail-tags/"><?php _e( 'Special mail tags' ); ?></a>
|
264 |
+
<div><small><?php _e( 'These tags are available only inside the loop as described by the plugin author', 'wpcf7-redirect' ); ?></small></div>
|
265 |
+
</div>
|
266 |
+
</div>
|
267 |
+
</div>
|
268 |
+
<?php
|
269 |
+
return ob_get_clean();
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Replace lead id from the lead manager
|
274 |
+
*
|
275 |
+
* @param $template
|
276 |
+
*/
|
277 |
+
public function replace_lead_id_tag( $template ) {
|
278 |
+
return str_replace( '[lead_id]', self::get_lead_id(), $template );
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Replace all mail tags in a string
|
283 |
+
*
|
284 |
+
* @param $content
|
285 |
+
* @param $args
|
286 |
+
*/
|
287 |
+
public function replace_tags( $content, $args = '' ) {
|
288 |
+
if ( true === $args ) {
|
289 |
+
$args = array( 'html' => true );
|
290 |
+
}
|
291 |
+
|
292 |
+
$args = wp_parse_args(
|
293 |
+
$args,
|
294 |
+
array(
|
295 |
+
'html' => false,
|
296 |
+
'exclude_blank' => false,
|
297 |
+
)
|
298 |
+
);
|
299 |
+
|
300 |
+
$replaced_tags = wpcf7_mail_replace_tags( $content, $args );
|
301 |
+
$replaced_tags = do_shortcode( $replaced_tags );
|
302 |
+
$replaced_tags = $this->replace_lead_id_tag( $replaced_tags );
|
303 |
+
|
304 |
+
$files = $this->get_files_shortcodes_from_submitted_data();
|
305 |
+
|
306 |
+
if ( $files ) {
|
307 |
+
foreach ( $files as $file_shortcodes ) {
|
308 |
+
foreach ( $file_shortcodes as $file_shortcode => $data ) {
|
309 |
+
$replaced_tags = str_replace( $file_shortcode, $data, $replaced_tags );
|
310 |
+
}
|
311 |
+
}
|
312 |
+
}
|
313 |
+
|
314 |
+
return $replaced_tags;
|
315 |
+
}
|
316 |
+
|
317 |
+
public function get_files_shortcodes_from_submitted_data() {
|
318 |
+
$submission = WPCF7_Submission::get_instance();
|
319 |
+
$file_tags = array();
|
320 |
+
|
321 |
+
if ( $submission ) {
|
322 |
+
$files = $submission->uploaded_files();
|
323 |
+
|
324 |
+
foreach ( $files as $file_key => $file_paths ) {
|
325 |
+
$file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths );
|
326 |
+
|
327 |
+
foreach ( $file_paths as $file_path ) {
|
328 |
+
$file_tags[ $file_key ] = array(
|
329 |
+
'[' . $file_key . '-filename]' => basename( $file_path ),
|
330 |
+
'[' . $file_key . '-base_64_file]' => $this->base_64_file( $file_path ),
|
331 |
+
'[' . $file_key . '-path]' => $file_path,
|
332 |
+
);
|
333 |
+
}
|
334 |
+
}
|
335 |
+
}
|
336 |
+
|
337 |
+
return $file_tags;
|
338 |
+
}
|
339 |
+
/**
|
340 |
+
* Encode A File to base64
|
341 |
+
*
|
342 |
+
* @param [type] $path
|
343 |
+
* @return void
|
344 |
+
*/
|
345 |
+
private function base_64_file( $path ) {
|
346 |
+
|
347 |
+
$data = file_get_contents( $path );
|
348 |
+
$base64 = base64_encode( $data );
|
349 |
+
|
350 |
+
return $base64;
|
351 |
+
}
|
352 |
+
|
353 |
+
/**
|
354 |
+
* Get the value of a specific field
|
355 |
+
*
|
356 |
+
* @param $field
|
357 |
+
*/
|
358 |
+
public function get_field_value( $field ) {
|
359 |
+
if ( is_array( $field ) ) {
|
360 |
+
return get_post_meta( $this->action_post_id, '_wpcf7_redirect_' . $field['name'], true );
|
361 |
+
} else {
|
362 |
+
return get_post_meta( $this->action_post_id, '_wpcf7_redirect_' . $field, true );
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
/**
|
367 |
+
* Get an instance of the relevant action class
|
368 |
+
*
|
369 |
+
* @param $post
|
370 |
+
*/
|
371 |
+
public static function get_action( $post ) {
|
372 |
+
if ( is_int( $post ) ) {
|
373 |
+
$post = get_post( $post );
|
374 |
+
}
|
375 |
+
|
376 |
+
if ( ! isset( $post->ID ) ) {
|
377 |
+
return false;
|
378 |
+
}
|
379 |
+
|
380 |
+
$action_type = self::get_action_type( $post->ID );
|
381 |
+
$class = "WPCF7R_Action_{$action_type}";
|
382 |
+
$action = '';
|
383 |
+
|
384 |
+
if ( class_exists( $class ) ) {
|
385 |
+
$action = new $class( $post );
|
386 |
+
} else {
|
387 |
+
$action_type = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $action_type ) ) );
|
388 |
+
$class = "WPCF7R_Action_{$action_type}";
|
389 |
+
|
390 |
+
if ( class_exists( $class ) ) {
|
391 |
+
$action = new $class( $post );
|
392 |
+
} else {
|
393 |
+
$action = new WP_Error( 'get_action', "Class {$class} Does not exist" );
|
394 |
+
}
|
395 |
+
}
|
396 |
+
|
397 |
+
return $action;
|
398 |
+
}
|
399 |
+
|
400 |
+
/**
|
401 |
+
* Get the action post_id
|
402 |
+
*/
|
403 |
+
public function get_id() {
|
404 |
+
return $this->action_post_id;
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Get the type of the action
|
409 |
+
*
|
410 |
+
* @param $post_id
|
411 |
+
*/
|
412 |
+
public static function get_action_type( $post_id ) {
|
413 |
+
$action_type = get_post_meta( $post_id, 'action_type', true );
|
414 |
+
|
415 |
+
$migration_list = array(
|
416 |
+
'send_mail' => 'SendMail',
|
417 |
+
'fire_script' => 'FireScript',
|
418 |
+
);
|
419 |
+
|
420 |
+
if ( isset( $migration_list[ $action_type ] ) ) {
|
421 |
+
update_post_meta( $post_id, 'action_type', $migration_list[ $action_type ] );
|
422 |
+
|
423 |
+
$action_type = $migration_list[ $action_type ];
|
424 |
+
}
|
425 |
+
|
426 |
+
return $action_type;
|
427 |
+
}
|
428 |
+
|
429 |
+
/**
|
430 |
+
* Get action status
|
431 |
+
*/
|
432 |
+
public function get_action_status() {
|
433 |
+
return $this->get( 'action_status' );
|
434 |
+
}
|
435 |
+
|
436 |
+
/**
|
437 |
+
* Get action status
|
438 |
+
*/
|
439 |
+
public function get_action_status_label() {
|
440 |
+
|
441 |
+
/* translators:%s the action status name */
|
442 |
+
return $this->get_action_status() === 'on' ? sprintf( __( 'Enable %s', 'wpcf7-redirect' ), $this->get_name() ) : __( 'Disabled', 'wpcf7-redirect' );
|
443 |
+
}
|
444 |
+
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Get contact form id
|
448 |
+
*
|
449 |
+
* @return int form id
|
450 |
+
*/
|
451 |
+
public function get_action_wpcf7_id() {
|
452 |
+
return $this->get( 'wpcf7_id' );
|
453 |
+
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Get the action title
|
457 |
+
*
|
458 |
+
* @return string action title
|
459 |
+
*/
|
460 |
+
public function get_title() {
|
461 |
+
return $this->action_post->post_title;
|
462 |
+
}
|
463 |
+
|
464 |
+
/**
|
465 |
+
* Get the action type
|
466 |
+
*
|
467 |
+
* @return string action type
|
468 |
+
*/
|
469 |
+
public function get_type() {
|
470 |
+
return $this->action;
|
471 |
+
}
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Get the action pretty name
|
475 |
+
*
|
476 |
+
* @return string action pretty name
|
477 |
+
*/
|
478 |
+
public function get_type_label() {
|
479 |
+
$actions = wpcf7r_get_available_actions();
|
480 |
+
$type = $actions[ $this->get_type() ]['label'];
|
481 |
+
return $type;
|
482 |
+
}
|
483 |
+
|
484 |
+
/**
|
485 |
+
* Get the action status
|
486 |
+
*
|
487 |
+
* @return string action status
|
488 |
+
*/
|
489 |
+
public function get_status() {
|
490 |
+
return $this->action_status;
|
491 |
+
}
|
492 |
+
|
493 |
+
/**
|
494 |
+
* Get the action menu order
|
495 |
+
*/
|
496 |
+
public function get_menu_order() {
|
497 |
+
return $this->action_post->menu_order;
|
498 |
+
}
|
499 |
+
|
500 |
+
/**
|
501 |
+
* Get the tags used on the form
|
502 |
+
*
|
503 |
+
* @param string $tag_name
|
504 |
+
*/
|
505 |
+
public function get_validation_mail_tags( $tag_name = '' ) {
|
506 |
+
$tags = WPCF7R_Form::get_validation_obj_tags();
|
507 |
+
if ( $tag_name ) {
|
508 |
+
foreach ( $tags as $tag ) {
|
509 |
+
if ( $tag->name === $tag_name ) {
|
510 |
+
return $tag;
|
511 |
+
}
|
512 |
+
}
|
513 |
+
} else {
|
514 |
+
return $tags;
|
515 |
+
}
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* Get default actions field
|
520 |
+
* This actions will apply for all child action classes
|
521 |
+
*/
|
522 |
+
function get_default_fields() {
|
523 |
+
$args = array(
|
524 |
+
'action_status' => array(
|
525 |
+
'name' => 'action_status',
|
526 |
+
'type' => 'checkbox',
|
527 |
+
'label' => $this->get_action_status_label(),
|
528 |
+
'sub_title' => 'if this is off the rule will not be applied',
|
529 |
+
'placeholder' => '',
|
530 |
+
'show_selector' => '',
|
531 |
+
'toggle-label' => json_encode(
|
532 |
+
array(
|
533 |
+
'.field-wrap-action_status .checkbox-label,.column-status a' => array(
|
534 |
+
__( 'Enabled', 'wpcf7-redirect' ),
|
535 |
+
__( 'Disabled', 'wpcf7-redirect' ),
|
536 |
+
),
|
537 |
+
)
|
538 |
+
),
|
539 |
+
'value' => $this->get( 'action_status' ),
|
540 |
+
),
|
541 |
+
);
|
542 |
+
|
543 |
+
if ( conditional_logic_enabled() ) {
|
544 |
+
$args['conditional_logic'] = array(
|
545 |
+
'name' => 'conditional_logic',
|
546 |
+
'type' => 'checkbox',
|
547 |
+
'label' => __( 'Conditional Logic', 'wpcf7-redirect' ),
|
548 |
+
'sub_title' => '',
|
549 |
+
'placeholder' => '',
|
550 |
+
'show_selector' => '.conditional-logic-blocks',
|
551 |
+
'value' => $this->get( 'conditional_logic' ),
|
552 |
+
);
|
553 |
+
} else {
|
554 |
+
$args['conditional_logic'] = array(
|
555 |
+
'name' => 'conditional_logic',
|
556 |
+
'type' => 'notice',
|
557 |
+
'label' => __( '<strong>CONDITIONAL LOGIC!</strong><br/>', 'wpcf7-redirect' ),
|
558 |
+
'sub_title' => __( 'You can purchase and activate conditional logic addon on the extensions tab.', 'wpcf7-redirect' ),
|
559 |
+
'placeholder' => '',
|
560 |
+
'class' => 'field-notice-alert',
|
561 |
+
'show_selector' => '',
|
562 |
+
);
|
563 |
+
}
|
564 |
+
|
565 |
+
$args['blocks'] = array(
|
566 |
+
'name' => 'blocks',
|
567 |
+
'type' => 'blocks',
|
568 |
+
'has_conditional_logic' => $this->get( 'conditional_logic' ),
|
569 |
+
'blocks' => $this->get_conditional_blocks(),
|
570 |
+
);
|
571 |
+
return $args;
|
572 |
+
}
|
573 |
+
|
574 |
+
/**
|
575 |
+
* Reset all action fields
|
576 |
+
*/
|
577 |
+
public function delete_all_fields() {
|
578 |
+
$fields = $this->get_action_fields();
|
579 |
+
|
580 |
+
foreach ( $fields as $field ) {
|
581 |
+
delete_post_meta( $this->action_post_id, $field['name'] );
|
582 |
+
|
583 |
+
if ( isset( $field['fields'] ) && $field['fields'] ) {
|
584 |
+
foreach ( $field['fields'] as $sub_field_key => $sub_field ) {
|
585 |
+
delete_post_meta( $this->action_post_id, $sub_field_key );
|
586 |
+
}
|
587 |
+
}
|
588 |
+
}
|
589 |
+
}
|
590 |
+
|
591 |
+
/**
|
592 |
+
* Get the template to display on the admin field
|
593 |
+
*
|
594 |
+
* @param $template
|
595 |
+
*/
|
596 |
+
public function get_settings_template( $template ) {
|
597 |
+
$prefix = "[actions][$this->action_post_id]";
|
598 |
+
include WPCF7_PRO_REDIRECT_ACTIONS_TEMPLATE_PATH . 'rule-title.php';
|
599 |
+
include WPCF7_PRO_REDIRECT_ACTIONS_TEMPLATE_PATH . $template;
|
600 |
+
}
|
601 |
+
|
602 |
+
/**
|
603 |
+
* Get a single action row
|
604 |
+
*/
|
605 |
+
public function get_action_row() {
|
606 |
+
ob_start();
|
607 |
+
do_action( 'before_wpcf7r_action_row', $this );
|
608 |
+
?>
|
609 |
+
<tr class="drag primary <?php echo $this->get_action_status() ? 'active' : 'non-active'; ?>" data-actionid="<?php echo $this->get_id(); ?>" id="post-<?php echo $this->get_id(); ?>">
|
610 |
+
<td class="manage-column cf7r-check-column ">
|
611 |
+
<span class="num"><?php echo $this->get_menu_order(); ?></span>
|
612 |
+
</td>
|
613 |
+
<td class="manage-column column-title column-primary sortable desc">
|
614 |
+
<span class="edit">
|
615 |
+
<a href="#" class="column-post-title" aria-label="<?php _e( 'Edit', 'wpcf7-redirect' ); ?>"><?php echo $this->get_title(); ?></a>
|
616 |
+
</span>
|
617 |
+
<div class="row-actions">
|
618 |
+
<span class="edit">
|
619 |
+
<a href="#" aria-label="<?php _e( 'Edit', 'wpcf7-redirect' ); ?>"><?php _e( 'Edit', 'wpcf7-redirect' ); ?></a> |
|
620 |
+
</span>
|
621 |
+
<span class="trash">
|
622 |
+
<a href="#" class="submitdelete" data-id="<?php echo $this->get_id(); ?>" aria-label="<?php _e( 'Move to trash', 'wpcf7-redirect' ); ?>"><?php _e( 'Move to trash', 'wpcf7-redirect' ); ?></a> |
|
623 |
+
</span>
|
624 |
+
<span class="duplicate">
|
625 |
+
<a href="#" class="submitduplicate" data-ruleid="default" data-id="<?php echo $this->get_id(); ?>" aria-label="<?php _e( 'Duplicate', 'wpcf7-redirect' ); ?>"><?php _e( 'Duplicate', 'wpcf7-redirect' ); ?></a>
|
626 |
+
</span>
|
627 |
+
<?php if ( $this->get_type() === 'save_lead' ) : ?>
|
628 |
+
<span class="view-leads">
|
629 |
+
| <a href="<?php echo WPCF7R_Leads_Manager::get_admin_url( $this->wpcf7_id ); ?>" class="show-leads" data-id="<?php echo $this->get_id(); ?>" aria-label="<?php _e( 'View Leads', 'wpcf7-redirect' ); ?>" target="_blank"><?php _e( 'View Leads', 'wpcf7-redirect' ); ?></a> |
|
630 |
+
</span>
|
631 |
+
<?php endif; ?>
|
632 |
+
|
633 |
+
<?php do_action( 'wpcf7r_after_actions_links', $this ); ?>
|
634 |
+
</div>
|
635 |
+
</td>
|
636 |
+
<td class="manage-column column-primary sortable desc edit">
|
637 |
+
<a href="#" aria-label="<?php _e( 'Edit', 'wpcf7-redirect' ); ?>"><?php echo $this->get_type_label(); ?></a>
|
638 |
+
</td>
|
639 |
+
<td class="manage-column column-primary sortable desc edit column-status">
|
640 |
+
<a href="#" aria-label="<?php _e( 'Edit', 'wpcf7-redirect' ); ?>"><?php echo $this->get_action_status_label(); ?></a>
|
641 |
+
</td>
|
642 |
+
<td class="manage-column cf7r-check-column">
|
643 |
+
<input type="hidden" name="post[]" value="<?php echo $this->get_id(); ?>">
|
644 |
+
<span class="dashicons dashicons-menu handle"></span>
|
645 |
+
</td>
|
646 |
+
</tr>
|
647 |
+
<tr data-actionid="<?php echo $this->get_id(); ?>" class="action-container">
|
648 |
+
<td colspan="5" >
|
649 |
+
<div class="hidden-action">
|
650 |
+
<?php $this->get_action_settings(); ?>
|
651 |
+
</div>
|
652 |
+
</td>
|
653 |
+
</tr>
|
654 |
+
<?php
|
655 |
+
|
656 |
+
do_action( 'after_wpcf7r_action_row', $this );
|
657 |
+
|
658 |
+
return apply_filters( 'wpcf7r_get_action_rows', ob_get_clean(), $this );
|
659 |
+
}
|
660 |
+
|
661 |
+
/**
|
662 |
+
* Get settings page
|
663 |
+
*/
|
664 |
+
public function get_action_settings() {
|
665 |
+
$this->get_settings_template( 'html-action-send-to-email.php' );
|
666 |
+
}
|
667 |
+
|
668 |
+
/**
|
669 |
+
* Render HTML field
|
670 |
+
*
|
671 |
+
* @param $field
|
672 |
+
* @param $prefix
|
673 |
+
*/
|
674 |
+
public function render_field( $field, $prefix ) {
|
675 |
+
WPCF7R_Html::render_field( $field, $prefix );
|
676 |
+
}
|
677 |
+
|
678 |
+
/**
|
679 |
+
* Check if the action has conditional rules
|
680 |
+
*
|
681 |
+
* @return boolean
|
682 |
+
*/
|
683 |
+
public function has_conditional_logic() {
|
684 |
+
return $this->get( 'conditional_logic' ) && conditional_logic_enabled() ? true : false;
|
685 |
+
}
|
686 |
+
|
687 |
+
/**
|
688 |
+
* Maybe perform actions before sending results to the user
|
689 |
+
*/
|
690 |
+
public function maybe_perform_pre_result_action() {
|
691 |
+
}
|
692 |
+
|
693 |
+
/**
|
694 |
+
* Get the submitted form data
|
695 |
+
*/
|
696 |
+
public function get_posted_data() {
|
697 |
+
return $this->submission_data;
|
698 |
+
}
|
699 |
+
|
700 |
+
/**
|
701 |
+
* This will process the required rules
|
702 |
+
*
|
703 |
+
* @param $cf7r_form
|
704 |
+
*/
|
705 |
+
public function process_action( $cf7r_form ) {
|
706 |
+
$results = array();
|
707 |
+
|
708 |
+
$this->cf7r_form = $cf7r_form;
|
709 |
+
$this->submission_data = $this->cf7r_form->get_submission();
|
710 |
+
$this->posted_data_raw = $this->submission_data->get_posted_data();
|
711 |
+
$this->form_tags = $this->cf7r_form->get_cf7_form_instance()->scan_form_tags();
|
712 |
+
|
713 |
+
// get conditional logic object
|
714 |
+
$clogic = class_exists( 'WPCF7_Redirect_Conditional_Logic' ) ? new WPCF7_Redirect_Conditional_Logic( $this->logic_blocks, $this->cf7r_form ) : '';
|
715 |
+
|
716 |
+
if ( ! conditional_logic_enabled() || ! $this->has_conditional_logic() ) {
|
717 |
+
// if no conditions are defined
|
718 |
+
$results = $this->process( $this->submission_data );
|
719 |
+
} elseif ( conditional_logic_enabled() && $clogic->conditions_met() ) {
|
720 |
+
$results = $this->process( $this->submission_data );
|
721 |
+
}
|
722 |
+
|
723 |
+
return $results;
|
724 |
+
}
|
725 |
+
|
726 |
+
/**
|
727 |
+
* Handle a simple redirect rule
|
728 |
+
*
|
729 |
+
* @param $rules
|
730 |
+
* @param $response
|
731 |
+
*/
|
732 |
+
public function process( $submission ) {
|
733 |
+
|
734 |
+
}
|
735 |
+
|
736 |
+
/**
|
737 |
+
* Get all saved blocks
|
738 |
+
*/
|
739 |
+
public function get_conditional_blocks() {
|
740 |
+
$blocks = $this->get( 'blocks' );
|
741 |
+
if ( ! $blocks ) {
|
742 |
+
$blocks = array(
|
743 |
+
array(
|
744 |
+
'block_title' => 'Block title',
|
745 |
+
'groups' => $this->get_groups(),
|
746 |
+
'block_key' => 'block_1',
|
747 |
+
),
|
748 |
+
);
|
749 |
+
} else {
|
750 |
+
$blocks = maybe_unserialize( $blocks );
|
751 |
+
$blocks['block_1']['block_key'] = 'block_1';
|
752 |
+
$blocks['block_1']['block_title'] = 'Block title';
|
753 |
+
}
|
754 |
+
return $blocks;
|
755 |
+
}
|
756 |
+
|
757 |
+
/**
|
758 |
+
* Find the relevant rule to use
|
759 |
+
*/
|
760 |
+
public function get_valid_rule_block() {
|
761 |
+
$blocks = $this->get( 'blocks' );
|
762 |
+
$blocks = maybe_unserialize( $blocks );
|
763 |
+
if ( isset( $blocks ) && $blocks ) {
|
764 |
+
foreach ( $blocks as $block ) {
|
765 |
+
if ( isset( $block['groups'] ) && $block['groups'] ) {
|
766 |
+
foreach ( $block['groups'] as $and_rows ) {
|
767 |
+
$valid = true;
|
768 |
+
if ( $and_rows ) {
|
769 |
+
foreach ( $and_rows as $and_row ) {
|
770 |
+
if ( ! $this->is_valid( $and_row ) ) {
|
771 |
+
$valid = false;
|
772 |
+
break;
|
773 |
+
}
|
774 |
+
}
|
775 |
+
if ( $valid ) {
|
776 |
+
break;
|
777 |
+
}
|
778 |
+
}
|
779 |
+
}
|
780 |
+
if ( $valid ) {
|
781 |
+
return $block;
|
782 |
+
}
|
783 |
+
}
|
784 |
+
}
|
785 |
+
}
|
786 |
+
}
|
787 |
+
|
788 |
+
/**
|
789 |
+
* Get an instance of a form tag object
|
790 |
+
*
|
791 |
+
* @param $form_tag_name
|
792 |
+
*/
|
793 |
+
private function get_form_tag( $form_tag_name ) {
|
794 |
+
if ( $this->form_tags ) {
|
795 |
+
foreach ( $this->form_tags as $form_tag ) {
|
796 |
+
if ( $form_tag->name === $form_tag_name ) {
|
797 |
+
return $form_tag;
|
798 |
+
}
|
799 |
+
}
|
800 |
+
}
|
801 |
+
}
|
802 |
+
|
803 |
+
/**
|
804 |
+
* Use cf7 mechanizm to get the form tag value
|
805 |
+
* Including pipes and default values
|
806 |
+
*
|
807 |
+
* @param $form_tag_name
|
808 |
+
*/
|
809 |
+
private function get_form_tag_posted_data( $form_tag_name ) {
|
810 |
+
$form_tag = $this->get_form_tag( $form_tag_name );
|
811 |
+
$value = '';
|
812 |
+
|
813 |
+
if ( $form_tag ) {
|
814 |
+
$posted_value = $this->submission_data->get_posted_data( $form_tag_name );
|
815 |
+
$type = $form_tag->type;
|
816 |
+
$name = $form_tag->name;
|
817 |
+
$pipes = $form_tag->pipes;
|
818 |
+
$value_orig = $value;
|
819 |
+
$value_orig = $posted_value;
|
820 |
+
if (
|
821 |
+
( defined( 'WPCF7_USE_PIPE' ) && WPCF7_USE_PIPE )
|
822 |
+
&& $pipes instanceof WPCF7_Pipes
|
823 |
+
&& ! $pipes->zero()
|
824 |
+
) {
|
825 |
+
if ( is_array( $value_orig ) ) {
|
826 |
+
$value = array();
|
827 |
+
foreach ( $value_orig as $v ) {
|
828 |
+
$value[] = $pipes->do_pipe( wp_unslash( $v ) );
|
829 |
+
}
|
830 |
+
} else {
|
831 |
+
$value = $pipes->do_pipe( wp_unslash( $value_orig ) );
|
832 |
+
}
|
833 |
+
} else {
|
834 |
+
$value = $posted_value;
|
835 |
+
}
|
836 |
+
}
|
837 |
+
return $value;
|
838 |
+
}
|
839 |
+
|
840 |
+
/**
|
841 |
+
* Check rule
|
842 |
+
*
|
843 |
+
* @param $and_row
|
844 |
+
*/
|
845 |
+
public function is_valid( $and_row ) {
|
846 |
+
$valid = false;
|
847 |
+
if ( isset( $and_row['condition'] ) && $and_row['condition'] ) {
|
848 |
+
$tag_name = isset( $and_row['if'] ) ? $and_row['if'] : '';
|
849 |
+
$posted_value = $this->get_form_tag_posted_data( $tag_name );
|
850 |
+
$compare_value = $and_row['value'];
|
851 |
+
switch ( $and_row['condition'] ) {
|
852 |
+
case 'equal':
|
853 |
+
if ( isset( $posted_value ) && is_array( $posted_value ) ) {
|
854 |
+
$valid = in_array( $compare_value, $posted_value, true ) || $compare_value === $posted_value ? true : false;
|
855 |
+
} else {
|
856 |
+
$valid = $compare_value === $posted_value;
|
857 |
+
}
|
858 |
+
break;
|
859 |
+
case 'not-equal':
|
860 |
+
if ( is_array( $posted_value ) ) {
|
861 |
+
$valid = ! in_array( $compare_value, $posted_value, true );
|
862 |
+
} else {
|
863 |
+
$valid = $compare_value !== $posted_value;
|
864 |
+
}
|
865 |
+
break;
|
866 |
+
case 'contain':
|
867 |
+
$valid = strpos( $posted_value, $compare_value ) !== false;
|
868 |
+
break;
|
869 |
+
case 'not-contain':
|
870 |
+
$valid = strpos( $posted_value, $compare_value ) === false;
|
871 |
+
break;
|
872 |
+
case 'greater_than':
|
873 |
+
$valid = $posted_value > $compare_value;
|
874 |
+
break;
|
875 |
+
case 'less_than':
|
876 |
+
$valid = $posted_value < $compare_value;
|
877 |
+
break;
|
878 |
+
case 'is_null':
|
879 |
+
$valid = '' === $posted_value;
|
880 |
+
break;
|
881 |
+
case 'is_not_null':
|
882 |
+
$valid = '' === $posted_value;
|
883 |
+
break;
|
884 |
+
}
|
885 |
+
}
|
886 |
+
return apply_filters( 'wpcf7r_is_valid', $valid, $and_row );
|
887 |
+
}
|
888 |
+
|
889 |
+
/**
|
890 |
+
* Get the fields relevant for conditional group
|
891 |
+
*/
|
892 |
+
public function get_group_fields() {
|
893 |
+
return array_merge(
|
894 |
+
array(
|
895 |
+
array(
|
896 |
+
'if' => '',
|
897 |
+
'condition' => '',
|
898 |
+
'value' => '',
|
899 |
+
),
|
900 |
+
)
|
901 |
+
);
|
902 |
+
}
|
903 |
+
|
904 |
+
/**
|
905 |
+
* Get the saved groups or display the default first one
|
906 |
+
*/
|
907 |
+
public function get_groups() {
|
908 |
+
$groups = array(
|
909 |
+
'group-0' => $this->get_group_fields(),
|
910 |
+
);
|
911 |
+
return $groups;
|
912 |
+
}
|
913 |
+
|
914 |
+
/**
|
915 |
+
* Process all pre cf7 submit actions
|
916 |
+
*/
|
917 |
+
public function process_pre_submit_actions() {
|
918 |
+
}
|
919 |
+
}
|
classes/class-wpcf7r-actions-list.php
CHANGED
@@ -1,102 +1,102 @@
|
|
1 |
-
<?php
|
2 |
-
defined( 'ABSPATH' ) || exit;
|
3 |
-
|
4 |
-
class Wpcf7r_Actions_List {
|
5 |
-
public static $action_posts;
|
6 |
-
|
7 |
-
public function __construct( $actions_posts = '' ) {
|
8 |
-
|
9 |
-
self::$action_posts = $actions_posts;
|
10 |
-
|
11 |
-
parent::__construct(
|
12 |
-
array(
|
13 |
-
'singular' => __( 'Action', 'wpcf7-redirect' ), // singular name of the listed records
|
14 |
-
'plural' => __( 'Actions', 'wpcf7-redirect' ), // plural name of the listed records
|
15 |
-
'ajax' => false, // should this table support ajax?
|
16 |
-
)
|
17 |
-
);
|
18 |
-
}
|
19 |
-
|
20 |
-
public function record_count() {
|
21 |
-
return count( self::$action_posts );
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Text diwpcf7-redirect layed when no customer data is available
|
26 |
-
*/
|
27 |
-
public function no_items() {
|
28 |
-
_e( 'No Actions Avaliable.', 'wpcf7-redirect' );
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Return an associative array containing the bulk action
|
33 |
-
*
|
34 |
-
* @return array
|
35 |
-
*/
|
36 |
-
public function get_bulk_actions() {
|
37 |
-
$actions = array(
|
38 |
-
'bulk-delete' => 'Delete',
|
39 |
-
);
|
40 |
-
|
41 |
-
return $actions;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Handles data query and filter, sorting, and pagination.
|
46 |
-
*/
|
47 |
-
public function prepare_items() {
|
48 |
-
$this->_column_headers = $this->get_column_info();
|
49 |
-
|
50 |
-
/** Process bulk action */
|
51 |
-
$this->process_bulk_action();
|
52 |
-
|
53 |
-
$per_page = 10;
|
54 |
-
$current_page = $this->get_pagenum();
|
55 |
-
$total_items = $this->record_count();
|
56 |
-
|
57 |
-
$this->set_pagination_args(
|
58 |
-
array(
|
59 |
-
'total_items' => $total_items, //WE have to calculate the total number of items
|
60 |
-
'per_page' => $per_page, //WE have to determine how many items to show on a page
|
61 |
-
)
|
62 |
-
);
|
63 |
-
|
64 |
-
$this->items = self::$action_posts;
|
65 |
-
}
|
66 |
-
|
67 |
-
public function process_bulk_action() {
|
68 |
-
|
69 |
-
//Detect when a bulk action is being triggered...
|
70 |
-
if ( 'delete' === $this->current_action() ) {
|
71 |
-
|
72 |
-
// In our file that handles the request, verify the nonce.
|
73 |
-
$nonce = esc_attr( $_REQUEST['_wpnonce'] );
|
74 |
-
|
75 |
-
if ( ! wp_verify_nonce( $nonce, 'sp_delete_customer' ) ) {
|
76 |
-
die( 'Go get a life script kiddies' );
|
77 |
-
} else {
|
78 |
-
self::delete_customer( absint( $_GET['customer'] ) );
|
79 |
-
|
80 |
-
wp_redirect( esc_url( add_query_arg() ) );
|
81 |
-
exit;
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
-
// If the delete bulk action is triggered
|
86 |
-
if ( ( isset( $_POST['action'] ) && 'bulk-delete' === $_POST['action'] )
|
87 |
-
|| ( isset( $_POST['action2'] ) && 'bulk-delete' === $_POST['action2'] )
|
88 |
-
) {
|
89 |
-
|
90 |
-
$delete_ids = esc_sql( $_POST['bulk-delete'] );
|
91 |
-
|
92 |
-
// loop over the array of record IDs and delete them
|
93 |
-
foreach ( $delete_ids as $id ) {
|
94 |
-
self::delete_customer( $id );
|
95 |
-
|
96 |
-
}
|
97 |
-
|
98 |
-
wp_redirect( esc_url( add_query_arg() ) );
|
99 |
-
exit;
|
100 |
-
}
|
101 |
-
}
|
102 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit;
|
3 |
+
|
4 |
+
class Wpcf7r_Actions_List {
|
5 |
+
public static $action_posts;
|
6 |
+
|
7 |
+
public function __construct( $actions_posts = '' ) {
|
8 |
+
|
9 |
+
self::$action_posts = $actions_posts;
|
10 |
+
|
11 |
+
parent::__construct(
|
12 |
+
array(
|
13 |
+
'singular' => __( 'Action', 'wpcf7-redirect' ), // singular name of the listed records
|
14 |
+
'plural' => __( 'Actions', 'wpcf7-redirect' ), // plural name of the listed records
|
15 |
+
'ajax' => false, // should this table support ajax?
|
16 |
+
)
|
17 |
+
);
|
18 |
+
}
|
19 |
+
|
20 |
+
public function record_count() {
|
21 |
+
return count( self::$action_posts );
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Text diwpcf7-redirect layed when no customer data is available
|
26 |
+
*/
|
27 |
+
public function no_items() {
|
28 |
+
_e( 'No Actions Avaliable.', 'wpcf7-redirect' );
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Return an associative array containing the bulk action
|
33 |
+
*
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
+
public function get_bulk_actions() {
|
37 |
+
$actions = array(
|
38 |
+
'bulk-delete' => 'Delete',
|
39 |
+
);
|
40 |
+
|
41 |
+
return $actions;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Handles data query and filter, sorting, and pagination.
|
46 |
+
*/
|
47 |
+
public function prepare_items() {
|
48 |
+
$this->_column_headers = $this->get_column_info();
|
49 |
+
|
50 |
+
/** Process bulk action */
|
51 |
+
$this->process_bulk_action();
|
52 |
+
|
53 |
+
$per_page = 10;
|
54 |
+
$current_page = $this->get_pagenum();
|
55 |
+
$total_items = $this->record_count();
|
56 |
+
|
57 |
+
$this->set_pagination_args(
|
58 |
+
array(
|
59 |
+
'total_items' => $total_items, //WE have to calculate the total number of items
|
60 |
+
'per_page' => $per_page, //WE have to determine how many items to show on a page
|
61 |
+
)
|
62 |
+
);
|
63 |
+
|
64 |
+
$this->items = self::$action_posts;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function process_bulk_action() {
|
68 |
+
|
69 |
+
//Detect when a bulk action is being triggered...
|
70 |
+
if ( 'delete' === $this->current_action() ) {
|
71 |
+
|
72 |
+
// In our file that handles the request, verify the nonce.
|
73 |
+
$nonce = esc_attr( $_REQUEST['_wpnonce'] );
|
74 |
+
|
75 |
+
if ( ! wp_verify_nonce( $nonce, 'sp_delete_customer' ) ) {
|
76 |
+
die( 'Go get a life script kiddies' );
|
77 |
+
} else {
|
78 |
+
self::delete_customer( absint( $_GET['customer'] ) );
|
79 |
+
|
80 |
+
wp_redirect( esc_url( add_query_arg() ) );
|
81 |
+
exit;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
// If the delete bulk action is triggered
|
86 |
+
if ( ( isset( $_POST['action'] ) && 'bulk-delete' === $_POST['action'] )
|
87 |
+
|| ( isset( $_POST['action2'] ) && 'bulk-delete' === $_POST['action2'] )
|
88 |
+
) {
|
89 |
+
|
90 |
+
$delete_ids = esc_sql( $_POST['bulk-delete'] );
|
91 |
+
|
92 |
+
// loop over the array of record IDs and delete them
|
93 |
+
foreach ( $delete_ids as $id ) {
|
94 |
+
self::delete_customer( $id );
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
wp_redirect( esc_url( add_query_arg() ) );
|
99 |
+
exit;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
classes/class-wpcf7r-actions.php
CHANGED
@@ -1,111 +1,111 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Actions
|
4 |
-
* A helper class for managing form actions
|
5 |
-
*/
|
6 |
-
|
7 |
-
defined( 'ABSPATH' ) || exit;
|
8 |
-
|
9 |
-
class WPCF7R_Actions {
|
10 |
-
public function __construct( $post_id, $wpcf7r_form ) {
|
11 |
-
$this->post_type = 'wpcf7r_action';
|
12 |
-
$this->wpcf7_post_id = $post_id;
|
13 |
-
$this->html = new WPCF7R_Html( WPCF7R_Form::$mail_tags );
|
14 |
-
}
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Get all actions that are relevant to this form
|
18 |
-
*
|
19 |
-
* @param $rule_id
|
20 |
-
* @param integer $count
|
21 |
-
* @param boolean $active
|
22 |
-
* @param array $args
|
23 |
-
*/
|
24 |
-
public function get_actions( $rule_id, $count = -1, $active = false, $args = array() ) {
|
25 |
-
$this->actions = array();
|
26 |
-
$actions = array();
|
27 |
-
|
28 |
-
$actions_posts = $this->get_action_posts( $rule_id, $count, $active, $args );
|
29 |
-
|
30 |
-
if ( $actions_posts && is_array( $actions_posts ) ) {
|
31 |
-
$counter = 0;
|
32 |
-
foreach ( $actions_posts as $action_post ) {
|
33 |
-
$action = WPCF7R_Action::get_action( $action_post );
|
34 |
-
|
35 |
-
if ( is_object( $action ) && ! is_wp_error( $action ) ) {
|
36 |
-
$actions[ $action->priority . '_' . $counter ] = $action;
|
37 |
-
$counter++;
|
38 |
-
}
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
ksort( $actions );
|
43 |
-
$this->actions = $actions;
|
44 |
-
|
45 |
-
return $this->actions;
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Get and return the posts that are used as actions
|
50 |
-
*
|
51 |
-
* @param $rule_id
|
52 |
-
* @param integer $count
|
53 |
-
* @param boolean $active
|
54 |
-
* @param array $extra_args
|
55 |
-
*/
|
56 |
-
public function get_action_posts( $rule_id, $count = -1, $active = false, $extra_args = array() ) {
|
57 |
-
|
58 |
-
$post_type = $this->post_type;
|
59 |
-
$post_id = $this->wpcf7_post_id;
|
60 |
-
|
61 |
-
$actions = wpcf7r_get_actions( $post_type, $count, $post_id, $rule_id, $extra_args, $active );
|
62 |
-
|
63 |
-
return $actions;
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Echo the templates used for the javascript process
|
68 |
-
*/
|
69 |
-
public function html_fregments() {
|
70 |
-
if ( ! isset( $this->wpcf7_post_id ) ) {
|
71 |
-
return;
|
72 |
-
}
|
73 |
-
|
74 |
-
$action = new WPCF7R_Action();
|
75 |
-
|
76 |
-
$new_block = array(
|
77 |
-
'block_title' => __( 'New Block', 'wpcf7-redirect' ),
|
78 |
-
'groups' => $action->get_groups(),
|
79 |
-
'block_key' => 'new_block',
|
80 |
-
|
81 |
-
);
|
82 |
-
|
83 |
-
$default_group = $action->get_group_fields();
|
84 |
-
$prefix = '[actions][action_id]';
|
85 |
-
$fields = $this->get_plugin_default_fields_values();
|
86 |
-
$row_template = $this->html->get_conditional_row_template( $new_block['block_key'], 'new_group', 'new_row', reset( $default_group ), $prefix );
|
87 |
-
$options['row_html'] = $row_template;
|
88 |
-
$options['group_html'] = $this->html->group_display( 'new_block', 'new_group', reset( $new_block['groups'] ), $prefix );
|
89 |
-
$options['block_html'] = $this->html->get_block_html( 'new_block', $new_block, false, false, $prefix );
|
90 |
-
$options['block_title_html'] = $this->html->get_block_title( 'new_block', $new_block, false, false, $prefix );
|
91 |
-
$options['mail_tags'] = WPCF7R_Form::$mail_tags;
|
92 |
-
|
93 |
-
echo '<script>';
|
94 |
-
echo 'var wpcfr_template = ' . json_encode( $options );
|
95 |
-
echo '</script>';
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Get form values
|
100 |
-
*/
|
101 |
-
public function get_plugin_default_fields_values() {
|
102 |
-
|
103 |
-
$fields = WPCF7r_Form_Helper::get_plugin_default_fields();
|
104 |
-
|
105 |
-
foreach ( $fields as $field ) {
|
106 |
-
// get_post_meta( $this->wpcf7_post_id, '_wpcf7_redirect_' . $field['name'] , true );
|
107 |
-
$values[ $field['name'] ] = '';
|
108 |
-
}
|
109 |
-
return $values;
|
110 |
-
}
|
111 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Actions
|
4 |
+
* A helper class for managing form actions
|
5 |
+
*/
|
6 |
+
|
7 |
+
defined( 'ABSPATH' ) || exit;
|
8 |
+
|
9 |
+
class WPCF7R_Actions {
|
10 |
+
public function __construct( $post_id, $wpcf7r_form ) {
|
11 |
+
$this->post_type = 'wpcf7r_action';
|
12 |
+
$this->wpcf7_post_id = $post_id;
|
13 |
+
$this->html = new WPCF7R_Html( WPCF7R_Form::$mail_tags );
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Get all actions that are relevant to this form
|
18 |
+
*
|
19 |
+
* @param $rule_id
|
20 |
+
* @param integer $count
|
21 |
+
* @param boolean $active
|
22 |
+
* @param array $args
|
23 |
+
*/
|
24 |
+
public function get_actions( $rule_id, $count = -1, $active = false, $args = array() ) {
|
25 |
+
$this->actions = array();
|
26 |
+
$actions = array();
|
27 |
+
|
28 |
+
$actions_posts = $this->get_action_posts( $rule_id, $count, $active, $args );
|
29 |
+
|
30 |
+
if ( $actions_posts && is_array( $actions_posts ) ) {
|
31 |
+
$counter = 0;
|
32 |
+
foreach ( $actions_posts as $action_post ) {
|
33 |
+
$action = WPCF7R_Action::get_action( $action_post );
|
34 |
+
|
35 |
+
if ( is_object( $action ) && ! is_wp_error( $action ) ) {
|
36 |
+
$actions[ $action->priority . '_' . $counter ] = $action;
|
37 |
+
$counter++;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
ksort( $actions );
|
43 |
+
$this->actions = $actions;
|
44 |
+
|
45 |
+
return $this->actions;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Get and return the posts that are used as actions
|
50 |
+
*
|
51 |
+
* @param $rule_id
|
52 |
+
* @param integer $count
|
53 |
+
* @param boolean $active
|
54 |
+
* @param array $extra_args
|
55 |
+
*/
|
56 |
+
public function get_action_posts( $rule_id, $count = -1, $active = false, $extra_args = array() ) {
|
57 |
+
|
58 |
+
$post_type = $this->post_type;
|
59 |
+
$post_id = $this->wpcf7_post_id;
|
60 |
+
|
61 |
+
$actions = wpcf7r_get_actions( $post_type, $count, $post_id, $rule_id, $extra_args, $active );
|
62 |
+
|
63 |
+
return $actions;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Echo the templates used for the javascript process
|
68 |
+
*/
|
69 |
+
public function html_fregments() {
|
70 |
+
if ( ! isset( $this->wpcf7_post_id ) ) {
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
|
74 |
+
$action = new WPCF7R_Action();
|
75 |
+
|
76 |
+
$new_block = array(
|
77 |
+
'block_title' => __( 'New Block', 'wpcf7-redirect' ),
|
78 |
+
'groups' => $action->get_groups(),
|
79 |
+
'block_key' => 'new_block',
|
80 |
+
|
81 |
+
);
|
82 |
+
|
83 |
+
$default_group = $action->get_group_fields();
|
84 |
+
$prefix = '[actions][action_id]';
|
85 |
+
$fields = $this->get_plugin_default_fields_values();
|
86 |
+
$row_template = $this->html->get_conditional_row_template( $new_block['block_key'], 'new_group', 'new_row', reset( $default_group ), $prefix );
|
87 |
+
$options['row_html'] = $row_template;
|
88 |
+
$options['group_html'] = $this->html->group_display( 'new_block', 'new_group', reset( $new_block['groups'] ), $prefix );
|
89 |
+
$options['block_html'] = $this->html->get_block_html( 'new_block', $new_block, false, false, $prefix );
|
90 |
+
$options['block_title_html'] = $this->html->get_block_title( 'new_block', $new_block, false, false, $prefix );
|
91 |
+
$options['mail_tags'] = WPCF7R_Form::$mail_tags;
|
92 |
+
|
93 |
+
echo '<script>';
|
94 |
+
echo 'var wpcfr_template = ' . json_encode( $options );
|
95 |
+
echo '</script>';
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Get form values
|
100 |
+
*/
|
101 |
+
public function get_plugin_default_fields_values() {
|
102 |
+
|
103 |
+
$fields = WPCF7r_Form_Helper::get_plugin_default_fields();
|
104 |
+
|
105 |
+
foreach ( $fields as $field ) {
|
106 |
+
// get_post_meta( $this->wpcf7_post_id, '_wpcf7_redirect_' . $field['name'] , true );
|
107 |
+
$values[ $field['name'] ] = '';
|
108 |
+
}
|
109 |
+
return $values;
|
110 |
+
}
|
111 |
+
}
|
classes/class-wpcf7r-extension.php
CHANGED
@@ -1,497 +1,497 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class for handling contact form 7 redirection pro extensions
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
class WPCF7R_Extension {
|
9 |
-
public function __construct( $extension ) {
|
10 |
-
|
11 |
-
$this->name = $extension['name'];
|
12 |
-
$this->title = $extension['title'];
|
13 |
-
$this->description = $extension['description'];
|
14 |
-
$this->icon = $extension['icon'];
|
15 |
-
$this->type = isset( $extension['type'] ) ? $extension['type'] : 'extension';
|
16 |
-
$this->btn_text = isset( $extension['btn_text'] ) ? $extension['btn_text'] : '';
|
17 |
-
$this->external_url = isset( $extension['external_url'] ) ? $extension['external_url'] : '';
|
18 |
-
$this->badge = isset( $extension['badge'] ) ? $extension['badge'] : '';
|
19 |
-
$this->classname = '';
|
20 |
-
$this->extension_file_name = '';
|
21 |
-
$this->sku = $this->get_sku();
|
22 |
-
$this->slug = '';
|
23 |
-
|
24 |
-
if ( 'affiliate' !== $this->type ) {
|
25 |
-
$this->serial = $this->get_serial();
|
26 |
-
$this->extension_file_name = isset( $extension['filename'] ) ? $extension['filename'] : '';
|
27 |
-
$this->slug = str_replace( '.php', '', $this->extension_file_name );
|
28 |
-
$this->extension_ver = $this->get_ver();
|
29 |
-
$this->classname = $extension['classname'];
|
30 |
-
|
31 |
-
if ( ! $this->extension_file_exists() ) {
|
32 |
-
$this->reset_activation();
|
33 |
-
|
34 |
-
$this->deactivate_license();
|
35 |
-
}
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Get affiliate url (if the extension is affiliated)
|
41 |
-
*/
|
42 |
-
public function get_aff_url() {
|
43 |
-
return isset( $this->external_url ) ? $this->external_url : '';
|
44 |
-
}
|
45 |
-
|
46 |
-
public function get_extension_file_name() {
|
47 |
-
return $this->extension_file_name;
|
48 |
-
}
|
49 |
-
/**
|
50 |
-
* Get the extension slug
|
51 |
-
*/
|
52 |
-
public function get_slug() {
|
53 |
-
return $this->slug;
|
54 |
-
}
|
55 |
-
/**
|
56 |
-
* Get the btn label
|
57 |
-
*/
|
58 |
-
public function get_btn_text() {
|
59 |
-
return $this->btn_text;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Get the extension version
|
64 |
-
*/
|
65 |
-
public function get_ver() {
|
66 |
-
|
67 |
-
$ver = '2.0';
|
68 |
-
|
69 |
-
if ( $this->extension_file_exists() ) {
|
70 |
-
$info_headers = array(
|
71 |
-
'ver' => 'ver',
|
72 |
-
);
|
73 |
-
|
74 |
-
$info = get_file_data( $this->get_extension_file_path(), $info_headers );
|
75 |
-
|
76 |
-
$ver = $info['ver'];
|
77 |
-
}
|
78 |
-
|
79 |
-
return $ver;
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Get the extension name
|
84 |
-
*/
|
85 |
-
public function get_name() {
|
86 |
-
return $this->name;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Get the extension type
|
91 |
-
*/
|
92 |
-
public function get_type() {
|
93 |
-
return $this->type;
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Get the installed extension version
|
98 |
-
*/
|
99 |
-
public function get_extension_ver() {
|
100 |
-
return isset( $this->extension_ver ) ? $this->extension_ver : '';
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Get the path of the extension
|
105 |
-
*/
|
106 |
-
public function get_extension_file_path() {
|
107 |
-
$path = '';
|
108 |
-
|
109 |
-
if ( class_exists( $this->get_class_name() ) && class_exists( 'ReflectionClass' ) ) {
|
110 |
-
$reflector = new ReflectionClass( $this->get_class_name() );
|
111 |
-
$path = $reflector->getFileName();
|
112 |
-
} elseif ( $this->extension_file_name ) {
|
113 |
-
$path = wpcf7r_get_addon_path( $this->extension_file_name );
|
114 |
-
}
|
115 |
-
|
116 |
-
return $path;
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Get the path of the extension for plugin activation
|
121 |
-
*/
|
122 |
-
public function get_extension_relative_path() {
|
123 |
-
|
124 |
-
$relative_path = $this->get_name() . '/' . $this->extension_file_name;
|
125 |
-
|
126 |
-
return $relative_path;
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Get the extension file name
|
131 |
-
*
|
132 |
-
* @return void
|
133 |
-
*/
|
134 |
-
public function get_class_name() {
|
135 |
-
return $this->classname;
|
136 |
-
}
|
137 |
-
|
138 |
-
/**
|
139 |
-
* Check if the file required for the extension exists
|
140 |
-
*/
|
141 |
-
public function extension_file_exists() {
|
142 |
-
return file_exists( $this->get_extension_file_path() );
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* Set the required update flag
|
147 |
-
*/
|
148 |
-
public function set_updated() {
|
149 |
-
delete_option( 'wpcf7r_extension-needs-update-' . $this->get_name() );
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Check if an extension requires an update
|
154 |
-
*
|
155 |
-
* @return boolean
|
156 |
-
*/
|
157 |
-
public function has_update() {
|
158 |
-
return get_option( 'wpcf7r_extension-needs-update-' . $this->get_name() ) && $this->is_active();
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Get the version of the update
|
163 |
-
*/
|
164 |
-
public function update_version() {
|
165 |
-
return get_option( 'wpcf7r_extension-needs-update-' . $this->get_name() );
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* Set the required update flag
|
170 |
-
*/
|
171 |
-
public function set_needs_update( $new_ver ) {
|
172 |
-
update_option( 'wpcf7r_extension-needs-update-' . $this->get_name(), $new_ver );
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Get the HTML box to display the promo box
|
177 |
-
*/
|
178 |
-
public function get_action_promo() {
|
179 |
-
include( WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'extensions/extension-promo-box.php' );
|
180 |
-
}
|
181 |
-
|
182 |
-
/**
|
183 |
-
* If the plugin file exists but license was not activated
|
184 |
-
*
|
185 |
-
* @return void
|
186 |
-
*/
|
187 |
-
public function needs_activation() {
|
188 |
-
return ! $this->is_active() && $this->extension_file_exists();
|
189 |
-
}
|
190 |
-
/**
|
191 |
-
* Check if the license is active
|
192 |
-
*/
|
193 |
-
public function is_active() {
|
194 |
-
return $this->get_activation_data() && $this->extension_file_exists();
|
195 |
-
}
|
196 |
-
|
197 |
-
/**
|
198 |
-
* Get the saved serial number
|
199 |
-
*/
|
200 |
-
public function get_serial() {
|
201 |
-
return get_option( 'wpcf7r_activation_serial-' . $this->get_name() );
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* Get the saved license activation data
|
206 |
-
*/
|
207 |
-
public function get_activation_data() {
|
208 |
-
return get_option( 'wpcf7r_activation_data-' . $this->get_name() );
|
209 |
-
}
|
210 |
-
|
211 |
-
/**
|
212 |
-
* Activate the serial via API
|
213 |
-
*
|
214 |
-
* @param $serial
|
215 |
-
*/
|
216 |
-
public function activate( $serial ) {
|
217 |
-
$this->api = new Qs_Api();
|
218 |
-
|
219 |
-
if ( ! $serial ) {
|
220 |
-
die( '-1' );
|
221 |
-
}
|
222 |
-
|
223 |
-
$activation_id = $this->get_activation_data();
|
224 |
-
|
225 |
-
$this->sku = $this->get_name();
|
226 |
-
|
227 |
-
if ( $activation_id ) {
|
228 |
-
$is_valid = $this->api->validate_serial( $activation_id, $serial, $this->get_name() );
|
229 |
-
} else {
|
230 |
-
$is_valid = $this->api->activate_serial( $serial, $this->get_name() );
|
231 |
-
|
232 |
-
if ( is_wp_error( $is_valid ) ) {
|
233 |
-
$is_valid = $this->api->activate_serial( $serial, $this->get_name() . '-unlimited' );
|
234 |
-
$this->sku = $this->get_name() . '-unlimited';
|
235 |
-
}
|
236 |
-
|
237 |
-
if ( is_wp_error( $is_valid ) ) {
|
238 |
-
$is_valid = $this->api->activate_serial( $serial, $this->get_name() . '-pro' );
|
239 |
-
$this->sku = $this->get_name() . '-pro';
|
240 |
-
}
|
241 |
-
}
|
242 |
-
|
243 |
-
//serial was not valid
|
244 |
-
if ( is_wp_error( $is_valid ) ) {
|
245 |
-
|
246 |
-
$message = $is_valid->get_error_message();
|
247 |
-
|
248 |
-
if ( is_object( $message ) && isset( $message->license_key ) ) {
|
249 |
-
$message = $message->license_key[0];
|
250 |
-
}
|
251 |
-
|
252 |
-
$this->reset_activation();
|
253 |
-
|
254 |
-
$this->deactivate_license();
|
255 |
-
|
256 |
-
$response = array(
|
257 |
-
'error' => $message,
|
258 |
-
);
|
259 |
-
|
260 |
-
} else {
|
261 |
-
//serial was valid, update the activation key for future validation
|
262 |
-
$this->set_activation( $is_valid->data, $serial );
|
263 |
-
|
264 |
-
if ( $this->extension_file_exists() ) {
|
265 |
-
$response['extension_html'] = $this->ajax_extension_html();
|
266 |
-
|
267 |
-
return $response;
|
268 |
-
}
|
269 |
-
|
270 |
-
deactivate_plugins( $this->get_extension_relative_path() );
|
271 |
-
|
272 |
-
$response = $this->save_extension_file();
|
273 |
-
|
274 |
-
if ( ! isset( $response['error'] ) ) {
|
275 |
-
$response['extension_html'] = $this->ajax_extension_html();
|
276 |
-
}
|
277 |
-
|
278 |
-
$file_path = $this->get_destination_path() . '/' . $this->extension_file_name;
|
279 |
-
|
280 |
-
//check if the require file exists
|
281 |
-
if ( file_exists( $file_path ) ) {
|
282 |
-
//check if the class exists if not include the required file
|
283 |
-
if ( ! class_exists( $this->classname ) ) {
|
284 |
-
if ( $file_path ) {
|
285 |
-
include( $file_path );
|
286 |
-
}
|
287 |
-
}
|
288 |
-
|
289 |
-
//if now both class exists and has a setup method.. run it
|
290 |
-
if ( class_exists( $this->classname ) && method_exists( $this->classname, 'setup' ) ) {
|
291 |
-
call_user_func( array( $this->classname, 'setup' ) );
|
292 |
-
}
|
293 |
-
|
294 |
-
$this->activate_new_plugin();
|
295 |
-
}
|
296 |
-
}
|
297 |
-
|
298 |
-
return $response;
|
299 |
-
}
|
300 |
-
|
301 |
-
public function get_destination_path() {
|
302 |
-
return WPCF7_PRO_REDIRECT_PLUGINS_PATH . $this->get_name();
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
* Get the extension download link
|
307 |
-
*/
|
308 |
-
public function get_extension_remote_file() {
|
309 |
-
$this->api = isset( $this->api ) && $this->api ? $this->api : new Qs_Api();
|
310 |
-
|
311 |
-
$download_link = $this->api->get_extension_download_url( $this->get_activation_data(), $this->get_sku() );
|
312 |
-
|
313 |
-
return $download_link;
|
314 |
-
}
|
315 |
-
/**
|
316 |
-
* Save the Newly downloaded file to the plugins dir
|
317 |
-
*/
|
318 |
-
public function save_extension_file() {
|
319 |
-
global $wp_filesystem;
|
320 |
-
|
321 |
-
$this->api = isset( $this->api ) && $this->api ? $this->api : new Qs_Api();
|
322 |
-
|
323 |
-
$response = array();
|
324 |
-
|
325 |
-
$file_path = $this->api->get_extension_file( $this->get_activation_data(), $this->get_sku() );
|
326 |
-
|
327 |
-
if ( is_wp_error( $file_path ) ) {
|
328 |
-
$response = array(
|
329 |
-
'error' => $file_path->get_error_message(),
|
330 |
-
);
|
331 |
-
|
332 |
-
$this->reset_activation();
|
333 |
-
} else {
|
334 |
-
|
335 |
-
WP_Filesystem();
|
336 |
-
|
337 |
-
$destination_path = $this->get_destination_path();
|
338 |
-
|
339 |
-
/**
|
340 |
-
* Create a directory for the action addons and create index.php for security
|
341 |
-
*/
|
342 |
-
if ( ! is_dir( $destination_path ) ) {
|
343 |
-
@mkdir( $destination_path );
|
344 |
-
$wp_filesystem->put_contents( $destination_path . '/index.php', 'SILENCE IS GOLDEN', FS_CHMOD_FILE );
|
345 |
-
}
|
346 |
-
|
347 |
-
if ( ! is_dir( $destination_path ) ) {
|
348 |
-
$response = array(
|
349 |
-
/* translators: %s: Destination path */
|
350 |
-
'error' => sprintf( __( 'Cannot create %s. Please create a directory manualy or fix permission issue.', 'wpcf7-redirect' ), $destination_path ),
|
351 |
-
);
|
352 |
-
} else {
|
353 |
-
$unzipfile = unzip_file( $file_path, $destination_path );
|
354 |
-
|
355 |
-
unlink( $file_path );
|
356 |
-
|
357 |
-
if ( is_wp_error( $unzipfile ) ) {
|
358 |
-
$response = array(
|
359 |
-
'error' => $unzipfile->get_error_message(),
|
360 |
-
);
|
361 |
-
$this->reset_activation();
|
362 |
-
} else {
|
363 |
-
$this->set_updated();
|
364 |
-
}
|
365 |
-
}
|
366 |
-
}
|
367 |
-
|
368 |
-
return $response;
|
369 |
-
}
|
370 |
-
|
371 |
-
/**
|
372 |
-
* Activate new downloaded extension
|
373 |
-
*
|
374 |
-
* @return void
|
375 |
-
*/
|
376 |
-
public function activate_new_plugin() {
|
377 |
-
|
378 |
-
if ( ! function_exists( 'activate_plugin' ) ) {
|
379 |
-
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
380 |
-
}
|
381 |
-
|
382 |
-
if ( ! is_plugin_active( $this->get_extension_relative_path() ) ) {
|
383 |
-
activate_plugin( $this->get_extension_relative_path() );
|
384 |
-
}
|
385 |
-
|
386 |
-
}
|
387 |
-
/**
|
388 |
-
* Get extension badge text
|
389 |
-
*
|
390 |
-
* @return void
|
391 |
-
*/
|
392 |
-
public function get_badge() {
|
393 |
-
return $this->badge ? "<span class='badge'>" . $this->badge . '</span>' : '';
|
394 |
-
}
|
395 |
-
|
396 |
-
/**
|
397 |
-
* Set all data related with the plugin activation
|
398 |
-
*
|
399 |
-
* @param $validation_data
|
400 |
-
* @param $serial
|
401 |
-
*/
|
402 |
-
public function set_activation( $validation_data, $serial ) {
|
403 |
-
update_option( 'wpcf7r_activation_id-' . $this->get_name(), $validation_data->activation_id );
|
404 |
-
update_option( 'wpcf7r_activation_expiration-' . $this->get_name(), $validation_data->expire );
|
405 |
-
update_option( 'wpcf7r_activation_data-' . $this->get_name(), $validation_data );
|
406 |
-
update_option( 'wpcf7r_activation_serial-' . $this->get_name(), $serial );
|
407 |
-
update_option( 'wpcf7r_activation_' . $this->get_name() . '-sku', $this->sku );
|
408 |
-
}
|
409 |
-
|
410 |
-
/**
|
411 |
-
* Clear all activation data
|
412 |
-
*/
|
413 |
-
public function reset_activation() {
|
414 |
-
delete_option( 'wpcf7r_activation_id-' . $this->get_name() );
|
415 |
-
delete_option( 'wpcf7r_activation_expiration-' . $this->get_name() );
|
416 |
-
delete_option( 'wpcf7r_activation_data-' . $this->get_name() );
|
417 |
-
delete_option( 'wpcf7r_activation_serial-' . $this->get_name() );
|
418 |
-
update_option( 'wpcf7r_activation_' . $this->get_name() . '-sku', $this->sku );
|
419 |
-
}
|
420 |
-
|
421 |
-
public function get_sku() {
|
422 |
-
return isset( $this->sku ) && $this->sku ? $this->sku : get_option( 'wpcf7r_activation_' . $this->get_name() . '-sku' );
|
423 |
-
}
|
424 |
-
/**
|
425 |
-
* Get the activation key
|
426 |
-
*/
|
427 |
-
public function get_activation_id() {
|
428 |
-
return get_option( 'wpcf7r_activation_id-' . $this->get_name() );
|
429 |
-
}
|
430 |
-
|
431 |
-
/**
|
432 |
-
* Deactivate extension license
|
433 |
-
*/
|
434 |
-
public function deactivate_license( $serial = '' ) {
|
435 |
-
|
436 |
-
$api = new Qs_Api();
|
437 |
-
|
438 |
-
$response = array();
|
439 |
-
|
440 |
-
$serial = $serial ? $serial : $this->get_serial();
|
441 |
-
|
442 |
-
$activation_id = $this->get_activation_id();
|
443 |
-
|
444 |
-
if ( ! $activation_id ) {
|
445 |
-
$this->reset_activation();
|
446 |
-
} else {
|
447 |
-
$results = $api->deactivate_liscense( $activation_id, $serial, $this->get_name() );
|
448 |
-
|
449 |
-
$this->reset_activation();
|
450 |
-
}
|
451 |
-
|
452 |
-
$response['extension_html'] = $this->ajax_extension_html();
|
453 |
-
|
454 |
-
return $response;
|
455 |
-
}
|
456 |
-
|
457 |
-
/**
|
458 |
-
* Ajax function for getting the extension html box
|
459 |
-
*/
|
460 |
-
public function ajax_extension_html() {
|
461 |
-
ob_start();
|
462 |
-
|
463 |
-
$this->get_action_promo();
|
464 |
-
|
465 |
-
$html = ob_get_clean();
|
466 |
-
|
467 |
-
return $html;
|
468 |
-
}
|
469 |
-
|
470 |
-
/**
|
471 |
-
* Get the link to purchase the extension
|
472 |
-
*/
|
473 |
-
public function get_purchase_link() {
|
474 |
-
return WPCF7_PRO_REDIRECT_PLUGIN_PAGE_URL . $this->name;
|
475 |
-
}
|
476 |
-
|
477 |
-
/**
|
478 |
-
* Get the extension description
|
479 |
-
*/
|
480 |
-
public function get_description() {
|
481 |
-
return $this->description;
|
482 |
-
}
|
483 |
-
|
484 |
-
/**
|
485 |
-
* Get the extension icon
|
486 |
-
*/
|
487 |
-
public function get_icon() {
|
488 |
-
return $this->icon;
|
489 |
-
}
|
490 |
-
|
491 |
-
/**
|
492 |
-
* Get the extension name
|
493 |
-
*/
|
494 |
-
public function get_title() {
|
495 |
-
return $this->title;
|
496 |
-
}
|
497 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class for handling contact form 7 redirection pro extensions
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
class WPCF7R_Extension {
|
9 |
+
public function __construct( $extension ) {
|
10 |
+
|
11 |
+
$this->name = $extension['name'];
|
12 |
+
$this->title = $extension['title'];
|
13 |
+
$this->description = $extension['description'];
|
14 |
+
$this->icon = $extension['icon'];
|
15 |
+
$this->type = isset( $extension['type'] ) ? $extension['type'] : 'extension';
|
16 |
+
$this->btn_text = isset( $extension['btn_text'] ) ? $extension['btn_text'] : '';
|
17 |
+
$this->external_url = isset( $extension['external_url'] ) ? $extension['external_url'] : '';
|
18 |
+
$this->badge = isset( $extension['badge'] ) ? $extension['badge'] : '';
|
19 |
+
$this->classname = '';
|
20 |
+
$this->extension_file_name = '';
|
21 |
+
$this->sku = $this->get_sku();
|
22 |
+
$this->slug = '';
|
23 |
+
|
24 |
+
if ( 'affiliate' !== $this->type ) {
|
25 |
+
$this->serial = $this->get_serial();
|
26 |
+
$this->extension_file_name = isset( $extension['filename'] ) ? $extension['filename'] : '';
|
27 |
+
$this->slug = str_replace( '.php', '', $this->extension_file_name );
|
28 |
+
$this->extension_ver = $this->get_ver();
|
29 |
+
$this->classname = $extension['classname'];
|
30 |
+
|
31 |
+
if ( ! $this->extension_file_exists() ) {
|
32 |
+
$this->reset_activation();
|
33 |
+
|
34 |
+
$this->deactivate_license();
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Get affiliate url (if the extension is affiliated)
|
41 |
+
*/
|
42 |
+
public function get_aff_url() {
|
43 |
+
return isset( $this->external_url ) ? $this->external_url : '';
|
44 |
+
}
|
45 |
+
|
46 |
+
public function get_extension_file_name() {
|
47 |
+
return $this->extension_file_name;
|
48 |
+
}
|
49 |
+
/**
|
50 |
+
* Get the extension slug
|
51 |
+
*/
|
52 |
+
public function get_slug() {
|
53 |
+
return $this->slug;
|
54 |
+
}
|
55 |
+
/**
|
56 |
+
* Get the btn label
|
57 |
+
*/
|
58 |
+
public function get_btn_text() {
|
59 |
+
return $this->btn_text;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Get the extension version
|
64 |
+
*/
|
65 |
+
public function get_ver() {
|
66 |
+
|
67 |
+
$ver = '2.0';
|
68 |
+
|
69 |
+
if ( $this->extension_file_exists() ) {
|
70 |
+
$info_headers = array(
|
71 |
+
'ver' => 'ver',
|
72 |
+
);
|
73 |
+
|
74 |
+
$info = get_file_data( $this->get_extension_file_path(), $info_headers );
|
75 |
+
|
76 |
+
$ver = $info['ver'];
|
77 |
+
}
|
78 |
+
|
79 |
+
return $ver;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Get the extension name
|
84 |
+
*/
|
85 |
+
public function get_name() {
|
86 |
+
return $this->name;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get the extension type
|
91 |
+
*/
|
92 |
+
public function get_type() {
|
93 |
+
return $this->type;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Get the installed extension version
|
98 |
+
*/
|
99 |
+
public function get_extension_ver() {
|
100 |
+
return isset( $this->extension_ver ) ? $this->extension_ver : '';
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Get the path of the extension
|
105 |
+
*/
|
106 |
+
public function get_extension_file_path() {
|
107 |
+
$path = '';
|
108 |
+
|
109 |
+
if ( class_exists( $this->get_class_name() ) && class_exists( 'ReflectionClass' ) ) {
|
110 |
+
$reflector = new ReflectionClass( $this->get_class_name() );
|
111 |
+
$path = $reflector->getFileName();
|
112 |
+
} elseif ( $this->extension_file_name ) {
|
113 |
+
$path = wpcf7r_get_addon_path( $this->extension_file_name );
|
114 |
+
}
|
115 |
+
|
116 |
+
return $path;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get the path of the extension for plugin activation
|
121 |
+
*/
|
122 |
+
public function get_extension_relative_path() {
|
123 |
+
|
124 |
+
$relative_path = $this->get_name() . '/' . $this->extension_file_name;
|
125 |
+
|
126 |
+
return $relative_path;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Get the extension file name
|
131 |
+
*
|
132 |
+
* @return void
|
133 |
+
*/
|
134 |
+
public function get_class_name() {
|
135 |
+
return $this->classname;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Check if the file required for the extension exists
|
140 |
+
*/
|
141 |
+
public function extension_file_exists() {
|
142 |
+
return file_exists( $this->get_extension_file_path() );
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Set the required update flag
|
147 |
+
*/
|
148 |
+
public function set_updated() {
|
149 |
+
delete_option( 'wpcf7r_extension-needs-update-' . $this->get_name() );
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Check if an extension requires an update
|
154 |
+
*
|
155 |
+
* @return boolean
|
156 |
+
*/
|
157 |
+
public function has_update() {
|
158 |
+
return get_option( 'wpcf7r_extension-needs-update-' . $this->get_name() ) && $this->is_active();
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Get the version of the update
|
163 |
+
*/
|
164 |
+
public function update_version() {
|
165 |
+
return get_option( 'wpcf7r_extension-needs-update-' . $this->get_name() );
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Set the required update flag
|
170 |
+
*/
|
171 |
+
public function set_needs_update( $new_ver ) {
|
172 |
+
update_option( 'wpcf7r_extension-needs-update-' . $this->get_name(), $new_ver );
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Get the HTML box to display the promo box
|
177 |
+
*/
|
178 |
+
public function get_action_promo() {
|
179 |
+
include( WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'extensions/extension-promo-box.php' );
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* If the plugin file exists but license was not activated
|
184 |
+
*
|
185 |
+
* @return void
|
186 |
+
*/
|
187 |
+
public function needs_activation() {
|
188 |
+
return ! $this->is_active() && $this->extension_file_exists();
|
189 |
+
}
|
190 |
+
/**
|
191 |
+
* Check if the license is active
|
192 |
+
*/
|
193 |
+
public function is_active() {
|
194 |
+
return $this->get_activation_data() && $this->extension_file_exists();
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Get the saved serial number
|
199 |
+
*/
|
200 |
+
public function get_serial() {
|
201 |
+
return get_option( 'wpcf7r_activation_serial-' . $this->get_name() );
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Get the saved license activation data
|
206 |
+
*/
|
207 |
+
public function get_activation_data() {
|
208 |
+
return get_option( 'wpcf7r_activation_data-' . $this->get_name() );
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Activate the serial via API
|
213 |
+
*
|
214 |
+
* @param $serial
|
215 |
+
*/
|
216 |
+
public function activate( $serial ) {
|
217 |
+
$this->api = new Qs_Api();
|
218 |
+
|
219 |
+
if ( ! $serial ) {
|
220 |
+
die( '-1' );
|
221 |
+
}
|
222 |
+
|
223 |
+
$activation_id = $this->get_activation_data();
|
224 |
+
|
225 |
+
$this->sku = $this->get_name();
|
226 |
+
|
227 |
+
if ( $activation_id ) {
|
228 |
+
$is_valid = $this->api->validate_serial( $activation_id, $serial, $this->get_name() );
|
229 |
+
} else {
|
230 |
+
$is_valid = $this->api->activate_serial( $serial, $this->get_name() );
|
231 |
+
|
232 |
+
if ( is_wp_error( $is_valid ) ) {
|
233 |
+
$is_valid = $this->api->activate_serial( $serial, $this->get_name() . '-unlimited' );
|
234 |
+
$this->sku = $this->get_name() . '-unlimited';
|
235 |
+
}
|
236 |
+
|
237 |
+
if ( is_wp_error( $is_valid ) ) {
|
238 |
+
$is_valid = $this->api->activate_serial( $serial, $this->get_name() . '-pro' );
|
239 |
+
$this->sku = $this->get_name() . '-pro';
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
//serial was not valid
|
244 |
+
if ( is_wp_error( $is_valid ) ) {
|
245 |
+
|
246 |
+
$message = $is_valid->get_error_message();
|
247 |
+
|
248 |
+
if ( is_object( $message ) && isset( $message->license_key ) ) {
|
249 |
+
$message = $message->license_key[0];
|
250 |
+
}
|
251 |
+
|
252 |
+
$this->reset_activation();
|
253 |
+
|
254 |
+
$this->deactivate_license();
|
255 |
+
|
256 |
+
$response = array(
|
257 |
+
'error' => $message,
|
258 |
+
);
|
259 |
+
|
260 |
+
} else {
|
261 |
+
//serial was valid, update the activation key for future validation
|
262 |
+
$this->set_activation( $is_valid->data, $serial );
|
263 |
+
|
264 |
+
if ( $this->extension_file_exists() ) {
|
265 |
+
$response['extension_html'] = $this->ajax_extension_html();
|
266 |
+
|
267 |
+
return $response;
|
268 |
+
}
|
269 |
+
|
270 |
+
deactivate_plugins( $this->get_extension_relative_path() );
|
271 |
+
|
272 |
+
$response = $this->save_extension_file();
|
273 |
+
|
274 |
+
if ( ! isset( $response['error'] ) ) {
|
275 |
+
$response['extension_html'] = $this->ajax_extension_html();
|
276 |
+
}
|
277 |
+
|
278 |
+
$file_path = $this->get_destination_path() . '/' . $this->extension_file_name;
|
279 |
+
|
280 |
+
//check if the require file exists
|
281 |
+
if ( file_exists( $file_path ) ) {
|
282 |
+
//check if the class exists if not include the required file
|
283 |
+
if ( ! class_exists( $this->classname ) ) {
|
284 |
+
if ( $file_path ) {
|
285 |
+
include( $file_path );
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
//if now both class exists and has a setup method.. run it
|
290 |
+
if ( class_exists( $this->classname ) && method_exists( $this->classname, 'setup' ) ) {
|
291 |
+
call_user_func( array( $this->classname, 'setup' ) );
|
292 |
+
}
|
293 |
+
|
294 |
+
$this->activate_new_plugin();
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
return $response;
|
299 |
+
}
|
300 |
+
|
301 |
+
public function get_destination_path() {
|
302 |
+
return WPCF7_PRO_REDIRECT_PLUGINS_PATH . $this->get_name();
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Get the extension download link
|
307 |
+
*/
|
308 |
+
public function get_extension_remote_file() {
|
309 |
+
$this->api = isset( $this->api ) && $this->api ? $this->api : new Qs_Api();
|
310 |
+
|
311 |
+
$download_link = $this->api->get_extension_download_url( $this->get_activation_data(), $this->get_sku() );
|
312 |
+
|
313 |
+
return $download_link;
|
314 |
+
}
|
315 |
+
/**
|
316 |
+
* Save the Newly downloaded file to the plugins dir
|
317 |
+
*/
|
318 |
+
public function save_extension_file() {
|
319 |
+
global $wp_filesystem;
|
320 |
+
|
321 |
+
$this->api = isset( $this->api ) && $this->api ? $this->api : new Qs_Api();
|
322 |
+
|
323 |
+
$response = array();
|
324 |
+
|
325 |
+
$file_path = $this->api->get_extension_file( $this->get_activation_data(), $this->get_sku() );
|
326 |
+
|
327 |
+
if ( is_wp_error( $file_path ) ) {
|
328 |
+
$response = array(
|
329 |
+
'error' => $file_path->get_error_message(),
|
330 |
+
);
|
331 |
+
|
332 |
+
$this->reset_activation();
|
333 |
+
} else {
|
334 |
+
|
335 |
+
WP_Filesystem();
|
336 |
+
|
337 |
+
$destination_path = $this->get_destination_path();
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Create a directory for the action addons and create index.php for security
|
341 |
+
*/
|
342 |
+
if ( ! is_dir( $destination_path ) ) {
|
343 |
+
@mkdir( $destination_path );
|
344 |
+
$wp_filesystem->put_contents( $destination_path . '/index.php', 'SILENCE IS GOLDEN', FS_CHMOD_FILE );
|
345 |
+
}
|
346 |
+
|
347 |
+
if ( ! is_dir( $destination_path ) ) {
|
348 |
+
$response = array(
|
349 |
+
/* translators: %s: Destination path */
|
350 |
+
'error' => sprintf( __( 'Cannot create %s. Please create a directory manualy or fix permission issue.', 'wpcf7-redirect' ), $destination_path ),
|
351 |
+
);
|
352 |
+
} else {
|
353 |
+
$unzipfile = unzip_file( $file_path, $destination_path );
|
354 |
+
|
355 |
+
unlink( $file_path );
|
356 |
+
|
357 |
+
if ( is_wp_error( $unzipfile ) ) {
|
358 |
+
$response = array(
|
359 |
+
'error' => $unzipfile->get_error_message(),
|
360 |
+
);
|
361 |
+
$this->reset_activation();
|
362 |
+
} else {
|
363 |
+
$this->set_updated();
|
364 |
+
}
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
return $response;
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Activate new downloaded extension
|
373 |
+
*
|
374 |
+
* @return void
|
375 |
+
*/
|
376 |
+
public function activate_new_plugin() {
|
377 |
+
|
378 |
+
if ( ! function_exists( 'activate_plugin' ) ) {
|
379 |
+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
380 |
+
}
|
381 |
+
|
382 |
+
if ( ! is_plugin_active( $this->get_extension_relative_path() ) ) {
|
383 |
+
activate_plugin( $this->get_extension_relative_path() );
|
384 |
+
}
|
385 |
+
|
386 |
+
}
|
387 |
+
/**
|
388 |
+
* Get extension badge text
|
389 |
+
*
|
390 |
+
* @return void
|
391 |
+
*/
|
392 |
+
public function get_badge() {
|
393 |
+
return $this->badge ? "<span class='badge'>" . $this->badge . '</span>' : '';
|
394 |
+
}
|
395 |
+
|
396 |
+
/**
|
397 |
+
* Set all data related with the plugin activation
|
398 |
+
*
|
399 |
+
* @param $validation_data
|
400 |
+
* @param $serial
|
401 |
+
*/
|
402 |
+
public function set_activation( $validation_data, $serial ) {
|
403 |
+
update_option( 'wpcf7r_activation_id-' . $this->get_name(), $validation_data->activation_id );
|
404 |
+
update_option( 'wpcf7r_activation_expiration-' . $this->get_name(), $validation_data->expire );
|
405 |
+
update_option( 'wpcf7r_activation_data-' . $this->get_name(), $validation_data );
|
406 |
+
update_option( 'wpcf7r_activation_serial-' . $this->get_name(), $serial );
|
407 |
+
update_option( 'wpcf7r_activation_' . $this->get_name() . '-sku', $this->sku );
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Clear all activation data
|
412 |
+
*/
|
413 |
+
public function reset_activation() {
|
414 |
+
delete_option( 'wpcf7r_activation_id-' . $this->get_name() );
|
415 |
+
delete_option( 'wpcf7r_activation_expiration-' . $this->get_name() );
|
416 |
+
delete_option( 'wpcf7r_activation_data-' . $this->get_name() );
|
417 |
+
delete_option( 'wpcf7r_activation_serial-' . $this->get_name() );
|
418 |
+
update_option( 'wpcf7r_activation_' . $this->get_name() . '-sku', $this->sku );
|
419 |
+
}
|
420 |
+
|
421 |
+
public function get_sku() {
|
422 |
+
return isset( $this->sku ) && $this->sku ? $this->sku : get_option( 'wpcf7r_activation_' . $this->get_name() . '-sku' );
|
423 |
+
}
|
424 |
+
/**
|
425 |
+
* Get the activation key
|
426 |
+
*/
|
427 |
+
public function get_activation_id() {
|
428 |
+
return get_option( 'wpcf7r_activation_id-' . $this->get_name() );
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Deactivate extension license
|
433 |
+
*/
|
434 |
+
public function deactivate_license( $serial = '' ) {
|
435 |
+
|
436 |
+
$api = new Qs_Api();
|
437 |
+
|
438 |
+
$response = array();
|
439 |
+
|
440 |
+
$serial = $serial ? $serial : $this->get_serial();
|
441 |
+
|
442 |
+
$activation_id = $this->get_activation_id();
|
443 |
+
|
444 |
+
if ( ! $activation_id ) {
|
445 |
+
$this->reset_activation();
|
446 |
+
} else {
|
447 |
+
$results = $api->deactivate_liscense( $activation_id, $serial, $this->get_name() );
|
448 |
+
|
449 |
+
$this->reset_activation();
|
450 |
+
}
|
451 |
+
|
452 |
+
$response['extension_html'] = $this->ajax_extension_html();
|
453 |
+
|
454 |
+
return $response;
|
455 |
+
}
|
456 |
+
|
457 |
+
/**
|
458 |
+
* Ajax function for getting the extension html box
|
459 |
+
*/
|
460 |
+
public function ajax_extension_html() {
|
461 |
+
ob_start();
|
462 |
+
|
463 |
+
$this->get_action_promo();
|
464 |
+
|
465 |
+
$html = ob_get_clean();
|
466 |
+
|
467 |
+
return $html;
|
468 |
+
}
|
469 |
+
|
470 |
+
/**
|
471 |
+
* Get the link to purchase the extension
|
472 |
+
*/
|
473 |
+
public function get_purchase_link() {
|
474 |
+
return WPCF7_PRO_REDIRECT_PLUGIN_PAGE_URL . $this->name;
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
* Get the extension description
|
479 |
+
*/
|
480 |
+
public function get_description() {
|
481 |
+
return $this->description;
|
482 |
+
}
|
483 |
+
|
484 |
+
/**
|
485 |
+
* Get the extension icon
|
486 |
+
*/
|
487 |
+
public function get_icon() {
|
488 |
+
return $this->icon;
|
489 |
+
}
|
490 |
+
|
491 |
+
/**
|
492 |
+
* Get the extension name
|
493 |
+
*/
|
494 |
+
public function get_title() {
|
495 |
+
return $this->title;
|
496 |
+
}
|
497 |
+
}
|
classes/class-wpcf7r-extensions.php
CHANGED
@@ -1,42 +1,42 @@
|
|
1 |
-
<?php
|
2 |
-
defined( 'ABSPATH' ) || exit;
|
3 |
-
|
4 |
-
class WPCF7R_Extensions {
|
5 |
-
|
6 |
-
public function __construct() {
|
7 |
-
$this->available_extensions = wpcf7_get_extensions();
|
8 |
-
$this->set_available_extensions();
|
9 |
-
}
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Set available extensions
|
13 |
-
*/
|
14 |
-
private function set_available_extensions() {
|
15 |
-
foreach ( $this->available_extensions as $extension ) {
|
16 |
-
$this->extensions[] = new WPCF7R_Extension( $extension );
|
17 |
-
}
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Initialize extensions table tab
|
22 |
-
*/
|
23 |
-
public function init() {
|
24 |
-
$this->display();
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* View available extensions
|
29 |
-
*/
|
30 |
-
public function get_extensions() {
|
31 |
-
return $this->extensions;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Display the extensions list
|
36 |
-
*
|
37 |
-
* @return void
|
38 |
-
*/
|
39 |
-
public function display() {
|
40 |
-
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'extensions.php' ;
|
41 |
-
}
|
42 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit;
|
3 |
+
|
4 |
+
class WPCF7R_Extensions {
|
5 |
+
|
6 |
+
public function __construct() {
|
7 |
+
$this->available_extensions = wpcf7_get_extensions();
|
8 |
+
$this->set_available_extensions();
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Set available extensions
|
13 |
+
*/
|
14 |
+
private function set_available_extensions() {
|
15 |
+
foreach ( $this->available_extensions as $extension ) {
|
16 |
+
$this->extensions[] = new WPCF7R_Extension( $extension );
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Initialize extensions table tab
|
22 |
+
*/
|
23 |
+
public function init() {
|
24 |
+
$this->display();
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* View available extensions
|
29 |
+
*/
|
30 |
+
public function get_extensions() {
|
31 |
+
return $this->extensions;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Display the extensions list
|
36 |
+
*
|
37 |
+
* @return void
|
38 |
+
*/
|
39 |
+
public function display() {
|
40 |
+
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'extensions.php' ;
|
41 |
+
}
|
42 |
+
}
|
classes/class-wpcf7r-form-helper.php
CHANGED
@@ -1,668 +1,668 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The main class that manages the plugin.
|
4 |
-
*
|
5 |
-
* @package wpcf7r
|
6 |
-
*/
|
7 |
-
|
8 |
-
defined( 'ABSPATH' ) || exit;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class WPCF7r_Form_Helper - Adds contact form scripts and actions
|
12 |
-
*/
|
13 |
-
class WPCF7r_Form_Helper {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Class Constructor
|
17 |
-
*/
|
18 |
-
public function __construct() {
|
19 |
-
|
20 |
-
$this->plugin_url = WPCF7_PRO_REDIRECT_BASE_URL;
|
21 |
-
$this->assets_js_lib = WPCF7_PRO_REDIRECT_BASE_URL . 'assets/lib/';
|
22 |
-
$this->assets_js_url = WPCF7_PRO_REDIRECT_BASE_URL . 'assets/js/';
|
23 |
-
$this->assets_css_url = WPCF7_PRO_REDIRECT_BASE_URL . 'assets/css/';
|
24 |
-
$this->build_js_url = WPCF7_PRO_REDIRECT_BASE_URL . 'build/js/';
|
25 |
-
$this->build_css_url = WPCF7_PRO_REDIRECT_BASE_URL . 'build/css/';
|
26 |
-
$this->extensions = wpcf7_get_extensions();
|
27 |
-
$this->add_actions();
|
28 |
-
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Add Actions
|
33 |
-
*/
|
34 |
-
private function add_actions() {
|
35 |
-
|
36 |
-
global $pagenow;
|
37 |
-
|
38 |
-
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
39 |
-
add_action( 'wpcf7_editor_panels', array( $this, 'add_panel' ) );
|
40 |
-
add_action( 'wpcf7_after_save', array( $this, 'store_meta' ) );
|
41 |
-
// add contact form scripts.
|
42 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'front_end_scripts' ) );
|
43 |
-
// add contact form scripts for admin panel.
|
44 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_backend' ) );
|
45 |
-
add_action( 'wp_ajax_activate_wpcf7r_extension', array( $this, 'activate_extension' ) );
|
46 |
-
add_action( 'wp_ajax_deactivate_wpcf7r_extension', array( $this, 'deactivate_plugin_license' ) );
|
47 |
-
add_action( 'admin_init', array( $this, 'maybe_update_extensions_check' ), 10 );
|
48 |
-
add_action( 'wp_ajax_wpcf7r_extension_update', array( $this, 'maybe_update_extension' ), 10 );
|
49 |
-
add_action( 'wp_ajax_get_coupon', array( $this, 'get_coupon' ) );
|
50 |
-
add_action( 'wpcf7_admin_notices', array( $this, 'render_discount_banner' ), 15, 3 );
|
51 |
-
add_action( 'admin_init', array( $this, 'dismiss_ads' ) );
|
52 |
-
|
53 |
-
// define the alternative API for updating checking
|
54 |
-
add_filter( 'pre_set_site_transient_update_plugins', array( &$this, 'check_update' ) );
|
55 |
-
|
56 |
-
add_filter( 'plugins_api', array( &$this, 'check_info' ), 10, 3 );
|
57 |
-
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Add our self-hosted description to the filter
|
62 |
-
*
|
63 |
-
* @param boolean $false
|
64 |
-
* @param array $action
|
65 |
-
* @param object $arg
|
66 |
-
* @return bool|object
|
67 |
-
*
|
68 |
-
* @version 1.0.0
|
69 |
-
*/
|
70 |
-
public function check_info( $false, $action, $arg ) {
|
71 |
-
$action_plugin = false;
|
72 |
-
|
73 |
-
$api = new Qs_Api();
|
74 |
-
|
75 |
-
foreach ( $this->extensions as $extension_type => $extension_details ) {
|
76 |
-
|
77 |
-
$extension = new WPCF7R_Extension( $extension_details );
|
78 |
-
|
79 |
-
if ( isset( $arg->slug ) && $arg->slug === $extension->get_slug() ) {
|
80 |
-
$action_plugin = $extension->get_sku();
|
81 |
-
break;
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
-
if ( ( $action == 'query_plugins' || $action == 'plugin_information' ) && $action_plugin ) {
|
86 |
-
|
87 |
-
$array_pattern = array(
|
88 |
-
'/^([\*\s])*(\d\d\.\d\d\.\d\d\d\d[^\n]*)/m',
|
89 |
-
'/^\n+|^[\t\s]*\n+/m',
|
90 |
-
'/\n/',
|
91 |
-
);
|
92 |
-
|
93 |
-
$array_replace = array(
|
94 |
-
'<h4>$2</h4>',
|
95 |
-
'</div><div>',
|
96 |
-
'</div><div>',
|
97 |
-
);
|
98 |
-
|
99 |
-
$changelog = $api->get_action_changelog( $action_plugin );
|
100 |
-
|
101 |
-
$information = new stdClass;
|
102 |
-
|
103 |
-
$information->sections['changelog'] = '<div>' . $changelog->changelog . '</div>';
|
104 |
-
|
105 |
-
return $information;
|
106 |
-
}
|
107 |
-
|
108 |
-
return $false;
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Add our self-hosted autoupdate plugin to the filter transient
|
113 |
-
*
|
114 |
-
* @param $transient
|
115 |
-
* @return object $ transient
|
116 |
-
*
|
117 |
-
* @version 1.0.0
|
118 |
-
*/
|
119 |
-
public function check_update( $transient ) {
|
120 |
-
if ( empty( $transient->checked ) ) {
|
121 |
-
return $transient;
|
122 |
-
}
|
123 |
-
|
124 |
-
foreach ( $this->extensions as $extension_type => $extension_details ) {
|
125 |
-
|
126 |
-
$extension = new WPCF7R_Extension( $extension_details );
|
127 |
-
|
128 |
-
if ( $extension->has_update() ) {
|
129 |
-
|
130 |
-
$update_url = add_query_arg( 'update', true, $extension->get_extension_remote_file() );
|
131 |
-
$obj = new stdClass();
|
132 |
-
$obj->id = $extension->get_slug();
|
133 |
-
$obj->slug = $extension->get_slug();
|
134 |
-
$obj->new_version = $extension->update_version();
|
135 |
-
$obj->url = $update_url;
|
136 |
-
$obj->plugin = $extension->get_extension_relative_path();
|
137 |
-
$obj->package = $update_url;
|
138 |
-
$obj->tested = WPCF7_PRO_REDIRECT_WP_TESTED;
|
139 |
-
$obj->icons = array(
|
140 |
-
'2x' => $extension->get_icon(),
|
141 |
-
'1x' => $extension->get_icon(),
|
142 |
-
);
|
143 |
-
|
144 |
-
$transient->response[ $extension->get_extension_relative_path() ] = $obj;
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
return $transient;
|
149 |
-
}
|
150 |
-
/**
|
151 |
-
* Check if an extension requires an update
|
152 |
-
*
|
153 |
-
* @return void
|
154 |
-
*/
|
155 |
-
public function maybe_update_extension() {
|
156 |
-
|
157 |
-
$results = array();
|
158 |
-
|
159 |
-
if ( current_user_can( 'administrator' ) && wpcf7_validate_nonce() ) {
|
160 |
-
$extension_name = isset( $_POST['extension_name'] ) && $_POST['extension_name'] ? sanitize_text_field( $_POST['extension_name'] ) : '';
|
161 |
-
|
162 |
-
if ( $extension_name ) {
|
163 |
-
$extension = $this->get_extension_object( $extension_name );
|
164 |
-
|
165 |
-
if ( $extension->has_update() ) {
|
166 |
-
$results = $extension->save_extension_file();
|
167 |
-
}
|
168 |
-
|
169 |
-
$results['html'] = $extension->ajax_extension_html();
|
170 |
-
}
|
171 |
-
}
|
172 |
-
|
173 |
-
wp_send_json( $results );
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* Check if there is a need for update check.
|
178 |
-
*
|
179 |
-
* @return void
|
180 |
-
*/
|
181 |
-
public function maybe_update_extensions_check() {
|
182 |
-
global $wp_version;
|
183 |
-
|
184 |
-
$current = get_transient( 'update_wpcf7r_extensions' );
|
185 |
-
|
186 |
-
if ( $current && ! isset( $_GET['force-check'] ) ) {
|
187 |
-
return;
|
188 |
-
}
|
189 |
-
|
190 |
-
$current = new stdClass();
|
191 |
-
|
192 |
-
$current->version_checked = $wp_version;
|
193 |
-
$current->last_checked = current_time( 'timestamp' );
|
194 |
-
|
195 |
-
set_transient( 'update_wpcf7r_extensions', $current, HOUR_IN_SECONDS * 24 * 12 );
|
196 |
-
|
197 |
-
$this->check_for_extensions_update();
|
198 |
-
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Check for extension update from API.
|
203 |
-
*
|
204 |
-
* @return void
|
205 |
-
*/
|
206 |
-
public function check_for_extensions_update() {
|
207 |
-
|
208 |
-
$api = new Qs_Api();
|
209 |
-
|
210 |
-
foreach ( $this->extensions as $extension_type => $extension_details ) {
|
211 |
-
|
212 |
-
$extension = new WPCF7R_Extension( $extension_details );
|
213 |
-
|
214 |
-
if ( $extension->is_active() ) {
|
215 |
-
|
216 |
-
$has_update = $api->extension_has_update( $extension );
|
217 |
-
|
218 |
-
if ( $has_update ) {
|
219 |
-
|
220 |
-
$extension->set_needs_update( $has_update );
|
221 |
-
|
222 |
-
} else {
|
223 |
-
|
224 |
-
$extension->set_updated();
|
225 |
-
|
226 |
-
}
|
227 |
-
}
|
228 |
-
}
|
229 |
-
}
|
230 |
-
|
231 |
-
/**
|
232 |
-
* Get the extension object
|
233 |
-
*
|
234 |
-
* @param [string] $extention_name - the name of the extension.
|
235 |
-
* @return object - $extention_object - the extension object.
|
236 |
-
*/
|
237 |
-
public function get_extension_object( $extention_name ) {
|
238 |
-
|
239 |
-
$extention_object = isset( $this->extensions[ $extention_name ] ) ? new WPCF7R_Extension( $this->extensions[ $extention_name ] ) : '';
|
240 |
-
|
241 |
-
return $extention_object;
|
242 |
-
|
243 |
-
}
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Deactivate plugin license.
|
247 |
-
*
|
248 |
-
* @return void
|
249 |
-
*/
|
250 |
-
public function deactivate_plugin_license() {
|
251 |
-
|
252 |
-
$results = array();
|
253 |
-
|
254 |
-
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
255 |
-
if ( ! isset( $_POST['extension_name'] ) ) {
|
256 |
-
|
257 |
-
$results = array(
|
258 |
-
'message' => __( 'Missing name or serial', 'wpcf7-redirect' ),
|
259 |
-
);
|
260 |
-
|
261 |
-
} else {
|
262 |
-
|
263 |
-
$extentsion_settings = $this->extensions[ $_POST['extension_name'] ];
|
264 |
-
|
265 |
-
if ( $extentsion_settings ) {
|
266 |
-
$extentsion = new WPCF7R_Extension( $extentsion_settings );
|
267 |
-
$results = $extentsion->deactivate_license();
|
268 |
-
}
|
269 |
-
}
|
270 |
-
}
|
271 |
-
|
272 |
-
wp_send_json( $results );
|
273 |
-
|
274 |
-
}
|
275 |
-
|
276 |
-
/**
|
277 |
-
* Activate extension license.
|
278 |
-
*
|
279 |
-
* @return void
|
280 |
-
*/
|
281 |
-
public function activate_extension() {
|
282 |
-
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
283 |
-
if ( ! isset( $_POST['extension_name'] ) || ! isset( $_POST['serial'] ) ) {
|
284 |
-
$results = array(
|
285 |
-
'message' => __( 'Missing name or serial', 'wpcf7-redirect' ),
|
286 |
-
);
|
287 |
-
} else {
|
288 |
-
|
289 |
-
$extentsion_settings = $this->extensions[ $_POST['extension_name'] ];
|
290 |
-
|
291 |
-
if ( $extentsion_settings ) {
|
292 |
-
$extentsion = new WPCF7R_extension( $extentsion_settings );
|
293 |
-
$serial = sanitize_text_field( $_POST['serial'] );
|
294 |
-
$results = $extentsion->activate( $serial );
|
295 |
-
} else {
|
296 |
-
$results['extension_html'] = __( 'Somthing went wrong', 'wpcf7-redirect' );
|
297 |
-
}
|
298 |
-
}
|
299 |
-
|
300 |
-
wp_send_json( $results );
|
301 |
-
}
|
302 |
-
}
|
303 |
-
|
304 |
-
/**
|
305 |
-
* Dismiss plugin ads
|
306 |
-
*/
|
307 |
-
public function dismiss_ads() {
|
308 |
-
|
309 |
-
if ( isset( $_GET['wpcf7_redirect_dismiss_banner'] ) && '1' === $_GET['wpcf7_redirect_dismiss_banner'] ) {
|
310 |
-
$banner_version = wpcf7r_get_banner_version() ? wpcf7r_get_banner_version() : 1;
|
311 |
-
|
312 |
-
update_option( 'wpcf7_redirect_dismiss_banner', $banner_version );
|
313 |
-
}
|
314 |
-
|
315 |
-
}
|
316 |
-
|
317 |
-
/**
|
318 |
-
* Only load scripts when contact form instance is created
|
319 |
-
*/
|
320 |
-
public function front_end_scripts() {
|
321 |
-
|
322 |
-
wp_register_style( 'wpcf7-redirect-script-frontend', $this->build_css_url . 'wpcf7-redirect-frontend.min.css', '1.1' );
|
323 |
-
wp_enqueue_style( 'wpcf7-redirect-script-frontend' );
|
324 |
-
wp_register_script( 'wpcf7-redirect-script', $this->build_js_url . 'wpcf7-redirect-frontend-script.js', array( 'jquery' ), '1.1', true );
|
325 |
-
wp_enqueue_script( 'wpcf7-redirect-script' );
|
326 |
-
wp_localize_script( 'wpcf7-redirect-script', 'wpcf7r', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
|
327 |
-
|
328 |
-
// Load active extensions scripts and styles.
|
329 |
-
$installed_extensions = wpcf7r_get_available_actions();
|
330 |
-
|
331 |
-
foreach ( $installed_extensions as $installed_extension ) {
|
332 |
-
if ( method_exists( $installed_extension['handler'], 'enqueue_frontend_scripts' ) ) {
|
333 |
-
call_user_func( array( $installed_extension['handler'], 'enqueue_frontend_scripts' ) );
|
334 |
-
}
|
335 |
-
}
|
336 |
-
|
337 |
-
// add support for other plugins
|
338 |
-
do_action( 'wpcf7_redirect_enqueue_frontend', $this );
|
339 |
-
}
|
340 |
-
|
341 |
-
/**
|
342 |
-
* Check if the current page is the plugin settings page
|
343 |
-
*/
|
344 |
-
public function is_wpcf7_settings_page() {
|
345 |
-
return isset( $_GET['page'] ) && 'wpc7_redirect' === $_GET['page'];
|
346 |
-
}
|
347 |
-
|
348 |
-
/**
|
349 |
-
* Check if the current admin post type is a lead post type.
|
350 |
-
*
|
351 |
-
* @return boolean
|
352 |
-
*/
|
353 |
-
public function is_wpcf7_lead_page() {
|
354 |
-
return 'wpcf7r_leads' === get_post_type();
|
355 |
-
}
|
356 |
-
|
357 |
-
/**
|
358 |
-
* Check if the current admin page is accesibe plugin page.
|
359 |
-
*
|
360 |
-
* @return boolean
|
361 |
-
*/
|
362 |
-
public function is_accesibe_page() {
|
363 |
-
$screen = get_current_screen();
|
364 |
-
|
365 |
-
return 'toplevel_page_' . qs_get_plugin_display_name() === $screen->base;
|
366 |
-
}
|
367 |
-
|
368 |
-
/**
|
369 |
-
* Check if the current page is the contact form edit screen
|
370 |
-
*/
|
371 |
-
public function is_wpcf7_edit() {
|
372 |
-
return wpcf7r_is_wpcf7_edit();
|
373 |
-
}
|
374 |
-
|
375 |
-
/**
|
376 |
-
* Load plugin textdomain.
|
377 |
-
*/
|
378 |
-
public function load_textdomain() {
|
379 |
-
load_plugin_textdomain( 'wpcf7-redirect', false, basename( dirname( __FILE__ ) ) . '/lang' );
|
380 |
-
}
|
381 |
-
|
382 |
-
/**
|
383 |
-
* Enqueue theme styles and scripts - back-end
|
384 |
-
*/
|
385 |
-
public function enqueue_backend() {
|
386 |
-
|
387 |
-
if ( $this->is_wpcf7_edit() || $this->is_wpcf7_settings_page() || $this->is_wpcf7_lead_page() || $this->is_accesibe_page() ) {
|
388 |
-
|
389 |
-
wp_enqueue_style( 'admin-build', $this->build_css_url . 'wpcf7-redirect-backend.css', array(), WPCF7_PRO_REDIRECT_PLUGIN_VERSION );
|
390 |
-
|
391 |
-
// wp_enqueue_script( 'jquery-validation', 'https://cdn.jsdelivr.net/npm/jquery-validation@1.19.3/dist/jquery.validate.js', array(), WPCF7_PRO_REDIRECT_PLUGIN_VERSION, true );
|
392 |
-
// wp_enqueue_script( 'admin-dev-select2', $this->assets_js_url . 'select2.js', array(), WPCF7_PRO_REDIRECT_PLUGIN_VERSION, true );
|
393 |
-
// wp_enqueue_script( 'admin-dev-validation-js', $this->assets_js_url . 'wpcf7-redirect-validation.js', array(), WPCF7_PRO_REDIRECT_PLUGIN_VERSION, true );
|
394 |
-
// wp_enqueue_script( 'admin-dev-js', $this->assets_js_url . 'wpcf7-redirect-backend-script.js', array(), WPCF7_PRO_REDIRECT_PLUGIN_VERSION, true );
|
395 |
-
|
396 |
-
wp_enqueue_script( 'admin-build-js', $this->build_js_url . 'wpcf7-redirect-backend-script.js', array(), WPCF7_PRO_REDIRECT_PLUGIN_VERSION, true );
|
397 |
-
wp_enqueue_script(
|
398 |
-
array(
|
399 |
-
'jquery-ui-core',
|
400 |
-
'jquery-ui-sortable',
|
401 |
-
'wp-color-picker',
|
402 |
-
)
|
403 |
-
);
|
404 |
-
|
405 |
-
// Load active extensions scripts and styles.
|
406 |
-
$installed_extensions = wpcf7r_get_available_actions();
|
407 |
-
|
408 |
-
foreach ( $installed_extensions as $installed_extension ) {
|
409 |
-
if ( method_exists( $installed_extension['handler'], 'enqueue_backend_scripts' ) ) {
|
410 |
-
call_user_func( array( $installed_extension['handler'], 'enqueue_backend_scripts' ) );
|
411 |
-
}
|
412 |
-
}
|
413 |
-
|
414 |
-
// add support for other plugins.
|
415 |
-
do_action( 'wpcf_7_redirect_admin_scripts', $this );
|
416 |
-
}
|
417 |
-
}
|
418 |
-
|
419 |
-
/**
|
420 |
-
* Store form data.
|
421 |
-
*
|
422 |
-
* @param [object] $cf7 -contact form object.
|
423 |
-
*/
|
424 |
-
public function store_meta( $cf7 ) {
|
425 |
-
|
426 |
-
$form = get_cf7r_form( $cf7->id() );
|
427 |
-
$form->store_meta( $cf7 );
|
428 |
-
}
|
429 |
-
|
430 |
-
/**
|
431 |
-
* Adds a tab to the editor on the form edit page
|
432 |
-
*
|
433 |
-
* @param array $panels An array of panels. Each panel has a callback function.
|
434 |
-
*/
|
435 |
-
public function add_panel( $panels ) {
|
436 |
-
|
437 |
-
// Disable plugin functionality for old contact form 7 installations.
|
438 |
-
|
439 |
-
if ( wpcf7_get_cf7_ver() > 4.8 ) {
|
440 |
-
|
441 |
-
$panels['redirect-panel'] = array(
|
442 |
-
'title' => __( 'Actions', 'wpcf7-redirect' ),
|
443 |
-
'callback' => array( $this, 'create_panel_inputs' ),
|
444 |
-
);
|
445 |
-
|
446 |
-
$panels['extensions-panel'] = array(
|
447 |
-
'title' => __( 'Extensions', 'wpcf7-redirect' ),
|
448 |
-
'callback' => array( $this, 'extensions_manager' ),
|
449 |
-
);
|
450 |
-
|
451 |
-
if ( is_wpcf7r_debug() ) {
|
452 |
-
|
453 |
-
$panels['debug-panel'] = array(
|
454 |
-
'title' => __( 'Debug', 'wpcf7-redirect' ),
|
455 |
-
'callback' => array( $this, 'wpcf7_debug' ),
|
456 |
-
);
|
457 |
-
|
458 |
-
}
|
459 |
-
}
|
460 |
-
|
461 |
-
return $panels;
|
462 |
-
}
|
463 |
-
|
464 |
-
/**
|
465 |
-
* Get the default fields
|
466 |
-
*/
|
467 |
-
public static function get_plugin_default_fields() {
|
468 |
-
|
469 |
-
return array(
|
470 |
-
array(
|
471 |
-
'name' => 'redirect_type',
|
472 |
-
'type' => 'text',
|
473 |
-
),
|
474 |
-
);
|
475 |
-
}
|
476 |
-
|
477 |
-
/**
|
478 |
-
* Handler to retrive banner to display
|
479 |
-
* At the moment used to display the pro version bannner
|
480 |
-
*/
|
481 |
-
public function banner() {
|
482 |
-
$banner_manager = new Banner_Manager();
|
483 |
-
$banner_manager->show_banner();
|
484 |
-
}
|
485 |
-
|
486 |
-
/**
|
487 |
-
* Create the panel inputs.
|
488 |
-
*
|
489 |
-
* @param object $cf7 - Contact form 7 post object.
|
490 |
-
*/
|
491 |
-
public function create_panel_inputs( $cf7 ) {
|
492 |
-
|
493 |
-
$form = get_cf7r_form( $cf7->id() );
|
494 |
-
|
495 |
-
$form->init();
|
496 |
-
}
|
497 |
-
|
498 |
-
/**
|
499 |
-
* Manage contact form 7 redirection pro extensions
|
500 |
-
*
|
501 |
-
* @param object $cf7 - Contact form 7 post object.
|
502 |
-
*/
|
503 |
-
public function extensions_manager( $cf7 ) {
|
504 |
-
|
505 |
-
$this->extensions_manager = $this->get_extension_manager();
|
506 |
-
$this->extensions_manager->init();
|
507 |
-
|
508 |
-
}
|
509 |
-
|
510 |
-
/**
|
511 |
-
* Get extension manager instance
|
512 |
-
*
|
513 |
-
* @return object - extensions manager object.
|
514 |
-
*/
|
515 |
-
public function get_extension_manager() {
|
516 |
-
return isset( $this->extensions_manager ) ? $this->extensions_manager : new WPCF7R_Extensions();
|
517 |
-
}
|
518 |
-
|
519 |
-
/**
|
520 |
-
* Display debug tab on contact form
|
521 |
-
*
|
522 |
-
* @param $cf7 - Contact form 7 post object.
|
523 |
-
* @return void
|
524 |
-
*/
|
525 |
-
public function wpcf7_debug( $cf7 ) {
|
526 |
-
|
527 |
-
global $wp_version;
|
528 |
-
|
529 |
-
$form_json = self::get_debug_data( $cf7->id() );
|
530 |
-
|
531 |
-
echo '<h3>' . __( 'Debug Information', 'wpcf7-redirect' ) . '</h3>';
|
532 |
-
echo '<div>' . __( 'The debug information includes the following details', 'wpcf7-redirect' ) . '</div><ul>';
|
533 |
-
echo '<li>' . __( 'Form post data.', 'wpcf7-redirect' ) . '</li>';
|
534 |
-
echo '<li>' . __( 'Actions post data.', 'wpcf7-redirect' ) . '</li>';
|
535 |
-
echo '<li>' . __( 'PHP Version', 'wpcf7-redirect' ) . '</li>';
|
536 |
-
echo '<li>' . __( 'Installed plugins list', 'wpcf7-redirect' ) . '</li>';
|
537 |
-
echo '<li>' . __( 'WordPress Version', 'wpcf7-redirect' ) . '</li>';
|
538 |
-
echo '</ul>';
|
539 |
-
echo '<div style="color:red;font-size:18px;margin-bottom:20px;">' . __( 'The data is used for debug purposes only!', 'wpcf7-redirect' ) . '</div>';
|
540 |
-
echo "<div><textarea style='width:100%;height:200px;margin-bottom:40px;font-size:11px'>{$form_json}</textarea><br/></div>";
|
541 |
-
echo '<input type="submit" class="button button-primary send-debug-info" value="Send Debug Report"/><br/><br/>';
|
542 |
-
echo '<label><input type="checkbox" class="approve-debug" /> I approve sending debug information to Query Solutions support team.</label>';
|
543 |
-
|
544 |
-
}
|
545 |
-
|
546 |
-
/**
|
547 |
-
* Get encoded debug data
|
548 |
-
*
|
549 |
-
* @param $form_id - contact form 7 ID.
|
550 |
-
* @return void
|
551 |
-
*/
|
552 |
-
public static function get_debug_data( $form_id ) {
|
553 |
-
global $wp_version;
|
554 |
-
|
555 |
-
$cf7r_form = get_cf7r_form( (int) $form_id );
|
556 |
-
|
557 |
-
$form_json = base64_encode(
|
558 |
-
serialize(
|
559 |
-
array(
|
560 |
-
'actions' => $cf7r_form->get_active_actions(),
|
561 |
-
'form_meta' => get_post_custom( $form_id ),
|
562 |
-
'form_post' => get_post( $form_id ),
|
563 |
-
'plugins' => json_encode( get_plugins() ),
|
564 |
-
'phpver' => phpversion(),
|
565 |
-
'wp_version' => $wp_version,
|
566 |
-
'site_url' => home_url(),
|
567 |
-
)
|
568 |
-
)
|
569 |
-
);
|
570 |
-
|
571 |
-
return $form_json;
|
572 |
-
}
|
573 |
-
|
574 |
-
/**
|
575 |
-
* Render discount banner
|
576 |
-
*
|
577 |
-
* @param [object] $page - the current page.
|
578 |
-
* @param [object] $action - the required action.
|
579 |
-
* @param [object] $object - contact form 7 object.
|
580 |
-
*/
|
581 |
-
public function render_discount_banner( $page, $action, $object ) {
|
582 |
-
|
583 |
-
if ( 'edit' === $action ) {
|
584 |
-
$banner_version_dismissed = get_option( 'wpcf7_redirect_dismiss_banner' );
|
585 |
-
$banner = wpcf7r_get_discount_banner();
|
586 |
-
|
587 |
-
if ( $banner ) {
|
588 |
-
update_option( 'wpcf7r_banner_version', $banner->version );
|
589 |
-
|
590 |
-
if ( ! $banner_version_dismissed && wpcf7r_get_banner_version() !== $banner_version_dismissed ) {
|
591 |
-
echo $banner->banner;
|
592 |
-
}
|
593 |
-
}
|
594 |
-
}
|
595 |
-
}
|
596 |
-
|
597 |
-
/**
|
598 |
-
* Returns an html for displaying a link to the form.
|
599 |
-
*
|
600 |
-
* @param [int] $form_id - the if of the contact form 7 post.
|
601 |
-
* @return [string] - a link to the form edit screen.
|
602 |
-
*/
|
603 |
-
public static function get_cf7_link_html( $form_id ) {
|
604 |
-
$form_post = get_post( $form_id );
|
605 |
-
$form_title = get_the_title( $form_id );
|
606 |
-
$link = get_edit_post_link( $form_id );
|
607 |
-
|
608 |
-
if ( $form_post ) {
|
609 |
-
return sprintf( "<a href='%s' target='_blank'>%s</a>", $link, $form_title );
|
610 |
-
}
|
611 |
-
|
612 |
-
return __( 'This form no longer exists', 'wpcf7-redirect' );
|
613 |
-
}
|
614 |
-
|
615 |
-
/**
|
616 |
-
* Get coupon ajax function
|
617 |
-
*/
|
618 |
-
public function get_coupon() {
|
619 |
-
$results = array();
|
620 |
-
|
621 |
-
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
622 |
-
$data = $_POST['data'];
|
623 |
-
|
624 |
-
$email = isset( $data['email'] ) && is_email( $data['email'] ) ? $data['email'] : false;
|
625 |
-
|
626 |
-
if ( ! $email ) {
|
627 |
-
$results = array(
|
628 |
-
'status' => 'rp-error',
|
629 |
-
'message' => 'Please enter a valid email.',
|
630 |
-
);
|
631 |
-
|
632 |
-
wp_send_json( $results );
|
633 |
-
} else {
|
634 |
-
$ip = $_SERVER['REMOTE_ADDR'];
|
635 |
-
$url = home_url();
|
636 |
-
$accept = sanitize_text_field( $data['get_offers'] );
|
637 |
-
$params = array(
|
638 |
-
'ip_address' => $ip,
|
639 |
-
'accept' => $accept,
|
640 |
-
'email' => $email,
|
641 |
-
'url' => $url,
|
642 |
-
);
|
643 |
-
|
644 |
-
$params = http_build_query( $params );
|
645 |
-
|
646 |
-
$endpoint = WPCF7_PRO_REDIRECT_PLUGIN_PAGE_URL . "wp-json/api-v1/get-coupon?{$params}";
|
647 |
-
|
648 |
-
$response = wp_remote_post( $endpoint );
|
649 |
-
|
650 |
-
$body = json_decode( wp_remote_retrieve_body( $response ), true );
|
651 |
-
|
652 |
-
if ( isset( $body['message'] ) ) {
|
653 |
-
$results = array(
|
654 |
-
'status' => 'rp-success',
|
655 |
-
'message' => $body['message'],
|
656 |
-
);
|
657 |
-
} elseif ( isset( $body['redirect'] ) ) {
|
658 |
-
$results = array(
|
659 |
-
'status' => 'rp-success',
|
660 |
-
'url' => $body['redirect'],
|
661 |
-
);
|
662 |
-
}
|
663 |
-
}
|
664 |
-
}
|
665 |
-
|
666 |
-
wp_send_json( $results );
|
667 |
-
}
|
668 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The main class that manages the plugin.
|
4 |
+
*
|
5 |
+
* @package wpcf7r
|
6 |
+
*/
|
7 |
+
|
8 |
+
defined( 'ABSPATH' ) || exit;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class WPCF7r_Form_Helper - Adds contact form scripts and actions
|
12 |
+
*/
|
13 |
+
class WPCF7r_Form_Helper {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Class Constructor
|
17 |
+
*/
|
18 |
+
public function __construct() {
|
19 |
+
|
20 |
+
$this->plugin_url = WPCF7_PRO_REDIRECT_BASE_URL;
|
21 |
+
$this->assets_js_lib = WPCF7_PRO_REDIRECT_BASE_URL . 'assets/lib/';
|
22 |
+
$this->assets_js_url = WPCF7_PRO_REDIRECT_BASE_URL . 'assets/js/';
|
23 |
+
$this->assets_css_url = WPCF7_PRO_REDIRECT_BASE_URL . 'assets/css/';
|
24 |
+
$this->build_js_url = WPCF7_PRO_REDIRECT_BASE_URL . 'build/js/';
|
25 |
+
$this->build_css_url = WPCF7_PRO_REDIRECT_BASE_URL . 'build/css/';
|
26 |
+
$this->extensions = wpcf7_get_extensions();
|
27 |
+
$this->add_actions();
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Add Actions
|
33 |
+
*/
|
34 |
+
private function add_actions() {
|
35 |
+
|
36 |
+
global $pagenow;
|
37 |
+
|
38 |
+
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
39 |
+
add_action( 'wpcf7_editor_panels', array( $this, 'add_panel' ) );
|
40 |
+
add_action( 'wpcf7_after_save', array( $this, 'store_meta' ) );
|
41 |
+
// add contact form scripts.
|
42 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'front_end_scripts' ) );
|
43 |
+
// add contact form scripts for admin panel.
|
44 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_backend' ) );
|
45 |
+
add_action( 'wp_ajax_activate_wpcf7r_extension', array( $this, 'activate_extension' ) );
|
46 |
+
add_action( 'wp_ajax_deactivate_wpcf7r_extension', array( $this, 'deactivate_plugin_license' ) );
|
47 |
+
add_action( 'admin_init', array( $this, 'maybe_update_extensions_check' ), 10 );
|
48 |
+
add_action( 'wp_ajax_wpcf7r_extension_update', array( $this, 'maybe_update_extension' ), 10 );
|
49 |
+
add_action( 'wp_ajax_get_coupon', array( $this, 'get_coupon' ) );
|
50 |
+
add_action( 'wpcf7_admin_notices', array( $this, 'render_discount_banner' ), 15, 3 );
|
51 |
+
add_action( 'admin_init', array( $this, 'dismiss_ads' ) );
|
52 |
+
|
53 |
+
// define the alternative API for updating checking
|
54 |
+
add_filter( 'pre_set_site_transient_update_plugins', array( &$this, 'check_update' ) );
|
55 |
+
|
56 |
+
add_filter( 'plugins_api', array( &$this, 'check_info' ), 10, 3 );
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Add our self-hosted description to the filter
|
62 |
+
*
|
63 |
+
* @param boolean $false
|
64 |
+
* @param array $action
|
65 |
+
* @param object $arg
|
66 |
+
* @return bool|object
|
67 |
+
*
|
68 |
+
* @version 1.0.0
|
69 |
+
*/
|
70 |
+
public function check_info( $false, $action, $arg ) {
|
71 |
+
$action_plugin = false;
|
72 |
+
|
73 |
+
$api = new Qs_Api();
|
74 |
+
|
75 |
+
foreach ( $this->extensions as $extension_type => $extension_details ) {
|
76 |
+
|
77 |
+
$extension = new WPCF7R_Extension( $extension_details );
|
78 |
+
|
79 |
+
if ( isset( $arg->slug ) && $arg->slug === $extension->get_slug() ) {
|
80 |
+
$action_plugin = $extension->get_sku();
|
81 |
+
break;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
if ( ( $action == 'query_plugins' || $action == 'plugin_information' ) && $action_plugin ) {
|
86 |
+
|
87 |
+
$array_pattern = array(
|
88 |
+
'/^([\*\s])*(\d\d\.\d\d\.\d\d\d\d[^\n]*)/m',
|
89 |
+
'/^\n+|^[\t\s]*\n+/m',
|
90 |
+
'/\n/',
|
91 |
+
);
|
92 |
+
|
93 |
+
$array_replace = array(
|
94 |
+
'<h4>$2</h4>',
|
95 |
+
'</div><div>',
|
96 |
+
'</div><div>',
|
97 |
+
);
|
98 |
+
|
99 |
+
$changelog = $api->get_action_changelog( $action_plugin );
|
100 |
+
|
101 |
+
$information = new stdClass;
|
102 |
+
|
103 |
+
$information->sections['changelog'] = '<div>' . $changelog->changelog . '</div>';
|
104 |
+
|
105 |
+
return $information;
|
106 |
+
}
|
107 |
+
|
108 |
+
return $false;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Add our self-hosted autoupdate plugin to the filter transient
|
113 |
+
*
|
114 |
+
* @param $transient
|
115 |
+
* @return object $ transient
|
116 |
+
*
|
117 |
+
* @version 1.0.0
|
118 |
+
*/
|
119 |
+
public function check_update( $transient ) {
|
120 |
+
if ( empty( $transient->checked ) ) {
|
121 |
+
return $transient;
|
122 |
+
}
|
123 |
+
|
124 |
+
foreach ( $this->extensions as $extension_type => $extension_details ) {
|
125 |
+
|
126 |
+
$extension = new WPCF7R_Extension( $extension_details );
|
127 |
+
|
128 |
+
if ( $extension->has_update() ) {
|
129 |
+
|
130 |
+
$update_url = add_query_arg( 'update', true, $extension->get_extension_remote_file() );
|
131 |
+
$obj = new stdClass();
|
132 |
+
$obj->id = $extension->get_slug();
|
133 |
+
$obj->slug = $extension->get_slug();
|
134 |
+
$obj->new_version = $extension->update_version();
|
135 |
+
$obj->url = $update_url;
|
136 |
+
$obj->plugin = $extension->get_extension_relative_path();
|
137 |
+
$obj->package = $update_url;
|
138 |
+
$obj->tested = WPCF7_PRO_REDIRECT_WP_TESTED;
|
139 |
+
$obj->icons = array(
|
140 |
+
'2x' => $extension->get_icon(),
|
141 |
+
'1x' => $extension->get_icon(),
|
142 |
+
);
|
143 |
+
|
144 |
+
$transient->response[ $extension->get_extension_relative_path() ] = $obj;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
return $transient;
|
149 |
+
}
|
150 |
+
/**
|
151 |
+
* Check if an extension requires an update
|
152 |
+
*
|
153 |
+
* @return void
|
154 |
+
*/
|
155 |
+
public function maybe_update_extension() {
|
156 |
+
|
157 |
+
$results = array();
|
158 |
+
|
159 |
+
if ( current_user_can( 'administrator' ) && wpcf7_validate_nonce() ) {
|
160 |
+
$extension_name = isset( $_POST['extension_name'] ) && $_POST['extension_name'] ? sanitize_text_field( $_POST['extension_name'] ) : '';
|
161 |
+
|
162 |
+
if ( $extension_name ) {
|
163 |
+
$extension = $this->get_extension_object( $extension_name );
|
164 |
+
|
165 |
+
if ( $extension->has_update() ) {
|
166 |
+
$results = $extension->save_extension_file();
|
167 |
+
}
|
168 |
+
|
169 |
+
$results['html'] = $extension->ajax_extension_html();
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
wp_send_json( $results );
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Check if there is a need for update check.
|
178 |
+
*
|
179 |
+
* @return void
|
180 |
+
*/
|
181 |
+
public function maybe_update_extensions_check() {
|
182 |
+
global $wp_version;
|
183 |
+
|
184 |
+
$current = get_transient( 'update_wpcf7r_extensions' );
|
185 |
+
|
186 |
+
if ( $current && ! isset( $_GET['force-check'] ) ) {
|
187 |
+
return;
|
188 |
+
}
|
189 |
+
|
190 |
+
$current = new stdClass();
|
191 |
+
|
192 |
+
$current->version_checked = $wp_version;
|
193 |
+
$current->last_checked = current_time( 'timestamp' );
|
194 |
+
|
195 |
+
set_transient( 'update_wpcf7r_extensions', $current, HOUR_IN_SECONDS * 24 * 12 );
|
196 |
+
|
197 |
+
$this->check_for_extensions_update();
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Check for extension update from API.
|
203 |
+
*
|
204 |
+
* @return void
|
205 |
+
*/
|
206 |
+
public function check_for_extensions_update() {
|
207 |
+
|
208 |
+
$api = new Qs_Api();
|
209 |
+
|
210 |
+
foreach ( $this->extensions as $extension_type => $extension_details ) {
|
211 |
+
|
212 |
+
$extension = new WPCF7R_Extension( $extension_details );
|
213 |
+
|
214 |
+
if ( $extension->is_active() ) {
|
215 |
+
|
216 |
+
$has_update = $api->extension_has_update( $extension );
|
217 |
+
|
218 |
+
if ( $has_update ) {
|
219 |
+
|
220 |
+
$extension->set_needs_update( $has_update );
|
221 |
+
|
222 |
+
} else {
|
223 |
+
|
224 |
+
$extension->set_updated();
|
225 |
+
|
226 |
+
}
|
227 |
+
}
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Get the extension object
|
233 |
+
*
|
234 |
+
* @param [string] $extention_name - the name of the extension.
|
235 |
+
* @return object - $extention_object - the extension object.
|
236 |
+
*/
|
237 |
+
public function get_extension_object( $extention_name ) {
|
238 |
+
|
239 |
+
$extention_object = isset( $this->extensions[ $extention_name ] ) ? new WPCF7R_Extension( $this->extensions[ $extention_name ] ) : '';
|
240 |
+
|
241 |
+
return $extention_object;
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Deactivate plugin license.
|
247 |
+
*
|
248 |
+
* @return void
|
249 |
+
*/
|
250 |
+
public function deactivate_plugin_license() {
|
251 |
+
|
252 |
+
$results = array();
|
253 |
+
|
254 |
+
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
255 |
+
if ( ! isset( $_POST['extension_name'] ) ) {
|
256 |
+
|
257 |
+
$results = array(
|
258 |
+
'message' => __( 'Missing name or serial', 'wpcf7-redirect' ),
|
259 |
+
);
|
260 |
+
|
261 |
+
} else {
|
262 |
+
|
263 |
+
$extentsion_settings = $this->extensions[ $_POST['extension_name'] ];
|
264 |
+
|
265 |
+
if ( $extentsion_settings ) {
|
266 |
+
$extentsion = new WPCF7R_Extension( $extentsion_settings );
|
267 |
+
$results = $extentsion->deactivate_license();
|
268 |
+
}
|
269 |
+
}
|
270 |
+
}
|
271 |
+
|
272 |
+
wp_send_json( $results );
|
273 |
+
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Activate extension license.
|
278 |
+
*
|
279 |
+
* @return void
|
280 |
+
*/
|
281 |
+
public function activate_extension() {
|
282 |
+
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
283 |
+
if ( ! isset( $_POST['extension_name'] ) || ! isset( $_POST['serial'] ) ) {
|
284 |
+
$results = array(
|
285 |
+
'message' => __( 'Missing name or serial', 'wpcf7-redirect' ),
|
286 |
+
);
|
287 |
+
} else {
|
288 |
+
|
289 |
+
$extentsion_settings = $this->extensions[ $_POST['extension_name'] ];
|
290 |
+
|
291 |
+
if ( $extentsion_settings ) {
|
292 |
+
$extentsion = new WPCF7R_extension( $extentsion_settings );
|
293 |
+
$serial = sanitize_text_field( $_POST['serial'] );
|
294 |
+
$results = $extentsion->activate( $serial );
|
295 |
+
} else {
|
296 |
+
$results['extension_html'] = __( 'Somthing went wrong', 'wpcf7-redirect' );
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
wp_send_json( $results );
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Dismiss plugin ads
|
306 |
+
*/
|
307 |
+
public function dismiss_ads() {
|
308 |
+
|
309 |
+
if ( isset( $_GET['wpcf7_redirect_dismiss_banner'] ) && '1' === $_GET['wpcf7_redirect_dismiss_banner'] ) {
|
310 |
+
$banner_version = wpcf7r_get_banner_version() ? wpcf7r_get_banner_version() : 1;
|
311 |
+
|
312 |
+
update_option( 'wpcf7_redirect_dismiss_banner', $banner_version );
|
313 |
+
}
|
314 |
+
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Only load scripts when contact form instance is created
|
319 |
+
*/
|
320 |
+
public function front_end_scripts() {
|
321 |
+
|
322 |
+
wp_register_style( 'wpcf7-redirect-script-frontend', $this->build_css_url . 'wpcf7-redirect-frontend.min.css', '1.1' );
|
323 |
+
wp_enqueue_style( 'wpcf7-redirect-script-frontend' );
|
324 |
+
wp_register_script( 'wpcf7-redirect-script', $this->build_js_url . 'wpcf7-redirect-frontend-script.js', array( 'jquery' ), '1.1', true );
|
325 |
+
wp_enqueue_script( 'wpcf7-redirect-script' );
|
326 |
+
wp_localize_script( 'wpcf7-redirect-script', 'wpcf7r', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
|
327 |
+
|
328 |
+
// Load active extensions scripts and styles.
|
329 |
+
$installed_extensions = wpcf7r_get_available_actions();
|
330 |
+
|
331 |
+
foreach ( $installed_extensions as $installed_extension ) {
|
332 |
+
if ( method_exists( $installed_extension['handler'], 'enqueue_frontend_scripts' ) ) {
|
333 |
+
call_user_func( array( $installed_extension['handler'], 'enqueue_frontend_scripts' ) );
|
334 |
+
}
|
335 |
+
}
|
336 |
+
|
337 |
+
// add support for other plugins
|
338 |
+
do_action( 'wpcf7_redirect_enqueue_frontend', $this );
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Check if the current page is the plugin settings page
|
343 |
+
*/
|
344 |
+
public function is_wpcf7_settings_page() {
|
345 |
+
return isset( $_GET['page'] ) && 'wpc7_redirect' === $_GET['page'];
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Check if the current admin post type is a lead post type.
|
350 |
+
*
|
351 |
+
* @return boolean
|
352 |
+
*/
|
353 |
+
public function is_wpcf7_lead_page() {
|
354 |
+
return 'wpcf7r_leads' === get_post_type();
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Check if the current admin page is accesibe plugin page.
|
359 |
+
*
|
360 |
+
* @return boolean
|
361 |
+
*/
|
362 |
+
public function is_accesibe_page() {
|
363 |
+
$screen = get_current_screen();
|
364 |
+
|
365 |
+
return 'toplevel_page_' . qs_get_plugin_display_name() === $screen->base;
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Check if the current page is the contact form edit screen
|
370 |
+
*/
|
371 |
+
public function is_wpcf7_edit() {
|
372 |
+
return wpcf7r_is_wpcf7_edit();
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* Load plugin textdomain.
|
377 |
+
*/
|
378 |
+
public function load_textdomain() {
|
379 |
+
load_plugin_textdomain( 'wpcf7-redirect', false, basename( dirname( __FILE__ ) ) . '/lang' );
|
380 |
+
}
|
381 |
+
|
382 |
+
/**
|
383 |
+
* Enqueue theme styles and scripts - back-end
|
384 |
+
*/
|
385 |
+
public function enqueue_backend() {
|
386 |
+
|
387 |
+
if ( $this->is_wpcf7_edit() || $this->is_wpcf7_settings_page() || $this->is_wpcf7_lead_page() || $this->is_accesibe_page() ) {
|
388 |
+
|
389 |
+
wp_enqueue_style( 'admin-build', $this->build_css_url . 'wpcf7-redirect-backend.css', array(), WPCF7_PRO_REDIRECT_PLUGIN_VERSION );
|
390 |
+
|
391 |
+
// wp_enqueue_script( 'jquery-validation', 'https://cdn.jsdelivr.net/npm/jquery-validation@1.19.3/dist/jquery.validate.js', array(), WPCF7_PRO_REDIRECT_PLUGIN_VERSION, true );
|
392 |
+
// wp_enqueue_script( 'admin-dev-select2', $this->assets_js_url . 'select2.js', array(), WPCF7_PRO_REDIRECT_PLUGIN_VERSION, true );
|
393 |
+
// wp_enqueue_script( 'admin-dev-validation-js', $this->assets_js_url . 'wpcf7-redirect-validation.js', array(), WPCF7_PRO_REDIRECT_PLUGIN_VERSION, true );
|
394 |
+
// wp_enqueue_script( 'admin-dev-js', $this->assets_js_url . 'wpcf7-redirect-backend-script.js', array(), WPCF7_PRO_REDIRECT_PLUGIN_VERSION, true );
|
395 |
+
|
396 |
+
wp_enqueue_script( 'admin-build-js', $this->build_js_url . 'wpcf7-redirect-backend-script.js', array(), WPCF7_PRO_REDIRECT_PLUGIN_VERSION, true );
|
397 |
+
wp_enqueue_script(
|
398 |
+
array(
|
399 |
+
'jquery-ui-core',
|
400 |
+
'jquery-ui-sortable',
|
401 |
+
'wp-color-picker',
|
402 |
+
)
|
403 |
+
);
|
404 |
+
|
405 |
+
// Load active extensions scripts and styles.
|
406 |
+
$installed_extensions = wpcf7r_get_available_actions();
|
407 |
+
|
408 |
+
foreach ( $installed_extensions as $installed_extension ) {
|
409 |
+
if ( method_exists( $installed_extension['handler'], 'enqueue_backend_scripts' ) ) {
|
410 |
+
call_user_func( array( $installed_extension['handler'], 'enqueue_backend_scripts' ) );
|
411 |
+
}
|
412 |
+
}
|
413 |
+
|
414 |
+
// add support for other plugins.
|
415 |
+
do_action( 'wpcf_7_redirect_admin_scripts', $this );
|
416 |
+
}
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Store form data.
|
421 |
+
*
|
422 |
+
* @param [object] $cf7 -contact form object.
|
423 |
+
*/
|
424 |
+
public function store_meta( $cf7 ) {
|
425 |
+
|
426 |
+
$form = get_cf7r_form( $cf7->id() );
|
427 |
+
$form->store_meta( $cf7 );
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Adds a tab to the editor on the form edit page
|
432 |
+
*
|
433 |
+
* @param array $panels An array of panels. Each panel has a callback function.
|
434 |
+
*/
|
435 |
+
public function add_panel( $panels ) {
|
436 |
+
|
437 |
+
// Disable plugin functionality for old contact form 7 installations.
|
438 |
+
|
439 |
+
if ( wpcf7_get_cf7_ver() > 4.8 ) {
|
440 |
+
|
441 |
+
$panels['redirect-panel'] = array(
|
442 |
+
'title' => __( 'Actions', 'wpcf7-redirect' ),
|
443 |
+
'callback' => array( $this, 'create_panel_inputs' ),
|
444 |
+
);
|
445 |
+
|
446 |
+
$panels['extensions-panel'] = array(
|
447 |
+
'title' => __( 'Extensions', 'wpcf7-redirect' ),
|
448 |
+
'callback' => array( $this, 'extensions_manager' ),
|
449 |
+
);
|
450 |
+
|
451 |
+
if ( is_wpcf7r_debug() ) {
|
452 |
+
|
453 |
+
$panels['debug-panel'] = array(
|
454 |
+
'title' => __( 'Debug', 'wpcf7-redirect' ),
|
455 |
+
'callback' => array( $this, 'wpcf7_debug' ),
|
456 |
+
);
|
457 |
+
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
+
return $panels;
|
462 |
+
}
|
463 |
+
|
464 |
+
/**
|
465 |
+
* Get the default fields
|
466 |
+
*/
|
467 |
+
public static function get_plugin_default_fields() {
|
468 |
+
|
469 |
+
return array(
|
470 |
+
array(
|
471 |
+
'name' => 'redirect_type',
|
472 |
+
'type' => 'text',
|
473 |
+
),
|
474 |
+
);
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
* Handler to retrive banner to display
|
479 |
+
* At the moment used to display the pro version bannner
|
480 |
+
*/
|
481 |
+
public function banner() {
|
482 |
+
$banner_manager = new Banner_Manager();
|
483 |
+
$banner_manager->show_banner();
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* Create the panel inputs.
|
488 |
+
*
|
489 |
+
* @param object $cf7 - Contact form 7 post object.
|
490 |
+
*/
|
491 |
+
public function create_panel_inputs( $cf7 ) {
|
492 |
+
|
493 |
+
$form = get_cf7r_form( $cf7->id() );
|
494 |
+
|
495 |
+
$form->init();
|
496 |
+
}
|
497 |
+
|
498 |
+
/**
|
499 |
+
* Manage contact form 7 redirection pro extensions
|
500 |
+
*
|
501 |
+
* @param object $cf7 - Contact form 7 post object.
|
502 |
+
*/
|
503 |
+
public function extensions_manager( $cf7 ) {
|
504 |
+
|
505 |
+
$this->extensions_manager = $this->get_extension_manager();
|
506 |
+
$this->extensions_manager->init();
|
507 |
+
|
508 |
+
}
|
509 |
+
|
510 |
+
/**
|
511 |
+
* Get extension manager instance
|
512 |
+
*
|
513 |
+
* @return object - extensions manager object.
|
514 |
+
*/
|
515 |
+
public function get_extension_manager() {
|
516 |
+
return isset( $this->extensions_manager ) ? $this->extensions_manager : new WPCF7R_Extensions();
|
517 |
+
}
|
518 |
+
|
519 |
+
/**
|
520 |
+
* Display debug tab on contact form
|
521 |
+
*
|
522 |
+
* @param $cf7 - Contact form 7 post object.
|
523 |
+
* @return void
|
524 |
+
*/
|
525 |
+
public function wpcf7_debug( $cf7 ) {
|
526 |
+
|
527 |
+
global $wp_version;
|
528 |
+
|
529 |
+
$form_json = self::get_debug_data( $cf7->id() );
|
530 |
+
|
531 |
+
echo '<h3>' . __( 'Debug Information', 'wpcf7-redirect' ) . '</h3>';
|
532 |
+
echo '<div>' . __( 'The debug information includes the following details', 'wpcf7-redirect' ) . '</div><ul>';
|
533 |
+
echo '<li>' . __( 'Form post data.', 'wpcf7-redirect' ) . '</li>';
|
534 |
+
echo '<li>' . __( 'Actions post data.', 'wpcf7-redirect' ) . '</li>';
|
535 |
+
echo '<li>' . __( 'PHP Version', 'wpcf7-redirect' ) . '</li>';
|
536 |
+
echo '<li>' . __( 'Installed plugins list', 'wpcf7-redirect' ) . '</li>';
|
537 |
+
echo '<li>' . __( 'WordPress Version', 'wpcf7-redirect' ) . '</li>';
|
538 |
+
echo '</ul>';
|
539 |
+
echo '<div style="color:red;font-size:18px;margin-bottom:20px;">' . __( 'The data is used for debug purposes only!', 'wpcf7-redirect' ) . '</div>';
|
540 |
+
echo "<div><textarea style='width:100%;height:200px;margin-bottom:40px;font-size:11px'>{$form_json}</textarea><br/></div>";
|
541 |
+
echo '<input type="submit" class="button button-primary send-debug-info" value="Send Debug Report"/><br/><br/>';
|
542 |
+
echo '<label><input type="checkbox" class="approve-debug" /> I approve sending debug information to Query Solutions support team.</label>';
|
543 |
+
|
544 |
+
}
|
545 |
+
|
546 |
+
/**
|
547 |
+
* Get encoded debug data
|
548 |
+
*
|
549 |
+
* @param $form_id - contact form 7 ID.
|
550 |
+
* @return void
|
551 |
+
*/
|
552 |
+
public static function get_debug_data( $form_id ) {
|
553 |
+
global $wp_version;
|
554 |
+
|
555 |
+
$cf7r_form = get_cf7r_form( (int) $form_id );
|
556 |
+
|
557 |
+
$form_json = base64_encode(
|
558 |
+
serialize(
|
559 |
+
array(
|
560 |
+
'actions' => $cf7r_form->get_active_actions(),
|
561 |
+
'form_meta' => get_post_custom( $form_id ),
|
562 |
+
'form_post' => get_post( $form_id ),
|
563 |
+
'plugins' => json_encode( get_plugins() ),
|
564 |
+
'phpver' => phpversion(),
|
565 |
+
'wp_version' => $wp_version,
|
566 |
+
'site_url' => home_url(),
|
567 |
+
)
|
568 |
+
)
|
569 |
+
);
|
570 |
+
|
571 |
+
return $form_json;
|
572 |
+
}
|
573 |
+
|
574 |
+
/**
|
575 |
+
* Render discount banner
|
576 |
+
*
|
577 |
+
* @param [object] $page - the current page.
|
578 |
+
* @param [object] $action - the required action.
|
579 |
+
* @param [object] $object - contact form 7 object.
|
580 |
+
*/
|
581 |
+
public function render_discount_banner( $page, $action, $object ) {
|
582 |
+
|
583 |
+
if ( 'edit' === $action ) {
|
584 |
+
$banner_version_dismissed = get_option( 'wpcf7_redirect_dismiss_banner' );
|
585 |
+
$banner = wpcf7r_get_discount_banner();
|
586 |
+
|
587 |
+
if ( $banner ) {
|
588 |
+
update_option( 'wpcf7r_banner_version', $banner->version );
|
589 |
+
|
590 |
+
if ( ! $banner_version_dismissed && wpcf7r_get_banner_version() !== $banner_version_dismissed ) {
|
591 |
+
echo $banner->banner;
|
592 |
+
}
|
593 |
+
}
|
594 |
+
}
|
595 |
+
}
|
596 |
+
|
597 |
+
/**
|
598 |
+
* Returns an html for displaying a link to the form.
|
599 |
+
*
|
600 |
+
* @param [int] $form_id - the if of the contact form 7 post.
|
601 |
+
* @return [string] - a link to the form edit screen.
|
602 |
+
*/
|
603 |
+
public static function get_cf7_link_html( $form_id ) {
|
604 |
+
$form_post = get_post( $form_id );
|
605 |
+
$form_title = get_the_title( $form_id );
|
606 |
+
$link = get_edit_post_link( $form_id );
|
607 |
+
|
608 |
+
if ( $form_post ) {
|
609 |
+
return sprintf( "<a href='%s' target='_blank'>%s</a>", $link, $form_title );
|
610 |
+
}
|
611 |
+
|
612 |
+
return __( 'This form no longer exists', 'wpcf7-redirect' );
|
613 |
+
}
|
614 |
+
|
615 |
+
/**
|
616 |
+
* Get coupon ajax function
|
617 |
+
*/
|
618 |
+
public function get_coupon() {
|
619 |
+
$results = array();
|
620 |
+
|
621 |
+
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
622 |
+
$data = $_POST['data'];
|
623 |
+
|
624 |
+
$email = isset( $data['email'] ) && is_email( $data['email'] ) ? $data['email'] : false;
|
625 |
+
|
626 |
+
if ( ! $email ) {
|
627 |
+
$results = array(
|
628 |
+
'status' => 'rp-error',
|
629 |
+
'message' => 'Please enter a valid email.',
|
630 |
+
);
|
631 |
+
|
632 |
+
wp_send_json( $results );
|
633 |
+
} else {
|
634 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
635 |
+
$url = home_url();
|
636 |
+
$accept = sanitize_text_field( $data['get_offers'] );
|
637 |
+
$params = array(
|
638 |
+
'ip_address' => $ip,
|
639 |
+
'accept' => $accept,
|
640 |
+
'email' => $email,
|
641 |
+
'url' => $url,
|
642 |
+
);
|
643 |
+
|
644 |
+
$params = http_build_query( $params );
|
645 |
+
|
646 |
+
$endpoint = WPCF7_PRO_REDIRECT_PLUGIN_PAGE_URL . "wp-json/api-v1/get-coupon?{$params}";
|
647 |
+
|
648 |
+
$response = wp_remote_post( $endpoint );
|
649 |
+
|
650 |
+
$body = json_decode( wp_remote_retrieve_body( $response ), true );
|
651 |
+
|
652 |
+
if ( isset( $body['message'] ) ) {
|
653 |
+
$results = array(
|
654 |
+
'status' => 'rp-success',
|
655 |
+
'message' => $body['message'],
|
656 |
+
);
|
657 |
+
} elseif ( isset( $body['redirect'] ) ) {
|
658 |
+
$results = array(
|
659 |
+
'status' => 'rp-success',
|
660 |
+
'url' => $body['redirect'],
|
661 |
+
);
|
662 |
+
}
|
663 |
+
}
|
664 |
+
}
|
665 |
+
|
666 |
+
wp_send_json( $results );
|
667 |
+
}
|
668 |
+
}
|
classes/class-wpcf7r-form.php
CHANGED
@@ -1,652 +1,652 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Form - Container class that wraps the CF7 form object and adds functionality
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
class WPCF7R_Form {
|
9 |
-
// Refrence to the mail tags
|
10 |
-
public static $mail_tags;
|
11 |
-
|
12 |
-
// Refrence to the current contact form 7 form
|
13 |
-
public static $cf7_form;
|
14 |
-
|
15 |
-
// Save refrence to the current instance
|
16 |
-
public static $instance;
|
17 |
-
public static $action_to_submit;
|
18 |
-
|
19 |
-
// holds an array of items remove from $_POST for security reasons
|
20 |
-
public static $removed_data;
|
21 |
-
|
22 |
-
// Save proceesed actions from validation stage
|
23 |
-
public static $processed_actions;
|
24 |
-
|
25 |
-
// Refrence to the current submitted torm validation obj
|
26 |
-
public static $wpcf_validation_obj;
|
27 |
-
|
28 |
-
// Reference to the current submitted form
|
29 |
-
public static $submission;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Main class Constructor
|
33 |
-
*
|
34 |
-
* @param $cf7
|
35 |
-
* @param $submission
|
36 |
-
* @param $validation_obj
|
37 |
-
*/
|
38 |
-
public function __construct( $cf7, $submission = '', $validation_obj = '' ) {
|
39 |
-
if ( is_int( $cf7 ) ) {
|
40 |
-
$this->post_id = $cf7;
|
41 |
-
$cf7 = WPCF7_ContactForm::get_instance( $this->post_id );
|
42 |
-
} elseif ( $cf7 ) {
|
43 |
-
$this->post_id = $cf7->id();
|
44 |
-
} else {
|
45 |
-
return;
|
46 |
-
}
|
47 |
-
|
48 |
-
// Keep refrences.
|
49 |
-
if ( $cf7 ) {
|
50 |
-
self::$cf7_form = $cf7;
|
51 |
-
}
|
52 |
-
if ( $validation_obj ) {
|
53 |
-
self::$wpcf_validation_obj = $validation_obj;
|
54 |
-
}
|
55 |
-
if ( $submission ) {
|
56 |
-
self::$submission = $submission;
|
57 |
-
}
|
58 |
-
|
59 |
-
$this->redirect_actions = new WPCF7R_Actions( $this->post_id, $this );
|
60 |
-
$this->cf7_post = $cf7;
|
61 |
-
|
62 |
-
// Avoid creating 2 instances of the same form.
|
63 |
-
if ( self::$instance && self::$instance->post_id === $this->post_id ) {
|
64 |
-
return self::$instance;
|
65 |
-
}
|
66 |
-
|
67 |
-
add_action( 'admin_footer', array( $this->redirect_actions, 'html_fregments' ) );
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Get submission refrerence
|
72 |
-
*/
|
73 |
-
public function get_submission() {
|
74 |
-
return self::$submission;
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Get the form submission status
|
79 |
-
*/
|
80 |
-
public function get_submission_status() {
|
81 |
-
return self::get_submission()->get_status();
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Disable all form actions except the requested one
|
86 |
-
*
|
87 |
-
* @param $action_id
|
88 |
-
*/
|
89 |
-
public function enable_action( $action_id ) {
|
90 |
-
self::$action_to_submit = $action_id;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* In case a specific action was required (used for testing)
|
95 |
-
*/
|
96 |
-
public function get_action_to_submit() {
|
97 |
-
return self::$action_to_submit;
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Get an instance of wpcf7 object
|
102 |
-
*/
|
103 |
-
public function get_cf7_form_instance() {
|
104 |
-
return $this->cf7_post;
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Get old redirection plugin rules
|
109 |
-
*/
|
110 |
-
public function get_cf7_redirection_settings() {
|
111 |
-
$custom_data = get_post_custom( $this->post_id );
|
112 |
-
$old_settings = array();
|
113 |
-
if ( isset( $custom_data['_wpcf7_redirect_redirect_type'] ) ) {
|
114 |
-
$old_settings['_wpcf7_redirect_redirect_type'] = maybe_unserialize( $custom_data['_wpcf7_redirect_redirect_type'][0] );
|
115 |
-
}
|
116 |
-
if ( isset( $custom_data['_wpcf7_redirect_page_id'] ) ) {
|
117 |
-
$old_settings['page_id'] = maybe_unserialize( $custom_data['_wpcf7_redirect_page_id'][0] );
|
118 |
-
}
|
119 |
-
if ( isset( $custom_data['_wpcf7_redirect_external_url'] ) ) {
|
120 |
-
$old_settings['external_url'] = maybe_unserialize( $custom_data['_wpcf7_redirect_external_url'][0] );
|
121 |
-
}
|
122 |
-
if ( isset( $custom_data['_wpcf7_redirect_use_external_url'] ) ) {
|
123 |
-
$old_settings['use_external_url'] = maybe_unserialize( $custom_data['_wpcf7_redirect_use_external_url'][0] );
|
124 |
-
}
|
125 |
-
if ( isset( $custom_data['_wpcf7_redirect_open_in_new_tab'] ) ) {
|
126 |
-
$old_settings['open_in_new_tab'] = maybe_unserialize( $custom_data['_wpcf7_redirect_open_in_new_tab'][0] );
|
127 |
-
}
|
128 |
-
if ( isset( $custom_data['_wpcf7_redirect_http_build_query'] ) ) {
|
129 |
-
$old_settings['http_build_query'] = maybe_unserialize( $custom_data['_wpcf7_redirect_http_build_query'][0] );
|
130 |
-
}
|
131 |
-
if ( isset( $custom_data['_wpcf7_redirect_http_build_query_selectively'] ) ) {
|
132 |
-
$old_settings['http_build_query_selectively'] = maybe_unserialize( $custom_data['_wpcf7_redirect_http_build_query_selectively'][0] );
|
133 |
-
}
|
134 |
-
if ( isset( $custom_data['_wpcf7_redirect_http_build_query_selectively_fields'] ) ) {
|
135 |
-
$old_settings['http_build_query_selectively_fields'] = maybe_unserialize( $custom_data['_wpcf7_redirect_http_build_query_selectively_fields'][0] );
|
136 |
-
}
|
137 |
-
if ( isset( $custom_data['_wpcf7_redirect_after_sent_script'] ) ) {
|
138 |
-
$old_settings['fire_sctipt'] = maybe_unserialize( $custom_data['_wpcf7_redirect_after_sent_script'][0] );
|
139 |
-
}
|
140 |
-
|
141 |
-
if ( isset( $custom_data['_wpcf7_redirect_delay_redirect'] ) && (int) $custom_data['_wpcf7_redirect_delay_redirect'] > 0 ) {
|
142 |
-
$old_settings['delay_redirect_seconds'] = $custom_data['_wpcf7_redirect_delay_redirect'][0] / 1000;
|
143 |
-
}
|
144 |
-
|
145 |
-
return $old_settings;
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Get the old contact form 7 to api settings
|
150 |
-
*/
|
151 |
-
public function get_cf7_api_settings() {
|
152 |
-
$custom_data = get_post_custom( $this->post_id );
|
153 |
-
$old_settings = array();
|
154 |
-
if ( isset( $custom_data['_wpcf7_api_data'] ) ) {
|
155 |
-
$old_settings['_wpcf7_api_data'] = maybe_unserialize( $custom_data['_wpcf7_api_data'][0] );
|
156 |
-
}
|
157 |
-
if ( isset( $custom_data['_wpcf7_api_data_map'] ) ) {
|
158 |
-
$old_settings['_wpcf7_api_data_map'] = maybe_unserialize( $custom_data['_wpcf7_api_data_map'][0] );
|
159 |
-
}
|
160 |
-
if ( isset( $custom_data['_template'] ) ) {
|
161 |
-
$old_settings['_template'] = maybe_unserialize( $custom_data['_template'][0] );
|
162 |
-
}
|
163 |
-
if ( isset( $custom_data['_json_template'] ) ) {
|
164 |
-
$old_settings['_json_template'] = maybe_unserialize( $custom_data['_json_template'][0] );
|
165 |
-
}
|
166 |
-
return $old_settings;
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Check if a form has a specific action type
|
171 |
-
*
|
172 |
-
* @param $type
|
173 |
-
* @return boolean
|
174 |
-
*/
|
175 |
-
public function has_action( $type ) {
|
176 |
-
$args = array();
|
177 |
-
$meta_query = array(
|
178 |
-
array(
|
179 |
-
'key' => 'action_type',
|
180 |
-
'value' => $type,
|
181 |
-
),
|
182 |
-
);
|
183 |
-
|
184 |
-
$args['meta_query'] = $meta_query;
|
185 |
-
$actions = $this->get_actions( 'default', 1, true, $args );
|
186 |
-
|
187 |
-
return $actions ? $actions : false;
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Update the plugin has migrated
|
192 |
-
*
|
193 |
-
* @param $migration_type
|
194 |
-
*/
|
195 |
-
public function update_migration( $migration_type ) {
|
196 |
-
update_post_meta( $this->post_id, $migration_type, true );
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Check if a form was migrated from old version
|
201 |
-
*
|
202 |
-
* @param $migration_type
|
203 |
-
* @return boolean
|
204 |
-
*/
|
205 |
-
public function has_migrated( $migration_type ) {
|
206 |
-
return get_post_meta( $this->post_id, $migration_type, true );
|
207 |
-
}
|
208 |
-
|
209 |
-
/**
|
210 |
-
* Check if there is old data on the DB
|
211 |
-
*
|
212 |
-
* @param $type
|
213 |
-
* @return boolean
|
214 |
-
*/
|
215 |
-
public function has_old_data( $type ) {
|
216 |
-
if ( 'migrate_from_cf7_api' === $type ) {
|
217 |
-
return $this->get_cf7_api_settings();
|
218 |
-
} else {
|
219 |
-
return $this->get_cf7_redirection_settings();
|
220 |
-
}
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Get a singelton
|
225 |
-
*
|
226 |
-
* @param string $post_id
|
227 |
-
*/
|
228 |
-
public static function get_instance( $post_id = '' ) {
|
229 |
-
if ( null === self::$instance || ( self::$cf7_form->id() !== $post_id && $post_id ) ) {
|
230 |
-
self::$instance = new self( $post_id );
|
231 |
-
}
|
232 |
-
return self::$instance;
|
233 |
-
}
|
234 |
-
|
235 |
-
public function is_new_form() {
|
236 |
-
return isset( $this->post_id ) && $this->post_id ? false : true;
|
237 |
-
}
|
238 |
-
|
239 |
-
/**
|
240 |
-
* Initialize form
|
241 |
-
*/
|
242 |
-
public function init() {
|
243 |
-
// Check if this is a new form
|
244 |
-
if ( $this->is_new_form() ) {
|
245 |
-
self::$mail_tags = __( 'You need to save your form', 'wpcf7-redirect' );
|
246 |
-
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'save-form.php';
|
247 |
-
} else {
|
248 |
-
self::$mail_tags = $this->get_cf7_fields();
|
249 |
-
$fields = $this->get_fields_values();
|
250 |
-
$redirect_type = isset( $fields['redirect_type'] ) && $fields['redirect_type'] ? $fields['redirect_type'] : '';
|
251 |
-
$active_tab_title = 'active';
|
252 |
-
$active_tab = 'active';
|
253 |
-
$this->html = new WPCF7R_html( self::$mail_tags );
|
254 |
-
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'settings.php';
|
255 |
-
}
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Get all posts relevant to this contact form
|
260 |
-
* returns posts object
|
261 |
-
*
|
262 |
-
* @param $rule
|
263 |
-
*/
|
264 |
-
public function get_action_posts( $rule ) {
|
265 |
-
return $this->redirect_actions->get_action_posts( $rule );
|
266 |
-
}
|
267 |
-
|
268 |
-
/**
|
269 |
-
* Get all actions relevant for this contact form
|
270 |
-
* Returns action classes
|
271 |
-
*
|
272 |
-
* @param $rule
|
273 |
-
* @param integer $count
|
274 |
-
* @param boolean $is_active
|
275 |
-
* @param array $args
|
276 |
-
*/
|
277 |
-
public function get_actions( $rule, $count = -1, $is_active = false, $args = array() ) {
|
278 |
-
$action_id = $this->get_action_to_submit();
|
279 |
-
|
280 |
-
if ( $action_id ) {
|
281 |
-
$args['post__in'] = array( $action_id );
|
282 |
-
}
|
283 |
-
|
284 |
-
$actions = isset( $this->redirect_actions ) && $this->redirect_actions ? $this->redirect_actions->get_actions( $rule, -1, $is_active, $args ) : array();
|
285 |
-
|
286 |
-
$this->actions = $actions;
|
287 |
-
|
288 |
-
return $actions;
|
289 |
-
}
|
290 |
-
|
291 |
-
/**
|
292 |
-
* Get all active actions
|
293 |
-
*/
|
294 |
-
public function get_active_actions() {
|
295 |
-
return $this->get_actions( 'default', -1, true );
|
296 |
-
}
|
297 |
-
|
298 |
-
/**
|
299 |
-
* Save reference for the items removed from the $_POST data
|
300 |
-
*
|
301 |
-
* @param $removed_data
|
302 |
-
*/
|
303 |
-
public function set_removed_posted_data( $removed_data ) {
|
304 |
-
if ( isset( self::$removed_data ) ) {
|
305 |
-
self::$removed_data = array_merge( $removed_data, self::$removed_data );
|
306 |
-
} else {
|
307 |
-
self::$removed_data = $removed_data;
|
308 |
-
}
|
309 |
-
}
|
310 |
-
|
311 |
-
/**
|
312 |
-
* Get all params removed from the $_POST
|
313 |
-
*/
|
314 |
-
public function get_removed_form_params() {
|
315 |
-
return isset( self::$removed_data ) ? self::$removed_data : '';
|
316 |
-
}
|
317 |
-
|
318 |
-
/**
|
319 |
-
* Validate and store meta data
|
320 |
-
*/
|
321 |
-
public function store_meta() {
|
322 |
-
if ( ! isset( $_POST ) || empty( $_POST['wpcf7-redirect'] ) ) {
|
323 |
-
return;
|
324 |
-
} else {
|
325 |
-
if ( ! wp_verify_nonce( $_POST['wpcf7_redirect_page_metaboxes_nonce'], 'wpcf7_redirect_page_metaboxes' ) ) {
|
326 |
-
return;
|
327 |
-
}
|
328 |
-
$form_id = $this->post_id;
|
329 |
-
$fields = $this->get_plugin_fields( $form_id );
|
330 |
-
$data = $_POST['wpcf7-redirect'];
|
331 |
-
$this->save_meta_fields( $form_id, $fields, $data );
|
332 |
-
if ( isset( $data['actions'] ) && $data['actions'] ) {
|
333 |
-
$this->save_actions( $data['actions'] );
|
334 |
-
}
|
335 |
-
}
|
336 |
-
}
|
337 |
-
|
338 |
-
/**
|
339 |
-
* Save all actions and actions data
|
340 |
-
*
|
341 |
-
* @param $actions
|
342 |
-
*/
|
343 |
-
public function save_actions( $actions ) {
|
344 |
-
foreach ( $actions as $post_id => $action_fields ) {
|
345 |
-
$action = WPCF7R_Action::get_action( $post_id );
|
346 |
-
if ( $action ) {
|
347 |
-
$action->delete_all_fields();
|
348 |
-
foreach ( $action_fields as $action_field_key => $action_field_value ) {
|
349 |
-
update_post_meta( $post_id, $action_field_key, $action_field_value );
|
350 |
-
}
|
351 |
-
if ( isset( $action_fields['post_title'] ) ) {
|
352 |
-
$update_post = array(
|
353 |
-
'ID' => $post_id,
|
354 |
-
'post_title' => $action_fields['post_title'],
|
355 |
-
);
|
356 |
-
wp_update_post( $update_post );
|
357 |
-
}
|
358 |
-
}
|
359 |
-
}
|
360 |
-
}
|
361 |
-
|
362 |
-
/**
|
363 |
-
* Save meta fields to cf7 post
|
364 |
-
* Save each action to its relevant action post
|
365 |
-
*
|
366 |
-
* @param $post_id
|
367 |
-
* @param $fields
|
368 |
-
* @param $data
|
369 |
-
*/
|
370 |
-
public function save_meta_fields( $post_id, $fields, $data ) {
|
371 |
-
unset( $data['actions'] );
|
372 |
-
if ( $data ) {
|
373 |
-
foreach ( $fields as $field ) {
|
374 |
-
$value = isset( $data[ $field['name'] ] ) ? $data[ $field['name'] ] : '';
|
375 |
-
switch ( $field['type'] ) {
|
376 |
-
case 'password':
|
377 |
-
case 'text':
|
378 |
-
case 'checkbox':
|
379 |
-
$value = sanitize_text_field( $value );
|
380 |
-
break;
|
381 |
-
case 'textarea':
|
382 |
-
$value = htmlspecialchars( $value );
|
383 |
-
break;
|
384 |
-
case 'number':
|
385 |
-
$value = intval( $value );
|
386 |
-
break;
|
387 |
-
case 'url':
|
388 |
-
$value = esc_url_raw( $value );
|
389 |
-
break;
|
390 |
-
}
|
391 |
-
update_post_meta( $post_id, '_wpcf7_redirect_' . $field['name'], $value );
|
392 |
-
}
|
393 |
-
}
|
394 |
-
}
|
395 |
-
|
396 |
-
/**
|
397 |
-
* Check if the form has active actions
|
398 |
-
*/
|
399 |
-
public function has_actions() {
|
400 |
-
$rule = 'default';
|
401 |
-
$count = 1;
|
402 |
-
$is_active = true;
|
403 |
-
$args = array();
|
404 |
-
$actions = $this->get_actions( $rule, $count, $is_active, $args ) ? true : false;
|
405 |
-
|
406 |
-
return $actions;
|
407 |
-
}
|
408 |
-
|
409 |
-
/**
|
410 |
-
* Get specific form fields
|
411 |
-
*
|
412 |
-
* @param $fields
|
413 |
-
*/
|
414 |
-
public function get_form_fields( $fields ) {
|
415 |
-
$forms = array();
|
416 |
-
foreach ( $fields as $field ) {
|
417 |
-
$forms[ $this->post_id ][ $field['name'] ] = get_post_meta( $this->post_id, '_wpcf7_redirect_' . $field['name'], true );
|
418 |
-
if ( 'textarea' === $field['type'] ) {
|
419 |
-
$forms[ $this->post_id ][ $field['name'] ] = $forms[ $this->post_id ][ $field['name'] ];
|
420 |
-
}
|
421 |
-
}
|
422 |
-
|
423 |
-
// Thank you page URL is a little bit different...
|
424 |
-
$forms[ $this->post_id ]['thankyou_page_url'] = $forms[ $this->post_id ]['page_id'] ? get_permalink( $forms[ $this->post_id ]['page_id'] ) : '';
|
425 |
-
return reset( $forms );
|
426 |
-
}
|
427 |
-
|
428 |
-
/**
|
429 |
-
* Get rules for a specific contact form
|
430 |
-
*/
|
431 |
-
public function get_redirect_rules() {
|
432 |
-
return get_post_meta( $this->post_id, '_wpcf7_redirect_' . $field['name'], true );
|
433 |
-
}
|
434 |
-
|
435 |
-
/**
|
436 |
-
* Get all fields values
|
437 |
-
*/
|
438 |
-
public function get_fields_values() {
|
439 |
-
$fields = $this->get_plugin_fields();
|
440 |
-
foreach ( $fields as $field ) {
|
441 |
-
$values[ $field['name'] ] = get_post_meta( $this->post_id, '_wpcf7_redirect_' . $field['name'], true );
|
442 |
-
}
|
443 |
-
return $values;
|
444 |
-
}
|
445 |
-
|
446 |
-
/**
|
447 |
-
* Create plugin fields
|
448 |
-
*/
|
449 |
-
public function get_plugin_fields() {
|
450 |
-
$fields = array_merge(
|
451 |
-
WPCF7r_Form_Helper::get_plugin_default_fields(),
|
452 |
-
array(
|
453 |
-
array(
|
454 |
-
'name' => 'blocks',
|
455 |
-
'type' => 'blocks',
|
456 |
-
),
|
457 |
-
)
|
458 |
-
);
|
459 |
-
return $fields;
|
460 |
-
}
|
461 |
-
|
462 |
-
/**
|
463 |
-
* Get the contact form id
|
464 |
-
*/
|
465 |
-
public function get_id() {
|
466 |
-
return $this->post_id;
|
467 |
-
}
|
468 |
-
|
469 |
-
/**
|
470 |
-
* Get the form fields for usage on the selectors
|
471 |
-
*/
|
472 |
-
public function get_cf7_fields() {
|
473 |
-
$tags = self::get_mail_tags();
|
474 |
-
return $tags;
|
475 |
-
}
|
476 |
-
|
477 |
-
/**
|
478 |
-
* Get special mail tags
|
479 |
-
*/
|
480 |
-
static function get_special_mail_tags() {
|
481 |
-
$mailtags = array();
|
482 |
-
$special_mail_tags = array(
|
483 |
-
'_remote_ip',
|
484 |
-
'_user_agent',
|
485 |
-
'_url',
|
486 |
-
'_date',
|
487 |
-
'_time',
|
488 |
-
'_post_id',
|
489 |
-
'_post_name',
|
490 |
-
'_post_title',
|
491 |
-
'_post_url',
|
492 |
-
'_post_author',
|
493 |
-
'_post_author_email',
|
494 |
-
'_site_title',
|
495 |
-
'_site_description',
|
496 |
-
'_site_url',
|
497 |
-
'_site_admin_email',
|
498 |
-
'user_login',
|
499 |
-
'user_email',
|
500 |
-
'user_url',
|
501 |
-
);
|
502 |
-
|
503 |
-
foreach ( $special_mail_tags as $special_mail_tag ) {
|
504 |
-
$tag = new WPCF7_MailTag( $special_mail_tag, $special_mail_tag, array() );
|
505 |
-
$mailtags[] = $tag;
|
506 |
-
}
|
507 |
-
|
508 |
-
return $mailtags;
|
509 |
-
}
|
510 |
-
|
511 |
-
/**
|
512 |
-
* Collect the mail tags from the form
|
513 |
-
*/
|
514 |
-
static function get_mail_tags() {
|
515 |
-
// If this is a new form there are no tags yet
|
516 |
-
if ( ! isset( self::$cf7_form ) || ! self::$cf7_form ) {
|
517 |
-
return;
|
518 |
-
}
|
519 |
-
|
520 |
-
$tags = apply_filters( 'wpcf7r_collect_mail_tags', self::$cf7_form->scan_form_tags() );
|
521 |
-
|
522 |
-
foreach ( (array) $tags as $tag ) {
|
523 |
-
$type = trim( $tag['type'], ' *' );
|
524 |
-
if ( empty( $type ) || empty( $tag['name'] ) ) {
|
525 |
-
continue;
|
526 |
-
} elseif ( ! empty( $args['include'] ) ) {
|
527 |
-
if ( ! in_array( $type, $args['include'], true ) ) {
|
528 |
-
continue;
|
529 |
-
}
|
530 |
-
} elseif ( ! empty( $args['exclude'] ) ) {
|
531 |
-
if ( in_array( $type, $args['exclude'], true ) ) {
|
532 |
-
continue;
|
533 |
-
}
|
534 |
-
}
|
535 |
-
$mailtags[] = $tag;
|
536 |
-
}
|
537 |
-
|
538 |
-
// create an instance to get the current form instance
|
539 |
-
$instance = self::get_instance( self::$cf7_form );
|
540 |
-
|
541 |
-
// add a save lead tag in case save lead action is on
|
542 |
-
if ( $instance->has_action( 'save_lead' ) ) {
|
543 |
-
$scanned_tag = array(
|
544 |
-
'type' => 'lead_id',
|
545 |
-
'basetype' => trim( '[lead_id]', '*' ),
|
546 |
-
'name' => 'lead_id',
|
547 |
-
'options' => array(),
|
548 |
-
'raw_values' => array(),
|
549 |
-
'values' => array(
|
550 |
-
WPCF7R_Action::get_lead_id(),
|
551 |
-
),
|
552 |
-
'pipes' => null,
|
553 |
-
'labels' => array(),
|
554 |
-
'attr' => '',
|
555 |
-
'content' => '',
|
556 |
-
);
|
557 |
-
$mailtags[] = new WPCF7_FormTag( $scanned_tag );
|
558 |
-
}
|
559 |
-
|
560 |
-
return $mailtags;
|
561 |
-
}
|
562 |
-
|
563 |
-
/**
|
564 |
-
* Process actions that are relevant for validation process
|
565 |
-
*/
|
566 |
-
public function process_validation_actions() {
|
567 |
-
$actions = $this->get_active_actions();
|
568 |
-
$results = array();
|
569 |
-
|
570 |
-
if ( $actions ) {
|
571 |
-
foreach ( $actions as $action ) {
|
572 |
-
$action_result = $action->process_validation( self::get_submission() );
|
573 |
-
if ( $action_result ) {
|
574 |
-
$results[ $action->get_type() ][] = $action_result;
|
575 |
-
}
|
576 |
-
}
|
577 |
-
}
|
578 |
-
return $results;
|
579 |
-
}
|
580 |
-
|
581 |
-
/**
|
582 |
-
* Get validation object
|
583 |
-
*/
|
584 |
-
public static function get_validation_obj() {
|
585 |
-
return self::$wpcf_validation_obj;
|
586 |
-
}
|
587 |
-
|
588 |
-
/**
|
589 |
-
* Get validation object $tags
|
590 |
-
*/
|
591 |
-
public static function get_validation_obj_tags() {
|
592 |
-
$validation_obj = self::get_validation_obj();
|
593 |
-
return isset( $validation_obj->tags ) ? $validation_obj->tags : '';
|
594 |
-
}
|
595 |
-
|
596 |
-
/**
|
597 |
-
* Save a referrence to the validaiont object
|
598 |
-
* This will enable invalidating tags later on
|
599 |
-
*
|
600 |
-
* @param object $wpcf_validation_obj
|
601 |
-
*/
|
602 |
-
public function set_validation_obj( $wpcf_validation_obj ) {
|
603 |
-
self::$wpcf_validation_obj = $wpcf_validation_obj;
|
604 |
-
}
|
605 |
-
|
606 |
-
/**
|
607 |
-
* Handles submission actions
|
608 |
-
*/
|
609 |
-
public function process_actions() {
|
610 |
-
// get all active actions
|
611 |
-
$actions = $this->get_active_actions();
|
612 |
-
|
613 |
-
// prepeare the results array
|
614 |
-
$results = array();
|
615 |
-
// get removed fom data
|
616 |
-
self::$submission->removed_posted_data = $this->get_removed_form_params();
|
617 |
-
|
618 |
-
if ( $actions ) {// loop through actions and process
|
619 |
-
foreach ( $actions as $action ) {
|
620 |
-
// save the validation object in case this action manipulates validations
|
621 |
-
// do the action
|
622 |
-
$action_result = $action->process_action( $this );
|
623 |
-
// add the action to the results array
|
624 |
-
$results[ $action->get_type() ][] = $action_result;
|
625 |
-
self::$processed_actions[] = $action;
|
626 |
-
}
|
627 |
-
} else {
|
628 |
-
return false;
|
629 |
-
}
|
630 |
-
|
631 |
-
return $results;
|
632 |
-
}
|
633 |
-
|
634 |
-
/**
|
635 |
-
* Get all processed actions
|
636 |
-
*/
|
637 |
-
public function get_processed_actions() {
|
638 |
-
return isset( self::$processed_actions ) && self::$processed_actions ? self::$processed_actions : '';
|
639 |
-
}
|
640 |
-
|
641 |
-
/**
|
642 |
-
* Check if actions hold one last thing to do before returning result to the user
|
643 |
-
*/
|
644 |
-
public function maybe_perform_pre_result_action() {
|
645 |
-
$actions = $this->get_processed_actions();
|
646 |
-
if ( $actions ) {
|
647 |
-
foreach ( $actions as $action ) {
|
648 |
-
$action->maybe_perform_pre_result_action();
|
649 |
-
}
|
650 |
-
}
|
651 |
-
}
|
652 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Form - Container class that wraps the CF7 form object and adds functionality
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
class WPCF7R_Form {
|
9 |
+
// Refrence to the mail tags
|
10 |
+
public static $mail_tags;
|
11 |
+
|
12 |
+
// Refrence to the current contact form 7 form
|
13 |
+
public static $cf7_form;
|
14 |
+
|
15 |
+
// Save refrence to the current instance
|
16 |
+
public static $instance;
|
17 |
+
public static $action_to_submit;
|
18 |
+
|
19 |
+
// holds an array of items remove from $_POST for security reasons
|
20 |
+
public static $removed_data;
|
21 |
+
|
22 |
+
// Save proceesed actions from validation stage
|
23 |
+
public static $processed_actions;
|
24 |
+
|
25 |
+
// Refrence to the current submitted torm validation obj
|
26 |
+
public static $wpcf_validation_obj;
|
27 |
+
|
28 |
+
// Reference to the current submitted form
|
29 |
+
public static $submission;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Main class Constructor
|
33 |
+
*
|
34 |
+
* @param $cf7
|
35 |
+
* @param $submission
|
36 |
+
* @param $validation_obj
|
37 |
+
*/
|
38 |
+
public function __construct( $cf7, $submission = '', $validation_obj = '' ) {
|
39 |
+
if ( is_int( $cf7 ) ) {
|
40 |
+
$this->post_id = $cf7;
|
41 |
+
$cf7 = WPCF7_ContactForm::get_instance( $this->post_id );
|
42 |
+
} elseif ( $cf7 ) {
|
43 |
+
$this->post_id = $cf7->id();
|
44 |
+
} else {
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
|
48 |
+
// Keep refrences.
|
49 |
+
if ( $cf7 ) {
|
50 |
+
self::$cf7_form = $cf7;
|
51 |
+
}
|
52 |
+
if ( $validation_obj ) {
|
53 |
+
self::$wpcf_validation_obj = $validation_obj;
|
54 |
+
}
|
55 |
+
if ( $submission ) {
|
56 |
+
self::$submission = $submission;
|
57 |
+
}
|
58 |
+
|
59 |
+
$this->redirect_actions = new WPCF7R_Actions( $this->post_id, $this );
|
60 |
+
$this->cf7_post = $cf7;
|
61 |
+
|
62 |
+
// Avoid creating 2 instances of the same form.
|
63 |
+
if ( self::$instance && self::$instance->post_id === $this->post_id ) {
|
64 |
+
return self::$instance;
|
65 |
+
}
|
66 |
+
|
67 |
+
add_action( 'admin_footer', array( $this->redirect_actions, 'html_fregments' ) );
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Get submission refrerence
|
72 |
+
*/
|
73 |
+
public function get_submission() {
|
74 |
+
return self::$submission;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Get the form submission status
|
79 |
+
*/
|
80 |
+
public function get_submission_status() {
|
81 |
+
return self::get_submission()->get_status();
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Disable all form actions except the requested one
|
86 |
+
*
|
87 |
+
* @param $action_id
|
88 |
+
*/
|
89 |
+
public function enable_action( $action_id ) {
|
90 |
+
self::$action_to_submit = $action_id;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* In case a specific action was required (used for testing)
|
95 |
+
*/
|
96 |
+
public function get_action_to_submit() {
|
97 |
+
return self::$action_to_submit;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Get an instance of wpcf7 object
|
102 |
+
*/
|
103 |
+
public function get_cf7_form_instance() {
|
104 |
+
return $this->cf7_post;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get old redirection plugin rules
|
109 |
+
*/
|
110 |
+
public function get_cf7_redirection_settings() {
|
111 |
+
$custom_data = get_post_custom( $this->post_id );
|
112 |
+
$old_settings = array();
|
113 |
+
if ( isset( $custom_data['_wpcf7_redirect_redirect_type'] ) ) {
|
114 |
+
$old_settings['_wpcf7_redirect_redirect_type'] = maybe_unserialize( $custom_data['_wpcf7_redirect_redirect_type'][0] );
|
115 |
+
}
|
116 |
+
if ( isset( $custom_data['_wpcf7_redirect_page_id'] ) ) {
|
117 |
+
$old_settings['page_id'] = maybe_unserialize( $custom_data['_wpcf7_redirect_page_id'][0] );
|
118 |
+
}
|
119 |
+
if ( isset( $custom_data['_wpcf7_redirect_external_url'] ) ) {
|
120 |
+
$old_settings['external_url'] = maybe_unserialize( $custom_data['_wpcf7_redirect_external_url'][0] );
|
121 |
+
}
|
122 |
+
if ( isset( $custom_data['_wpcf7_redirect_use_external_url'] ) ) {
|
123 |
+
$old_settings['use_external_url'] = maybe_unserialize( $custom_data['_wpcf7_redirect_use_external_url'][0] );
|
124 |
+
}
|
125 |
+
if ( isset( $custom_data['_wpcf7_redirect_open_in_new_tab'] ) ) {
|
126 |
+
$old_settings['open_in_new_tab'] = maybe_unserialize( $custom_data['_wpcf7_redirect_open_in_new_tab'][0] );
|
127 |
+
}
|
128 |
+
if ( isset( $custom_data['_wpcf7_redirect_http_build_query'] ) ) {
|
129 |
+
$old_settings['http_build_query'] = maybe_unserialize( $custom_data['_wpcf7_redirect_http_build_query'][0] );
|
130 |
+
}
|
131 |
+
if ( isset( $custom_data['_wpcf7_redirect_http_build_query_selectively'] ) ) {
|
132 |
+
$old_settings['http_build_query_selectively'] = maybe_unserialize( $custom_data['_wpcf7_redirect_http_build_query_selectively'][0] );
|
133 |
+
}
|
134 |
+
if ( isset( $custom_data['_wpcf7_redirect_http_build_query_selectively_fields'] ) ) {
|
135 |
+
$old_settings['http_build_query_selectively_fields'] = maybe_unserialize( $custom_data['_wpcf7_redirect_http_build_query_selectively_fields'][0] );
|
136 |
+
}
|
137 |
+
if ( isset( $custom_data['_wpcf7_redirect_after_sent_script'] ) ) {
|
138 |
+
$old_settings['fire_sctipt'] = maybe_unserialize( $custom_data['_wpcf7_redirect_after_sent_script'][0] );
|
139 |
+
}
|
140 |
+
|
141 |
+
if ( isset( $custom_data['_wpcf7_redirect_delay_redirect'] ) && (int) $custom_data['_wpcf7_redirect_delay_redirect'] > 0 ) {
|
142 |
+
$old_settings['delay_redirect_seconds'] = $custom_data['_wpcf7_redirect_delay_redirect'][0] / 1000;
|
143 |
+
}
|
144 |
+
|
145 |
+
return $old_settings;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Get the old contact form 7 to api settings
|
150 |
+
*/
|
151 |
+
public function get_cf7_api_settings() {
|
152 |
+
$custom_data = get_post_custom( $this->post_id );
|
153 |
+
$old_settings = array();
|
154 |
+
if ( isset( $custom_data['_wpcf7_api_data'] ) ) {
|
155 |
+
$old_settings['_wpcf7_api_data'] = maybe_unserialize( $custom_data['_wpcf7_api_data'][0] );
|
156 |
+
}
|
157 |
+
if ( isset( $custom_data['_wpcf7_api_data_map'] ) ) {
|
158 |
+
$old_settings['_wpcf7_api_data_map'] = maybe_unserialize( $custom_data['_wpcf7_api_data_map'][0] );
|
159 |
+
}
|
160 |
+
if ( isset( $custom_data['_template'] ) ) {
|
161 |
+
$old_settings['_template'] = maybe_unserialize( $custom_data['_template'][0] );
|
162 |
+
}
|
163 |
+
if ( isset( $custom_data['_json_template'] ) ) {
|
164 |
+
$old_settings['_json_template'] = maybe_unserialize( $custom_data['_json_template'][0] );
|
165 |
+
}
|
166 |
+
return $old_settings;
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Check if a form has a specific action type
|
171 |
+
*
|
172 |
+
* @param $type
|
173 |
+
* @return boolean
|
174 |
+
*/
|
175 |
+
public function has_action( $type ) {
|
176 |
+
$args = array();
|
177 |
+
$meta_query = array(
|
178 |
+
array(
|
179 |
+
'key' => 'action_type',
|
180 |
+
'value' => $type,
|
181 |
+
),
|
182 |
+
);
|
183 |
+
|
184 |
+
$args['meta_query'] = $meta_query;
|
185 |
+
$actions = $this->get_actions( 'default', 1, true, $args );
|
186 |
+
|
187 |
+
return $actions ? $actions : false;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Update the plugin has migrated
|
192 |
+
*
|
193 |
+
* @param $migration_type
|
194 |
+
*/
|
195 |
+
public function update_migration( $migration_type ) {
|
196 |
+
update_post_meta( $this->post_id, $migration_type, true );
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Check if a form was migrated from old version
|
201 |
+
*
|
202 |
+
* @param $migration_type
|
203 |
+
* @return boolean
|
204 |
+
*/
|
205 |
+
public function has_migrated( $migration_type ) {
|
206 |
+
return get_post_meta( $this->post_id, $migration_type, true );
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Check if there is old data on the DB
|
211 |
+
*
|
212 |
+
* @param $type
|
213 |
+
* @return boolean
|
214 |
+
*/
|
215 |
+
public function has_old_data( $type ) {
|
216 |
+
if ( 'migrate_from_cf7_api' === $type ) {
|
217 |
+
return $this->get_cf7_api_settings();
|
218 |
+
} else {
|
219 |
+
return $this->get_cf7_redirection_settings();
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Get a singelton
|
225 |
+
*
|
226 |
+
* @param string $post_id
|
227 |
+
*/
|
228 |
+
public static function get_instance( $post_id = '' ) {
|
229 |
+
if ( null === self::$instance || ( self::$cf7_form->id() !== $post_id && $post_id ) ) {
|
230 |
+
self::$instance = new self( $post_id );
|
231 |
+
}
|
232 |
+
return self::$instance;
|
233 |
+
}
|
234 |
+
|
235 |
+
public function is_new_form() {
|
236 |
+
return isset( $this->post_id ) && $this->post_id ? false : true;
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Initialize form
|
241 |
+
*/
|
242 |
+
public function init() {
|
243 |
+
// Check if this is a new form
|
244 |
+
if ( $this->is_new_form() ) {
|
245 |
+
self::$mail_tags = __( 'You need to save your form', 'wpcf7-redirect' );
|
246 |
+
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'save-form.php';
|
247 |
+
} else {
|
248 |
+
self::$mail_tags = $this->get_cf7_fields();
|
249 |
+
$fields = $this->get_fields_values();
|
250 |
+
$redirect_type = isset( $fields['redirect_type'] ) && $fields['redirect_type'] ? $fields['redirect_type'] : '';
|
251 |
+
$active_tab_title = 'active';
|
252 |
+
$active_tab = 'active';
|
253 |
+
$this->html = new WPCF7R_html( self::$mail_tags );
|
254 |
+
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'settings.php';
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Get all posts relevant to this contact form
|
260 |
+
* returns posts object
|
261 |
+
*
|
262 |
+
* @param $rule
|
263 |
+
*/
|
264 |
+
public function get_action_posts( $rule ) {
|
265 |
+
return $this->redirect_actions->get_action_posts( $rule );
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Get all actions relevant for this contact form
|
270 |
+
* Returns action classes
|
271 |
+
*
|
272 |
+
* @param $rule
|
273 |
+
* @param integer $count
|
274 |
+
* @param boolean $is_active
|
275 |
+
* @param array $args
|
276 |
+
*/
|
277 |
+
public function get_actions( $rule, $count = -1, $is_active = false, $args = array() ) {
|
278 |
+
$action_id = $this->get_action_to_submit();
|
279 |
+
|
280 |
+
if ( $action_id ) {
|
281 |
+
$args['post__in'] = array( $action_id );
|
282 |
+
}
|
283 |
+
|
284 |
+
$actions = isset( $this->redirect_actions ) && $this->redirect_actions ? $this->redirect_actions->get_actions( $rule, -1, $is_active, $args ) : array();
|
285 |
+
|
286 |
+
$this->actions = $actions;
|
287 |
+
|
288 |
+
return $actions;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Get all active actions
|
293 |
+
*/
|
294 |
+
public function get_active_actions() {
|
295 |
+
return $this->get_actions( 'default', -1, true );
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Save reference for the items removed from the $_POST data
|
300 |
+
*
|
301 |
+
* @param $removed_data
|
302 |
+
*/
|
303 |
+
public function set_removed_posted_data( $removed_data ) {
|
304 |
+
if ( isset( self::$removed_data ) ) {
|
305 |
+
self::$removed_data = array_merge( $removed_data, self::$removed_data );
|
306 |
+
} else {
|
307 |
+
self::$removed_data = $removed_data;
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* Get all params removed from the $_POST
|
313 |
+
*/
|
314 |
+
public function get_removed_form_params() {
|
315 |
+
return isset( self::$removed_data ) ? self::$removed_data : '';
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Validate and store meta data
|
320 |
+
*/
|
321 |
+
public function store_meta() {
|
322 |
+
if ( ! isset( $_POST ) || empty( $_POST['wpcf7-redirect'] ) ) {
|
323 |
+
return;
|
324 |
+
} else {
|
325 |
+
if ( ! wp_verify_nonce( $_POST['wpcf7_redirect_page_metaboxes_nonce'], 'wpcf7_redirect_page_metaboxes' ) ) {
|
326 |
+
return;
|
327 |
+
}
|
328 |
+
$form_id = $this->post_id;
|
329 |
+
$fields = $this->get_plugin_fields( $form_id );
|
330 |
+
$data = $_POST['wpcf7-redirect'];
|
331 |
+
$this->save_meta_fields( $form_id, $fields, $data );
|
332 |
+
if ( isset( $data['actions'] ) && $data['actions'] ) {
|
333 |
+
$this->save_actions( $data['actions'] );
|
334 |
+
}
|
335 |
+
}
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Save all actions and actions data
|
340 |
+
*
|
341 |
+
* @param $actions
|
342 |
+
*/
|
343 |
+
public function save_actions( $actions ) {
|
344 |
+
foreach ( $actions as $post_id => $action_fields ) {
|
345 |
+
$action = WPCF7R_Action::get_action( $post_id );
|
346 |
+
if ( $action ) {
|
347 |
+
$action->delete_all_fields();
|
348 |
+
foreach ( $action_fields as $action_field_key => $action_field_value ) {
|
349 |
+
update_post_meta( $post_id, $action_field_key, $action_field_value );
|
350 |
+
}
|
351 |
+
if ( isset( $action_fields['post_title'] ) ) {
|
352 |
+
$update_post = array(
|
353 |
+
'ID' => $post_id,
|
354 |
+
'post_title' => $action_fields['post_title'],
|
355 |
+
);
|
356 |
+
wp_update_post( $update_post );
|
357 |
+
}
|
358 |
+
}
|
359 |
+
}
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Save meta fields to cf7 post
|
364 |
+
* Save each action to its relevant action post
|
365 |
+
*
|
366 |
+
* @param $post_id
|
367 |
+
* @param $fields
|
368 |
+
* @param $data
|
369 |
+
*/
|
370 |
+
public function save_meta_fields( $post_id, $fields, $data ) {
|
371 |
+
unset( $data['actions'] );
|
372 |
+
if ( $data ) {
|
373 |
+
foreach ( $fields as $field ) {
|
374 |
+
$value = isset( $data[ $field['name'] ] ) ? $data[ $field['name'] ] : '';
|
375 |
+
switch ( $field['type'] ) {
|
376 |
+
case 'password':
|
377 |
+
case 'text':
|
378 |
+
case 'checkbox':
|
379 |
+
$value = sanitize_text_field( $value );
|
380 |
+
break;
|
381 |
+
case 'textarea':
|
382 |
+
$value = htmlspecialchars( $value );
|
383 |
+
break;
|
384 |
+
case 'number':
|
385 |
+
$value = intval( $value );
|
386 |
+
break;
|
387 |
+
case 'url':
|
388 |
+
$value = esc_url_raw( $value );
|
389 |
+
break;
|
390 |
+
}
|
391 |
+
update_post_meta( $post_id, '_wpcf7_redirect_' . $field['name'], $value );
|
392 |
+
}
|
393 |
+
}
|
394 |
+
}
|
395 |
+
|
396 |
+
/**
|
397 |
+
* Check if the form has active actions
|
398 |
+
*/
|
399 |
+
public function has_actions() {
|
400 |
+
$rule = 'default';
|
401 |
+
$count = 1;
|
402 |
+
$is_active = true;
|
403 |
+
$args = array();
|
404 |
+
$actions = $this->get_actions( $rule, $count, $is_active, $args ) ? true : false;
|
405 |
+
|
406 |
+
return $actions;
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Get specific form fields
|
411 |
+
*
|
412 |
+
* @param $fields
|
413 |
+
*/
|
414 |
+
public function get_form_fields( $fields ) {
|
415 |
+
$forms = array();
|
416 |
+
foreach ( $fields as $field ) {
|
417 |
+
$forms[ $this->post_id ][ $field['name'] ] = get_post_meta( $this->post_id, '_wpcf7_redirect_' . $field['name'], true );
|
418 |
+
if ( 'textarea' === $field['type'] ) {
|
419 |
+
$forms[ $this->post_id ][ $field['name'] ] = $forms[ $this->post_id ][ $field['name'] ];
|
420 |
+
}
|
421 |
+
}
|
422 |
+
|
423 |
+
// Thank you page URL is a little bit different...
|
424 |
+
$forms[ $this->post_id ]['thankyou_page_url'] = $forms[ $this->post_id ]['page_id'] ? get_permalink( $forms[ $this->post_id ]['page_id'] ) : '';
|
425 |
+
return reset( $forms );
|
426 |
+
}
|
427 |
+
|
428 |
+
/**
|
429 |
+
* Get rules for a specific contact form
|
430 |
+
*/
|
431 |
+
public function get_redirect_rules() {
|
432 |
+
return get_post_meta( $this->post_id, '_wpcf7_redirect_' . $field['name'], true );
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Get all fields values
|
437 |
+
*/
|
438 |
+
public function get_fields_values() {
|
439 |
+
$fields = $this->get_plugin_fields();
|
440 |
+
foreach ( $fields as $field ) {
|
441 |
+
$values[ $field['name'] ] = get_post_meta( $this->post_id, '_wpcf7_redirect_' . $field['name'], true );
|
442 |
+
}
|
443 |
+
return $values;
|
444 |
+
}
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Create plugin fields
|
448 |
+
*/
|
449 |
+
public function get_plugin_fields() {
|
450 |
+
$fields = array_merge(
|
451 |
+
WPCF7r_Form_Helper::get_plugin_default_fields(),
|
452 |
+
array(
|
453 |
+
array(
|
454 |
+
'name' => 'blocks',
|
455 |
+
'type' => 'blocks',
|
456 |
+
),
|
457 |
+
)
|
458 |
+
);
|
459 |
+
return $fields;
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* Get the contact form id
|
464 |
+
*/
|
465 |
+
public function get_id() {
|
466 |
+
return $this->post_id;
|
467 |
+
}
|
468 |
+
|
469 |
+
/**
|
470 |
+
* Get the form fields for usage on the selectors
|
471 |
+
*/
|
472 |
+
public function get_cf7_fields() {
|
473 |
+
$tags = self::get_mail_tags();
|
474 |
+
return $tags;
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
* Get special mail tags
|
479 |
+
*/
|
480 |
+
static function get_special_mail_tags() {
|
481 |
+
$mailtags = array();
|
482 |
+
$special_mail_tags = array(
|
483 |
+
'_remote_ip',
|
484 |
+
'_user_agent',
|
485 |
+
'_url',
|
486 |
+
'_date',
|
487 |
+
'_time',
|
488 |
+
'_post_id',
|
489 |
+
'_post_name',
|
490 |
+
'_post_title',
|
491 |
+
'_post_url',
|
492 |
+
'_post_author',
|
493 |
+
'_post_author_email',
|
494 |
+
'_site_title',
|
495 |
+
'_site_description',
|
496 |
+
'_site_url',
|
497 |
+
'_site_admin_email',
|
498 |
+
'user_login',
|
499 |
+
'user_email',
|
500 |
+
'user_url',
|
501 |
+
);
|
502 |
+
|
503 |
+
foreach ( $special_mail_tags as $special_mail_tag ) {
|
504 |
+
$tag = new WPCF7_MailTag( $special_mail_tag, $special_mail_tag, array() );
|
505 |
+
$mailtags[] = $tag;
|
506 |
+
}
|
507 |
+
|
508 |
+
return $mailtags;
|
509 |
+
}
|
510 |
+
|
511 |
+
/**
|
512 |
+
* Collect the mail tags from the form
|
513 |
+
*/
|
514 |
+
static function get_mail_tags() {
|
515 |
+
// If this is a new form there are no tags yet
|
516 |
+
if ( ! isset( self::$cf7_form ) || ! self::$cf7_form ) {
|
517 |
+
return;
|
518 |
+
}
|
519 |
+
|
520 |
+
$tags = apply_filters( 'wpcf7r_collect_mail_tags', self::$cf7_form->scan_form_tags() );
|
521 |
+
|
522 |
+
foreach ( (array) $tags as $tag ) {
|
523 |
+
$type = trim( $tag['type'], ' *' );
|
524 |
+
if ( empty( $type ) || empty( $tag['name'] ) ) {
|
525 |
+
continue;
|
526 |
+
} elseif ( ! empty( $args['include'] ) ) {
|
527 |
+
if ( ! in_array( $type, $args['include'], true ) ) {
|
528 |
+
continue;
|
529 |
+
}
|
530 |
+
} elseif ( ! empty( $args['exclude'] ) ) {
|
531 |
+
if ( in_array( $type, $args['exclude'], true ) ) {
|
532 |
+
continue;
|
533 |
+
}
|
534 |
+
}
|
535 |
+
$mailtags[] = $tag;
|
536 |
+
}
|
537 |
+
|
538 |
+
// create an instance to get the current form instance
|
539 |
+
$instance = self::get_instance( self::$cf7_form );
|
540 |
+
|
541 |
+
// add a save lead tag in case save lead action is on
|
542 |
+
if ( $instance->has_action( 'save_lead' ) ) {
|
543 |
+
$scanned_tag = array(
|
544 |
+
'type' => 'lead_id',
|
545 |
+
'basetype' => trim( '[lead_id]', '*' ),
|
546 |
+
'name' => 'lead_id',
|
547 |
+
'options' => array(),
|
548 |
+
'raw_values' => array(),
|
549 |
+
'values' => array(
|
550 |
+
WPCF7R_Action::get_lead_id(),
|
551 |
+
),
|
552 |
+
'pipes' => null,
|
553 |
+
'labels' => array(),
|
554 |
+
'attr' => '',
|
555 |
+
'content' => '',
|
556 |
+
);
|
557 |
+
$mailtags[] = new WPCF7_FormTag( $scanned_tag );
|
558 |
+
}
|
559 |
+
|
560 |
+
return $mailtags;
|
561 |
+
}
|
562 |
+
|
563 |
+
/**
|
564 |
+
* Process actions that are relevant for validation process
|
565 |
+
*/
|
566 |
+
public function process_validation_actions() {
|
567 |
+
$actions = $this->get_active_actions();
|
568 |
+
$results = array();
|
569 |
+
|
570 |
+
if ( $actions ) {
|
571 |
+
foreach ( $actions as $action ) {
|
572 |
+
$action_result = $action->process_validation( self::get_submission() );
|
573 |
+
if ( $action_result ) {
|
574 |
+
$results[ $action->get_type() ][] = $action_result;
|
575 |
+
}
|
576 |
+
}
|
577 |
+
}
|
578 |
+
return $results;
|
579 |
+
}
|
580 |
+
|
581 |
+
/**
|
582 |
+
* Get validation object
|
583 |
+
*/
|
584 |
+
public static function get_validation_obj() {
|
585 |
+
return self::$wpcf_validation_obj;
|
586 |
+
}
|
587 |
+
|
588 |
+
/**
|
589 |
+
* Get validation object $tags
|
590 |
+
*/
|
591 |
+
public static function get_validation_obj_tags() {
|
592 |
+
$validation_obj = self::get_validation_obj();
|
593 |
+
return isset( $validation_obj->tags ) ? $validation_obj->tags : '';
|
594 |
+
}
|
595 |
+
|
596 |
+
/**
|
597 |
+
* Save a referrence to the validaiont object
|
598 |
+
* This will enable invalidating tags later on
|
599 |
+
*
|
600 |
+
* @param object $wpcf_validation_obj
|
601 |
+
*/
|
602 |
+
public function set_validation_obj( $wpcf_validation_obj ) {
|
603 |
+
self::$wpcf_validation_obj = $wpcf_validation_obj;
|
604 |
+
}
|
605 |
+
|
606 |
+
/**
|
607 |
+
* Handles submission actions
|
608 |
+
*/
|
609 |
+
public function process_actions() {
|
610 |
+
// get all active actions
|
611 |
+
$actions = $this->get_active_actions();
|
612 |
+
|
613 |
+
// prepeare the results array
|
614 |
+
$results = array();
|
615 |
+
// get removed fom data
|
616 |
+
self::$submission->removed_posted_data = $this->get_removed_form_params();
|
617 |
+
|
618 |
+
if ( $actions ) {// loop through actions and process
|
619 |
+
foreach ( $actions as $action ) {
|
620 |
+
// save the validation object in case this action manipulates validations
|
621 |
+
// do the action
|
622 |
+
$action_result = $action->process_action( $this );
|
623 |
+
// add the action to the results array
|
624 |
+
$results[ $action->get_type() ][] = $action_result;
|
625 |
+
self::$processed_actions[] = $action;
|
626 |
+
}
|
627 |
+
} else {
|
628 |
+
return false;
|
629 |
+
}
|
630 |
+
|
631 |
+
return $results;
|
632 |
+
}
|
633 |
+
|
634 |
+
/**
|
635 |
+
* Get all processed actions
|
636 |
+
*/
|
637 |
+
public function get_processed_actions() {
|
638 |
+
return isset( self::$processed_actions ) && self::$processed_actions ? self::$processed_actions : '';
|
639 |
+
}
|
640 |
+
|
641 |
+
/**
|
642 |
+
* Check if actions hold one last thing to do before returning result to the user
|
643 |
+
*/
|
644 |
+
public function maybe_perform_pre_result_action() {
|
645 |
+
$actions = $this->get_processed_actions();
|
646 |
+
if ( $actions ) {
|
647 |
+
foreach ( $actions as $action ) {
|
648 |
+
$action->maybe_perform_pre_result_action();
|
649 |
+
}
|
650 |
+
}
|
651 |
+
}
|
652 |
+
}
|
classes/class-wpcf7r-html.php
CHANGED
@@ -1,302 +1,302 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Html - Mainly static functions class to create html fregments
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
class WPCF7R_Html {
|
9 |
-
public static $mail_tags;
|
10 |
-
|
11 |
-
public static $active_conditional_logic;
|
12 |
-
/**
|
13 |
-
* The main class constructor
|
14 |
-
*
|
15 |
-
* @param string $mail_tags
|
16 |
-
*/
|
17 |
-
|
18 |
-
public function __construct( $mail_tags = '' ) {
|
19 |
-
self::$mail_tags = $mail_tags;
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Display admin groupos
|
24 |
-
*/
|
25 |
-
public static function conditional_groups_display( $group_block, $prefix ) {
|
26 |
-
foreach ( $group_block['groups'] as $group_key => $group ) {
|
27 |
-
echo self::group_display( 'block_1', $group_key, $group, $prefix );
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Print a single group of seetings
|
33 |
-
*/
|
34 |
-
public static function group_display( $block_key = '', $group_key = '', $group = array(), $prefix ) {
|
35 |
-
ob_start();
|
36 |
-
echo self::get_conditional_row_group_start( $group_key, $group );
|
37 |
-
echo self::get_conditional_row_group_rows_start( $group_key, $group );
|
38 |
-
|
39 |
-
foreach ( $group as $group_row => $row_fields ) {
|
40 |
-
echo self::get_conditional_row_template( $block_key, $group_key, $group_row, $row_fields, $prefix, false );
|
41 |
-
}
|
42 |
-
|
43 |
-
echo self::get_conditional_row_group_rows_end();
|
44 |
-
echo self::get_conditional_row_group_end();
|
45 |
-
return ob_get_clean();
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Conditional group row start html
|
50 |
-
*/
|
51 |
-
public static function get_conditional_row_group_rows_start( $group_key, $group ) {
|
52 |
-
return '<div class="conditional-group-block active" data-block-id="block_1">
|
53 |
-
<table class="wp-list-table widefat fixed striped pages repeater-table leads-list">
|
54 |
-
<thead>
|
55 |
-
<tr>
|
56 |
-
<th colspan="4"><h3>' . __( 'IF', 'wpcf7-redirect' ) . '</h3></th>
|
57 |
-
</tr>
|
58 |
-
</thead>
|
59 |
-
<tbody>';
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Conditional group row end html
|
64 |
-
*/
|
65 |
-
public static function get_conditional_row_group_rows_end() {
|
66 |
-
return '</tbody></table></div>';
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Conditional row group start
|
71 |
-
*/
|
72 |
-
public static function get_conditional_row_group_start( $group_key, $group ) {
|
73 |
-
return '<div class="wpcfr-rule-group group-' . $group_key . '" data-group-id="' . $group_key . '"><div class="group-title title-or"><h3>' . __( 'OR', 'wpcf7-redirect' ) . '</h3></div>';
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Get Conditional Row Group End
|
78 |
-
*/
|
79 |
-
public static function get_conditional_row_group_end() {
|
80 |
-
return '</div>';
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Get the title html block
|
85 |
-
*
|
86 |
-
* @param $group_block_key
|
87 |
-
* @param $group_block
|
88 |
-
* @param $active_tab_title
|
89 |
-
* @param boolean $echo
|
90 |
-
* @param $prefix
|
91 |
-
*/
|
92 |
-
public static function get_block_title( $group_block_key, $group_block, $active_tab_title, $echo = true, $prefix ) {
|
93 |
-
ob_start();
|
94 |
-
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'block-title.php';
|
95 |
-
if ( $echo ) {
|
96 |
-
echo ob_get_clean();
|
97 |
-
} else {
|
98 |
-
return ob_get_clean();
|
99 |
-
}
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Get an HTML template of a condition row
|
104 |
-
*/
|
105 |
-
public static function get_conditional_row_template( $block_key = '', $group_key = '', $group_row = '', $row_fields = array(), $prefix, $required = true ) {
|
106 |
-
ob_start();
|
107 |
-
$condition = $row_fields['condition'];
|
108 |
-
$tags = WPCF7R_Form::get_mail_tags();
|
109 |
-
$required = $required ? 'required' : '';
|
110 |
-
?>
|
111 |
-
<tr class="row-template">
|
112 |
-
<td>
|
113 |
-
<select class="wpcf7r-fields" name="wpcf7-redirect<?php echo $prefix; ?>[blocks][<?php echo $block_key; ?>][groups][<?php echo $group_key; ?>][<?php echo $group_row; ?>][if]" <?php echo $required; ?>>
|
114 |
-
<option value="" <?php selected( $row_fields['if'], '' ); ?>><?php _e( 'Select' ); ?></option>
|
115 |
-
<?php
|
116 |
-
if ( $tags ) :
|
117 |
-
foreach ( $tags as $mail_tag ) :
|
118 |
-
?>
|
119 |
-
<option value="<?php echo $mail_tag['name']; ?>" <?php selected( $mail_tag['name'], $row_fields['if'] ); ?>><?php echo $mail_tag['name']; ?></option>
|
120 |
-
<?php
|
121 |
-
endforeach;
|
122 |
-
endif;
|
123 |
-
?>
|
124 |
-
</select>
|
125 |
-
</td>
|
126 |
-
<td>
|
127 |
-
<select class="compare-options" name="wpcf7-redirect<?php echo $prefix; ?>[blocks][<?php echo $block_key; ?>][groups][<?php echo $group_key; ?>][<?php echo $group_row; ?>][condition]" <?php echo $required; ?>>
|
128 |
-
<option value="" <?php selected( $condition, '' ); ?>><?php _e( 'Select', 'wpcf7-redirect' ); ?></option>
|
129 |
-
<option value="equal" <?php selected( $condition, 'equal' ); ?> data-comparetype="select"><?php _e( 'Equal', 'wpcf7-redirect' ); ?></option>
|
130 |
-
<option value="not-equal" <?php selected( $condition, 'not-equal' ); ?> data-comparetype="select"><?php _e( 'Non Equal', 'wpcf7-redirect' ); ?></option>
|
131 |
-
<option value="contain" <?php selected( $condition, 'contain' ); ?> data-comparetype=""><?php _e( 'Contains', 'wpcf7-redirect' ); ?></option>
|
132 |
-
<option value="not-contain" <?php selected( $condition, 'not-contain' ); ?> data-comparetype=""><?php _e( 'Does not Contain', 'wpcf7-redirect' ); ?></option>
|
133 |
-
<option value="less_than" <?php selected( $condition, 'less_than' ); ?> data-comparetype=""><?php _e( 'Less than', 'wpcf7-redirect' ); ?></option>
|
134 |
-
<option value="greater_than" <?php selected( $condition, 'greater_than' ); ?> data-comparetype=""><?php _e( 'Greater than', 'wpcf7-redirect' ); ?></option>
|
135 |
-
<option value="is_null" <?php selected( $condition, 'is_null' ); ?> data-comparetype=""><?php _e( 'Is Empty', 'wpcf7-redirect' ); ?></option>
|
136 |
-
<option value="is_not_null" <?php selected( $condition, 'is_not_null' ); ?> data-comparetype=""><?php _e( 'Is Not Empty', 'wpcf7-redirect' ); ?></option>
|
137 |
-
</select>
|
138 |
-
</td>
|
139 |
-
<td>
|
140 |
-
<?php
|
141 |
-
$select_visible = false;
|
142 |
-
$select_fields = array(
|
143 |
-
'select*',
|
144 |
-
'radio*',
|
145 |
-
'checkbox*',
|
146 |
-
'select',
|
147 |
-
'radio',
|
148 |
-
'checkbox',
|
149 |
-
);
|
150 |
-
if ( $tags ) :
|
151 |
-
foreach ( $tags as $mail_tag ) :
|
152 |
-
?>
|
153 |
-
<?php if ( in_array( $mail_tag->type, $select_fields, true ) ) : ?>
|
154 |
-
<?php $select_visible = $row_fields['if'] === $mail_tag['name'] ? true : $select_visible; ?>
|
155 |
-
<select class="group_row_value group_row_value_select" style="<?php echo $row_fields['if'] !== $mail_tag['name'] ? 'display:none;' : ''; ?>" data-rel="<?php echo $mail_tag['name']; ?>">
|
156 |
-
<option value="" <?php selected( $row_fields['value'], '' ); ?>><?php _e( 'Select', 'wpcf7-redirect' ); ?></option>
|
157 |
-
<?php
|
158 |
-
foreach ( $mail_tag->raw_values as $orig_value ) :
|
159 |
-
$orig_value = explode( '|', $orig_value );
|
160 |
-
$label = $orig_value[0];
|
161 |
-
$value = isset( $orig_value[1] ) && $orig_value[1] ? $orig_value[1] : $orig_value[0];
|
162 |
-
?>
|
163 |
-
<option value="<?php echo $value; ?>"
|
164 |
-
<?php
|
165 |
-
if ( isset( $row_fields['value'] ) ) :
|
166 |
-
selected( $row_fields['value'], $value );
|
167 |
-
endif;
|
168 |
-
?>
|
169 |
-
>
|
170 |
-
<?php echo $label; ?>
|
171 |
-
</option>
|
172 |
-
<?php endforeach; ?>
|
173 |
-
</select>
|
174 |
-
<?php endif; ?>
|
175 |
-
<?php
|
176 |
-
endforeach;
|
177 |
-
endif;
|
178 |
-
?>
|
179 |
-
<input type="text" class="group_row_value wpcf7-redirect-value" name="wpcf7-redirect<?php echo $prefix; ?>[blocks][<?php echo $block_key; ?>][groups][<?php echo $group_key; ?>][<?php echo $group_row; ?>][value]" value="<?php echo isset( $row_fields['value'] ) ? esc_html( $row_fields['value'] ) : ''; ?>" placeholder="<?php _e( 'Your value here' ); ?>" style="<?php echo $select_visible ? 'display:none;' : ''; ?>">
|
180 |
-
</td>
|
181 |
-
<td>
|
182 |
-
<div class="qs-condition-actions">
|
183 |
-
<div class="group-actions">
|
184 |
-
<span class="dashicons dashicons-minus"></span>
|
185 |
-
<a href="#" class="button add-condition"><?php _e( 'And', 'wpcf7-redirect' ); ?></a>
|
186 |
-
</div>
|
187 |
-
</div>
|
188 |
-
</td>
|
189 |
-
</tr>
|
190 |
-
<?php
|
191 |
-
return ob_get_clean();
|
192 |
-
}
|
193 |
-
|
194 |
-
/**
|
195 |
-
* Get the html of the rule block
|
196 |
-
*
|
197 |
-
* @param $group_block_key
|
198 |
-
* @param $group_block
|
199 |
-
* @param $active_tab
|
200 |
-
* @param boolean $echo
|
201 |
-
* @param $prefix
|
202 |
-
*/
|
203 |
-
public static function get_block_html( $group_block_key, $group_block, $active_tab, $echo = true, $prefix ) {
|
204 |
-
ob_start();
|
205 |
-
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'block-html.php';
|
206 |
-
if ( $echo ) {
|
207 |
-
echo ob_get_clean();
|
208 |
-
} else {
|
209 |
-
return ob_get_clean();
|
210 |
-
}
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* A function that returns the relevant field HTML
|
215 |
-
*
|
216 |
-
* @param $field
|
217 |
-
* @param $prefix
|
218 |
-
*/
|
219 |
-
public static function render_field( $field, $prefix ) {
|
220 |
-
switch ( $field['type'] ) {
|
221 |
-
case 'text':
|
222 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-text.php';
|
223 |
-
break;
|
224 |
-
case 'download':
|
225 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-download.php';
|
226 |
-
break;
|
227 |
-
case 'password':
|
228 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-password.php';
|
229 |
-
break;
|
230 |
-
case 'url':
|
231 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-url.php';
|
232 |
-
break;
|
233 |
-
case 'textarea':
|
234 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-textarea.php';
|
235 |
-
break;
|
236 |
-
case 'blocks':
|
237 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-rule-blocks.php';
|
238 |
-
break;
|
239 |
-
case 'checkbox':
|
240 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-checkbox.php';
|
241 |
-
break;
|
242 |
-
case 'post_type_select':
|
243 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-post-type-select.php';
|
244 |
-
break;
|
245 |
-
case 'page_select':
|
246 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-page-select.php';
|
247 |
-
break;
|
248 |
-
case 'notice':
|
249 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-notice.php';
|
250 |
-
break;
|
251 |
-
case 'select':
|
252 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-select.php';
|
253 |
-
break;
|
254 |
-
case 'tags_map':
|
255 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-tags-map.php';
|
256 |
-
break;
|
257 |
-
case 'leads_map':
|
258 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-leads-mapping.php';
|
259 |
-
break;
|
260 |
-
case 'debug_log':
|
261 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-debug-log.php';
|
262 |
-
break;
|
263 |
-
case 'json':
|
264 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-json-editor.php';
|
265 |
-
break;
|
266 |
-
case 'repeater':
|
267 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-repeater.php';
|
268 |
-
break;
|
269 |
-
case 'section':
|
270 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'section.php';
|
271 |
-
break;
|
272 |
-
case 'button':
|
273 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-button.php';
|
274 |
-
break;
|
275 |
-
case 'description':
|
276 |
-
case 'editor':
|
277 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-editor.php';
|
278 |
-
break;
|
279 |
-
case 'number':
|
280 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-number.php';
|
281 |
-
break;
|
282 |
-
case 'taxonomy':
|
283 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-taxonomy.php';
|
284 |
-
break;
|
285 |
-
case 'post_author_select':
|
286 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-post-author-select.php';
|
287 |
-
break;
|
288 |
-
case 'media':
|
289 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-media.php';
|
290 |
-
break;
|
291 |
-
case 'upload':
|
292 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-upload.php';
|
293 |
-
break;
|
294 |
-
case 'preview':
|
295 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-preview.php';
|
296 |
-
break;
|
297 |
-
}
|
298 |
-
|
299 |
-
$template = apply_filters( 'render_field', $template, $field, $prefix, WPCF7_PRO_REDIRECT_FIELDS_PATH );
|
300 |
-
include $template;
|
301 |
-
}
|
302 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Html - Mainly static functions class to create html fregments
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
class WPCF7R_Html {
|
9 |
+
public static $mail_tags;
|
10 |
+
|
11 |
+
public static $active_conditional_logic;
|
12 |
+
/**
|
13 |
+
* The main class constructor
|
14 |
+
*
|
15 |
+
* @param string $mail_tags
|
16 |
+
*/
|
17 |
+
|
18 |
+
public function __construct( $mail_tags = '' ) {
|
19 |
+
self::$mail_tags = $mail_tags;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Display admin groupos
|
24 |
+
*/
|
25 |
+
public static function conditional_groups_display( $group_block, $prefix ) {
|
26 |
+
foreach ( $group_block['groups'] as $group_key => $group ) {
|
27 |
+
echo self::group_display( 'block_1', $group_key, $group, $prefix );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Print a single group of seetings
|
33 |
+
*/
|
34 |
+
public static function group_display( $block_key = '', $group_key = '', $group = array(), $prefix ) {
|
35 |
+
ob_start();
|
36 |
+
echo self::get_conditional_row_group_start( $group_key, $group );
|
37 |
+
echo self::get_conditional_row_group_rows_start( $group_key, $group );
|
38 |
+
|
39 |
+
foreach ( $group as $group_row => $row_fields ) {
|
40 |
+
echo self::get_conditional_row_template( $block_key, $group_key, $group_row, $row_fields, $prefix, false );
|
41 |
+
}
|
42 |
+
|
43 |
+
echo self::get_conditional_row_group_rows_end();
|
44 |
+
echo self::get_conditional_row_group_end();
|
45 |
+
return ob_get_clean();
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Conditional group row start html
|
50 |
+
*/
|
51 |
+
public static function get_conditional_row_group_rows_start( $group_key, $group ) {
|
52 |
+
return '<div class="conditional-group-block active" data-block-id="block_1">
|
53 |
+
<table class="wp-list-table widefat fixed striped pages repeater-table leads-list">
|
54 |
+
<thead>
|
55 |
+
<tr>
|
56 |
+
<th colspan="4"><h3>' . __( 'IF', 'wpcf7-redirect' ) . '</h3></th>
|
57 |
+
</tr>
|
58 |
+
</thead>
|
59 |
+
<tbody>';
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Conditional group row end html
|
64 |
+
*/
|
65 |
+
public static function get_conditional_row_group_rows_end() {
|
66 |
+
return '</tbody></table></div>';
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Conditional row group start
|
71 |
+
*/
|
72 |
+
public static function get_conditional_row_group_start( $group_key, $group ) {
|
73 |
+
return '<div class="wpcfr-rule-group group-' . $group_key . '" data-group-id="' . $group_key . '"><div class="group-title title-or"><h3>' . __( 'OR', 'wpcf7-redirect' ) . '</h3></div>';
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Get Conditional Row Group End
|
78 |
+
*/
|
79 |
+
public static function get_conditional_row_group_end() {
|
80 |
+
return '</div>';
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Get the title html block
|
85 |
+
*
|
86 |
+
* @param $group_block_key
|
87 |
+
* @param $group_block
|
88 |
+
* @param $active_tab_title
|
89 |
+
* @param boolean $echo
|
90 |
+
* @param $prefix
|
91 |
+
*/
|
92 |
+
public static function get_block_title( $group_block_key, $group_block, $active_tab_title, $echo = true, $prefix ) {
|
93 |
+
ob_start();
|
94 |
+
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'block-title.php';
|
95 |
+
if ( $echo ) {
|
96 |
+
echo ob_get_clean();
|
97 |
+
} else {
|
98 |
+
return ob_get_clean();
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Get an HTML template of a condition row
|
104 |
+
*/
|
105 |
+
public static function get_conditional_row_template( $block_key = '', $group_key = '', $group_row = '', $row_fields = array(), $prefix, $required = true ) {
|
106 |
+
ob_start();
|
107 |
+
$condition = $row_fields['condition'];
|
108 |
+
$tags = WPCF7R_Form::get_mail_tags();
|
109 |
+
$required = $required ? 'required' : '';
|
110 |
+
?>
|
111 |
+
<tr class="row-template">
|
112 |
+
<td>
|
113 |
+
<select class="wpcf7r-fields" name="wpcf7-redirect<?php echo $prefix; ?>[blocks][<?php echo $block_key; ?>][groups][<?php echo $group_key; ?>][<?php echo $group_row; ?>][if]" <?php echo $required; ?>>
|
114 |
+
<option value="" <?php selected( $row_fields['if'], '' ); ?>><?php _e( 'Select' ); ?></option>
|
115 |
+
<?php
|
116 |
+
if ( $tags ) :
|
117 |
+
foreach ( $tags as $mail_tag ) :
|
118 |
+
?>
|
119 |
+
<option value="<?php echo $mail_tag['name']; ?>" <?php selected( $mail_tag['name'], $row_fields['if'] ); ?>><?php echo $mail_tag['name']; ?></option>
|
120 |
+
<?php
|
121 |
+
endforeach;
|
122 |
+
endif;
|
123 |
+
?>
|
124 |
+
</select>
|
125 |
+
</td>
|
126 |
+
<td>
|
127 |
+
<select class="compare-options" name="wpcf7-redirect<?php echo $prefix; ?>[blocks][<?php echo $block_key; ?>][groups][<?php echo $group_key; ?>][<?php echo $group_row; ?>][condition]" <?php echo $required; ?>>
|
128 |
+
<option value="" <?php selected( $condition, '' ); ?>><?php _e( 'Select', 'wpcf7-redirect' ); ?></option>
|
129 |
+
<option value="equal" <?php selected( $condition, 'equal' ); ?> data-comparetype="select"><?php _e( 'Equal', 'wpcf7-redirect' ); ?></option>
|
130 |
+
<option value="not-equal" <?php selected( $condition, 'not-equal' ); ?> data-comparetype="select"><?php _e( 'Non Equal', 'wpcf7-redirect' ); ?></option>
|
131 |
+
<option value="contain" <?php selected( $condition, 'contain' ); ?> data-comparetype=""><?php _e( 'Contains', 'wpcf7-redirect' ); ?></option>
|
132 |
+
<option value="not-contain" <?php selected( $condition, 'not-contain' ); ?> data-comparetype=""><?php _e( 'Does not Contain', 'wpcf7-redirect' ); ?></option>
|
133 |
+
<option value="less_than" <?php selected( $condition, 'less_than' ); ?> data-comparetype=""><?php _e( 'Less than', 'wpcf7-redirect' ); ?></option>
|
134 |
+
<option value="greater_than" <?php selected( $condition, 'greater_than' ); ?> data-comparetype=""><?php _e( 'Greater than', 'wpcf7-redirect' ); ?></option>
|
135 |
+
<option value="is_null" <?php selected( $condition, 'is_null' ); ?> data-comparetype=""><?php _e( 'Is Empty', 'wpcf7-redirect' ); ?></option>
|
136 |
+
<option value="is_not_null" <?php selected( $condition, 'is_not_null' ); ?> data-comparetype=""><?php _e( 'Is Not Empty', 'wpcf7-redirect' ); ?></option>
|
137 |
+
</select>
|
138 |
+
</td>
|
139 |
+
<td>
|
140 |
+
<?php
|
141 |
+
$select_visible = false;
|
142 |
+
$select_fields = array(
|
143 |
+
'select*',
|
144 |
+
'radio*',
|
145 |
+
'checkbox*',
|
146 |
+
'select',
|
147 |
+
'radio',
|
148 |
+
'checkbox',
|
149 |
+
);
|
150 |
+
if ( $tags ) :
|
151 |
+
foreach ( $tags as $mail_tag ) :
|
152 |
+
?>
|
153 |
+
<?php if ( in_array( $mail_tag->type, $select_fields, true ) ) : ?>
|
154 |
+
<?php $select_visible = $row_fields['if'] === $mail_tag['name'] ? true : $select_visible; ?>
|
155 |
+
<select class="group_row_value group_row_value_select" style="<?php echo $row_fields['if'] !== $mail_tag['name'] ? 'display:none;' : ''; ?>" data-rel="<?php echo $mail_tag['name']; ?>">
|
156 |
+
<option value="" <?php selected( $row_fields['value'], '' ); ?>><?php _e( 'Select', 'wpcf7-redirect' ); ?></option>
|
157 |
+
<?php
|
158 |
+
foreach ( $mail_tag->raw_values as $orig_value ) :
|
159 |
+
$orig_value = explode( '|', $orig_value );
|
160 |
+
$label = $orig_value[0];
|
161 |
+
$value = isset( $orig_value[1] ) && $orig_value[1] ? $orig_value[1] : $orig_value[0];
|
162 |
+
?>
|
163 |
+
<option value="<?php echo $value; ?>"
|
164 |
+
<?php
|
165 |
+
if ( isset( $row_fields['value'] ) ) :
|
166 |
+
selected( $row_fields['value'], $value );
|
167 |
+
endif;
|
168 |
+
?>
|
169 |
+
>
|
170 |
+
<?php echo $label; ?>
|
171 |
+
</option>
|
172 |
+
<?php endforeach; ?>
|
173 |
+
</select>
|
174 |
+
<?php endif; ?>
|
175 |
+
<?php
|
176 |
+
endforeach;
|
177 |
+
endif;
|
178 |
+
?>
|
179 |
+
<input type="text" class="group_row_value wpcf7-redirect-value" name="wpcf7-redirect<?php echo $prefix; ?>[blocks][<?php echo $block_key; ?>][groups][<?php echo $group_key; ?>][<?php echo $group_row; ?>][value]" value="<?php echo isset( $row_fields['value'] ) ? esc_html( $row_fields['value'] ) : ''; ?>" placeholder="<?php _e( 'Your value here' ); ?>" style="<?php echo $select_visible ? 'display:none;' : ''; ?>">
|
180 |
+
</td>
|
181 |
+
<td>
|
182 |
+
<div class="qs-condition-actions">
|
183 |
+
<div class="group-actions">
|
184 |
+
<span class="dashicons dashicons-minus"></span>
|
185 |
+
<a href="#" class="button add-condition"><?php _e( 'And', 'wpcf7-redirect' ); ?></a>
|
186 |
+
</div>
|
187 |
+
</div>
|
188 |
+
</td>
|
189 |
+
</tr>
|
190 |
+
<?php
|
191 |
+
return ob_get_clean();
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Get the html of the rule block
|
196 |
+
*
|
197 |
+
* @param $group_block_key
|
198 |
+
* @param $group_block
|
199 |
+
* @param $active_tab
|
200 |
+
* @param boolean $echo
|
201 |
+
* @param $prefix
|
202 |
+
*/
|
203 |
+
public static function get_block_html( $group_block_key, $group_block, $active_tab, $echo = true, $prefix ) {
|
204 |
+
ob_start();
|
205 |
+
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'block-html.php';
|
206 |
+
if ( $echo ) {
|
207 |
+
echo ob_get_clean();
|
208 |
+
} else {
|
209 |
+
return ob_get_clean();
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* A function that returns the relevant field HTML
|
215 |
+
*
|
216 |
+
* @param $field
|
217 |
+
* @param $prefix
|
218 |
+
*/
|
219 |
+
public static function render_field( $field, $prefix ) {
|
220 |
+
switch ( $field['type'] ) {
|
221 |
+
case 'text':
|
222 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-text.php';
|
223 |
+
break;
|
224 |
+
case 'download':
|
225 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-download.php';
|
226 |
+
break;
|
227 |
+
case 'password':
|
228 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-password.php';
|
229 |
+
break;
|
230 |
+
case 'url':
|
231 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-url.php';
|
232 |
+
break;
|
233 |
+
case 'textarea':
|
234 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-textarea.php';
|
235 |
+
break;
|
236 |
+
case 'blocks':
|
237 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-rule-blocks.php';
|
238 |
+
break;
|
239 |
+
case 'checkbox':
|
240 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-checkbox.php';
|
241 |
+
break;
|
242 |
+
case 'post_type_select':
|
243 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-post-type-select.php';
|
244 |
+
break;
|
245 |
+
case 'page_select':
|
246 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-page-select.php';
|
247 |
+
break;
|
248 |
+
case 'notice':
|
249 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-notice.php';
|
250 |
+
break;
|
251 |
+
case 'select':
|
252 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-select.php';
|
253 |
+
break;
|
254 |
+
case 'tags_map':
|
255 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-tags-map.php';
|
256 |
+
break;
|
257 |
+
case 'leads_map':
|
258 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-leads-mapping.php';
|
259 |
+
break;
|
260 |
+
case 'debug_log':
|
261 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-debug-log.php';
|
262 |
+
break;
|
263 |
+
case 'json':
|
264 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-json-editor.php';
|
265 |
+
break;
|
266 |
+
case 'repeater':
|
267 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-repeater.php';
|
268 |
+
break;
|
269 |
+
case 'section':
|
270 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'section.php';
|
271 |
+
break;
|
272 |
+
case 'button':
|
273 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-button.php';
|
274 |
+
break;
|
275 |
+
case 'description':
|
276 |
+
case 'editor':
|
277 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-editor.php';
|
278 |
+
break;
|
279 |
+
case 'number':
|
280 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-number.php';
|
281 |
+
break;
|
282 |
+
case 'taxonomy':
|
283 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-taxonomy.php';
|
284 |
+
break;
|
285 |
+
case 'post_author_select':
|
286 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-post-author-select.php';
|
287 |
+
break;
|
288 |
+
case 'media':
|
289 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-media.php';
|
290 |
+
break;
|
291 |
+
case 'upload':
|
292 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-upload.php';
|
293 |
+
break;
|
294 |
+
case 'preview':
|
295 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-preview.php';
|
296 |
+
break;
|
297 |
+
}
|
298 |
+
|
299 |
+
$template = apply_filters( 'render_field', $template, $field, $prefix, WPCF7_PRO_REDIRECT_FIELDS_PATH );
|
300 |
+
include $template;
|
301 |
+
}
|
302 |
+
}
|
classes/class-wpcf7r-lead.php
CHANGED
@@ -1,197 +1,197 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Lead - Container class that handles lead
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
class WPCF7R_Lead {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Create an instance
|
12 |
-
* Save the post id and post reference
|
13 |
-
*
|
14 |
-
* @param string $post_id
|
15 |
-
*/
|
16 |
-
public function __construct( $post_id = '' ) {
|
17 |
-
if ( is_object( $post_id ) ) {
|
18 |
-
$this->post_id = $post_id->ID;
|
19 |
-
$this->post = $post_id;
|
20 |
-
} else {
|
21 |
-
$this->post_id = $post_id;
|
22 |
-
$this->post = $post_id;
|
23 |
-
}
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Update submitted form data
|
28 |
-
*
|
29 |
-
* @param array $args
|
30 |
-
*/
|
31 |
-
public function update_lead_data( $args = array() ) {
|
32 |
-
if ( $args ) {
|
33 |
-
foreach ( $args as $meta_key => $meta_value ) {
|
34 |
-
update_post_meta( $this->post_id, $meta_key, $meta_value );
|
35 |
-
}
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Return the lead ID
|
41 |
-
*/
|
42 |
-
public function get_id() {
|
43 |
-
return $this->post_id;
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Get the post title
|
48 |
-
*/
|
49 |
-
public function get_title() {
|
50 |
-
return get_the_title( $this->get_id() );
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Update the type of lead
|
55 |
-
*
|
56 |
-
* @param $lead_type
|
57 |
-
*/
|
58 |
-
public function update_lead_type( $lead_type ) {
|
59 |
-
update_post_meta( $this->post_id, 'lead_type', $lead_type );
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Save the action reference and results
|
64 |
-
* @param $action_id
|
65 |
-
* @param $action_type
|
66 |
-
* @param $action_results
|
67 |
-
*/
|
68 |
-
public function add_action_debug( $action_id, $action_type, $action_results ) {
|
69 |
-
$action_details = array(
|
70 |
-
'action_id' => $action_id,
|
71 |
-
'results' => $action_results,
|
72 |
-
);
|
73 |
-
add_post_meta( $this->post_id, $action_type, $action_details );
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Get the creation post of the lead
|
78 |
-
*/
|
79 |
-
public function get_date() {
|
80 |
-
return get_the_date( get_option( 'date_format' ), $this->post_id );
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Get the creation post of the lead
|
85 |
-
*/
|
86 |
-
public function get_time() {
|
87 |
-
return get_the_date( get_option( 'time_format' ), $this->post_id );
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Get the lead type
|
92 |
-
*/
|
93 |
-
public function get_lead_type() {
|
94 |
-
return get_post_meta( $this->post_id, 'lead_type', true );
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Save the user submitted files
|
99 |
-
*
|
100 |
-
* @return void
|
101 |
-
*/
|
102 |
-
public function update_lead_files( $files ) {
|
103 |
-
update_post_meta( $this->post_id, 'files', $files );
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Get lead fields
|
108 |
-
*/
|
109 |
-
public function get_lead_fields() {
|
110 |
-
$action_id = get_post_meta( $this->post_id, 'cf7_action_id', true );
|
111 |
-
|
112 |
-
$custom_meta_fields = get_post_custom( $this->post_id );
|
113 |
-
$lead_fields = array();
|
114 |
-
|
115 |
-
$action = WPCF7R_Action::get_action( (int) $action_id );
|
116 |
-
|
117 |
-
if ( $action_id && $action ) {
|
118 |
-
|
119 |
-
$fields = maybe_unserialize( $action->get( 'leads_map' ) );
|
120 |
-
|
121 |
-
foreach ( $fields as $field_key => $field_value ) {
|
122 |
-
if ( 'lead_id' === $field_key ) {
|
123 |
-
continue;
|
124 |
-
} else {
|
125 |
-
if ( isset( $custom_meta_fields[ $field_key ] ) ) {
|
126 |
-
$value = maybe_unserialize( $custom_meta_fields[ $field_key ][0] );
|
127 |
-
} elseif ( isset( $custom_meta_fields['files'] ) && $custom_meta_fields['files'] ) {
|
128 |
-
$value = maybe_unserialize( $custom_meta_fields['files'][0] );
|
129 |
-
$value = isset( $value[ $field_key ] ) && $value[ $field_key ] ? $value[ $field_key ] : '';
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
if ( is_array( $value ) ) {
|
134 |
-
if ( isset( $value['path'] ) ) {
|
135 |
-
$lead_fields[ $field_key ] = array(
|
136 |
-
'type' => 'download',
|
137 |
-
'placeholder' => '',
|
138 |
-
'value' => $value['base64_file'],
|
139 |
-
'filetype' => $value['type'],
|
140 |
-
'filename' => $value['name'],
|
141 |
-
'label' => isset( $field_value['tag'] ) && $field_value['tag'] ? $field_value['tag'] : __( 'File', 'wpcf7-redirect' ),
|
142 |
-
'name' => $field_key,
|
143 |
-
'prefix' => '',
|
144 |
-
);
|
145 |
-
} else {
|
146 |
-
foreach ( $value as $value_field_key => $value_field_value ) {
|
147 |
-
$lead_fields[ $field_key . '-' . $value_field_key ] = array(
|
148 |
-
'type' => 'text',
|
149 |
-
'placeholder' => '',
|
150 |
-
'label' => isset( $field_value['tag'] ) && $field_value['tag'] ? $field_value['tag'] : $field_key,
|
151 |
-
'name' => $field_key,
|
152 |
-
'value' => maybe_unserialize( $value_field_value ),
|
153 |
-
'prefix' => '',
|
154 |
-
);
|
155 |
-
}
|
156 |
-
}
|
157 |
-
} else {
|
158 |
-
$lead_fields[ $field_key ] = array(
|
159 |
-
'type' => 'text',
|
160 |
-
'placeholder' => '',
|
161 |
-
'value' => $value,
|
162 |
-
'label' => isset( $field_value['tag'] ) && $field_value['tag'] ? $field_value['tag'] : $field_key,
|
163 |
-
'name' => $field_key,
|
164 |
-
'prefix' => '',
|
165 |
-
);
|
166 |
-
}
|
167 |
-
}
|
168 |
-
} else {
|
169 |
-
foreach ( $custom_meta_fields as $field_key => $field_value ) {
|
170 |
-
$value = maybe_unserialize( $field_value[0] );
|
171 |
-
if ( is_array( $value ) ) {
|
172 |
-
foreach ( $value as $value_field_key => $value_field_value ) {
|
173 |
-
$lead_fields[ $field_key . '-' . $value_field_key ] = array(
|
174 |
-
'type' => 'text',
|
175 |
-
'placeholder' => '',
|
176 |
-
'label' => $field_key,
|
177 |
-
'name' => $field_key,
|
178 |
-
'value' => maybe_unserialize( $value_field_value ),
|
179 |
-
'prefix' => '',
|
180 |
-
);
|
181 |
-
}
|
182 |
-
} else {
|
183 |
-
$lead_fields[ $field_key ] = array(
|
184 |
-
'type' => 'text',
|
185 |
-
'placeholder' => '',
|
186 |
-
'value' => $value,
|
187 |
-
'label' => $field_key,
|
188 |
-
'name' => $field_key,
|
189 |
-
'prefix' => '',
|
190 |
-
);
|
191 |
-
}
|
192 |
-
}
|
193 |
-
}
|
194 |
-
|
195 |
-
return apply_filters( 'wpcf7r_fields' , $lead_fields );
|
196 |
-
}
|
197 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Lead - Container class that handles lead
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
class WPCF7R_Lead {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Create an instance
|
12 |
+
* Save the post id and post reference
|
13 |
+
*
|
14 |
+
* @param string $post_id
|
15 |
+
*/
|
16 |
+
public function __construct( $post_id = '' ) {
|
17 |
+
if ( is_object( $post_id ) ) {
|
18 |
+
$this->post_id = $post_id->ID;
|
19 |
+
$this->post = $post_id;
|
20 |
+
} else {
|
21 |
+
$this->post_id = $post_id;
|
22 |
+
$this->post = $post_id;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Update submitted form data
|
28 |
+
*
|
29 |
+
* @param array $args
|
30 |
+
*/
|
31 |
+
public function update_lead_data( $args = array() ) {
|
32 |
+
if ( $args ) {
|
33 |
+
foreach ( $args as $meta_key => $meta_value ) {
|
34 |
+
update_post_meta( $this->post_id, $meta_key, $meta_value );
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Return the lead ID
|
41 |
+
*/
|
42 |
+
public function get_id() {
|
43 |
+
return $this->post_id;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Get the post title
|
48 |
+
*/
|
49 |
+
public function get_title() {
|
50 |
+
return get_the_title( $this->get_id() );
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Update the type of lead
|
55 |
+
*
|
56 |
+
* @param $lead_type
|
57 |
+
*/
|
58 |
+
public function update_lead_type( $lead_type ) {
|
59 |
+
update_post_meta( $this->post_id, 'lead_type', $lead_type );
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Save the action reference and results
|
64 |
+
* @param $action_id
|
65 |
+
* @param $action_type
|
66 |
+
* @param $action_results
|
67 |
+
*/
|
68 |
+
public function add_action_debug( $action_id, $action_type, $action_results ) {
|
69 |
+
$action_details = array(
|
70 |
+
'action_id' => $action_id,
|
71 |
+
'results' => $action_results,
|
72 |
+
);
|
73 |
+
add_post_meta( $this->post_id, $action_type, $action_details );
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Get the creation post of the lead
|
78 |
+
*/
|
79 |
+
public function get_date() {
|
80 |
+
return get_the_date( get_option( 'date_format' ), $this->post_id );
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Get the creation post of the lead
|
85 |
+
*/
|
86 |
+
public function get_time() {
|
87 |
+
return get_the_date( get_option( 'time_format' ), $this->post_id );
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Get the lead type
|
92 |
+
*/
|
93 |
+
public function get_lead_type() {
|
94 |
+
return get_post_meta( $this->post_id, 'lead_type', true );
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Save the user submitted files
|
99 |
+
*
|
100 |
+
* @return void
|
101 |
+
*/
|
102 |
+
public function update_lead_files( $files ) {
|
103 |
+
update_post_meta( $this->post_id, 'files', $files );
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Get lead fields
|
108 |
+
*/
|
109 |
+
public function get_lead_fields() {
|
110 |
+
$action_id = get_post_meta( $this->post_id, 'cf7_action_id', true );
|
111 |
+
|
112 |
+
$custom_meta_fields = get_post_custom( $this->post_id );
|
113 |
+
$lead_fields = array();
|
114 |
+
|
115 |
+
$action = WPCF7R_Action::get_action( (int) $action_id );
|
116 |
+
|
117 |
+
if ( $action_id && $action ) {
|
118 |
+
|
119 |
+
$fields = maybe_unserialize( $action->get( 'leads_map' ) );
|
120 |
+
|
121 |
+
foreach ( $fields as $field_key => $field_value ) {
|
122 |
+
if ( 'lead_id' === $field_key ) {
|
123 |
+
continue;
|
124 |
+
} else {
|
125 |
+
if ( isset( $custom_meta_fields[ $field_key ] ) ) {
|
126 |
+
$value = maybe_unserialize( $custom_meta_fields[ $field_key ][0] );
|
127 |
+
} elseif ( isset( $custom_meta_fields['files'] ) && $custom_meta_fields['files'] ) {
|
128 |
+
$value = maybe_unserialize( $custom_meta_fields['files'][0] );
|
129 |
+
$value = isset( $value[ $field_key ] ) && $value[ $field_key ] ? $value[ $field_key ] : '';
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
if ( is_array( $value ) ) {
|
134 |
+
if ( isset( $value['path'] ) ) {
|
135 |
+
$lead_fields[ $field_key ] = array(
|
136 |
+
'type' => 'download',
|
137 |
+
'placeholder' => '',
|
138 |
+
'value' => $value['base64_file'],
|
139 |
+
'filetype' => $value['type'],
|
140 |
+
'filename' => $value['name'],
|
141 |
+
'label' => isset( $field_value['tag'] ) && $field_value['tag'] ? $field_value['tag'] : __( 'File', 'wpcf7-redirect' ),
|
142 |
+
'name' => $field_key,
|
143 |
+
'prefix' => '',
|
144 |
+
);
|
145 |
+
} else {
|
146 |
+
foreach ( $value as $value_field_key => $value_field_value ) {
|
147 |
+
$lead_fields[ $field_key . '-' . $value_field_key ] = array(
|
148 |
+
'type' => 'text',
|
149 |
+
'placeholder' => '',
|
150 |
+
'label' => isset( $field_value['tag'] ) && $field_value['tag'] ? $field_value['tag'] : $field_key,
|
151 |
+
'name' => $field_key,
|
152 |
+
'value' => maybe_unserialize( $value_field_value ),
|
153 |
+
'prefix' => '',
|
154 |
+
);
|
155 |
+
}
|
156 |
+
}
|
157 |
+
} else {
|
158 |
+
$lead_fields[ $field_key ] = array(
|
159 |
+
'type' => 'text',
|
160 |
+
'placeholder' => '',
|
161 |
+
'value' => $value,
|
162 |
+
'label' => isset( $field_value['tag'] ) && $field_value['tag'] ? $field_value['tag'] : $field_key,
|
163 |
+
'name' => $field_key,
|
164 |
+
'prefix' => '',
|
165 |
+
);
|
166 |
+
}
|
167 |
+
}
|
168 |
+
} else {
|
169 |
+
foreach ( $custom_meta_fields as $field_key => $field_value ) {
|
170 |
+
$value = maybe_unserialize( $field_value[0] );
|
171 |
+
if ( is_array( $value ) ) {
|
172 |
+
foreach ( $value as $value_field_key => $value_field_value ) {
|
173 |
+
$lead_fields[ $field_key . '-' . $value_field_key ] = array(
|
174 |
+
'type' => 'text',
|
175 |
+
'placeholder' => '',
|
176 |
+
'label' => $field_key,
|
177 |
+
'name' => $field_key,
|
178 |
+
'value' => maybe_unserialize( $value_field_value ),
|
179 |
+
'prefix' => '',
|
180 |
+
);
|
181 |
+
}
|
182 |
+
} else {
|
183 |
+
$lead_fields[ $field_key ] = array(
|
184 |
+
'type' => 'text',
|
185 |
+
'placeholder' => '',
|
186 |
+
'value' => $value,
|
187 |
+
'label' => $field_key,
|
188 |
+
'name' => $field_key,
|
189 |
+
'prefix' => '',
|
190 |
+
);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
return apply_filters( 'wpcf7r_fields' , $lead_fields );
|
196 |
+
}
|
197 |
+
}
|
classes/class-wpcf7r-leads-manager.php
CHANGED
@@ -1,422 +1,422 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Leads_Manager - Container class that handles leads management
|
4 |
-
*/
|
5 |
-
defined( 'ABSPATH' ) || exit;
|
6 |
-
|
7 |
-
class WPCF7R_Leads_Manager {
|
8 |
-
/**
|
9 |
-
* Save a reference to the last lead inserted to the DB
|
10 |
-
*/
|
11 |
-
public static $new_lead_id;
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Define the leads post type
|
15 |
-
*
|
16 |
-
* @var string $cf7_id - contact form id.
|
17 |
-
*/
|
18 |
-
public static $post_type = 'wpcf7r_leads';
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Main leads manager initializaition.
|
22 |
-
*
|
23 |
-
* @param [string] $cf7_id - contact form id.
|
24 |
-
*/
|
25 |
-
public function __construct( $cf7_id ) {
|
26 |
-
$this->cf7_id = $cf7_id;
|
27 |
-
|
28 |
-
$this->leads = array();
|
29 |
-
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Admin init hook.
|
34 |
-
*
|
35 |
-
* @return void
|
36 |
-
*/
|
37 |
-
public static function admin_init_scripts() {
|
38 |
-
add_filter( 'manage_wpcf7r_leads_posts_columns', array( 'WPCF7R_Leads_Manager', 'set_custom_edit_wpcf7r_leads_columns' ) );
|
39 |
-
add_action( 'manage_wpcf7r_leads_posts_custom_column', array( 'WPCF7R_Leads_Manager', 'custom_wpcf7r_leads_column' ), 10, 2 );
|
40 |
-
add_action( 'manage_posts_extra_tablenav', array( 'WPCF7R_Leads_Manager', 'display_export_button' ), 10, 2 );
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Display custom post type columns on edit list.
|
45 |
-
*
|
46 |
-
* @param [type] $column - the key of the column.
|
47 |
-
* @param [int] $post_id - the lead id.
|
48 |
-
* @return void
|
49 |
-
*/
|
50 |
-
public static function custom_wpcf7r_leads_column( $column, $lead_id ) {
|
51 |
-
$action_id = get_post_meta( $lead_id, 'cf7_action_id', true );
|
52 |
-
|
53 |
-
$action = WPCF7R_Action::get_action( (int) $action_id );
|
54 |
-
|
55 |
-
if ( $action ) {
|
56 |
-
$action->display_action_column_content( $column, $lead_id );
|
57 |
-
} else {
|
58 |
-
switch ( $column ) {
|
59 |
-
case 'data_preview':
|
60 |
-
echo __( 'Preview is not available: action does not exist', 'wpcf7-redirect' );
|
61 |
-
break;
|
62 |
-
case 'form':
|
63 |
-
$form_id = get_post_meta( $lead_id, 'cf7_form', true );
|
64 |
-
echo WPCF7r_Form_Helper::get_cf7_link_html( $form_id );
|
65 |
-
break;
|
66 |
-
}
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Adds an export button on the edit post list.
|
72 |
-
*
|
73 |
-
* @param [type] $which
|
74 |
-
* @return void
|
75 |
-
*/
|
76 |
-
public static function display_export_button( $which ) {
|
77 |
-
global $typenow;
|
78 |
-
|
79 |
-
if ( self::get_post_type() === $typenow && 'top' === $which ) {
|
80 |
-
?>
|
81 |
-
<input type="submit" name="export_leads" class="button button-primary" value="<?php _e( 'Export' ); ?>" />
|
82 |
-
<?php
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Export the current filtered list.
|
88 |
-
*
|
89 |
-
* @return void
|
90 |
-
*/
|
91 |
-
public static function export_current_filtered_view() {
|
92 |
-
|
93 |
-
if ( isset( $_GET['export_leads'] ) ) {
|
94 |
-
$meta_query = array();
|
95 |
-
|
96 |
-
$args = array(
|
97 |
-
'post_type' => self::get_post_type(),
|
98 |
-
'post_status' => 'any',
|
99 |
-
'posts_per_page' => -1,
|
100 |
-
);
|
101 |
-
|
102 |
-
if ( isset( $_GET['cf7_form'] ) && $_GET['cf7_form'] ) {
|
103 |
-
$meta_query[] = array(
|
104 |
-
'key' => 'cf7_form',
|
105 |
-
'value' => (int) $_GET['cf7_form'],
|
106 |
-
);
|
107 |
-
}
|
108 |
-
|
109 |
-
if ( isset( $_GET['m'] ) && $_GET['m'] ) {
|
110 |
-
|
111 |
-
$month = substr( $_GET['m'], 4, 2 );
|
112 |
-
$year = substr( $_GET['m'], 0, 4 );
|
113 |
-
|
114 |
-
$args['date_query'] = array(
|
115 |
-
array(
|
116 |
-
'year' => $year,
|
117 |
-
'month' => $month,
|
118 |
-
),
|
119 |
-
);
|
120 |
-
}
|
121 |
-
|
122 |
-
if ( $meta_query ) {
|
123 |
-
$args['meta_query'] = $meta_query;
|
124 |
-
}
|
125 |
-
|
126 |
-
$arr_post = get_posts( $args );
|
127 |
-
|
128 |
-
$forms = array();
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Order leads by form.
|
132 |
-
* Because the forms are dynamic we create diffrent headers for each form.
|
133 |
-
*/
|
134 |
-
foreach ( $arr_post as $lead ) {
|
135 |
-
$form_id = get_post_meta( $lead->ID, 'cf7_form', true );
|
136 |
-
|
137 |
-
$custom_fields = get_post_custom( $lead->ID );
|
138 |
-
|
139 |
-
foreach ( $custom_fields as $custom_field_key => $custom_field_value ) {
|
140 |
-
$value = maybe_unserialize( reset( $custom_field_value ) );
|
141 |
-
|
142 |
-
if ( ! is_array( $value ) && '_' !== substr( $custom_field_key, 0, 1 ) ) {
|
143 |
-
$forms[ $form_id ]['leads'][ $lead->ID ][ $custom_field_key ] = $value;
|
144 |
-
$forms[ $form_id ]['headers'][ $custom_field_key ] = $custom_field_key;
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
$forms[ $form_id ]['leads'][ $lead->ID ]['form_name'] = get_the_title( $form_id ) ? get_the_title( $form_id ) : __( 'Form does not exist', 'wpcf7-redirect' );
|
149 |
-
$forms[ $form_id ]['leads'][ $lead->ID ]['form_id'] = $form_id;
|
150 |
-
$forms[ $form_id ]['leads'][ $lead->ID ]['record_date'] = get_the_date( 'Y-m-d H:i', $lead->ID );
|
151 |
-
}
|
152 |
-
|
153 |
-
if ( $forms ) {
|
154 |
-
|
155 |
-
header( 'Content-type: text/csv' );
|
156 |
-
header( 'Content-Disposition: attachment; filename="wp-leads.csv"' );
|
157 |
-
header( 'Pragma: no-cache' );
|
158 |
-
header( 'Expires: 0' );
|
159 |
-
|
160 |
-
$file = fopen( 'php://output', 'w' );
|
161 |
-
|
162 |
-
// Print UTF8 encoding.
|
163 |
-
fprintf( $file, chr( 0xEF ) . chr( 0xBB ) . chr( 0xBF ) );
|
164 |
-
|
165 |
-
foreach ( $forms as $form_id => $form ) {
|
166 |
-
// Add default headers.
|
167 |
-
$form['headers']['form_name'] = 'form_name';
|
168 |
-
$form['headers']['form_id'] = 'form_id';
|
169 |
-
$form['headers']['record_date'] = 'record_date';
|
170 |
-
|
171 |
-
// Print headers.
|
172 |
-
fputcsv( $file, $form['headers'] );
|
173 |
-
|
174 |
-
foreach ( $form['leads'] as $lead ) {
|
175 |
-
$values_to_print = array();
|
176 |
-
|
177 |
-
foreach ( $form['headers'] as $header_key ) {
|
178 |
-
$values_to_print[ $header_key ] = isset( $lead[ $header_key ] ) ? $lead[ $header_key ] : '';
|
179 |
-
}
|
180 |
-
|
181 |
-
fputcsv( $file, $values_to_print );
|
182 |
-
}
|
183 |
-
|
184 |
-
fputcsv( $file, array() );
|
185 |
-
}
|
186 |
-
|
187 |
-
exit();
|
188 |
-
}
|
189 |
-
}
|
190 |
-
}
|
191 |
-
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Undocumented function
|
195 |
-
*
|
196 |
-
* @param [array] $columns - list of columns.
|
197 |
-
* @return [array] - the key of the column.
|
198 |
-
*/
|
199 |
-
public static function set_custom_edit_wpcf7r_leads_columns( $columns ) {
|
200 |
-
|
201 |
-
$columns['form'] = __( 'Form', 'wpcf7-redirect' );
|
202 |
-
$columns['data_preview'] = __( 'Preview', 'wpcf7-redirect' );
|
203 |
-
|
204 |
-
return $columns;
|
205 |
-
}
|
206 |
-
/**
|
207 |
-
* Get the leads post type
|
208 |
-
*/
|
209 |
-
public static function get_post_type() {
|
210 |
-
return self::$post_type;
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* Add A select filter on edit.php screen to filter records by form
|
215 |
-
*/
|
216 |
-
public static function add_form_filter() {
|
217 |
-
|
218 |
-
$post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : '';
|
219 |
-
|
220 |
-
if ( $post_type && self::get_post_type() === $post_type ) {
|
221 |
-
$values = array();
|
222 |
-
|
223 |
-
$forms = get_posts(
|
224 |
-
array(
|
225 |
-
'post_status' => 'any',
|
226 |
-
'posts_per_page' => -1,
|
227 |
-
'post_type' => 'wpcf7_contact_form',
|
228 |
-
)
|
229 |
-
);
|
230 |
-
|
231 |
-
foreach ( $forms as $form ) :
|
232 |
-
$values[ $form->post_title ] = $form->ID;
|
233 |
-
endforeach;
|
234 |
-
|
235 |
-
?>
|
236 |
-
|
237 |
-
<select name="cf7_form">
|
238 |
-
<option value=""><?php _e( 'Form', 'wpcf7-redirect' ); ?></option>
|
239 |
-
<?php
|
240 |
-
$current_v = isset( $_GET['cf7_form'] ) ? (int) $_GET['cf7_form'] : '';
|
241 |
-
|
242 |
-
foreach ( $values as $label => $value ) {
|
243 |
-
printf(
|
244 |
-
'<option value="%s"%s>%s</option>',
|
245 |
-
$value,
|
246 |
-
$value === $current_v ? ' selected="selected"' : '',
|
247 |
-
$label
|
248 |
-
);
|
249 |
-
}
|
250 |
-
?>
|
251 |
-
</select>
|
252 |
-
<?php
|
253 |
-
}
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Search by filters
|
258 |
-
*
|
259 |
-
* @param [object] $query - WP_Query object.
|
260 |
-
* @return [object] - WP_Query.
|
261 |
-
*/
|
262 |
-
public static function filter_request_query( $query ) {
|
263 |
-
// modify the query only if it admin and main query.
|
264 |
-
if ( ! ( is_admin() && $query->is_main_query() ) ) {
|
265 |
-
return $query;
|
266 |
-
}
|
267 |
-
|
268 |
-
// we want to modify the query for the targeted custom post and filter option.
|
269 |
-
if ( ! isset( $query->query['post_type'] ) || ( ! ( self::get_post_type() === $query->query['post_type'] && isset( $_REQUEST['cf7_form'] ) ) ) ) {
|
270 |
-
return $query;
|
271 |
-
}
|
272 |
-
|
273 |
-
// for the default value of our filter no modification is required.
|
274 |
-
if ( 0 === (int) $_REQUEST['cf7_form'] ) {
|
275 |
-
return $query;
|
276 |
-
}
|
277 |
-
|
278 |
-
// modify the query_vars.
|
279 |
-
$posted_value = isset( $_REQUEST['cf7_form'] ) && (int) $_REQUEST['cf7_form'] ? (int) $_REQUEST['cf7_form'] : '';
|
280 |
-
|
281 |
-
$meta_query = $query->get( 'meta_query' );
|
282 |
-
|
283 |
-
if ( ! $meta_query ) {
|
284 |
-
$meta_query = array();
|
285 |
-
}
|
286 |
-
|
287 |
-
$meta_query[] = array(
|
288 |
-
array(
|
289 |
-
'key' => 'cf7_form',
|
290 |
-
'value' => $posted_value,
|
291 |
-
'compare' => '=',
|
292 |
-
),
|
293 |
-
);
|
294 |
-
|
295 |
-
$query->set( 'meta_query', $meta_query );
|
296 |
-
|
297 |
-
return $query;
|
298 |
-
}
|
299 |
-
|
300 |
-
/**
|
301 |
-
* Initialize leads table tab
|
302 |
-
*/
|
303 |
-
public function init() {
|
304 |
-
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'leads . php';
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* Get the url to the admin post type list
|
309 |
-
* Auto filter by selected action
|
310 |
-
*
|
311 |
-
* @param [int] $form_id - the contact form id.
|
312 |
-
* @return [string] - the new url.
|
313 |
-
*/
|
314 |
-
public static function get_admin_url( $form_id ) {
|
315 |
-
$url = admin_url( 'edit.php?post_type=' . self::get_post_type() );
|
316 |
-
|
317 |
-
return add_query_arg( 'cf7_form', $form_id, $url );
|
318 |
-
}
|
319 |
-
|
320 |
-
/**
|
321 |
-
* Get leads
|
322 |
-
*/
|
323 |
-
public function get_leads() {
|
324 |
-
$args = array(
|
325 |
-
'post_type' => self::get_post_type(),
|
326 |
-
'post_status' => 'private',
|
327 |
-
'posts_per_page' => 20,
|
328 |
-
'meta_query' => array(
|
329 |
-
array(
|
330 |
-
'key' => 'cf7_form',
|
331 |
-
'value' => $this->cf7_id,
|
332 |
-
),
|
333 |
-
),
|
334 |
-
);
|
335 |
-
|
336 |
-
$leads_posts = get_posts( $args );
|
337 |
-
|
338 |
-
if ( $leads_posts ) {
|
339 |
-
foreach ( $leads_posts as $leads_post ) {
|
340 |
-
$lead = new WPCF7R_Lead( $leads_post );
|
341 |
-
|
342 |
-
$this->leads[] = $lead;
|
343 |
-
}
|
344 |
-
}
|
345 |
-
|
346 |
-
return $this->leads;
|
347 |
-
}
|
348 |
-
|
349 |
-
/**
|
350 |
-
* Insert new lead
|
351 |
-
*/
|
352 |
-
public static function insert_lead( $cf7_form_id, $args, $files = array(), $lead_type, $action_id ) {
|
353 |
-
$args['cf7_form'] = $cf7_form_id;
|
354 |
-
$args['cf7_action_id'] = $action_id;
|
355 |
-
|
356 |
-
$contact_form_title = get_the_title( $cf7_form_id );
|
357 |
-
|
358 |
-
$new_post = array(
|
359 |
-
'post_type' => self::get_post_type(),
|
360 |
-
'post_status' => 'private',
|
361 |
-
'post_title' => __( 'Lead from contact form: ', 'wpcf7-redirect' ) . $contact_form_title,
|
362 |
-
);
|
363 |
-
|
364 |
-
self::$new_lead_id = wp_insert_post( $new_post );
|
365 |
-
|
366 |
-
$lead = new WPCF7R_Lead( self::$new_lead_id );
|
367 |
-
|
368 |
-
$lead->update_lead_data( $args );
|
369 |
-
|
370 |
-
$lead->update_lead_files( $files );
|
371 |
-
|
372 |
-
$lead->update_lead_type( $lead_type );
|
373 |
-
|
374 |
-
return $lead;
|
375 |
-
}
|
376 |
-
|
377 |
-
/**
|
378 |
-
* Save the action to the db lead
|
379 |
-
*
|
380 |
-
* @param $lead_id
|
381 |
-
* @param $action_name
|
382 |
-
* @param $details
|
383 |
-
*/
|
384 |
-
public static function save_action( $lead_id, $action_name, $details ) {
|
385 |
-
add_post_meta( $lead_id, 'action - ' . $action_name, $details );
|
386 |
-
}
|
387 |
-
|
388 |
-
/**
|
389 |
-
* Get a single action row
|
390 |
-
*/
|
391 |
-
public function get_lead_row( $lead ) {
|
392 |
-
ob_start();
|
393 |
-
do_action( 'before_wpcf7r_lead_row', $this );
|
394 |
-
?>
|
395 |
-
|
396 |
-
<tr class="primary" data-postid="<?php echo $lead->get_id(); ?>">
|
397 |
-
<td class="manage-column column-primary sortable desc edit column-id">
|
398 |
-
<?php echo $lead->get_id(); ?>
|
399 |
-
<div class="row-actions">
|
400 |
-
<span class="edit">
|
401 |
-
<a href="<?php echo get_edit_post_link( $lead->get_id() ); ?>" data-id="<?php echo $lead->get_id(); ?>" aria-label="<?php _e( 'View', 'wpcf7-redirect' ); ?>" target="_blank"><?php _e( 'View', 'wpcf7-redirect' ); ?></a> |
|
402 |
-
</span>
|
403 |
-
<span class="trash">
|
404 |
-
<a href="#" class="submitdelete" data-id="<?php echo $lead->get_id(); ?>" aria-label="<?php _e( 'Move to trash', 'wpcf7-redirect' ); ?>"><?php _e( 'Move to trash', 'wpcf7-redirect' ); ?></a> |
|
405 |
-
</span>
|
406 |
-
<?php do_action( 'wpcf7r_after_lead_links', $lead ); ?>
|
407 |
-
</div>
|
408 |
-
</td>
|
409 |
-
<td class="manage-column column-primary sortable desc edit column-date">
|
410 |
-
<?php echo $lead->get_date(); ?>
|
411 |
-
</td>
|
412 |
-
<td class="manage-column column-primary sortable desc edit column-time"><?php echo $lead->get_time(); ?></td>
|
413 |
-
<td class="manage-column column-primary sortable desc edit column-type"><?php echo $lead->get_lead_type(); ?></td>
|
414 |
-
<td></td>
|
415 |
-
</tr>
|
416 |
-
|
417 |
-
<?php
|
418 |
-
do_action( 'after_wpcf7r_lead_row', $this );
|
419 |
-
|
420 |
-
return apply_filters( 'wpcf7r_get_lead_row', ob_get_clean(), $this );
|
421 |
-
}
|
422 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Leads_Manager - Container class that handles leads management
|
4 |
+
*/
|
5 |
+
defined( 'ABSPATH' ) || exit;
|
6 |
+
|
7 |
+
class WPCF7R_Leads_Manager {
|
8 |
+
/**
|
9 |
+
* Save a reference to the last lead inserted to the DB
|
10 |
+
*/
|
11 |
+
public static $new_lead_id;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Define the leads post type
|
15 |
+
*
|
16 |
+
* @var string $cf7_id - contact form id.
|
17 |
+
*/
|
18 |
+
public static $post_type = 'wpcf7r_leads';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Main leads manager initializaition.
|
22 |
+
*
|
23 |
+
* @param [string] $cf7_id - contact form id.
|
24 |
+
*/
|
25 |
+
public function __construct( $cf7_id ) {
|
26 |
+
$this->cf7_id = $cf7_id;
|
27 |
+
|
28 |
+
$this->leads = array();
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Admin init hook.
|
34 |
+
*
|
35 |
+
* @return void
|
36 |
+
*/
|
37 |
+
public static function admin_init_scripts() {
|
38 |
+
add_filter( 'manage_wpcf7r_leads_posts_columns', array( 'WPCF7R_Leads_Manager', 'set_custom_edit_wpcf7r_leads_columns' ) );
|
39 |
+
add_action( 'manage_wpcf7r_leads_posts_custom_column', array( 'WPCF7R_Leads_Manager', 'custom_wpcf7r_leads_column' ), 10, 2 );
|
40 |
+
add_action( 'manage_posts_extra_tablenav', array( 'WPCF7R_Leads_Manager', 'display_export_button' ), 10, 2 );
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Display custom post type columns on edit list.
|
45 |
+
*
|
46 |
+
* @param [type] $column - the key of the column.
|
47 |
+
* @param [int] $post_id - the lead id.
|
48 |
+
* @return void
|
49 |
+
*/
|
50 |
+
public static function custom_wpcf7r_leads_column( $column, $lead_id ) {
|
51 |
+
$action_id = get_post_meta( $lead_id, 'cf7_action_id', true );
|
52 |
+
|
53 |
+
$action = WPCF7R_Action::get_action( (int) $action_id );
|
54 |
+
|
55 |
+
if ( $action && method_exists( $action, 'display_action_column_content' ) ) {
|
56 |
+
$action->display_action_column_content( $column, $lead_id );
|
57 |
+
} else {
|
58 |
+
switch ( $column ) {
|
59 |
+
case 'data_preview':
|
60 |
+
echo __( 'Preview is not available: save lead action does not exist', 'wpcf7-redirect' );
|
61 |
+
break;
|
62 |
+
case 'form':
|
63 |
+
$form_id = get_post_meta( $lead_id, 'cf7_form', true );
|
64 |
+
echo WPCF7r_Form_Helper::get_cf7_link_html( $form_id );
|
65 |
+
break;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Adds an export button on the edit post list.
|
72 |
+
*
|
73 |
+
* @param [type] $which
|
74 |
+
* @return void
|
75 |
+
*/
|
76 |
+
public static function display_export_button( $which ) {
|
77 |
+
global $typenow;
|
78 |
+
|
79 |
+
if ( self::get_post_type() === $typenow && 'top' === $which ) {
|
80 |
+
?>
|
81 |
+
<input type="submit" name="export_leads" class="button button-primary" value="<?php _e( 'Export' ); ?>" />
|
82 |
+
<?php
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Export the current filtered list.
|
88 |
+
*
|
89 |
+
* @return void
|
90 |
+
*/
|
91 |
+
public static function export_current_filtered_view() {
|
92 |
+
|
93 |
+
if ( isset( $_GET['export_leads'] ) ) {
|
94 |
+
$meta_query = array();
|
95 |
+
|
96 |
+
$args = array(
|
97 |
+
'post_type' => self::get_post_type(),
|
98 |
+
'post_status' => 'any',
|
99 |
+
'posts_per_page' => -1,
|
100 |
+
);
|
101 |
+
|
102 |
+
if ( isset( $_GET['cf7_form'] ) && $_GET['cf7_form'] ) {
|
103 |
+
$meta_query[] = array(
|
104 |
+
'key' => 'cf7_form',
|
105 |
+
'value' => (int) $_GET['cf7_form'],
|
106 |
+
);
|
107 |
+
}
|
108 |
+
|
109 |
+
if ( isset( $_GET['m'] ) && $_GET['m'] ) {
|
110 |
+
|
111 |
+
$month = substr( $_GET['m'], 4, 2 );
|
112 |
+
$year = substr( $_GET['m'], 0, 4 );
|
113 |
+
|
114 |
+
$args['date_query'] = array(
|
115 |
+
array(
|
116 |
+
'year' => $year,
|
117 |
+
'month' => $month,
|
118 |
+
),
|
119 |
+
);
|
120 |
+
}
|
121 |
+
|
122 |
+
if ( $meta_query ) {
|
123 |
+
$args['meta_query'] = $meta_query;
|
124 |
+
}
|
125 |
+
|
126 |
+
$arr_post = get_posts( $args );
|
127 |
+
|
128 |
+
$forms = array();
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Order leads by form.
|
132 |
+
* Because the forms are dynamic we create diffrent headers for each form.
|
133 |
+
*/
|
134 |
+
foreach ( $arr_post as $lead ) {
|
135 |
+
$form_id = get_post_meta( $lead->ID, 'cf7_form', true );
|
136 |
+
|
137 |
+
$custom_fields = get_post_custom( $lead->ID );
|
138 |
+
|
139 |
+
foreach ( $custom_fields as $custom_field_key => $custom_field_value ) {
|
140 |
+
$value = maybe_unserialize( reset( $custom_field_value ) );
|
141 |
+
|
142 |
+
if ( ! is_array( $value ) && '_' !== substr( $custom_field_key, 0, 1 ) ) {
|
143 |
+
$forms[ $form_id ]['leads'][ $lead->ID ][ $custom_field_key ] = $value;
|
144 |
+
$forms[ $form_id ]['headers'][ $custom_field_key ] = $custom_field_key;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
$forms[ $form_id ]['leads'][ $lead->ID ]['form_name'] = get_the_title( $form_id ) ? get_the_title( $form_id ) : __( 'Form does not exist', 'wpcf7-redirect' );
|
149 |
+
$forms[ $form_id ]['leads'][ $lead->ID ]['form_id'] = $form_id;
|
150 |
+
$forms[ $form_id ]['leads'][ $lead->ID ]['record_date'] = get_the_date( 'Y-m-d H:i', $lead->ID );
|
151 |
+
}
|
152 |
+
|
153 |
+
if ( $forms ) {
|
154 |
+
|
155 |
+
header( 'Content-type: text/csv' );
|
156 |
+
header( 'Content-Disposition: attachment; filename="wp-leads.csv"' );
|
157 |
+
header( 'Pragma: no-cache' );
|
158 |
+
header( 'Expires: 0' );
|
159 |
+
|
160 |
+
$file = fopen( 'php://output', 'w' );
|
161 |
+
|
162 |
+
// Print UTF8 encoding.
|
163 |
+
fprintf( $file, chr( 0xEF ) . chr( 0xBB ) . chr( 0xBF ) );
|
164 |
+
|
165 |
+
foreach ( $forms as $form_id => $form ) {
|
166 |
+
// Add default headers.
|
167 |
+
$form['headers']['form_name'] = 'form_name';
|
168 |
+
$form['headers']['form_id'] = 'form_id';
|
169 |
+
$form['headers']['record_date'] = 'record_date';
|
170 |
+
|
171 |
+
// Print headers.
|
172 |
+
fputcsv( $file, $form['headers'] );
|
173 |
+
|
174 |
+
foreach ( $form['leads'] as $lead ) {
|
175 |
+
$values_to_print = array();
|
176 |
+
|
177 |
+
foreach ( $form['headers'] as $header_key ) {
|
178 |
+
$values_to_print[ $header_key ] = isset( $lead[ $header_key ] ) ? $lead[ $header_key ] : '';
|
179 |
+
}
|
180 |
+
|
181 |
+
fputcsv( $file, $values_to_print );
|
182 |
+
}
|
183 |
+
|
184 |
+
fputcsv( $file, array() );
|
185 |
+
}
|
186 |
+
|
187 |
+
exit();
|
188 |
+
}
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Undocumented function
|
195 |
+
*
|
196 |
+
* @param [array] $columns - list of columns.
|
197 |
+
* @return [array] - the key of the column.
|
198 |
+
*/
|
199 |
+
public static function set_custom_edit_wpcf7r_leads_columns( $columns ) {
|
200 |
+
|
201 |
+
$columns['form'] = __( 'Form', 'wpcf7-redirect' );
|
202 |
+
$columns['data_preview'] = __( 'Preview', 'wpcf7-redirect' );
|
203 |
+
|
204 |
+
return $columns;
|
205 |
+
}
|
206 |
+
/**
|
207 |
+
* Get the leads post type
|
208 |
+
*/
|
209 |
+
public static function get_post_type() {
|
210 |
+
return self::$post_type;
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Add A select filter on edit.php screen to filter records by form
|
215 |
+
*/
|
216 |
+
public static function add_form_filter() {
|
217 |
+
|
218 |
+
$post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : '';
|
219 |
+
|
220 |
+
if ( $post_type && self::get_post_type() === $post_type ) {
|
221 |
+
$values = array();
|
222 |
+
|
223 |
+
$forms = get_posts(
|
224 |
+
array(
|
225 |
+
'post_status' => 'any',
|
226 |
+
'posts_per_page' => -1,
|
227 |
+
'post_type' => 'wpcf7_contact_form',
|
228 |
+
)
|
229 |
+
);
|
230 |
+
|
231 |
+
foreach ( $forms as $form ) :
|
232 |
+
$values[ $form->post_title ] = $form->ID;
|
233 |
+
endforeach;
|
234 |
+
|
235 |
+
?>
|
236 |
+
|
237 |
+
<select name="cf7_form">
|
238 |
+
<option value=""><?php _e( 'Form', 'wpcf7-redirect' ); ?></option>
|
239 |
+
<?php
|
240 |
+
$current_v = isset( $_GET['cf7_form'] ) ? (int) $_GET['cf7_form'] : '';
|
241 |
+
|
242 |
+
foreach ( $values as $label => $value ) {
|
243 |
+
printf(
|
244 |
+
'<option value="%s"%s>%s</option>',
|
245 |
+
$value,
|
246 |
+
$value === $current_v ? ' selected="selected"' : '',
|
247 |
+
$label
|
248 |
+
);
|
249 |
+
}
|
250 |
+
?>
|
251 |
+
</select>
|
252 |
+
<?php
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Search by filters
|
258 |
+
*
|
259 |
+
* @param [object] $query - WP_Query object.
|
260 |
+
* @return [object] - WP_Query.
|
261 |
+
*/
|
262 |
+
public static function filter_request_query( $query ) {
|
263 |
+
// modify the query only if it admin and main query.
|
264 |
+
if ( ! ( is_admin() && $query->is_main_query() ) ) {
|
265 |
+
return $query;
|
266 |
+
}
|
267 |
+
|
268 |
+
// we want to modify the query for the targeted custom post and filter option.
|
269 |
+
if ( ! isset( $query->query['post_type'] ) || ( ! ( self::get_post_type() === $query->query['post_type'] && isset( $_REQUEST['cf7_form'] ) ) ) ) {
|
270 |
+
return $query;
|
271 |
+
}
|
272 |
+
|
273 |
+
// for the default value of our filter no modification is required.
|
274 |
+
if ( 0 === (int) $_REQUEST['cf7_form'] ) {
|
275 |
+
return $query;
|
276 |
+
}
|
277 |
+
|
278 |
+
// modify the query_vars.
|
279 |
+
$posted_value = isset( $_REQUEST['cf7_form'] ) && (int) $_REQUEST['cf7_form'] ? (int) $_REQUEST['cf7_form'] : '';
|
280 |
+
|
281 |
+
$meta_query = $query->get( 'meta_query' );
|
282 |
+
|
283 |
+
if ( ! $meta_query ) {
|
284 |
+
$meta_query = array();
|
285 |
+
}
|
286 |
+
|
287 |
+
$meta_query[] = array(
|
288 |
+
array(
|
289 |
+
'key' => 'cf7_form',
|
290 |
+
'value' => $posted_value,
|
291 |
+
'compare' => '=',
|
292 |
+
),
|
293 |
+
);
|
294 |
+
|
295 |
+
$query->set( 'meta_query', $meta_query );
|
296 |
+
|
297 |
+
return $query;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Initialize leads table tab
|
302 |
+
*/
|
303 |
+
public function init() {
|
304 |
+
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'leads . php';
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Get the url to the admin post type list
|
309 |
+
* Auto filter by selected action
|
310 |
+
*
|
311 |
+
* @param [int] $form_id - the contact form id.
|
312 |
+
* @return [string] - the new url.
|
313 |
+
*/
|
314 |
+
public static function get_admin_url( $form_id ) {
|
315 |
+
$url = admin_url( 'edit.php?post_type=' . self::get_post_type() );
|
316 |
+
|
317 |
+
return add_query_arg( 'cf7_form', $form_id, $url );
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Get leads
|
322 |
+
*/
|
323 |
+
public function get_leads() {
|
324 |
+
$args = array(
|
325 |
+
'post_type' => self::get_post_type(),
|
326 |
+
'post_status' => 'private',
|
327 |
+
'posts_per_page' => 20,
|
328 |
+
'meta_query' => array(
|
329 |
+
array(
|
330 |
+
'key' => 'cf7_form',
|
331 |
+
'value' => $this->cf7_id,
|
332 |
+
),
|
333 |
+
),
|
334 |
+
);
|
335 |
+
|
336 |
+
$leads_posts = get_posts( $args );
|
337 |
+
|
338 |
+
if ( $leads_posts ) {
|
339 |
+
foreach ( $leads_posts as $leads_post ) {
|
340 |
+
$lead = new WPCF7R_Lead( $leads_post );
|
341 |
+
|
342 |
+
$this->leads[] = $lead;
|
343 |
+
}
|
344 |
+
}
|
345 |
+
|
346 |
+
return $this->leads;
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Insert new lead
|
351 |
+
*/
|
352 |
+
public static function insert_lead( $cf7_form_id, $args, $files = array(), $lead_type, $action_id ) {
|
353 |
+
$args['cf7_form'] = $cf7_form_id;
|
354 |
+
$args['cf7_action_id'] = $action_id;
|
355 |
+
|
356 |
+
$contact_form_title = get_the_title( $cf7_form_id );
|
357 |
+
|
358 |
+
$new_post = array(
|
359 |
+
'post_type' => self::get_post_type(),
|
360 |
+
'post_status' => 'private',
|
361 |
+
'post_title' => __( 'Lead from contact form: ', 'wpcf7-redirect' ) . $contact_form_title,
|
362 |
+
);
|
363 |
+
|
364 |
+
self::$new_lead_id = wp_insert_post( $new_post );
|
365 |
+
|
366 |
+
$lead = new WPCF7R_Lead( self::$new_lead_id );
|
367 |
+
|
368 |
+
$lead->update_lead_data( $args );
|
369 |
+
|
370 |
+
$lead->update_lead_files( $files );
|
371 |
+
|
372 |
+
$lead->update_lead_type( $lead_type );
|
373 |
+
|
374 |
+
return $lead;
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Save the action to the db lead
|
379 |
+
*
|
380 |
+
* @param $lead_id
|
381 |
+
* @param $action_name
|
382 |
+
* @param $details
|
383 |
+
*/
|
384 |
+
public static function save_action( $lead_id, $action_name, $details ) {
|
385 |
+
add_post_meta( $lead_id, 'action - ' . $action_name, $details );
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Get a single action row
|
390 |
+
*/
|
391 |
+
public function get_lead_row( $lead ) {
|
392 |
+
ob_start();
|
393 |
+
do_action( 'before_wpcf7r_lead_row', $this );
|
394 |
+
?>
|
395 |
+
|
396 |
+
<tr class="primary" data-postid="<?php echo $lead->get_id(); ?>">
|
397 |
+
<td class="manage-column column-primary sortable desc edit column-id">
|
398 |
+
<?php echo $lead->get_id(); ?>
|
399 |
+
<div class="row-actions">
|
400 |
+
<span class="edit">
|
401 |
+
<a href="<?php echo get_edit_post_link( $lead->get_id() ); ?>" data-id="<?php echo $lead->get_id(); ?>" aria-label="<?php _e( 'View', 'wpcf7-redirect' ); ?>" target="_blank"><?php _e( 'View', 'wpcf7-redirect' ); ?></a> |
|
402 |
+
</span>
|
403 |
+
<span class="trash">
|
404 |
+
<a href="#" class="submitdelete" data-id="<?php echo $lead->get_id(); ?>" aria-label="<?php _e( 'Move to trash', 'wpcf7-redirect' ); ?>"><?php _e( 'Move to trash', 'wpcf7-redirect' ); ?></a> |
|
405 |
+
</span>
|
406 |
+
<?php do_action( 'wpcf7r_after_lead_links', $lead ); ?>
|
407 |
+
</div>
|
408 |
+
</td>
|
409 |
+
<td class="manage-column column-primary sortable desc edit column-date">
|
410 |
+
<?php echo $lead->get_date(); ?>
|
411 |
+
</td>
|
412 |
+
<td class="manage-column column-primary sortable desc edit column-time"><?php echo $lead->get_time(); ?></td>
|
413 |
+
<td class="manage-column column-primary sortable desc edit column-type"><?php echo $lead->get_lead_type(); ?></td>
|
414 |
+
<td></td>
|
415 |
+
</tr>
|
416 |
+
|
417 |
+
<?php
|
418 |
+
do_action( 'after_wpcf7r_lead_row', $this );
|
419 |
+
|
420 |
+
return apply_filters( 'wpcf7r_get_lead_row', ob_get_clean(), $this );
|
421 |
+
}
|
422 |
+
}
|
classes/class-wpcf7r-list-table.php
CHANGED
@@ -1,133 +1,133 @@
|
|
1 |
-
<?php
|
2 |
-
defined( 'ABSPATH' ) || exit;
|
3 |
-
|
4 |
-
if ( class_exists( 'WP_List_Table' ) ) {
|
5 |
-
class WPCF7R_List_Table extends WP_List_Table {
|
6 |
-
|
7 |
-
public $list_data = array();
|
8 |
-
/**
|
9 |
-
* Constructor will create the menu item
|
10 |
-
*/
|
11 |
-
public function __construct( $columns, $data ) {
|
12 |
-
|
13 |
-
parent::__construct();
|
14 |
-
|
15 |
-
$this->list_data = $data;
|
16 |
-
|
17 |
-
$this->columns = $columns;
|
18 |
-
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Display the list table page
|
23 |
-
*/
|
24 |
-
public function list_table_page() {
|
25 |
-
|
26 |
-
$this->prepare_items();
|
27 |
-
|
28 |
-
$this->display();
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Prepare the items for the table to process
|
33 |
-
*/
|
34 |
-
public function prepare_items() {
|
35 |
-
$columns = $this->get_columns();
|
36 |
-
$hidden = $this->get_hidden_columns();
|
37 |
-
$sortable = $this->get_sortable_columns();
|
38 |
-
$data = $this->list_data;
|
39 |
-
$per_page = 2;
|
40 |
-
$current_page = $this->get_pagenum();
|
41 |
-
|
42 |
-
usort( $data, array( &$this, 'sort_data' ) );
|
43 |
-
$total_items = count( $data );
|
44 |
-
|
45 |
-
$this->set_pagination_args(
|
46 |
-
array(
|
47 |
-
'total_items' => $total_items,
|
48 |
-
'per_page' => $per_page,
|
49 |
-
)
|
50 |
-
);
|
51 |
-
|
52 |
-
$data = array_slice( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
|
53 |
-
|
54 |
-
$this->_column_headers = array( $columns, $hidden, $sortable );
|
55 |
-
$this->items = $data;
|
56 |
-
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Override the parent columns method. Defines the columns to use in your listing table
|
61 |
-
*/
|
62 |
-
public function get_columns() {
|
63 |
-
return $this->columns;
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Define which columns are hidden
|
68 |
-
*/
|
69 |
-
public function get_hidden_columns() {
|
70 |
-
return array();
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Define the sortable columns
|
75 |
-
*/
|
76 |
-
public function get_sortable_columns() {
|
77 |
-
return array( 'title' => array( 'title', false ) );
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Define what data to show on each column of the table
|
82 |
-
*
|
83 |
-
* @param $item
|
84 |
-
* @param $column_name
|
85 |
-
*/
|
86 |
-
public function column_default( $item, $column_name ) {
|
87 |
-
|
88 |
-
switch ( $column_name ) {
|
89 |
-
case 'id':
|
90 |
-
case 'title':
|
91 |
-
case 'description':
|
92 |
-
case 'year':
|
93 |
-
case 'director':
|
94 |
-
case 'rating':
|
95 |
-
return $item[ $column_name ];
|
96 |
-
|
97 |
-
default:
|
98 |
-
return print_r( $item, true );
|
99 |
-
}
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Allows you to sort the data by the variables set in the $_GET
|
104 |
-
*
|
105 |
-
* @param $a
|
106 |
-
* @param $b
|
107 |
-
*/
|
108 |
-
private function sort_data( $a, $b ) {
|
109 |
-
// Set defaults
|
110 |
-
$orderby = 'title';
|
111 |
-
$order = 'asc';
|
112 |
-
|
113 |
-
// If orderby is set, use this as the sort column
|
114 |
-
if ( ! empty( $_GET['orderby'] ) ) {
|
115 |
-
$orderby = $_GET['orderby'];
|
116 |
-
}
|
117 |
-
|
118 |
-
// If order is set use this as the order
|
119 |
-
if ( ! empty( $_GET['order'] ) ) {
|
120 |
-
$order = $_GET['order'];
|
121 |
-
}
|
122 |
-
|
123 |
-
$result = strcmp( $a[ $orderby ], $b[ $orderby ] );
|
124 |
-
|
125 |
-
if ( 'asc' === $order ) {
|
126 |
-
return $result;
|
127 |
-
}
|
128 |
-
|
129 |
-
return -$result;
|
130 |
-
}
|
131 |
-
}
|
132 |
-
}
|
133 |
-
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit;
|
3 |
+
|
4 |
+
if ( class_exists( 'WP_List_Table' ) ) {
|
5 |
+
class WPCF7R_List_Table extends WP_List_Table {
|
6 |
+
|
7 |
+
public $list_data = array();
|
8 |
+
/**
|
9 |
+
* Constructor will create the menu item
|
10 |
+
*/
|
11 |
+
public function __construct( $columns, $data ) {
|
12 |
+
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
$this->list_data = $data;
|
16 |
+
|
17 |
+
$this->columns = $columns;
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Display the list table page
|
23 |
+
*/
|
24 |
+
public function list_table_page() {
|
25 |
+
|
26 |
+
$this->prepare_items();
|
27 |
+
|
28 |
+
$this->display();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Prepare the items for the table to process
|
33 |
+
*/
|
34 |
+
public function prepare_items() {
|
35 |
+
$columns = $this->get_columns();
|
36 |
+
$hidden = $this->get_hidden_columns();
|
37 |
+
$sortable = $this->get_sortable_columns();
|
38 |
+
$data = $this->list_data;
|
39 |
+
$per_page = 2;
|
40 |
+
$current_page = $this->get_pagenum();
|
41 |
+
|
42 |
+
usort( $data, array( &$this, 'sort_data' ) );
|
43 |
+
$total_items = count( $data );
|
44 |
+
|
45 |
+
$this->set_pagination_args(
|
46 |
+
array(
|
47 |
+
'total_items' => $total_items,
|
48 |
+
'per_page' => $per_page,
|
49 |
+
)
|
50 |
+
);
|
51 |
+
|
52 |
+
$data = array_slice( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
|
53 |
+
|
54 |
+
$this->_column_headers = array( $columns, $hidden, $sortable );
|
55 |
+
$this->items = $data;
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Override the parent columns method. Defines the columns to use in your listing table
|
61 |
+
*/
|
62 |
+
public function get_columns() {
|
63 |
+
return $this->columns;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Define which columns are hidden
|
68 |
+
*/
|
69 |
+
public function get_hidden_columns() {
|
70 |
+
return array();
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Define the sortable columns
|
75 |
+
*/
|
76 |
+
public function get_sortable_columns() {
|
77 |
+
return array( 'title' => array( 'title', false ) );
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Define what data to show on each column of the table
|
82 |
+
*
|
83 |
+
* @param $item
|
84 |
+
* @param $column_name
|
85 |
+
*/
|
86 |
+
public function column_default( $item, $column_name ) {
|
87 |
+
|
88 |
+
switch ( $column_name ) {
|
89 |
+
case 'id':
|
90 |
+
case 'title':
|
91 |
+
case 'description':
|
92 |
+
case 'year':
|
93 |
+
case 'director':
|
94 |
+
case 'rating':
|
95 |
+
return $item[ $column_name ];
|
96 |
+
|
97 |
+
default:
|
98 |
+
return print_r( $item, true );
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Allows you to sort the data by the variables set in the $_GET
|
104 |
+
*
|
105 |
+
* @param $a
|
106 |
+
* @param $b
|
107 |
+
*/
|
108 |
+
private function sort_data( $a, $b ) {
|
109 |
+
// Set defaults
|
110 |
+
$orderby = 'title';
|
111 |
+
$order = 'asc';
|
112 |
+
|
113 |
+
// If orderby is set, use this as the sort column
|
114 |
+
if ( ! empty( $_GET['orderby'] ) ) {
|
115 |
+
$orderby = $_GET['orderby'];
|
116 |
+
}
|
117 |
+
|
118 |
+
// If order is set use this as the order
|
119 |
+
if ( ! empty( $_GET['order'] ) ) {
|
120 |
+
$order = $_GET['order'];
|
121 |
+
}
|
122 |
+
|
123 |
+
$result = strcmp( $a[ $orderby ], $b[ $orderby ] );
|
124 |
+
|
125 |
+
if ( 'asc' === $order ) {
|
126 |
+
return $result;
|
127 |
+
}
|
128 |
+
|
129 |
+
return -$result;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
classes/class-wpcf7r-module.php
CHANGED
@@ -1,77 +1,77 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Module - parent class for all wpcf7r Modules
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
class WPCF7R_Module {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Hold the active modules
|
12 |
-
*
|
13 |
-
* @var [type]
|
14 |
-
*/
|
15 |
-
private static $registered_modules;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* General init function for all child modules
|
19 |
-
*
|
20 |
-
* @return void
|
21 |
-
*/
|
22 |
-
public function init( $module ) {
|
23 |
-
$this->name = $module['name'];
|
24 |
-
$this->title = $module['title'];
|
25 |
-
|
26 |
-
//register global modules actions
|
27 |
-
if ( method_exists( get_class( $this ), 'add_panel' ) ) {
|
28 |
-
add_action( 'wpcf7_editor_panels', array( $this, 'add_panel' ) );
|
29 |
-
}
|
30 |
-
//enqueue required admin scripts or styles
|
31 |
-
if ( method_exists( get_class( $this ), 'enqueue_admin_scripts' ) ) {
|
32 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
|
33 |
-
}
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Add a new module
|
38 |
-
*
|
39 |
-
* @param [string] $name the module name
|
40 |
-
* @param [string] $title the module title
|
41 |
-
* @param [string] $class the name of the module main class
|
42 |
-
* @return void
|
43 |
-
*/
|
44 |
-
public static function register_module( $name, $title, $class ) {
|
45 |
-
self::$registered_modules[ $name ] = array(
|
46 |
-
'name' => $name,
|
47 |
-
'title' => $title,
|
48 |
-
'class' => $class,
|
49 |
-
);
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Initialize all registered modules
|
54 |
-
*
|
55 |
-
* @return void
|
56 |
-
*/
|
57 |
-
public static function init_modules() {
|
58 |
-
if ( self::get_active_modules() ) {
|
59 |
-
foreach ( self::get_active_modules() as $module ) {
|
60 |
-
$class_name = $module['class'];
|
61 |
-
$module_object = new $class_name;
|
62 |
-
|
63 |
-
//create an instance of the loaded module
|
64 |
-
$module_object->init( $module );
|
65 |
-
}
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Return the registered modules array
|
71 |
-
*
|
72 |
-
* @return void
|
73 |
-
*/
|
74 |
-
public static function get_active_modules() {
|
75 |
-
return self::$registered_modules;
|
76 |
-
}
|
77 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Module - parent class for all wpcf7r Modules
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
class WPCF7R_Module {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Hold the active modules
|
12 |
+
*
|
13 |
+
* @var [type]
|
14 |
+
*/
|
15 |
+
private static $registered_modules;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* General init function for all child modules
|
19 |
+
*
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
public function init( $module ) {
|
23 |
+
$this->name = $module['name'];
|
24 |
+
$this->title = $module['title'];
|
25 |
+
|
26 |
+
//register global modules actions
|
27 |
+
if ( method_exists( get_class( $this ), 'add_panel' ) ) {
|
28 |
+
add_action( 'wpcf7_editor_panels', array( $this, 'add_panel' ) );
|
29 |
+
}
|
30 |
+
//enqueue required admin scripts or styles
|
31 |
+
if ( method_exists( get_class( $this ), 'enqueue_admin_scripts' ) ) {
|
32 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Add a new module
|
38 |
+
*
|
39 |
+
* @param [string] $name the module name
|
40 |
+
* @param [string] $title the module title
|
41 |
+
* @param [string] $class the name of the module main class
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
public static function register_module( $name, $title, $class ) {
|
45 |
+
self::$registered_modules[ $name ] = array(
|
46 |
+
'name' => $name,
|
47 |
+
'title' => $title,
|
48 |
+
'class' => $class,
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Initialize all registered modules
|
54 |
+
*
|
55 |
+
* @return void
|
56 |
+
*/
|
57 |
+
public static function init_modules() {
|
58 |
+
if ( self::get_active_modules() ) {
|
59 |
+
foreach ( self::get_active_modules() as $module ) {
|
60 |
+
$class_name = $module['class'];
|
61 |
+
$module_object = new $class_name;
|
62 |
+
|
63 |
+
//create an instance of the loaded module
|
64 |
+
$module_object->init( $module );
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Return the registered modules array
|
71 |
+
*
|
72 |
+
* @return void
|
73 |
+
*/
|
74 |
+
public static function get_active_modules() {
|
75 |
+
return self::$registered_modules;
|
76 |
+
}
|
77 |
+
}
|
classes/class-wpcf7r-post-types.php
CHANGED
@@ -1,221 +1,237 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_Post_Types
|
4 |
-
* Create a post type that will act as a container for the form actions
|
5 |
-
* This post type is invisible to all users and displayed only under Contact Form 7 tab
|
6 |
-
*/
|
7 |
-
|
8 |
-
defined( 'ABSPATH' ) || exit;
|
9 |
-
|
10 |
-
class WPCF7R_Post_Types {
|
11 |
-
|
12 |
-
public function __construct() {
|
13 |
-
add_action( 'init', array( $this, 'wpcf7r_post_type' ) );
|
14 |
-
add_action( 'add_meta_boxes', array( $this, 'wporg_add_custom_box' ) );
|
15 |
-
add_action( 'save_post', array( $this, 'save_changes' ) );
|
16 |
-
add_action( 'init', array( $this, 'wpcf7r_leads_post_type' ) );
|
17 |
-
}
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Register leads post type
|
21 |
-
*/
|
22 |
-
public function wpcf7r_leads_post_type() {
|
23 |
-
|
24 |
-
if ( class_exists( 'WPCF7R_Leads_Manager' ) && class_exists( 'WPCF7R_Action_Save_Lead' ) ) {
|
25 |
-
$labels = array(
|
26 |
-
'name' => _x( 'Leads', 'Post Type General Name', 'wpcf7-redirect' ),
|
27 |
-
'singular_name' => _x( 'Lead', 'Post Type Singular Name', 'wpcf7-redirect' ),
|
28 |
-
'menu_name' => __( 'Leads', 'wpcf7-redirect' ),
|
29 |
-
'name_admin_bar' => __( 'Post Type', 'wpcf7-redirect' ),
|
30 |
-
'archives' => __( 'Item Archives', 'wpcf7-redirect' ),
|
31 |
-
'attributes' => __( 'Item Attributes', 'wpcf7-redirect' ),
|
32 |
-
'parent_item_colon' => __( 'Parent Item:', 'wpcf7-redirect' ),
|
33 |
-
'all_items' => __( 'All Items', 'wpcf7-redirect' ),
|
34 |
-
'add_new_item' => __( 'Add New Item', 'wpcf7-redirect' ),
|
35 |
-
'add_new' => __( 'Add New', 'wpcf7-redirect' ),
|
36 |
-
'new_item' => __( 'New Item', 'wpcf7-redirect' ),
|
37 |
-
'edit_item' => __( 'Edit Item', 'wpcf7-redirect' ),
|
38 |
-
'update_item' => __( 'Update Item', 'wpcf7-redirect' ),
|
39 |
-
'view_item' => __( 'View Item', 'wpcf7-redirect' ),
|
40 |
-
'view_items' => __( 'View Items', 'wpcf7-redirect' ),
|
41 |
-
'search_items' => __( 'Search Item', 'wpcf7-redirect' ),
|
42 |
-
'not_found' => __( 'Not found', 'wpcf7-redirect' ),
|
43 |
-
'not_found_in_trash' => __( 'Not found in Trash', 'wpcf7-redirect' ),
|
44 |
-
'featured_image' => __( 'Featured Image', 'wpcf7-redirect' ),
|
45 |
-
'set_featured_image' => __( 'Set featured image', 'wpcf7-redirect' ),
|
46 |
-
'remove_featured_image' => __( 'Remove featured image', 'wpcf7-redirect' ),
|
47 |
-
'use_featured_image' => __( 'Use as featured image', 'wpcf7-redirect' ),
|
48 |
-
'insert_into_item' => __( 'Insert into item', 'wpcf7-redirect' ),
|
49 |
-
'uploaded_to_this_item' => __( 'Uploaded to this item', 'wpcf7-redirect' ),
|
50 |
-
'items_list' => __( 'Items list', 'wpcf7-redirect' ),
|
51 |
-
'items_list_navigation' => __( 'Items list navigation', 'wpcf7-redirect' ),
|
52 |
-
'filter_items_list' => __( 'Filter items list', 'wpcf7-redirect' ),
|
53 |
-
);
|
54 |
-
$args = array(
|
55 |
-
'label' => __( 'Leads', 'wpcf7-redirect' ),
|
56 |
-
'description' => __( 'Leads', 'wpcf7-redirect' ),
|
57 |
-
'labels' => $labels,
|
58 |
-
'supports' => array( 'title' ),
|
59 |
-
'hierarchical' => false,
|
60 |
-
'public' => false,
|
61 |
-
'show_ui' => true,
|
62 |
-
'show_in_menu' => 'admin.php?page=wpcf7',
|
63 |
-
'menu_position' => 5,
|
64 |
-
'show_in_admin_bar' => false,
|
65 |
-
'show_in_nav_menus' => false,
|
66 |
-
'can_export' => true,
|
67 |
-
'has_archive' => false,
|
68 |
-
'exclude_from_search' => false,
|
69 |
-
'publicly_queryable' => false,
|
70 |
-
'rewrite' => false,
|
71 |
-
'capability_type' => 'page',
|
72 |
-
'show_in_rest' => false,
|
73 |
-
);
|
74 |
-
register_post_type( 'wpcf7r_leads', $args );
|
75 |
-
|
76 |
-
if ( defined( 'CF7_REDIRECT_DEBUG' ) && CF7_REDIRECT_DEBUG ) {
|
77 |
-
add_post_type_support( 'wpcf7r_leads', 'custom-fields' );
|
78 |
-
}
|
79 |
-
|
80 |
-
add_action( 'admin_menu', 'my_admin_menu' );
|
81 |
-
}
|
82 |
-
|
83 |
-
function my_admin_menu() {
|
84 |
-
add_submenu_page( 'wpcf7', 'Leads', 'Leads', 'manage_options', 'edit.php?post_type=wpcf7r_leads' );
|
85 |
-
//add_submenu_page( 'wpcf7', 'New lead', 'New lead', 'manage_options', 'post-new.php?post_type=wpcf7r_leads' );
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
// Register Custom Post Type
|
90 |
-
function wpcf7r_post_type() {
|
91 |
-
$labels = array(
|
92 |
-
'name' => _x( 'Actions', 'Post Type General Name', 'wpcf7-redirect' ),
|
93 |
-
'singular_name' => _x( 'Action', 'Post Type Singular Name', 'wpcf7-redirect' ),
|
94 |
-
'menu_name' => __( 'Actions', 'wpcf7-redirect' ),
|
95 |
-
'name_admin_bar' => __( 'Post Type', 'wpcf7-redirect' ),
|
96 |
-
'archives' => __( 'Item Archives', 'wpcf7-redirect' ),
|
97 |
-
'attributes' => __( 'Item Attributes', 'wpcf7-redirect' ),
|
98 |
-
'parent_item_colon' => __( 'Parent Item:', 'wpcf7-redirect' ),
|
99 |
-
'all_items' => __( 'All Items', 'wpcf7-redirect' ),
|
100 |
-
'add_new_item' => __( 'Add New Item', 'wpcf7-redirect' ),
|
101 |
-
'add_new' => __( 'Add New', 'wpcf7-redirect' ),
|
102 |
-
'new_item' => __( 'New Item', 'wpcf7-redirect' ),
|
103 |
-
'edit_item' => __( 'Edit Item', 'wpcf7-redirect' ),
|
104 |
-
'update_item' => __( 'Update Item', 'wpcf7-redirect' ),
|
105 |
-
'view_item' => __( 'View Item', 'wpcf7-redirect' ),
|
106 |
-
'view_items' => __( 'View Items', 'wpcf7-redirect' ),
|
107 |
-
'search_items' => __( 'Search Item', 'wpcf7-redirect' ),
|
108 |
-
'not_found' => __( 'Not found', 'wpcf7-redirect' ),
|
109 |
-
'not_found_in_trash' => __( 'Not found in Trash', 'wpcf7-redirect' ),
|
110 |
-
'featured_image' => __( 'Featured Image', 'wpcf7-redirect' ),
|
111 |
-
'set_featured_image' => __( 'Set featured image', 'wpcf7-redirect' ),
|
112 |
-
'remove_featured_image' => __( 'Remove featured image', 'wpcf7-redirect' ),
|
113 |
-
'use_featured_image' => __( 'Use as featured image', 'wpcf7-redirect' ),
|
114 |
-
'insert_into_item' => __( 'Insert into item', 'wpcf7-redirect' ),
|
115 |
-
'uploaded_to_this_item' => __( 'Uploaded to this item', 'wpcf7-redirect' ),
|
116 |
-
'items_list' => __( 'Items list', 'wpcf7-redirect' ),
|
117 |
-
'items_list_navigation' => __( 'Items list navigation', 'wpcf7-redirect' ),
|
118 |
-
'filter_items_list' => __( 'Filter items list', 'wpcf7-redirect' ),
|
119 |
-
);
|
120 |
-
|
121 |
-
$args = array(
|
122 |
-
'label' => __( 'Redirection For Contact Form 7 Actions', 'wpcf7-redirect' ),
|
123 |
-
'description' => __( 'Actions', 'wpcf7-redirect' ),
|
124 |
-
'labels' => $labels,
|
125 |
-
'supports' => array( 'title', 'custom_fields', 'custom-fields' ),
|
126 |
-
'hierarchical' => true,
|
127 |
-
'public' => CF7_REDIRECT_DEBUG,
|
128 |
-
'show_ui' => CF7_REDIRECT_DEBUG,
|
129 |
-
'show_in_menu' => 'admin.php?page=wpcf7',
|
130 |
-
'menu_position' => 5,
|
131 |
-
'show_in_admin_bar' => CF7_REDIRECT_DEBUG,
|
132 |
-
'show_in_nav_menus' => CF7_REDIRECT_DEBUG,
|
133 |
-
'can_export' => CF7_REDIRECT_DEBUG,
|
134 |
-
'has_archive' => CF7_REDIRECT_DEBUG,
|
135 |
-
'exclude_from_search' => CF7_REDIRECT_DEBUG,
|
136 |
-
'publicly_queryable' => CF7_REDIRECT_DEBUG,
|
137 |
-
'rewrite' => CF7_REDIRECT_DEBUG,
|
138 |
-
'capability_type' => 'page',
|
139 |
-
'show_in_rest' => CF7_REDIRECT_DEBUG,
|
140 |
-
);
|
141 |
-
|
142 |
-
register_post_type( 'wpcf7r_action', $args );
|
143 |
-
add_post_type_support( 'wpcf7r_action', 'custom-fields' );
|
144 |
-
|
145 |
-
if ( defined( 'CF7_REDIRECT_DEBUG' ) && CF7_REDIRECT_DEBUG ) {
|
146 |
-
add_action( 'admin_menu', 'add_actions_menu' );
|
147 |
-
|
148 |
-
function add_actions_menu() {
|
149 |
-
add_submenu_page( 'wpcf7', __( 'Actions List', 'wpcf7-redirect' ), __( 'Actions List', 'wpcf7-redirect' ), 'manage_options', 'edit.php?post_type=wpcf7r_action' );
|
150 |
-
}
|
151 |
-
}
|
152 |
-
|
153 |
-
}
|
154 |
-
|
155 |
-
function wporg_add_custom_box() {
|
156 |
-
$screens = array( 'wpcf7r_action' );
|
157 |
-
if ( is_wpcf7r_debug() ) {
|
158 |
-
$screens[] = 'wpcf7r_leads';
|
159 |
-
}
|
160 |
-
|
161 |
-
foreach ( $screens as $screen ) {
|
162 |
-
add_meta_box(
|
163 |
-
'wpcf7r_action_meta',
|
164 |
-
__( 'Action Meta', 'wpcf7-redirect' ),
|
165 |
-
array( $this, 'debug_helper' ),
|
166 |
-
$screen
|
167 |
-
);
|
168 |
-
}
|
169 |
-
|
170 |
-
add_meta_box(
|
171 |
-
'wpcf7r_leads',
|
172 |
-
__( 'Lead Details', 'wpcf7-redirect' ),
|
173 |
-
array( $this, 'lead_fields_html' ),
|
174 |
-
'wpcf7r_leads'
|
175 |
-
);
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Get the meta html
|
180 |
-
*
|
181 |
-
* @param $post
|
182 |
-
*/
|
183 |
-
function lead_fields_html( $post ) {
|
184 |
-
$lead = new WPCF7R_Lead( $post->ID );
|
185 |
-
|
186 |
-
$fields = $lead->get_lead_fields();
|
187 |
-
|
188 |
-
foreach ( $fields as $field ) {
|
189 |
-
switch ( $field['name'] ) {
|
190 |
-
case 'action-save_lead':
|
191 |
-
$field['value'] = $field['value']['data']['lead_id'];
|
192 |
-
break;
|
193 |
-
case 'action-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_Post_Types
|
4 |
+
* Create a post type that will act as a container for the form actions
|
5 |
+
* This post type is invisible to all users and displayed only under Contact Form 7 tab
|
6 |
+
*/
|
7 |
+
|
8 |
+
defined( 'ABSPATH' ) || exit;
|
9 |
+
|
10 |
+
class WPCF7R_Post_Types {
|
11 |
+
|
12 |
+
public function __construct() {
|
13 |
+
add_action( 'init', array( $this, 'wpcf7r_post_type' ) );
|
14 |
+
add_action( 'add_meta_boxes', array( $this, 'wporg_add_custom_box' ) );
|
15 |
+
add_action( 'save_post', array( $this, 'save_changes' ) );
|
16 |
+
add_action( 'init', array( $this, 'wpcf7r_leads_post_type' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Register leads post type
|
21 |
+
*/
|
22 |
+
public function wpcf7r_leads_post_type() {
|
23 |
+
|
24 |
+
if ( class_exists( 'WPCF7R_Leads_Manager' ) && class_exists( 'WPCF7R_Action_Save_Lead' ) ) {
|
25 |
+
$labels = array(
|
26 |
+
'name' => _x( 'Leads', 'Post Type General Name', 'wpcf7-redirect' ),
|
27 |
+
'singular_name' => _x( 'Lead', 'Post Type Singular Name', 'wpcf7-redirect' ),
|
28 |
+
'menu_name' => __( 'Leads', 'wpcf7-redirect' ),
|
29 |
+
'name_admin_bar' => __( 'Post Type', 'wpcf7-redirect' ),
|
30 |
+
'archives' => __( 'Item Archives', 'wpcf7-redirect' ),
|
31 |
+
'attributes' => __( 'Item Attributes', 'wpcf7-redirect' ),
|
32 |
+
'parent_item_colon' => __( 'Parent Item:', 'wpcf7-redirect' ),
|
33 |
+
'all_items' => __( 'All Items', 'wpcf7-redirect' ),
|
34 |
+
'add_new_item' => __( 'Add New Item', 'wpcf7-redirect' ),
|
35 |
+
'add_new' => __( 'Add New', 'wpcf7-redirect' ),
|
36 |
+
'new_item' => __( 'New Item', 'wpcf7-redirect' ),
|
37 |
+
'edit_item' => __( 'Edit Item', 'wpcf7-redirect' ),
|
38 |
+
'update_item' => __( 'Update Item', 'wpcf7-redirect' ),
|
39 |
+
'view_item' => __( 'View Item', 'wpcf7-redirect' ),
|
40 |
+
'view_items' => __( 'View Items', 'wpcf7-redirect' ),
|
41 |
+
'search_items' => __( 'Search Item', 'wpcf7-redirect' ),
|
42 |
+
'not_found' => __( 'Not found', 'wpcf7-redirect' ),
|
43 |
+
'not_found_in_trash' => __( 'Not found in Trash', 'wpcf7-redirect' ),
|
44 |
+
'featured_image' => __( 'Featured Image', 'wpcf7-redirect' ),
|
45 |
+
'set_featured_image' => __( 'Set featured image', 'wpcf7-redirect' ),
|
46 |
+
'remove_featured_image' => __( 'Remove featured image', 'wpcf7-redirect' ),
|
47 |
+
'use_featured_image' => __( 'Use as featured image', 'wpcf7-redirect' ),
|
48 |
+
'insert_into_item' => __( 'Insert into item', 'wpcf7-redirect' ),
|
49 |
+
'uploaded_to_this_item' => __( 'Uploaded to this item', 'wpcf7-redirect' ),
|
50 |
+
'items_list' => __( 'Items list', 'wpcf7-redirect' ),
|
51 |
+
'items_list_navigation' => __( 'Items list navigation', 'wpcf7-redirect' ),
|
52 |
+
'filter_items_list' => __( 'Filter items list', 'wpcf7-redirect' ),
|
53 |
+
);
|
54 |
+
$args = array(
|
55 |
+
'label' => __( 'Leads', 'wpcf7-redirect' ),
|
56 |
+
'description' => __( 'Leads', 'wpcf7-redirect' ),
|
57 |
+
'labels' => $labels,
|
58 |
+
'supports' => array( 'title' ),
|
59 |
+
'hierarchical' => false,
|
60 |
+
'public' => false,
|
61 |
+
'show_ui' => true,
|
62 |
+
'show_in_menu' => 'admin.php?page=wpcf7',
|
63 |
+
'menu_position' => 5,
|
64 |
+
'show_in_admin_bar' => false,
|
65 |
+
'show_in_nav_menus' => false,
|
66 |
+
'can_export' => true,
|
67 |
+
'has_archive' => false,
|
68 |
+
'exclude_from_search' => false,
|
69 |
+
'publicly_queryable' => false,
|
70 |
+
'rewrite' => false,
|
71 |
+
'capability_type' => 'page',
|
72 |
+
'show_in_rest' => false,
|
73 |
+
);
|
74 |
+
register_post_type( 'wpcf7r_leads', $args );
|
75 |
+
|
76 |
+
if ( defined( 'CF7_REDIRECT_DEBUG' ) && CF7_REDIRECT_DEBUG ) {
|
77 |
+
add_post_type_support( 'wpcf7r_leads', 'custom-fields' );
|
78 |
+
}
|
79 |
+
|
80 |
+
add_action( 'admin_menu', 'my_admin_menu' );
|
81 |
+
}
|
82 |
+
|
83 |
+
function my_admin_menu() {
|
84 |
+
add_submenu_page( 'wpcf7', 'Leads', 'Leads', 'manage_options', 'edit.php?post_type=wpcf7r_leads' );
|
85 |
+
//add_submenu_page( 'wpcf7', 'New lead', 'New lead', 'manage_options', 'post-new.php?post_type=wpcf7r_leads' );
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
// Register Custom Post Type
|
90 |
+
function wpcf7r_post_type() {
|
91 |
+
$labels = array(
|
92 |
+
'name' => _x( 'Actions', 'Post Type General Name', 'wpcf7-redirect' ),
|
93 |
+
'singular_name' => _x( 'Action', 'Post Type Singular Name', 'wpcf7-redirect' ),
|
94 |
+
'menu_name' => __( 'Actions', 'wpcf7-redirect' ),
|
95 |
+
'name_admin_bar' => __( 'Post Type', 'wpcf7-redirect' ),
|
96 |
+
'archives' => __( 'Item Archives', 'wpcf7-redirect' ),
|
97 |
+
'attributes' => __( 'Item Attributes', 'wpcf7-redirect' ),
|
98 |
+
'parent_item_colon' => __( 'Parent Item:', 'wpcf7-redirect' ),
|
99 |
+
'all_items' => __( 'All Items', 'wpcf7-redirect' ),
|
100 |
+
'add_new_item' => __( 'Add New Item', 'wpcf7-redirect' ),
|
101 |
+
'add_new' => __( 'Add New', 'wpcf7-redirect' ),
|
102 |
+
'new_item' => __( 'New Item', 'wpcf7-redirect' ),
|
103 |
+
'edit_item' => __( 'Edit Item', 'wpcf7-redirect' ),
|
104 |
+
'update_item' => __( 'Update Item', 'wpcf7-redirect' ),
|
105 |
+
'view_item' => __( 'View Item', 'wpcf7-redirect' ),
|
106 |
+
'view_items' => __( 'View Items', 'wpcf7-redirect' ),
|
107 |
+
'search_items' => __( 'Search Item', 'wpcf7-redirect' ),
|
108 |
+
'not_found' => __( 'Not found', 'wpcf7-redirect' ),
|
109 |
+
'not_found_in_trash' => __( 'Not found in Trash', 'wpcf7-redirect' ),
|
110 |
+
'featured_image' => __( 'Featured Image', 'wpcf7-redirect' ),
|
111 |
+
'set_featured_image' => __( 'Set featured image', 'wpcf7-redirect' ),
|
112 |
+
'remove_featured_image' => __( 'Remove featured image', 'wpcf7-redirect' ),
|
113 |
+
'use_featured_image' => __( 'Use as featured image', 'wpcf7-redirect' ),
|
114 |
+
'insert_into_item' => __( 'Insert into item', 'wpcf7-redirect' ),
|
115 |
+
'uploaded_to_this_item' => __( 'Uploaded to this item', 'wpcf7-redirect' ),
|
116 |
+
'items_list' => __( 'Items list', 'wpcf7-redirect' ),
|
117 |
+
'items_list_navigation' => __( 'Items list navigation', 'wpcf7-redirect' ),
|
118 |
+
'filter_items_list' => __( 'Filter items list', 'wpcf7-redirect' ),
|
119 |
+
);
|
120 |
+
|
121 |
+
$args = array(
|
122 |
+
'label' => __( 'Redirection For Contact Form 7 Actions', 'wpcf7-redirect' ),
|
123 |
+
'description' => __( 'Actions', 'wpcf7-redirect' ),
|
124 |
+
'labels' => $labels,
|
125 |
+
'supports' => array( 'title', 'custom_fields', 'custom-fields' ),
|
126 |
+
'hierarchical' => true,
|
127 |
+
'public' => CF7_REDIRECT_DEBUG,
|
128 |
+
'show_ui' => CF7_REDIRECT_DEBUG,
|
129 |
+
'show_in_menu' => 'admin.php?page=wpcf7',
|
130 |
+
'menu_position' => 5,
|
131 |
+
'show_in_admin_bar' => CF7_REDIRECT_DEBUG,
|
132 |
+
'show_in_nav_menus' => CF7_REDIRECT_DEBUG,
|
133 |
+
'can_export' => CF7_REDIRECT_DEBUG,
|
134 |
+
'has_archive' => CF7_REDIRECT_DEBUG,
|
135 |
+
'exclude_from_search' => CF7_REDIRECT_DEBUG,
|
136 |
+
'publicly_queryable' => CF7_REDIRECT_DEBUG,
|
137 |
+
'rewrite' => CF7_REDIRECT_DEBUG,
|
138 |
+
'capability_type' => 'page',
|
139 |
+
'show_in_rest' => CF7_REDIRECT_DEBUG,
|
140 |
+
);
|
141 |
+
|
142 |
+
register_post_type( 'wpcf7r_action', $args );
|
143 |
+
add_post_type_support( 'wpcf7r_action', 'custom-fields' );
|
144 |
+
|
145 |
+
if ( defined( 'CF7_REDIRECT_DEBUG' ) && CF7_REDIRECT_DEBUG ) {
|
146 |
+
add_action( 'admin_menu', 'add_actions_menu' );
|
147 |
+
|
148 |
+
function add_actions_menu() {
|
149 |
+
add_submenu_page( 'wpcf7', __( 'Actions List', 'wpcf7-redirect' ), __( 'Actions List', 'wpcf7-redirect' ), 'manage_options', 'edit.php?post_type=wpcf7r_action' );
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
}
|
154 |
+
|
155 |
+
function wporg_add_custom_box() {
|
156 |
+
$screens = array( 'wpcf7r_action' );
|
157 |
+
if ( is_wpcf7r_debug() ) {
|
158 |
+
$screens[] = 'wpcf7r_leads';
|
159 |
+
}
|
160 |
+
|
161 |
+
foreach ( $screens as $screen ) {
|
162 |
+
add_meta_box(
|
163 |
+
'wpcf7r_action_meta',
|
164 |
+
__( 'Action Meta', 'wpcf7-redirect' ),
|
165 |
+
array( $this, 'debug_helper' ),
|
166 |
+
$screen
|
167 |
+
);
|
168 |
+
}
|
169 |
+
|
170 |
+
add_meta_box(
|
171 |
+
'wpcf7r_leads',
|
172 |
+
__( 'Lead Details', 'wpcf7-redirect' ),
|
173 |
+
array( $this, 'lead_fields_html' ),
|
174 |
+
'wpcf7r_leads'
|
175 |
+
);
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Get the meta html
|
180 |
+
*
|
181 |
+
* @param $post
|
182 |
+
*/
|
183 |
+
function lead_fields_html( $post ) {
|
184 |
+
$lead = new WPCF7R_Lead( $post->ID );
|
185 |
+
|
186 |
+
$fields = $lead->get_lead_fields();
|
187 |
+
|
188 |
+
foreach ( $fields as $field ) {
|
189 |
+
switch ( $field['name'] ) {
|
190 |
+
case 'action-save_lead':
|
191 |
+
$field['value'] = $field['value']['data']['lead_id'];
|
192 |
+
break;
|
193 |
+
case 'action-popup':
|
194 |
+
$field['value'] = $field['value'] ? true : false;
|
195 |
+
break;
|
196 |
+
case 'action-mailchimp':
|
197 |
+
if ( is_wp_error( $field['value'] ) ) {
|
198 |
+
$field['value'] = $field['value']->get_error_message();
|
199 |
+
}
|
200 |
+
break;
|
201 |
+
}
|
202 |
+
|
203 |
+
if ( substr( $field['name'], 0, 1 ) === '_' ) {
|
204 |
+
continue;
|
205 |
+
} elseif ( strpos( $field['name'], 'action-' ) === false ) {
|
206 |
+
WPCF7R_Html::render_field( $field, $field['prefix'] );
|
207 |
+
} else {
|
208 |
+
?>
|
209 |
+
<div class="field-wrap">
|
210 |
+
<label class="wpcf7-redirect-lead_type">
|
211 |
+
<strong><?php echo $field['label']; ?></strong>
|
212 |
+
</label>
|
213 |
+
<?php echo is_array( $field['value'] ) ? esc_html( serialize( $field['value'] ) ) : $field['value']; ?>
|
214 |
+
</div>
|
215 |
+
<?php
|
216 |
+
}
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
public function save_changes( $post_id ) {
|
221 |
+
$post_type = get_post_type( $post_id );
|
222 |
+
|
223 |
+
if ( 'wpcf7r_leads' === $post_type ) {
|
224 |
+
if ( isset( $_POST['wpcf7-redirect'] ) ) {
|
225 |
+
foreach ( $_POST['wpcf7-redirect'] as $meta_key => $meta_value ) {
|
226 |
+
update_post_meta( $post_id, $meta_key, $meta_value );
|
227 |
+
}
|
228 |
+
}
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
function debug_helper() {
|
233 |
+
echo '<pre>';
|
234 |
+
print_r( get_post_custom() );
|
235 |
+
echo '</pre>';
|
236 |
+
}
|
237 |
+
}
|
classes/class-wpcf7r-settings.php
CHANGED
@@ -1,303 +1,296 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7r_Settings file.
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Contact form 7 Redirect Settings panel
|
10 |
-
*/
|
11 |
-
class WPCF7r_Settings {
|
12 |
-
public $product_url = WPCF7_PRO_REDIRECT_PLUGIN_PAGE_URL;
|
13 |
-
|
14 |
-
public function __construct() {
|
15 |
-
$this->page_slug = 'wpc7_redirect';
|
16 |
-
$this->api = new Qs_Api();
|
17 |
-
|
18 |
-
add_action( 'admin_menu', array( $this, 'create_plugin_settings_page' ) );
|
19 |
-
add_action( 'admin_init', array( $this, 'wpcf7r_register_options' ) );
|
20 |
-
add_filter( 'plugin_row_meta', array( $this, 'register_plugin_links' ), 10, 2 );
|
21 |
-
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Deactivate the license - Disabled on v2.0
|
26 |
-
*/
|
27 |
-
public function deactivate_license() {
|
28 |
-
$serial = WPCF7r_Utils::get_serial_key();
|
29 |
-
$activation_id = WPCF7r_Utils::get_activation_id();
|
30 |
-
|
31 |
-
$this->api->deactivate_liscense( $activation_id, $serial );
|
32 |
-
$this->reset_activation();
|
33 |
-
|
34 |
-
wp_redirect( WPCF7r_Utils::get_plugin_settings_page_url() );
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Register plugin options
|
39 |
-
*/
|
40 |
-
public function wpcf7r_register_options() {
|
41 |
-
$this->fields = array();
|
42 |
-
// $this->add_license_section();
|
43 |
-
$this->add_settings_section();
|
44 |
-
|
45 |
-
foreach ( $this->fields as $field ) {
|
46 |
-
$args = array();
|
47 |
-
add_settings_field( $field['uid'], $field['label'], array( $this, 'field_callback' ), $this->page_slug, $field['section'], $field );
|
48 |
-
// $args['sanitize_callback'] = array($this, 'validate_serial_key');
|
49 |
-
register_setting( $this->page_slug, $field['uid'], $args );
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
public function add_settings_section() {
|
54 |
-
|
55 |
-
add_settings_section( 'settings_section', __( 'Global Settings', 'wpcf7-redirect' ), array( $this, 'section_callback' ), $this->page_slug );
|
56 |
-
|
57 |
-
$this->fields = array_merge(
|
58 |
-
$this->fields,
|
59 |
-
array(
|
60 |
-
array(
|
61 |
-
'uid' => 'wpcf_debug',
|
62 |
-
'label' => 'Debug',
|
63 |
-
'section' => 'settings_section',
|
64 |
-
'type' => 'checkbox',
|
65 |
-
'options' => false,
|
66 |
-
'placeholder' => '',
|
67 |
-
'helper' => '',
|
68 |
-
'supplemental' => __( 'This will open the actions post type and display debug feature.', 'wpcf7-redirect' ),
|
69 |
-
'default' => '',
|
70 |
-
),
|
71 |
-
)
|
72 |
-
);
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* add_license_section - Deprecated
|
77 |
-
*/
|
78 |
-
public function add_license_section() {
|
79 |
-
add_settings_section( 'serial_section', __( 'License Information', 'wpcf7-redirect' ), array( $this, 'section_callback' ), $this->page_slug );
|
80 |
-
|
81 |
-
$this->fields = array_merge(
|
82 |
-
$this->fields,
|
83 |
-
array(
|
84 |
-
array(
|
85 |
-
'uid' => 'wpcf7r_serial_number',
|
86 |
-
'label' => 'Serial Number',
|
87 |
-
'section' => 'serial_section',
|
88 |
-
'type' => 'text',
|
89 |
-
'options' => false,
|
90 |
-
'placeholder' => 'Type your serial here',
|
91 |
-
'helper' => '',
|
92 |
-
'supplemental' => __( 'This process will send your serial/domain to a 3rd party validation server to validate the key authenticity', 'wpcf7-redirect' ),
|
93 |
-
'default' => '',
|
94 |
-
),
|
95 |
-
)
|
96 |
-
);
|
97 |
-
|
98 |
-
return $fields;
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Validate serial key process
|
103 |
-
*
|
104 |
-
* @param $serial
|
105 |
-
*/
|
106 |
-
public function validate_serial_key( $serial ) {
|
107 |
-
if ( ! $serial ) {
|
108 |
-
return;
|
109 |
-
}
|
110 |
-
|
111 |
-
$activation_id = WPCF7r_Utils::get_activation_id();
|
112 |
-
|
113 |
-
if ( ! $activation_id ) {
|
114 |
-
$is_valid = $this->api->activate_serial( $serial );
|
115 |
-
} else {
|
116 |
-
$is_valid = $this->api->validate_serial( $activation_id, $serial );
|
117 |
-
}
|
118 |
-
|
119 |
-
// serial was not valid
|
120 |
-
if ( is_wp_error( $is_valid ) ) {
|
121 |
-
$message = $is_valid->get_error_message();
|
122 |
-
if ( is_object( $message ) && isset( $message->license_key ) ) {
|
123 |
-
$message = $message->license_key[0];
|
124 |
-
}
|
125 |
-
add_settings_error(
|
126 |
-
'wpcf7r_serial_number',
|
127 |
-
'not-valid-serial',
|
128 |
-
$message,
|
129 |
-
'error'
|
130 |
-
);
|
131 |
-
$this->reset_activation();
|
132 |
-
return false;
|
133 |
-
} elseif ( ! $activation_id ) {
|
134 |
-
// serial was valid, update the activation key for future validation
|
135 |
-
$this->set_activation( $is_valid->data );
|
136 |
-
}
|
137 |
-
|
138 |
-
if ( isset( $_GET['deactivate'] ) ) {
|
139 |
-
return '';
|
140 |
-
}
|
141 |
-
|
142 |
-
return $serial;
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* Delete all activation data - use in case activation validation or activation returns an error
|
147 |
-
*/
|
148 |
-
public function reset_activation() {
|
149 |
-
delete_option( 'wpcf7r_activation_id' );
|
150 |
-
delete_option( 'wpcf7r_activation_expiration' );
|
151 |
-
delete_option( 'wpcf7r_activation_data' );
|
152 |
-
|
153 |
-
WPCF7r_Utils::delete_serial_key();
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Set all data related with the plugin activation
|
158 |
-
*
|
159 |
-
* @param $validation_data
|
160 |
-
*/
|
161 |
-
public function set_activation( $validation_data ) {
|
162 |
-
update_option( 'wpcf7r_activation_id', $validation_data->activation_id );
|
163 |
-
update_option( 'wpcf7r_activation_expiration', $validation_data->expire );
|
164 |
-
update_option( 'wpcf7r_activation_data', $validation_data );
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* A function for displaying a field on the admin settings page
|
169 |
-
*/
|
170 |
-
public function field_callback( $arguments ) {
|
171 |
-
$value = get_option( $arguments['uid'] ); // Get the current value, if there is one
|
172 |
-
if ( ! $value ) { // If no value exists
|
173 |
-
$value = $arguments['default']; // Set to our default
|
174 |
-
}
|
175 |
-
// Check which type of field we want
|
176 |
-
switch ( $arguments['type'] ) {
|
177 |
-
case 'text': // If it is a text field
|
178 |
-
case 'password':
|
179 |
-
printf( '<input name="%1$s" id="%1$s" type="%2$s" placeholder="%3$s" value="%4$s" class="widefat" />', $arguments['uid'], $arguments['type'], $arguments['placeholder'], $value );
|
180 |
-
break;
|
181 |
-
case 'checkbox': // If it is a text field
|
182 |
-
$checked = checked( $value, '1', false );
|
183 |
-
printf( '<input name="%1$s" id="%1$s" type="%2$s" placeholder="%3$s" value="%4$s" class="widefat" %5$s/>', $arguments['uid'], $arguments['type'], $arguments['placeholder'], '1', $checked );
|
184 |
-
break;
|
185 |
-
}
|
186 |
-
|
187 |
-
$helper = $arguments['helper'];
|
188 |
-
$supplimental = $arguments['supplemental'];
|
189 |
-
|
190 |
-
// If there is help text
|
191 |
-
if ( $helper ) {
|
192 |
-
printf( '<span class="helper"> %s</span>', $helper ); // Show it
|
193 |
-
}
|
194 |
-
|
195 |
-
// If there is supplemental text
|
196 |
-
if ( $supplimental ) {
|
197 |
-
printf( '<p class="description">%s</p>', $supplimental ); // Show it
|
198 |
-
}
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Main call for creating the settings page
|
203 |
-
*/
|
204 |
-
public function create_plugin_settings_page() {
|
205 |
-
// Add the menu item and page
|
206 |
-
$page_title = 'Extensions';
|
207 |
-
$menu_title = 'Extensions';
|
208 |
-
$capability = 'manage_options';
|
209 |
-
$callback = array( $this, 'plugin_settings_page_content' );
|
210 |
-
$icon = 'dashicons-admin-plugins';
|
211 |
-
$position = 100;
|
212 |
-
|
213 |
-
add_submenu_page(
|
214 |
-
'wpcf7',
|
215 |
-
$page_title,
|
216 |
-
$page_title,
|
217 |
-
$capability,
|
218 |
-
$this->page_slug,
|
219 |
-
$callback
|
220 |
-
);
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* The setting page template HTML
|
225 |
-
*/
|
226 |
-
public function plugin_settings_page_content() {
|
227 |
-
$wpcf7_extensions = new WPCF7R_Extensions();
|
228 |
-
?>
|
229 |
-
<section class="padbox">
|
230 |
-
<div class="wrap wrap-wpcf7redirect">
|
231 |
-
<h2>
|
232 |
-
<span>
|
233 |
-
<?php _e( 'Redirection For Contact Form 7', 'wpcf7-redirect' ); ?>
|
234 |
-
</span>
|
235 |
-
</h2>
|
236 |
-
<div class="user-message">
|
237 |
-
<ul>
|
238 |
-
<li>The new and improved Submission Action System is how redirection for Contact Form 7 processes submission data.</li>
|
239 |
-
<li>Submission Actions are like modules which can be added to each form.</li>
|
240 |
-
<li>You can add multiple actions to a single form or a single action can be added to any form.</li>
|
241 |
-
<li>Create custom login/registration forms, manage your conversion pixels, set conditional rules and much more.</li>
|
242 |
-
</ul>
|
243 |
-
<form method="post">
|
244 |
-
<br/>
|
245 |
-
<input type="submit" value="Check For Updates" class="button-primary" name="extensions-updates-check"/>
|
246 |
-
<br
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
?>
|
267 |
-
|
268 |
-
<?php
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
function register_plugin_links( $links, $file ) {
|
298 |
-
if ( WPCF7_PRO_REDIRECT_BASE_NAME === $file ) {
|
299 |
-
$links[] = WPCF7r_Utils::get_settings_link();
|
300 |
-
}
|
301 |
-
return $links;
|
302 |
-
}
|
303 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7r_Settings file.
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Contact form 7 Redirect Settings panel
|
10 |
+
*/
|
11 |
+
class WPCF7r_Settings {
|
12 |
+
public $product_url = WPCF7_PRO_REDIRECT_PLUGIN_PAGE_URL;
|
13 |
+
|
14 |
+
public function __construct() {
|
15 |
+
$this->page_slug = 'wpc7_redirect';
|
16 |
+
$this->api = new Qs_Api();
|
17 |
+
|
18 |
+
add_action( 'admin_menu', array( $this, 'create_plugin_settings_page' ) );
|
19 |
+
add_action( 'admin_init', array( $this, 'wpcf7r_register_options' ) );
|
20 |
+
add_filter( 'plugin_row_meta', array( $this, 'register_plugin_links' ), 10, 2 );
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Deactivate the license - Disabled on v2.0
|
26 |
+
*/
|
27 |
+
public function deactivate_license() {
|
28 |
+
$serial = WPCF7r_Utils::get_serial_key();
|
29 |
+
$activation_id = WPCF7r_Utils::get_activation_id();
|
30 |
+
|
31 |
+
$this->api->deactivate_liscense( $activation_id, $serial );
|
32 |
+
$this->reset_activation();
|
33 |
+
|
34 |
+
wp_redirect( WPCF7r_Utils::get_plugin_settings_page_url() );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Register plugin options
|
39 |
+
*/
|
40 |
+
public function wpcf7r_register_options() {
|
41 |
+
$this->fields = array();
|
42 |
+
// $this->add_license_section();
|
43 |
+
$this->add_settings_section();
|
44 |
+
|
45 |
+
foreach ( $this->fields as $field ) {
|
46 |
+
$args = array();
|
47 |
+
add_settings_field( $field['uid'], $field['label'], array( $this, 'field_callback' ), $this->page_slug, $field['section'], $field );
|
48 |
+
// $args['sanitize_callback'] = array($this, 'validate_serial_key');
|
49 |
+
register_setting( $this->page_slug, $field['uid'], $args );
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
public function add_settings_section() {
|
54 |
+
|
55 |
+
add_settings_section( 'settings_section', __( 'Global Settings', 'wpcf7-redirect' ), array( $this, 'section_callback' ), $this->page_slug );
|
56 |
+
|
57 |
+
$this->fields = array_merge(
|
58 |
+
$this->fields,
|
59 |
+
array(
|
60 |
+
array(
|
61 |
+
'uid' => 'wpcf_debug',
|
62 |
+
'label' => 'Debug',
|
63 |
+
'section' => 'settings_section',
|
64 |
+
'type' => 'checkbox',
|
65 |
+
'options' => false,
|
66 |
+
'placeholder' => '',
|
67 |
+
'helper' => '',
|
68 |
+
'supplemental' => __( 'This will open the actions post type and display debug feature.', 'wpcf7-redirect' ),
|
69 |
+
'default' => '',
|
70 |
+
),
|
71 |
+
)
|
72 |
+
);
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* add_license_section - Deprecated
|
77 |
+
*/
|
78 |
+
public function add_license_section() {
|
79 |
+
add_settings_section( 'serial_section', __( 'License Information', 'wpcf7-redirect' ), array( $this, 'section_callback' ), $this->page_slug );
|
80 |
+
|
81 |
+
$this->fields = array_merge(
|
82 |
+
$this->fields,
|
83 |
+
array(
|
84 |
+
array(
|
85 |
+
'uid' => 'wpcf7r_serial_number',
|
86 |
+
'label' => 'Serial Number',
|
87 |
+
'section' => 'serial_section',
|
88 |
+
'type' => 'text',
|
89 |
+
'options' => false,
|
90 |
+
'placeholder' => 'Type your serial here',
|
91 |
+
'helper' => '',
|
92 |
+
'supplemental' => __( 'This process will send your serial/domain to a 3rd party validation server to validate the key authenticity', 'wpcf7-redirect' ),
|
93 |
+
'default' => '',
|
94 |
+
),
|
95 |
+
)
|
96 |
+
);
|
97 |
+
|
98 |
+
return $fields;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Validate serial key process
|
103 |
+
*
|
104 |
+
* @param $serial
|
105 |
+
*/
|
106 |
+
public function validate_serial_key( $serial ) {
|
107 |
+
if ( ! $serial ) {
|
108 |
+
return;
|
109 |
+
}
|
110 |
+
|
111 |
+
$activation_id = WPCF7r_Utils::get_activation_id();
|
112 |
+
|
113 |
+
if ( ! $activation_id ) {
|
114 |
+
$is_valid = $this->api->activate_serial( $serial );
|
115 |
+
} else {
|
116 |
+
$is_valid = $this->api->validate_serial( $activation_id, $serial );
|
117 |
+
}
|
118 |
+
|
119 |
+
// serial was not valid
|
120 |
+
if ( is_wp_error( $is_valid ) ) {
|
121 |
+
$message = $is_valid->get_error_message();
|
122 |
+
if ( is_object( $message ) && isset( $message->license_key ) ) {
|
123 |
+
$message = $message->license_key[0];
|
124 |
+
}
|
125 |
+
add_settings_error(
|
126 |
+
'wpcf7r_serial_number',
|
127 |
+
'not-valid-serial',
|
128 |
+
$message,
|
129 |
+
'error'
|
130 |
+
);
|
131 |
+
$this->reset_activation();
|
132 |
+
return false;
|
133 |
+
} elseif ( ! $activation_id ) {
|
134 |
+
// serial was valid, update the activation key for future validation
|
135 |
+
$this->set_activation( $is_valid->data );
|
136 |
+
}
|
137 |
+
|
138 |
+
if ( isset( $_GET['deactivate'] ) ) {
|
139 |
+
return '';
|
140 |
+
}
|
141 |
+
|
142 |
+
return $serial;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Delete all activation data - use in case activation validation or activation returns an error
|
147 |
+
*/
|
148 |
+
public function reset_activation() {
|
149 |
+
delete_option( 'wpcf7r_activation_id' );
|
150 |
+
delete_option( 'wpcf7r_activation_expiration' );
|
151 |
+
delete_option( 'wpcf7r_activation_data' );
|
152 |
+
|
153 |
+
WPCF7r_Utils::delete_serial_key();
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Set all data related with the plugin activation
|
158 |
+
*
|
159 |
+
* @param $validation_data
|
160 |
+
*/
|
161 |
+
public function set_activation( $validation_data ) {
|
162 |
+
update_option( 'wpcf7r_activation_id', $validation_data->activation_id );
|
163 |
+
update_option( 'wpcf7r_activation_expiration', $validation_data->expire );
|
164 |
+
update_option( 'wpcf7r_activation_data', $validation_data );
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* A function for displaying a field on the admin settings page
|
169 |
+
*/
|
170 |
+
public function field_callback( $arguments ) {
|
171 |
+
$value = get_option( $arguments['uid'] ); // Get the current value, if there is one
|
172 |
+
if ( ! $value ) { // If no value exists
|
173 |
+
$value = $arguments['default']; // Set to our default
|
174 |
+
}
|
175 |
+
// Check which type of field we want
|
176 |
+
switch ( $arguments['type'] ) {
|
177 |
+
case 'text': // If it is a text field
|
178 |
+
case 'password':
|
179 |
+
printf( '<input name="%1$s" id="%1$s" type="%2$s" placeholder="%3$s" value="%4$s" class="widefat" />', $arguments['uid'], $arguments['type'], $arguments['placeholder'], $value );
|
180 |
+
break;
|
181 |
+
case 'checkbox': // If it is a text field
|
182 |
+
$checked = checked( $value, '1', false );
|
183 |
+
printf( '<input name="%1$s" id="%1$s" type="%2$s" placeholder="%3$s" value="%4$s" class="widefat" %5$s/>', $arguments['uid'], $arguments['type'], $arguments['placeholder'], '1', $checked );
|
184 |
+
break;
|
185 |
+
}
|
186 |
+
|
187 |
+
$helper = $arguments['helper'];
|
188 |
+
$supplimental = $arguments['supplemental'];
|
189 |
+
|
190 |
+
// If there is help text
|
191 |
+
if ( $helper ) {
|
192 |
+
printf( '<span class="helper"> %s</span>', $helper ); // Show it
|
193 |
+
}
|
194 |
+
|
195 |
+
// If there is supplemental text
|
196 |
+
if ( $supplimental ) {
|
197 |
+
printf( '<p class="description">%s</p>', $supplimental ); // Show it
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Main call for creating the settings page
|
203 |
+
*/
|
204 |
+
public function create_plugin_settings_page() {
|
205 |
+
// Add the menu item and page
|
206 |
+
$page_title = 'Extensions';
|
207 |
+
$menu_title = 'Extensions';
|
208 |
+
$capability = 'manage_options';
|
209 |
+
$callback = array( $this, 'plugin_settings_page_content' );
|
210 |
+
$icon = 'dashicons-admin-plugins';
|
211 |
+
$position = 100;
|
212 |
+
|
213 |
+
add_submenu_page(
|
214 |
+
'wpcf7',
|
215 |
+
$page_title,
|
216 |
+
$page_title,
|
217 |
+
$capability,
|
218 |
+
$this->page_slug,
|
219 |
+
$callback
|
220 |
+
);
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* The setting page template HTML
|
225 |
+
*/
|
226 |
+
public function plugin_settings_page_content() {
|
227 |
+
$wpcf7_extensions = new WPCF7R_Extensions();
|
228 |
+
?>
|
229 |
+
<section class="padbox">
|
230 |
+
<div class="wrap wrap-wpcf7redirect">
|
231 |
+
<h2>
|
232 |
+
<span>
|
233 |
+
<?php _e( 'Redirection For Contact Form 7', 'wpcf7-redirect' ); ?>
|
234 |
+
</span>
|
235 |
+
</h2>
|
236 |
+
<div class="user-message">
|
237 |
+
<ul>
|
238 |
+
<li>The new and improved Submission Action System is how redirection for Contact Form 7 processes submission data.</li>
|
239 |
+
<li>Submission Actions are like modules which can be added to each form.</li>
|
240 |
+
<li>You can add multiple actions to a single form or a single action can be added to any form.</li>
|
241 |
+
<li>Create custom login/registration forms, manage your conversion pixels, set conditional rules and much more.</li>
|
242 |
+
</ul>
|
243 |
+
<form method="post">
|
244 |
+
<br/>
|
245 |
+
<input type="submit" value="Check For Updates" class="button-primary" name="extensions-updates-check"/>
|
246 |
+
<br/>
|
247 |
+
</form>
|
248 |
+
</div>
|
249 |
+
<div class="postbox extensions-list-wrap">
|
250 |
+
<div class="padbox">
|
251 |
+
<?php $wpcf7_extensions->display(); ?>
|
252 |
+
</div>
|
253 |
+
</div>
|
254 |
+
<div class="postbox">
|
255 |
+
<div class="padbox">
|
256 |
+
<form method="POST" action="options.php" name="wpcfr7_settings">
|
257 |
+
<?php
|
258 |
+
do_action( 'before_settings_fields' );
|
259 |
+
settings_fields( $this->page_slug );
|
260 |
+
do_settings_sections( $this->page_slug );
|
261 |
+
submit_button();
|
262 |
+
?>
|
263 |
+
</form>
|
264 |
+
<?php if ( is_wpcf7r_debug() ) : ?>
|
265 |
+
<input type="button" name="migrate_again" value="<?php _e( 'Migrate Again from Old Settings', 'wpcf7-redirect' ); ?>" class="migrate_again button button-secondary" />
|
266 |
+
<input type="button" name="reset_all" value="<?php _e( 'Reset all Settings - BE CAREFUL! this will delete all Redirection for Contact Form 7 data.', 'wpcf7-redirect' ); ?>" class="cf7-redirect-reset button button-secondary" />
|
267 |
+
|
268 |
+
<?php endif; ?>
|
269 |
+
</div>
|
270 |
+
</div>
|
271 |
+
</div>
|
272 |
+
</section>
|
273 |
+
<?php
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Create a section on the admin settings page
|
278 |
+
*/
|
279 |
+
public function section_callback( $arguments ) {
|
280 |
+
switch ( $arguments['id'] ) {
|
281 |
+
case 'serial_section':
|
282 |
+
echo sprintf( "In order to gain access to plugin updates, please enter your license key below. If you don't have a licence key, please <a href='%s' target='_blank'>click Here</a>.", $this->product_url );
|
283 |
+
break;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Add a link to the options page to the plugin description block.
|
289 |
+
*/
|
290 |
+
function register_plugin_links( $links, $file ) {
|
291 |
+
if ( WPCF7_PRO_REDIRECT_BASE_NAME === $file ) {
|
292 |
+
$links[] = WPCF7r_Utils::get_settings_link();
|
293 |
+
}
|
294 |
+
return $links;
|
295 |
+
}
|
296 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/class-wpcf7r-submission.php
CHANGED
@@ -1,233 +1,233 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Redirection for Contact Form 7 Submission handler
|
4 |
-
*
|
5 |
-
* @package wpcf7r
|
6 |
-
*/
|
7 |
-
|
8 |
-
defined( 'ABSPATH' ) || exit;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* WPCF7r_Submission Class - handles the submission process.
|
12 |
-
*/
|
13 |
-
class WPCF7r_Submission {
|
14 |
-
/**
|
15 |
-
* Change the response object returned to the client
|
16 |
-
*
|
17 |
-
* @param [object] $response - contact form 7 response object.
|
18 |
-
* @return [object] $response - contact form 7 updated response object.
|
19 |
-
*/
|
20 |
-
public function manipulate_cf7_response_object( $response ) {
|
21 |
-
|
22 |
-
if ( isset( $this->response ) && $this->response ) {
|
23 |
-
$response = array_merge( $this->response, $response );
|
24 |
-
}
|
25 |
-
|
26 |
-
return apply_filters( 'wpcf7r_manipulate_cf7_response_object', $response, $this );
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Add plugin support to browsers that don't support ajax.
|
31 |
-
*
|
32 |
-
* @param [object] $wpcf7 - contact form 7 form object.
|
33 |
-
* @return void
|
34 |
-
*/
|
35 |
-
public function non_ajax_redirection( $wpcf7 ) {
|
36 |
-
|
37 |
-
if ( ! WPCF7_Submission::is_restful() ) {
|
38 |
-
|
39 |
-
$submission = WPCF7_Submission::get_instance();
|
40 |
-
|
41 |
-
$wpcf7_form = get_cf7r_form( $wpcf7, $submission );
|
42 |
-
|
43 |
-
if ( 'mail_sent' === $wpcf7_form->get_submission_status() ) {
|
44 |
-
|
45 |
-
$results = $this->handle_valid_actions( $wpcf7 );
|
46 |
-
|
47 |
-
if ( $results ) {
|
48 |
-
foreach ( $results as $result_type => $result_actions ) {
|
49 |
-
if ( ( 'FireScript' === $result_type || 'firescript' === strtolower( $result_type ) ) && $result_action ) {
|
50 |
-
$this->scripts = $result_actions;
|
51 |
-
|
52 |
-
add_action( 'wp_head', array( $this, 'add_header_script' ) );
|
53 |
-
}
|
54 |
-
|
55 |
-
foreach ( $result_actions as $result_action ) {
|
56 |
-
if ( 'redirect' === $result_type ) {
|
57 |
-
$this->redirect_url = $result_action['redirect_url'];
|
58 |
-
|
59 |
-
if ( 'new_tab' === $result_action['type'] ) {
|
60 |
-
add_action( 'wp_head', array( $this, 'open_new_tab' ), 9999 );
|
61 |
-
} else {
|
62 |
-
// Do this last.
|
63 |
-
add_action( 'wp_head', array( $this, 'redirect' ), 9999 );
|
64 |
-
}
|
65 |
-
}
|
66 |
-
}
|
67 |
-
}
|
68 |
-
}
|
69 |
-
}
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Print header scripts for non ajax submits
|
75 |
-
*/
|
76 |
-
public function add_header_script() {
|
77 |
-
if ( isset( $this->scripts ) && $this->scripts ) {
|
78 |
-
foreach ( $this->scripts as $script ) {
|
79 |
-
echo '<script>' . $script . '</script>';
|
80 |
-
}
|
81 |
-
}
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Redirect support for non ajax browsers
|
86 |
-
*/
|
87 |
-
public function redirect() {
|
88 |
-
// Allow other plugins to manipulate the redirect url settings.
|
89 |
-
$redirect_url = apply_filters( 'wpcf7_redirect_url', $this->redirect_url );
|
90 |
-
|
91 |
-
echo "<script>window.location='" . esc_attr( $redirect_url ) . "'</script>";
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Open new tab on non ajax submits
|
96 |
-
*/
|
97 |
-
public function open_new_tab() {
|
98 |
-
// Allow other plugins to manipulate the redirect url settings.
|
99 |
-
$redirect_url = apply_filters( 'wpcf7_redirect_url', $this->redirect_url );
|
100 |
-
|
101 |
-
echo "<script>window.open('" . esc_attr( $redirect_url ) . "')</script>";
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* This function is fired before send email
|
106 |
-
*
|
107 |
-
* @param [object] $wpcf7 - cf7 form object.
|
108 |
-
* @return mixed - redirect response
|
109 |
-
*/
|
110 |
-
public function handle_valid_actions( $wpcf7 ) {
|
111 |
-
|
112 |
-
$submission = WPCF7_Submission::get_instance();
|
113 |
-
|
114 |
-
$wpcf7_form = get_cf7r_form( $wpcf7, $submission );
|
115 |
-
|
116 |
-
if ( $submission && $wpcf7_form->has_actions() ) {
|
117 |
-
// Get the submitted data.
|
118 |
-
$this->posted_data = $submission->get_posted_data();
|
119 |
-
|
120 |
-
// Process all relevant actions.
|
121 |
-
$this->response = $wpcf7_form->process_actions();
|
122 |
-
|
123 |
-
// Skip default contact form 7 email.
|
124 |
-
if ( isset( $this->response['send_mail'] ) && $this->response['send_mail'] ) {
|
125 |
-
add_filter(
|
126 |
-
'wpcf7_skip_mail',
|
127 |
-
function() {
|
128 |
-
return true;
|
129 |
-
}
|
130 |
-
);
|
131 |
-
}
|
132 |
-
|
133 |
-
$this->save_lead_actions( $this->response );
|
134 |
-
|
135 |
-
$wpcf7_form->maybe_perform_pre_result_action();
|
136 |
-
|
137 |
-
return $this->response;
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Save lead actions
|
143 |
-
*
|
144 |
-
* @param [array] $actions_results - save actions on the lead record.
|
145 |
-
* @return void
|
146 |
-
*/
|
147 |
-
public function save_lead_actions( $actions_results ) {
|
148 |
-
foreach ( $actions_results as $action_type => $actions_result ) {
|
149 |
-
WPCF7R_Leads_Manager::save_action( WPCF7R_Action::get_lead_id(), $action_type, $actions_result );
|
150 |
-
}
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* Early hook to catch cf7 submissions before they are processed
|
155 |
-
*
|
156 |
-
* @param [object] $cf7 - contact form 7 form object.
|
157 |
-
* @return void
|
158 |
-
*/
|
159 |
-
public function after_cf7_object_created( $cf7 ) {
|
160 |
-
if ( WPCF7_Submission::is_restful() || isset( $_POST['_wpcf7'] ) ) {
|
161 |
-
// Get an instance of contact form 7 redirection post.
|
162 |
-
$wpcf7_form = get_cf7r_form( $cf7 );
|
163 |
-
|
164 |
-
// Check if the form has validation actions.
|
165 |
-
$actions = $wpcf7_form->get_active_actions();
|
166 |
-
|
167 |
-
if ( $actions ) {
|
168 |
-
foreach ( $actions as $action ) {
|
169 |
-
$results = $action->process_pre_submit_actions();
|
170 |
-
// Saved reference for the items removed from the $_POST data.
|
171 |
-
if ( isset( $results['removed_params'] ) && $results['removed_params'] ) {
|
172 |
-
$wpcf7_form->set_removed_posted_data( $results['removed_params'] );
|
173 |
-
}
|
174 |
-
}
|
175 |
-
}
|
176 |
-
}
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Handle validation actions
|
181 |
-
*
|
182 |
-
* @param [object] $wpcf_validation_obj - validation object.
|
183 |
-
* @param [array] $tags - contact form 7 tags array.
|
184 |
-
* @return object - $new_validation_obj - the updated validation object.
|
185 |
-
*/
|
186 |
-
public function handle_validation_actions( $wpcf_validation_obj, $tags ) {
|
187 |
-
|
188 |
-
// store refrence to the form tags status.
|
189 |
-
$wpcf_validation_obj->tags = $tags;
|
190 |
-
// get an instance of the form submission.
|
191 |
-
$submission = WPCF7_Submission::get_instance();
|
192 |
-
|
193 |
-
if ( ! $submission ) {
|
194 |
-
return $wpcf_validation_obj;
|
195 |
-
}
|
196 |
-
|
197 |
-
// Get an instance of the contact form 7 form.
|
198 |
-
$cf7_form = $submission->get_contact_form();
|
199 |
-
// Get an instance of contact form 7 redirection post.
|
200 |
-
$wpcf7_form = get_cf7r_form( $cf7_form, $submission, $wpcf_validation_obj );
|
201 |
-
|
202 |
-
$new_validation_obj = $wpcf_validation_obj;
|
203 |
-
|
204 |
-
// Check if the form has validation actions.
|
205 |
-
if ( $submission && $wpcf7_form->has_actions() ) {
|
206 |
-
// process all actions.
|
207 |
-
$invalid_tags = $wpcf7_form->process_validation_actions();
|
208 |
-
|
209 |
-
if ( $invalid_tags ) {
|
210 |
-
$new_validation_obj = new WPCF7_Validation();
|
211 |
-
|
212 |
-
// Invalidate all invalid tags.
|
213 |
-
foreach ( reset( $invalid_tags ) as $custom_error_action_results ) {
|
214 |
-
if ( isset( $custom_error_action_results['invalid_tags'] ) && $custom_error_action_results['invalid_tags'] ) {
|
215 |
-
foreach ( $custom_error_action_results['invalid_tags'] as $wp_error ) {
|
216 |
-
$error = $wp_error->get_error_message();
|
217 |
-
|
218 |
-
$new_validation_obj->invalidate( $error['tag'], $error['error_message'] );
|
219 |
-
}
|
220 |
-
}
|
221 |
-
// invalidate default tag errors.
|
222 |
-
foreach ( $tags as $tag ) {
|
223 |
-
if ( ! $custom_error_action_results['ignored_tags'] || ! in_array( $tag->name, $custom_error_action_results['ignored_tags'], true ) ) {
|
224 |
-
$result = apply_filters( "wpcf7_validate_{$tag->type}", $new_validation_obj, $tag );
|
225 |
-
}
|
226 |
-
}
|
227 |
-
}
|
228 |
-
}
|
229 |
-
}
|
230 |
-
|
231 |
-
return $new_validation_obj;
|
232 |
-
}
|
233 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Redirection for Contact Form 7 Submission handler
|
4 |
+
*
|
5 |
+
* @package wpcf7r
|
6 |
+
*/
|
7 |
+
|
8 |
+
defined( 'ABSPATH' ) || exit;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* WPCF7r_Submission Class - handles the submission process.
|
12 |
+
*/
|
13 |
+
class WPCF7r_Submission {
|
14 |
+
/**
|
15 |
+
* Change the response object returned to the client
|
16 |
+
*
|
17 |
+
* @param [object] $response - contact form 7 response object.
|
18 |
+
* @return [object] $response - contact form 7 updated response object.
|
19 |
+
*/
|
20 |
+
public function manipulate_cf7_response_object( $response ) {
|
21 |
+
|
22 |
+
if ( isset( $this->response ) && $this->response ) {
|
23 |
+
$response = array_merge( $this->response, $response );
|
24 |
+
}
|
25 |
+
|
26 |
+
return apply_filters( 'wpcf7r_manipulate_cf7_response_object', $response, $this );
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Add plugin support to browsers that don't support ajax.
|
31 |
+
*
|
32 |
+
* @param [object] $wpcf7 - contact form 7 form object.
|
33 |
+
* @return void
|
34 |
+
*/
|
35 |
+
public function non_ajax_redirection( $wpcf7 ) {
|
36 |
+
|
37 |
+
if ( ! WPCF7_Submission::is_restful() ) {
|
38 |
+
|
39 |
+
$submission = WPCF7_Submission::get_instance();
|
40 |
+
|
41 |
+
$wpcf7_form = get_cf7r_form( $wpcf7, $submission );
|
42 |
+
|
43 |
+
if ( 'mail_sent' === $wpcf7_form->get_submission_status() ) {
|
44 |
+
|
45 |
+
$results = $this->handle_valid_actions( $wpcf7 );
|
46 |
+
|
47 |
+
if ( $results ) {
|
48 |
+
foreach ( $results as $result_type => $result_actions ) {
|
49 |
+
if ( ( 'FireScript' === $result_type || 'firescript' === strtolower( $result_type ) ) && $result_action ) {
|
50 |
+
$this->scripts = $result_actions;
|
51 |
+
|
52 |
+
add_action( 'wp_head', array( $this, 'add_header_script' ) );
|
53 |
+
}
|
54 |
+
|
55 |
+
foreach ( $result_actions as $result_action ) {
|
56 |
+
if ( 'redirect' === $result_type ) {
|
57 |
+
$this->redirect_url = $result_action['redirect_url'];
|
58 |
+
|
59 |
+
if ( 'new_tab' === $result_action['type'] ) {
|
60 |
+
add_action( 'wp_head', array( $this, 'open_new_tab' ), 9999 );
|
61 |
+
} else {
|
62 |
+
// Do this last.
|
63 |
+
add_action( 'wp_head', array( $this, 'redirect' ), 9999 );
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Print header scripts for non ajax submits
|
75 |
+
*/
|
76 |
+
public function add_header_script() {
|
77 |
+
if ( isset( $this->scripts ) && $this->scripts ) {
|
78 |
+
foreach ( $this->scripts as $script ) {
|
79 |
+
echo '<script>' . $script . '</script>';
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Redirect support for non ajax browsers
|
86 |
+
*/
|
87 |
+
public function redirect() {
|
88 |
+
// Allow other plugins to manipulate the redirect url settings.
|
89 |
+
$redirect_url = apply_filters( 'wpcf7_redirect_url', $this->redirect_url );
|
90 |
+
|
91 |
+
echo "<script>window.location='" . esc_attr( $redirect_url ) . "'</script>";
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Open new tab on non ajax submits
|
96 |
+
*/
|
97 |
+
public function open_new_tab() {
|
98 |
+
// Allow other plugins to manipulate the redirect url settings.
|
99 |
+
$redirect_url = apply_filters( 'wpcf7_redirect_url', $this->redirect_url );
|
100 |
+
|
101 |
+
echo "<script>window.open('" . esc_attr( $redirect_url ) . "')</script>";
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* This function is fired before send email
|
106 |
+
*
|
107 |
+
* @param [object] $wpcf7 - cf7 form object.
|
108 |
+
* @return mixed - redirect response
|
109 |
+
*/
|
110 |
+
public function handle_valid_actions( $wpcf7 ) {
|
111 |
+
|
112 |
+
$submission = WPCF7_Submission::get_instance();
|
113 |
+
|
114 |
+
$wpcf7_form = get_cf7r_form( $wpcf7, $submission );
|
115 |
+
|
116 |
+
if ( $submission && $wpcf7_form->has_actions() ) {
|
117 |
+
// Get the submitted data.
|
118 |
+
$this->posted_data = $submission->get_posted_data();
|
119 |
+
|
120 |
+
// Process all relevant actions.
|
121 |
+
$this->response = $wpcf7_form->process_actions();
|
122 |
+
|
123 |
+
// Skip default contact form 7 email.
|
124 |
+
if ( isset( $this->response['send_mail'] ) && $this->response['send_mail'] ) {
|
125 |
+
add_filter(
|
126 |
+
'wpcf7_skip_mail',
|
127 |
+
function() {
|
128 |
+
return true;
|
129 |
+
}
|
130 |
+
);
|
131 |
+
}
|
132 |
+
|
133 |
+
$this->save_lead_actions( $this->response );
|
134 |
+
|
135 |
+
$wpcf7_form->maybe_perform_pre_result_action();
|
136 |
+
|
137 |
+
return $this->response;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Save lead actions
|
143 |
+
*
|
144 |
+
* @param [array] $actions_results - save actions on the lead record.
|
145 |
+
* @return void
|
146 |
+
*/
|
147 |
+
public function save_lead_actions( $actions_results ) {
|
148 |
+
foreach ( $actions_results as $action_type => $actions_result ) {
|
149 |
+
WPCF7R_Leads_Manager::save_action( WPCF7R_Action::get_lead_id(), $action_type, $actions_result );
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Early hook to catch cf7 submissions before they are processed
|
155 |
+
*
|
156 |
+
* @param [object] $cf7 - contact form 7 form object.
|
157 |
+
* @return void
|
158 |
+
*/
|
159 |
+
public function after_cf7_object_created( $cf7 ) {
|
160 |
+
if ( WPCF7_Submission::is_restful() || isset( $_POST['_wpcf7'] ) ) {
|
161 |
+
// Get an instance of contact form 7 redirection post.
|
162 |
+
$wpcf7_form = get_cf7r_form( $cf7 );
|
163 |
+
|
164 |
+
// Check if the form has validation actions.
|
165 |
+
$actions = $wpcf7_form->get_active_actions();
|
166 |
+
|
167 |
+
if ( $actions ) {
|
168 |
+
foreach ( $actions as $action ) {
|
169 |
+
$results = $action->process_pre_submit_actions();
|
170 |
+
// Saved reference for the items removed from the $_POST data.
|
171 |
+
if ( isset( $results['removed_params'] ) && $results['removed_params'] ) {
|
172 |
+
$wpcf7_form->set_removed_posted_data( $results['removed_params'] );
|
173 |
+
}
|
174 |
+
}
|
175 |
+
}
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Handle validation actions
|
181 |
+
*
|
182 |
+
* @param [object] $wpcf_validation_obj - validation object.
|
183 |
+
* @param [array] $tags - contact form 7 tags array.
|
184 |
+
* @return object - $new_validation_obj - the updated validation object.
|
185 |
+
*/
|
186 |
+
public function handle_validation_actions( $wpcf_validation_obj, $tags ) {
|
187 |
+
|
188 |
+
// store refrence to the form tags status.
|
189 |
+
$wpcf_validation_obj->tags = $tags;
|
190 |
+
// get an instance of the form submission.
|
191 |
+
$submission = WPCF7_Submission::get_instance();
|
192 |
+
|
193 |
+
if ( ! $submission ) {
|
194 |
+
return $wpcf_validation_obj;
|
195 |
+
}
|
196 |
+
|
197 |
+
// Get an instance of the contact form 7 form.
|
198 |
+
$cf7_form = $submission->get_contact_form();
|
199 |
+
// Get an instance of contact form 7 redirection post.
|
200 |
+
$wpcf7_form = get_cf7r_form( $cf7_form, $submission, $wpcf_validation_obj );
|
201 |
+
|
202 |
+
$new_validation_obj = $wpcf_validation_obj;
|
203 |
+
|
204 |
+
// Check if the form has validation actions.
|
205 |
+
if ( $submission && $wpcf7_form->has_actions() ) {
|
206 |
+
// process all actions.
|
207 |
+
$invalid_tags = $wpcf7_form->process_validation_actions();
|
208 |
+
|
209 |
+
if ( $invalid_tags ) {
|
210 |
+
$new_validation_obj = new WPCF7_Validation();
|
211 |
+
|
212 |
+
// Invalidate all invalid tags.
|
213 |
+
foreach ( reset( $invalid_tags ) as $custom_error_action_results ) {
|
214 |
+
if ( isset( $custom_error_action_results['invalid_tags'] ) && $custom_error_action_results['invalid_tags'] ) {
|
215 |
+
foreach ( $custom_error_action_results['invalid_tags'] as $wp_error ) {
|
216 |
+
$error = $wp_error->get_error_message();
|
217 |
+
|
218 |
+
$new_validation_obj->invalidate( $error['tag'], $error['error_message'] );
|
219 |
+
}
|
220 |
+
}
|
221 |
+
// invalidate default tag errors.
|
222 |
+
foreach ( $tags as $tag ) {
|
223 |
+
if ( ! $custom_error_action_results['ignored_tags'] || ! in_array( $tag->name, $custom_error_action_results['ignored_tags'], true ) ) {
|
224 |
+
$result = apply_filters( "wpcf7_validate_{$tag->type}", $new_validation_obj, $tag );
|
225 |
+
}
|
226 |
+
}
|
227 |
+
}
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
return $new_validation_obj;
|
232 |
+
}
|
233 |
+
}
|
classes/class-wpcf7r-updates.php
CHANGED
@@ -1,146 +1,146 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class Wpcf7r_Updates
|
4 |
-
* A class used for updating the plugin using th QS API
|
5 |
-
*/
|
6 |
-
|
7 |
-
defined( 'ABSPATH' ) || exit;
|
8 |
-
|
9 |
-
class Wpcf7r_Updates {
|
10 |
-
// Plugin current version
|
11 |
-
private $current_version;
|
12 |
-
|
13 |
-
// Plugin remote update path
|
14 |
-
private $update_url;
|
15 |
-
|
16 |
-
// Plugin Slug (plugin_directory/plugin_file.php)
|
17 |
-
private $plugin_slug;
|
18 |
-
|
19 |
-
// Plugin name (plugin_file)
|
20 |
-
private $slug;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Initialize a new instance of the WordPress Auto-Update class
|
24 |
-
*
|
25 |
-
* @param $current_version
|
26 |
-
* @param $plugin_slug
|
27 |
-
*/
|
28 |
-
public function __construct( $current_version, $plugin_slug ) {
|
29 |
-
// Set the class public variables
|
30 |
-
$this->current_version = $current_version;
|
31 |
-
$this->update_url = add_query_arg( 'update', '', WPCF7_PRO_REDIRECT_PLUGIN_UPDATES );
|
32 |
-
|
33 |
-
// Set the Plugin Slug
|
34 |
-
$this->plugin_slug = $plugin_slug;
|
35 |
-
list ($t1, $t2) = explode( '/', $plugin_slug );
|
36 |
-
$this->slug = str_replace( '.php', '', $t2 );
|
37 |
-
|
38 |
-
$this->activation_id = WPCF7r_Utils::get_activation_id();
|
39 |
-
$this->serial = WPCF7r_Utils::get_serial_key();
|
40 |
-
$this->domain = $_SERVER['HTTP_HOST'];
|
41 |
-
// define the alternative API for updating checking
|
42 |
-
add_filter( 'pre_set_site_transient_update_plugins', array( &$this, 'check_update' ) );
|
43 |
-
|
44 |
-
// Define the alternative response for information checking
|
45 |
-
add_filter( 'plugins_api', array( &$this, 'check_info' ), 10, 3 );
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Add our self-hosted autoupdate plugin to the filter transient
|
50 |
-
*
|
51 |
-
* @param $transient
|
52 |
-
* @return 'self-hosted' autoupdate plugin to the filter transient
|
53 |
-
*/
|
54 |
-
public function check_update( $transient ) {
|
55 |
-
|
56 |
-
if ( empty( $transient->checked ) ) {
|
57 |
-
return $transient;
|
58 |
-
}
|
59 |
-
|
60 |
-
// Get the remote version
|
61 |
-
$remote_version = $this->get_remote( 'version' );
|
62 |
-
|
63 |
-
if ( $remote_version && ! is_wp_error( $remote_version ) ) {
|
64 |
-
// If a newer version is available, add the update
|
65 |
-
if ( version_compare( $this->current_version, $remote_version->new_version, '<' ) ) {
|
66 |
-
$obj = new stdClass();
|
67 |
-
$obj->slug = $this->slug;
|
68 |
-
$obj->new_version = $remote_version->new_version;
|
69 |
-
$obj->url = $remote_version->url;
|
70 |
-
$obj->requires = $remote_version->requires;
|
71 |
-
$obj->plugin = $this->plugin_slug;
|
72 |
-
$obj->package = $remote_version->package;
|
73 |
-
$obj->tested = $remote_version->tested;
|
74 |
-
$transient->response[ $this->plugin_slug ] = $obj;
|
75 |
-
}
|
76 |
-
}
|
77 |
-
|
78 |
-
return $transient;
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Add our self-hosted description to the filter
|
83 |
-
*
|
84 |
-
* @param $false
|
85 |
-
* @param $action
|
86 |
-
* @param $arg
|
87 |
-
* @return bool|object
|
88 |
-
*/
|
89 |
-
public function check_info( $false, $action, $arg ) {
|
90 |
-
if ( ( 'query_plugins' === $action || 'plugin_information' === $action ) &&
|
91 |
-
isset( $arg->slug ) && $arg->slug === $this->slug ) {
|
92 |
-
|
93 |
-
$information = $this->get_remote( 'info' );
|
94 |
-
|
95 |
-
$information->sections = (array) $information->sections;
|
96 |
-
$information->banners = (array) $information->banners;
|
97 |
-
|
98 |
-
$array_pattern = array(
|
99 |
-
'/^([\*\s])*(\d\d\.\d\d\.\d\d\d\d[^\n]*)/m',
|
100 |
-
'/^\n+|^[\t\s]*\n+/m',
|
101 |
-
'/\n/',
|
102 |
-
);
|
103 |
-
$array_replace = array(
|
104 |
-
'<h4>$2</h4>',
|
105 |
-
'</div><div>',
|
106 |
-
'</div><div>',
|
107 |
-
);
|
108 |
-
|
109 |
-
$information->sections['changelog'] = '<div>' . preg_replace( $array_pattern, $array_replace, $information->sections['changelog'] ) . '</div>';
|
110 |
-
|
111 |
-
return $information;
|
112 |
-
}
|
113 |
-
|
114 |
-
return $false;
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Return the remote version
|
119 |
-
*
|
120 |
-
* @param $action
|
121 |
-
* @return string $remote_version
|
122 |
-
*/
|
123 |
-
public function get_remote( $action = '' ) {
|
124 |
-
|
125 |
-
$params = array(
|
126 |
-
'body' => array(
|
127 |
-
'action' => $action,
|
128 |
-
'activation_id' => $this->activation_id,
|
129 |
-
'serial' => $this->serial,
|
130 |
-
'plugin' => $this->plugin_slug,
|
131 |
-
'domain' => $this->domain,
|
132 |
-
),
|
133 |
-
);
|
134 |
-
|
135 |
-
// Make the POST request
|
136 |
-
$response = wp_remote_post( $this->update_url, $params );
|
137 |
-
|
138 |
-
// Check if response is valid
|
139 |
-
if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
|
140 |
-
$response = json_decode( wp_remote_retrieve_body( $response ) );
|
141 |
-
|
142 |
-
}
|
143 |
-
|
144 |
-
return $response;
|
145 |
-
}
|
146 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Wpcf7r_Updates
|
4 |
+
* A class used for updating the plugin using th QS API
|
5 |
+
*/
|
6 |
+
|
7 |
+
defined( 'ABSPATH' ) || exit;
|
8 |
+
|
9 |
+
class Wpcf7r_Updates {
|
10 |
+
// Plugin current version
|
11 |
+
private $current_version;
|
12 |
+
|
13 |
+
// Plugin remote update path
|
14 |
+
private $update_url;
|
15 |
+
|
16 |
+
// Plugin Slug (plugin_directory/plugin_file.php)
|
17 |
+
private $plugin_slug;
|
18 |
+
|
19 |
+
// Plugin name (plugin_file)
|
20 |
+
private $slug;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Initialize a new instance of the WordPress Auto-Update class
|
24 |
+
*
|
25 |
+
* @param $current_version
|
26 |
+
* @param $plugin_slug
|
27 |
+
*/
|
28 |
+
public function __construct( $current_version, $plugin_slug ) {
|
29 |
+
// Set the class public variables
|
30 |
+
$this->current_version = $current_version;
|
31 |
+
$this->update_url = add_query_arg( 'update', '', WPCF7_PRO_REDIRECT_PLUGIN_UPDATES );
|
32 |
+
|
33 |
+
// Set the Plugin Slug
|
34 |
+
$this->plugin_slug = $plugin_slug;
|
35 |
+
list ($t1, $t2) = explode( '/', $plugin_slug );
|
36 |
+
$this->slug = str_replace( '.php', '', $t2 );
|
37 |
+
|
38 |
+
$this->activation_id = WPCF7r_Utils::get_activation_id();
|
39 |
+
$this->serial = WPCF7r_Utils::get_serial_key();
|
40 |
+
$this->domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (string)parse_url(get_option('siteurl'), PHP_URL_HOST);
|
41 |
+
// define the alternative API for updating checking
|
42 |
+
add_filter( 'pre_set_site_transient_update_plugins', array( &$this, 'check_update' ) );
|
43 |
+
|
44 |
+
// Define the alternative response for information checking
|
45 |
+
add_filter( 'plugins_api', array( &$this, 'check_info' ), 10, 3 );
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Add our self-hosted autoupdate plugin to the filter transient
|
50 |
+
*
|
51 |
+
* @param $transient
|
52 |
+
* @return 'self-hosted' autoupdate plugin to the filter transient
|
53 |
+
*/
|
54 |
+
public function check_update( $transient ) {
|
55 |
+
|
56 |
+
if ( empty( $transient->checked ) ) {
|
57 |
+
return $transient;
|
58 |
+
}
|
59 |
+
|
60 |
+
// Get the remote version
|
61 |
+
$remote_version = $this->get_remote( 'version' );
|
62 |
+
|
63 |
+
if ( $remote_version && ! is_wp_error( $remote_version ) ) {
|
64 |
+
// If a newer version is available, add the update
|
65 |
+
if ( version_compare( $this->current_version, $remote_version->new_version, '<' ) ) {
|
66 |
+
$obj = new stdClass();
|
67 |
+
$obj->slug = $this->slug;
|
68 |
+
$obj->new_version = $remote_version->new_version;
|
69 |
+
$obj->url = $remote_version->url;
|
70 |
+
$obj->requires = $remote_version->requires;
|
71 |
+
$obj->plugin = $this->plugin_slug;
|
72 |
+
$obj->package = $remote_version->package;
|
73 |
+
$obj->tested = $remote_version->tested;
|
74 |
+
$transient->response[ $this->plugin_slug ] = $obj;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
return $transient;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Add our self-hosted description to the filter
|
83 |
+
*
|
84 |
+
* @param $false
|
85 |
+
* @param $action
|
86 |
+
* @param $arg
|
87 |
+
* @return bool|object
|
88 |
+
*/
|
89 |
+
public function check_info( $false, $action, $arg ) {
|
90 |
+
if ( ( 'query_plugins' === $action || 'plugin_information' === $action ) &&
|
91 |
+
isset( $arg->slug ) && $arg->slug === $this->slug ) {
|
92 |
+
|
93 |
+
$information = $this->get_remote( 'info' );
|
94 |
+
|
95 |
+
$information->sections = (array) $information->sections;
|
96 |
+
$information->banners = (array) $information->banners;
|
97 |
+
|
98 |
+
$array_pattern = array(
|
99 |
+
'/^([\*\s])*(\d\d\.\d\d\.\d\d\d\d[^\n]*)/m',
|
100 |
+
'/^\n+|^[\t\s]*\n+/m',
|
101 |
+
'/\n/',
|
102 |
+
);
|
103 |
+
$array_replace = array(
|
104 |
+
'<h4>$2</h4>',
|
105 |
+
'</div><div>',
|
106 |
+
'</div><div>',
|
107 |
+
);
|
108 |
+
|
109 |
+
$information->sections['changelog'] = '<div>' . preg_replace( $array_pattern, $array_replace, $information->sections['changelog'] ) . '</div>';
|
110 |
+
|
111 |
+
return $information;
|
112 |
+
}
|
113 |
+
|
114 |
+
return $false;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Return the remote version
|
119 |
+
*
|
120 |
+
* @param $action
|
121 |
+
* @return string $remote_version
|
122 |
+
*/
|
123 |
+
public function get_remote( $action = '' ) {
|
124 |
+
|
125 |
+
$params = array(
|
126 |
+
'body' => array(
|
127 |
+
'action' => $action,
|
128 |
+
'activation_id' => $this->activation_id,
|
129 |
+
'serial' => $this->serial,
|
130 |
+
'plugin' => $this->plugin_slug,
|
131 |
+
'domain' => $this->domain,
|
132 |
+
),
|
133 |
+
);
|
134 |
+
|
135 |
+
// Make the POST request
|
136 |
+
$response = wp_remote_post( $this->update_url, $params );
|
137 |
+
|
138 |
+
// Check if response is valid
|
139 |
+
if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
|
140 |
+
$response = json_decode( wp_remote_retrieve_body( $response ) );
|
141 |
+
|
142 |
+
}
|
143 |
+
|
144 |
+
return $response;
|
145 |
+
}
|
146 |
+
}
|
classes/class-wpcf7r-user.php
CHANGED
@@ -1,117 +1,117 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7R_user - Parent class that handles all redirect actions.
|
4 |
-
*/
|
5 |
-
defined( 'ABSPATH' ) || exit;
|
6 |
-
|
7 |
-
class WPCF7R_User {
|
8 |
-
|
9 |
-
public function __construct() {
|
10 |
-
add_action( 'show_user_profile', array( $this, 'additional_profile_fields' ) );
|
11 |
-
add_action( 'edit_user_profile', array( $this, 'additional_profile_fields' ) );
|
12 |
-
|
13 |
-
add_action( 'personal_options_update', array( $this, 'save_custom_user_fields' ) );
|
14 |
-
add_action( 'edit_user_profile_update', array( $this, 'save_custom_user_fields' ) );
|
15 |
-
|
16 |
-
}
|
17 |
-
|
18 |
-
private function get_all_forms_fields() {
|
19 |
-
$this->fields = array();
|
20 |
-
|
21 |
-
$cf7_forms = $this->get_cf7_forms();
|
22 |
-
|
23 |
-
if ( $cf7_forms ) {
|
24 |
-
foreach ( $cf7_forms as $cf7_form ) {
|
25 |
-
$wpcf7r_form = get_cf7r_form( $cf7_form->ID );
|
26 |
-
|
27 |
-
$actions = $wpcf7r_form->get_actions( 'default' );
|
28 |
-
|
29 |
-
foreach ( $actions as $action ) {
|
30 |
-
$action_type = $action->get( 'action_type' );
|
31 |
-
if ( 'register' === $action_type ) {
|
32 |
-
|
33 |
-
$fields_mapping = maybe_unserialize( $action->get( 'user_fields' ) );
|
34 |
-
|
35 |
-
if ( $fields_mapping ) {
|
36 |
-
$this->fields = array_merge( $fields_mapping, $this->fields );
|
37 |
-
}
|
38 |
-
}
|
39 |
-
}
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
return $this->fields;
|
44 |
-
}
|
45 |
-
|
46 |
-
private function get_cf7_forms() {
|
47 |
-
$args = array(
|
48 |
-
'post_type' => 'wpcf7_contact_form',
|
49 |
-
'posts_per_page' => -1,
|
50 |
-
);
|
51 |
-
|
52 |
-
$cf7_forms = get_posts( $args );
|
53 |
-
|
54 |
-
return $cf7_forms;
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Add new fields above 'Update' button.
|
59 |
-
*
|
60 |
-
* @param $user_id
|
61 |
-
*/
|
62 |
-
public function save_custom_user_fields( $user_id ) {
|
63 |
-
|
64 |
-
if ( ! current_user_can( 'edit_user', $user_id ) ) {
|
65 |
-
return false;
|
66 |
-
}
|
67 |
-
|
68 |
-
$fields = $this->get_all_forms_fields();
|
69 |
-
|
70 |
-
if ( ! $fields ) {
|
71 |
-
return;
|
72 |
-
}
|
73 |
-
|
74 |
-
foreach ( $fields as $field ) {
|
75 |
-
$value = isset( $_POST[ $field['user_field_key'] ] ) ? $_POST[ $field['user_field_key'] ] : '';
|
76 |
-
update_user_meta( $user_id, $field['user_field_key'], $value );
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Add new fields above 'Update' button.
|
82 |
-
*
|
83 |
-
* @param WP_User $user User object.
|
84 |
-
*/
|
85 |
-
public function additional_profile_fields( $user ) {
|
86 |
-
|
87 |
-
$fields = $this->get_all_forms_fields();
|
88 |
-
|
89 |
-
if ( ! $fields ) {
|
90 |
-
return;
|
91 |
-
}
|
92 |
-
|
93 |
-
?>
|
94 |
-
|
95 |
-
<h3><?php _e( 'Extra profile information', 'wpcf7-redirect' ); ?></h3>
|
96 |
-
|
97 |
-
<table class="form-table">
|
98 |
-
<?php foreach ( $fields as $field ) : ?>
|
99 |
-
<?php
|
100 |
-
if ( ! $field['user_field_key'] ) {
|
101 |
-
continue;}
|
102 |
-
?>
|
103 |
-
<?php $value = get_user_meta( $user->ID, $field['user_field_key'], true ); ?>
|
104 |
-
<tr>
|
105 |
-
<th>
|
106 |
-
<label for="<?php echo $field['user_field_key']; ?>"><?php echo $field['user_field_key']; ?></label>
|
107 |
-
</th>
|
108 |
-
<td>
|
109 |
-
<input type="text" name="<?php echo $field['user_field_key']; ?>" value="<?php echo $value; ?>">
|
110 |
-
</td>
|
111 |
-
</tr>
|
112 |
-
<?php endforeach; ?>
|
113 |
-
</table>
|
114 |
-
<?php
|
115 |
-
}
|
116 |
-
|
117 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7R_user - Parent class that handles all redirect actions.
|
4 |
+
*/
|
5 |
+
defined( 'ABSPATH' ) || exit;
|
6 |
+
|
7 |
+
class WPCF7R_User {
|
8 |
+
|
9 |
+
public function __construct() {
|
10 |
+
add_action( 'show_user_profile', array( $this, 'additional_profile_fields' ) );
|
11 |
+
add_action( 'edit_user_profile', array( $this, 'additional_profile_fields' ) );
|
12 |
+
|
13 |
+
add_action( 'personal_options_update', array( $this, 'save_custom_user_fields' ) );
|
14 |
+
add_action( 'edit_user_profile_update', array( $this, 'save_custom_user_fields' ) );
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
private function get_all_forms_fields() {
|
19 |
+
$this->fields = array();
|
20 |
+
|
21 |
+
$cf7_forms = $this->get_cf7_forms();
|
22 |
+
|
23 |
+
if ( $cf7_forms ) {
|
24 |
+
foreach ( $cf7_forms as $cf7_form ) {
|
25 |
+
$wpcf7r_form = get_cf7r_form( $cf7_form->ID );
|
26 |
+
|
27 |
+
$actions = $wpcf7r_form->get_actions( 'default' );
|
28 |
+
|
29 |
+
foreach ( $actions as $action ) {
|
30 |
+
$action_type = $action->get( 'action_type' );
|
31 |
+
if ( 'register' === $action_type ) {
|
32 |
+
|
33 |
+
$fields_mapping = maybe_unserialize( $action->get( 'user_fields' ) );
|
34 |
+
|
35 |
+
if ( $fields_mapping ) {
|
36 |
+
$this->fields = array_merge( $fields_mapping, $this->fields );
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
return $this->fields;
|
44 |
+
}
|
45 |
+
|
46 |
+
private function get_cf7_forms() {
|
47 |
+
$args = array(
|
48 |
+
'post_type' => 'wpcf7_contact_form',
|
49 |
+
'posts_per_page' => -1,
|
50 |
+
);
|
51 |
+
|
52 |
+
$cf7_forms = get_posts( $args );
|
53 |
+
|
54 |
+
return $cf7_forms;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Add new fields above 'Update' button.
|
59 |
+
*
|
60 |
+
* @param $user_id
|
61 |
+
*/
|
62 |
+
public function save_custom_user_fields( $user_id ) {
|
63 |
+
|
64 |
+
if ( ! current_user_can( 'edit_user', $user_id ) ) {
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
|
68 |
+
$fields = $this->get_all_forms_fields();
|
69 |
+
|
70 |
+
if ( ! $fields ) {
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
|
74 |
+
foreach ( $fields as $field ) {
|
75 |
+
$value = isset( $_POST[ $field['user_field_key'] ] ) ? $_POST[ $field['user_field_key'] ] : '';
|
76 |
+
update_user_meta( $user_id, $field['user_field_key'], $value );
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Add new fields above 'Update' button.
|
82 |
+
*
|
83 |
+
* @param WP_User $user User object.
|
84 |
+
*/
|
85 |
+
public function additional_profile_fields( $user ) {
|
86 |
+
|
87 |
+
$fields = $this->get_all_forms_fields();
|
88 |
+
|
89 |
+
if ( ! $fields ) {
|
90 |
+
return;
|
91 |
+
}
|
92 |
+
|
93 |
+
?>
|
94 |
+
|
95 |
+
<h3><?php _e( 'Extra profile information', 'wpcf7-redirect' ); ?></h3>
|
96 |
+
|
97 |
+
<table class="form-table">
|
98 |
+
<?php foreach ( $fields as $field ) : ?>
|
99 |
+
<?php
|
100 |
+
if ( ! $field['user_field_key'] ) {
|
101 |
+
continue;}
|
102 |
+
?>
|
103 |
+
<?php $value = get_user_meta( $user->ID, $field['user_field_key'], true ); ?>
|
104 |
+
<tr>
|
105 |
+
<th>
|
106 |
+
<label for="<?php echo $field['user_field_key']; ?>"><?php echo $field['user_field_key']; ?></label>
|
107 |
+
</th>
|
108 |
+
<td>
|
109 |
+
<input type="text" name="<?php echo $field['user_field_key']; ?>" value="<?php echo $value; ?>">
|
110 |
+
</td>
|
111 |
+
</tr>
|
112 |
+
<?php endforeach; ?>
|
113 |
+
</table>
|
114 |
+
<?php
|
115 |
+
}
|
116 |
+
|
117 |
+
}
|
classes/class-wpcf7r-utils.php
CHANGED
@@ -1,914 +1,914 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class WPCF7r_Utils file.
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Contact form 7 redirect utilities
|
10 |
-
*/
|
11 |
-
class WPCF7r_Utils {
|
12 |
-
public $banner_version = 1.01;
|
13 |
-
public static $instance;
|
14 |
-
public static $actions_list = array();
|
15 |
-
public static $rendered_elements = array();
|
16 |
-
|
17 |
-
public function __construct() {
|
18 |
-
self::$instance = $this;
|
19 |
-
|
20 |
-
$this->api = new Qs_Api();
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Add a message to the session collector
|
25 |
-
*
|
26 |
-
* @param $type
|
27 |
-
* @param $message
|
28 |
-
*/
|
29 |
-
public static function add_admin_notice( $type, $message ) {
|
30 |
-
$_SESSION['wpcf7r_admin_notices'][ $type ] = $message;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Register a new type of action
|
35 |
-
*
|
36 |
-
* @param $name
|
37 |
-
* @param $title
|
38 |
-
* @param $class
|
39 |
-
*/
|
40 |
-
public static function register_wpcf7r_actions( $name, $title, $class, $order ) {
|
41 |
-
self::$actions_list[ $name ] = array(
|
42 |
-
'label' => $title,
|
43 |
-
'attr' => '',
|
44 |
-
'handler' => $class,
|
45 |
-
'order' => $order,
|
46 |
-
);
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Get action name
|
51 |
-
*
|
52 |
-
* @param $action_type
|
53 |
-
*/
|
54 |
-
public static function get_action_name( $action_type ) {
|
55 |
-
return isset( self::$actions_list[ $action_type ] ) ? self::$actions_list[ $action_type ]['label'] : $action_type;
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Get the available actions
|
60 |
-
*/
|
61 |
-
public static function get_wpcf7r_actions() {
|
62 |
-
return self::$actions_list;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Duplicate all action posts and connect it to the new created form
|
67 |
-
*
|
68 |
-
* @param $new_cf7
|
69 |
-
*/
|
70 |
-
public function duplicate_form_support( $new_cf7 ) {
|
71 |
-
|
72 |
-
if ( isset( $_POST['wpcf7-copy'] ) && 'Duplicate' === $_POST['wpcf7-copy'] || ( isset( $_GET['action'] ) && 'copy' === $_GET['action'] ) ) {
|
73 |
-
|
74 |
-
$original_post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : (int) $_GET['post'];
|
75 |
-
|
76 |
-
$original_cf7 = get_cf7r_form( $original_post_id );
|
77 |
-
|
78 |
-
$original_action_posts = $original_cf7->get_actions( 'default' );
|
79 |
-
|
80 |
-
if ( $original_action_posts ) {
|
81 |
-
foreach ( $original_action_posts as $original_action_post ) {
|
82 |
-
$new_post_id = $this->duplicate_post( $original_action_post->action_post );
|
83 |
-
|
84 |
-
update_post_meta( $new_post_id, 'wpcf7_id', $new_cf7->id() );
|
85 |
-
}
|
86 |
-
}
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* After form deletion delete all its actions
|
92 |
-
*
|
93 |
-
* @param int $post_id
|
94 |
-
*/
|
95 |
-
public function delete_all_form_actions( $post_id ) {
|
96 |
-
global $post_type;
|
97 |
-
|
98 |
-
if ( get_post_type( $post_id ) === 'wpcf7_contact_form' ) {
|
99 |
-
|
100 |
-
$wpcf7r = get_cf7r_form( $post_id );
|
101 |
-
|
102 |
-
$action_posts = $wpcf7r->get_actions( 'default' );
|
103 |
-
|
104 |
-
if ( $action_posts ) {
|
105 |
-
foreach ( $action_posts as $action_post ) {
|
106 |
-
wp_delete_post( $action_post->get_id() );
|
107 |
-
}
|
108 |
-
}
|
109 |
-
};
|
110 |
-
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Dupplicate contact form and all its actions
|
115 |
-
*
|
116 |
-
* @param $action
|
117 |
-
*/
|
118 |
-
public function duplicate_post( $action ) {
|
119 |
-
global $wpdb;
|
120 |
-
|
121 |
-
// if you don't want current user to be the new post author,
|
122 |
-
// then change next couple of lines to this: $new_post_author = $post->post_author;
|
123 |
-
$current_user = wp_get_current_user();
|
124 |
-
$new_post_author = $current_user->ID;
|
125 |
-
$post_id = $action->ID;
|
126 |
-
|
127 |
-
// if post data exists, create the post duplicate
|
128 |
-
if ( isset( $action ) && null !== $action ) {
|
129 |
-
// new post data array
|
130 |
-
$args = array(
|
131 |
-
'comment_status' => $action->comment_status,
|
132 |
-
'ping_status' => $action->ping_status,
|
133 |
-
'post_author' => $new_post_author,
|
134 |
-
'post_content' => $action->post_content,
|
135 |
-
'post_excerpt' => $action->post_excerpt,
|
136 |
-
'post_name' => $action->post_name,
|
137 |
-
'post_parent' => $action->post_parent,
|
138 |
-
'post_password' => $action->post_password,
|
139 |
-
'post_status' => 'private',
|
140 |
-
'post_title' => $action->post_title,
|
141 |
-
'post_type' => $action->post_type,
|
142 |
-
'to_ping' => $action->to_ping,
|
143 |
-
'menu_order' => $action->menu_order,
|
144 |
-
);
|
145 |
-
|
146 |
-
// insert the post by wp_insert_post() function
|
147 |
-
$new_post_id = wp_insert_post( $args );
|
148 |
-
|
149 |
-
// get all current post terms ad set them to the new post draft
|
150 |
-
$taxonomies = get_object_taxonomies( $action->post_type );
|
151 |
-
|
152 |
-
// returns array of taxonomy names for post type, ex array("category", "post_tag");
|
153 |
-
if ( $taxonomies ) {
|
154 |
-
foreach ( $taxonomies as $taxonomy ) {
|
155 |
-
$post_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'slugs' ) );
|
156 |
-
wp_set_object_terms( $new_post_id, $post_terms, $taxonomy, false );
|
157 |
-
}
|
158 |
-
}
|
159 |
-
|
160 |
-
// duplicate all post meta just in two SQL queries
|
161 |
-
$sql = $wpdb->prepare( "SELECT meta_key, meta_value FROM {$wpdb->postmeta} WHERE post_id='%s'", $post_id );
|
162 |
-
|
163 |
-
$post_meta_infos = $wpdb->get_results( $sql );
|
164 |
-
|
165 |
-
foreach ( $post_meta_infos as $meta_info ) {
|
166 |
-
if ( '_wp_old_slug' === $meta_info->meta_key ) {
|
167 |
-
continue;
|
168 |
-
}
|
169 |
-
|
170 |
-
update_post_meta( $new_post_id, $meta_info->meta_key, maybe_unserialize( $meta_info->meta_value ) );
|
171 |
-
}
|
172 |
-
|
173 |
-
return $new_post_id;
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Set actions order
|
179 |
-
*/
|
180 |
-
public function set_action_menu_order() {
|
181 |
-
global $wpdb;
|
182 |
-
|
183 |
-
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
184 |
-
parse_str( $_POST['data']['order'], $data );
|
185 |
-
|
186 |
-
if ( ! is_array( $data ) ) {
|
187 |
-
return false;
|
188 |
-
}
|
189 |
-
|
190 |
-
// get objects per now page
|
191 |
-
$id_arr = array();
|
192 |
-
foreach ( $data as $key => $values ) {
|
193 |
-
foreach ( $values as $position => $id ) {
|
194 |
-
$id_arr[] = $id;
|
195 |
-
}
|
196 |
-
}
|
197 |
-
|
198 |
-
foreach ( $id_arr as $key => $post_id ) {
|
199 |
-
$menu_order = $key + 1;
|
200 |
-
$wpdb->update( $wpdb->posts, array( 'menu_order' => $menu_order ), array( 'ID' => intval( $post_id ) ) );
|
201 |
-
}
|
202 |
-
}
|
203 |
-
|
204 |
-
die('1');
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Render elements required by actions
|
209 |
-
*
|
210 |
-
* @return void
|
211 |
-
*/
|
212 |
-
public function render_actions_elements( $properties, $form ) {
|
213 |
-
|
214 |
-
$action_posts = wpcf7r_get_actions( 'wpcf7r_action', -1, $form->id(), 'default', array(), true );
|
215 |
-
|
216 |
-
if ( $action_posts ) {
|
217 |
-
foreach ( $action_posts as $action_post ) {
|
218 |
-
$action = WPCF7R_Action::get_action( $action_post );
|
219 |
-
|
220 |
-
if ( ! isset( self::$rendered_elements[ $action_post->ID ] ) ) {
|
221 |
-
// these actions will run once.
|
222 |
-
if ( is_object( $action ) && ! is_wp_error( $action ) && method_exists( $action, 'render_callback_once' ) ) {
|
223 |
-
$properties = $action->render_callback_once( $properties, $form );
|
224 |
-
}
|
225 |
-
|
226 |
-
self::$rendered_elements[ $action_post->ID ] = $action_post->ID;
|
227 |
-
}
|
228 |
-
|
229 |
-
// Render_callback will be called several times because of the way contact form 7 uses these properties.
|
230 |
-
// use state and db on the action to limit it to run only once.
|
231 |
-
if ( is_object( $action ) && ! is_wp_error( $action ) && method_exists( $action, 'render_callback' ) ) {
|
232 |
-
$properties = $action->render_callback( $properties, $form );
|
233 |
-
}
|
234 |
-
}
|
235 |
-
}
|
236 |
-
|
237 |
-
return $properties;
|
238 |
-
}
|
239 |
-
/**
|
240 |
-
* Delete an action
|
241 |
-
*/
|
242 |
-
public function delete_action_post() {
|
243 |
-
$response['status'] = 'failed';
|
244 |
-
|
245 |
-
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
246 |
-
$data = isset( $_POST['data'] ) ? $_POST['data'] : '';
|
247 |
-
|
248 |
-
if ( $data ) {
|
249 |
-
foreach ( $data as $post_to_delete ) {
|
250 |
-
if ( $post_to_delete ) {
|
251 |
-
wp_trash_post( $post_to_delete['post_id'] );
|
252 |
-
$response['status'] = 'deleted';
|
253 |
-
}
|
254 |
-
}
|
255 |
-
}
|
256 |
-
}
|
257 |
-
|
258 |
-
wp_send_json( $response );
|
259 |
-
}
|
260 |
-
|
261 |
-
/**
|
262 |
-
* Show notices on admin panel
|
263 |
-
*/
|
264 |
-
public function show_admin_notices() {
|
265 |
-
global $wp_sessions;
|
266 |
-
|
267 |
-
if ( ! isset( $_SESSION['wpcf7r_admin_notices'] ) ) {
|
268 |
-
return;
|
269 |
-
}
|
270 |
-
|
271 |
-
foreach ( $_SESSION['wpcf7r_admin_notices'] as $notice_type => $notice ) :
|
272 |
-
?>
|
273 |
-
|
274 |
-
<div class="notice notice-error is-dismissible <?php echo $notice_type; ?>">
|
275 |
-
<p><?php echo $notice; ?></p>
|
276 |
-
</div>
|
277 |
-
|
278 |
-
<?php
|
279 |
-
endforeach;
|
280 |
-
}
|
281 |
-
|
282 |
-
/**
|
283 |
-
* Send debug data to querysol support api
|
284 |
-
*
|
285 |
-
* @return void
|
286 |
-
*/
|
287 |
-
public function send_debug_info() {
|
288 |
-
if ( current_user_can( 'administrator' ) && wpcf7_validate_nonce() ) {
|
289 |
-
$data = isset( $_POST['data'] ) ? $_POST['data'] : '';
|
290 |
-
|
291 |
-
if ( $data['form_id'] ) {
|
292 |
-
$debug_data = WPCF7r_Form_Helper::get_debug_data( $data['form_id'] );
|
293 |
-
|
294 |
-
$api = new Qs_Api();
|
295 |
-
|
296 |
-
$args = array(
|
297 |
-
'headers' => array( 'Content-Type' => 'application/json; charset=utf-8' ),
|
298 |
-
);
|
299 |
-
|
300 |
-
$url = add_query_arg( 'site_url', home_url(), WPCF7_PRO_REDIRECT_DEBUG_URL );
|
301 |
-
|
302 |
-
$api->api_call( $url, json_encode( array( 'debug_data' => $debug_data ) ), $args );
|
303 |
-
}
|
304 |
-
}
|
305 |
-
|
306 |
-
wp_send_json_success();
|
307 |
-
}
|
308 |
-
/**
|
309 |
-
* Auto function to migrate old plugin to the new one
|
310 |
-
*
|
311 |
-
* @param $migration_action migrate_from_cf7_redirect/migrate_from_cf7_api
|
312 |
-
* @param boolean $force
|
313 |
-
*/
|
314 |
-
public static function auto_migrate( $migration_action, $force = false ) {
|
315 |
-
|
316 |
-
$instance = self::get_instance();
|
317 |
-
|
318 |
-
$cf7_forms = self::get_all_cf7_forms();
|
319 |
-
|
320 |
-
foreach ( $cf7_forms as $cf7_form_id ) {
|
321 |
-
|
322 |
-
$cf7r_form = new WPCF7R_Form( $cf7_form_id );
|
323 |
-
|
324 |
-
$instance->delete_all_form_actions( $cf7_form_id );
|
325 |
-
|
326 |
-
if ( ! $cf7r_form->has_migrated( $migration_action ) || $force ) {
|
327 |
-
$instance->convert_to_action( $cf7r_form, $migration_action, $cf7_form_id, 'default' );
|
328 |
-
|
329 |
-
$cf7r_form->update_migration( $migration_action );
|
330 |
-
}
|
331 |
-
}
|
332 |
-
}
|
333 |
-
|
334 |
-
/**
|
335 |
-
* Get all Contact Forms 7 forms
|
336 |
-
*/
|
337 |
-
public static function get_all_cf7_forms() {
|
338 |
-
$args = array(
|
339 |
-
'post_type' => 'wpcf7_contact_form',
|
340 |
-
'posts_per_page' => -1,
|
341 |
-
'fields' => 'ids',
|
342 |
-
'suppress_filters' => true,
|
343 |
-
);
|
344 |
-
|
345 |
-
$cf7_forms = get_posts( $args );
|
346 |
-
|
347 |
-
return $cf7_forms;
|
348 |
-
}
|
349 |
-
|
350 |
-
/**
|
351 |
-
* Duplicate an existing action and connect it with the form.
|
352 |
-
*
|
353 |
-
* @return void
|
354 |
-
*/
|
355 |
-
public function duplicate_action() {
|
356 |
-
$results['action_row'] = '';
|
357 |
-
|
358 |
-
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
359 |
-
if ( isset( $_POST['data'] ) ) {
|
360 |
-
$action_data = $_POST['data'];
|
361 |
-
|
362 |
-
$action_post_id = $action_data['post_id'];
|
363 |
-
|
364 |
-
$action_post = get_post( $action_post_id );
|
365 |
-
|
366 |
-
$new_action_post_id = $this->duplicate_post( $action_post );
|
367 |
-
|
368 |
-
update_post_meta( $new_action_post_id, 'wpcf7_id', $action_data['form_id'] );
|
369 |
-
|
370 |
-
$action = WPCF7R_Action::get_action( $new_action_post_id );
|
371 |
-
|
372 |
-
$results['action_row'] = $action->get_action_row();
|
373 |
-
}
|
374 |
-
}
|
375 |
-
|
376 |
-
wp_send_json( $results );
|
377 |
-
}
|
378 |
-
/**
|
379 |
-
* Create a new action post
|
380 |
-
*/
|
381 |
-
public function add_action_post() {
|
382 |
-
$results['action_row'] = '';
|
383 |
-
|
384 |
-
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
385 |
-
$post_id = isset( $_POST['data']['post_id'] ) ? (int) sanitize_text_field( $_POST['data']['post_id'] ) : '';
|
386 |
-
$rule_id = isset( $_POST['data']['rule_id'] ) ? sanitize_text_field( $_POST['data']['rule_id'] ) : '';
|
387 |
-
$action_type = isset( $_POST['data']['action_type'] ) ? sanitize_text_field( $_POST['data']['action_type'] ) : '';
|
388 |
-
|
389 |
-
$rule_name = __( 'New Action', 'wpcf7-redirect' );
|
390 |
-
|
391 |
-
$this->cf7r_form = get_cf7r_form( $post_id );
|
392 |
-
|
393 |
-
$actions = array();
|
394 |
-
|
395 |
-
// migrate from old api plugin
|
396 |
-
if ( 'migrate_from_cf7_api' === $action_type || 'migrate_from_cf7_redirect' === $action_type ) {
|
397 |
-
if ( ! $this->cf7r_form->has_migrated( $action_type ) ) {
|
398 |
-
$actions = $this->convert_to_action( $action_type, $post_id, $rule_name, $rule_id );
|
399 |
-
$this->cf7r_form->update_migration( $action_type );
|
400 |
-
}
|
401 |
-
} else {
|
402 |
-
$actions[] = $this->create_action( $post_id, $rule_name, $rule_id, $action_type );
|
403 |
-
}
|
404 |
-
|
405 |
-
if ( $actions ) {
|
406 |
-
foreach ( $actions as $action ) {
|
407 |
-
if ( ! is_wp_error( $action ) ) {
|
408 |
-
$results['action_row'] .= $action->get_action_row();
|
409 |
-
} else {
|
410 |
-
wp_send_json( $results );
|
411 |
-
}
|
412 |
-
}
|
413 |
-
} else {
|
414 |
-
$results['action_row'] = '';
|
415 |
-
}
|
416 |
-
}
|
417 |
-
|
418 |
-
wp_send_json( $results );
|
419 |
-
}
|
420 |
-
|
421 |
-
/**
|
422 |
-
* Convert old plugin data to new structure
|
423 |
-
*
|
424 |
-
* @param $required_conversion
|
425 |
-
* @param $post_id
|
426 |
-
* @param $rule_name
|
427 |
-
* @param $rule_id
|
428 |
-
* @return Actions
|
429 |
-
*
|
430 |
-
* @version 1.2
|
431 |
-
*/
|
432 |
-
|
433 |
-
private function convert_to_action( $cf7r_form, $required_conversion, $post_id, $rule_id ) {
|
434 |
-
$actions = array();
|
435 |
-
|
436 |
-
if ( 'migrate_from_cf7_redirect' === $required_conversion ) {
|
437 |
-
$old_api_action = $cf7r_form->get_cf7_redirection_settings();
|
438 |
-
|
439 |
-
if ( $old_api_action ) {
|
440 |
-
// CREATE JAVSCRIPT ACTION.
|
441 |
-
if ( $old_api_action['fire_sctipt'] ) {
|
442 |
-
$javscript_action = $this->create_action( $post_id, __( 'Migrated Javascript Action From Old Plugin', 'wpcf7-redirect' ), $rule_id, 'FireScript' );
|
443 |
-
|
444 |
-
$javscript_action->set( 'script', $old_api_action['fire_sctipt'] );
|
445 |
-
$javscript_action->set( 'action_status', 'on' );
|
446 |
-
|
447 |
-
unset( $old_api_action['fire_sctipt'] );
|
448 |
-
|
449 |
-
$actions[] = $javscript_action;
|
450 |
-
}
|
451 |
-
|
452 |
-
// CREATE REDIRECT ACTION.
|
453 |
-
$action = $this->create_action( $post_id, __( 'Migrated Redirect Action From Old Plugin', 'wpcf7-redirect' ), $rule_id, 'redirect' );
|
454 |
-
|
455 |
-
$action->set( 'action_status', 'on' );
|
456 |
-
|
457 |
-
foreach ( $old_api_action as $key => $value ) {
|
458 |
-
$action->set( $key, $value );
|
459 |
-
}
|
460 |
-
|
461 |
-
$actions[] = $action;
|
462 |
-
|
463 |
-
}
|
464 |
-
} elseif ( 'migrate_from_cf7_api' === $required_conversion ) {
|
465 |
-
$old_api_action = $cf7r_form->get_cf7_api_settings();
|
466 |
-
|
467 |
-
if ( $old_api_action ) {
|
468 |
-
|
469 |
-
$old_api__wpcf7_api_data = $old_api_action['_wpcf7_api_data'];
|
470 |
-
$old_tags_map = $old_api_action['_wpcf7_api_data_map'];
|
471 |
-
|
472 |
-
if ( 'params' === $old_api__wpcf7_api_data['input_type'] ) {
|
473 |
-
$action_type = 'api_url_request';
|
474 |
-
} elseif ( 'xml' === $old_api__wpcf7_api_data['input_type'] || 'json' === $old_api__wpcf7_api_data['input_type'] ) {
|
475 |
-
$action_type = 'api_json_xml_request';
|
476 |
-
}
|
477 |
-
|
478 |
-
$action = $this->create_action( $post_id, __( 'Migrated Data from Old Plugin', 'wpcf7-redirect' ), $rule_id, $action_type );
|
479 |
-
|
480 |
-
if ( ! is_wp_error( $action ) ) {
|
481 |
-
$action->set( 'base_url', $old_api__wpcf7_api_data['base_url'] );
|
482 |
-
$action->set( 'input_type', strtolower( $old_api__wpcf7_api_data['method'] ) );
|
483 |
-
$action->set( 'record_type', strtolower( $old_api__wpcf7_api_data['input_type'] ) );
|
484 |
-
$action->set( 'show_debug', '' );
|
485 |
-
$action->set( 'action_status', $old_api__wpcf7_api_data['send_to_api'] );
|
486 |
-
|
487 |
-
$tags_map = array();
|
488 |
-
|
489 |
-
if ( $old_tags_map ) {
|
490 |
-
foreach ( $old_tags_map as $tag_key => $tag_api_key ) {
|
491 |
-
$tags_map[ $tag_key ] = $tag_api_key;
|
492 |
-
}
|
493 |
-
|
494 |
-
$action->set( 'tags_map', $tags_map );
|
495 |
-
}
|
496 |
-
|
497 |
-
if ( isset( $old_api_action['_template'] ) && $old_api_action['_template'] ) {
|
498 |
-
$action->set( 'request_template', $old_api_action['_template'] );
|
499 |
-
} elseif ( isset( $old_api_action['_json_template'] ) && $old_api_action['_json_template'] ) {
|
500 |
-
$action->set( 'request_template', $old_api_action['_json_template'] );
|
501 |
-
}
|
502 |
-
|
503 |
-
$actions[] = $action;
|
504 |
-
}
|
505 |
-
}
|
506 |
-
}
|
507 |
-
|
508 |
-
return $actions;
|
509 |
-
}
|
510 |
-
|
511 |
-
/**
|
512 |
-
* Create new post that will hold the action
|
513 |
-
*
|
514 |
-
* @param $rule_name
|
515 |
-
* @param $rule_id
|
516 |
-
* @param $action_type
|
517 |
-
* @return Actions
|
518 |
-
*/
|
519 |
-
public function create_action( $post_id, $rule_name, $rule_id, $action_type ) {
|
520 |
-
$new_action_post = array(
|
521 |
-
'post_type' => 'wpcf7r_action',
|
522 |
-
'post_title' => $rule_name,
|
523 |
-
'post_status' => 'private',
|
524 |
-
'menu_order' => 1,
|
525 |
-
'meta_input' => array(
|
526 |
-
'wpcf7_id' => $post_id,
|
527 |
-
'wpcf7_rule_id' => $rule_id,
|
528 |
-
'action_type' => $action_type,
|
529 |
-
'action_status' => 'on',
|
530 |
-
),
|
531 |
-
);
|
532 |
-
|
533 |
-
$new_action_id = wp_insert_post( $new_action_post );
|
534 |
-
|
535 |
-
return WPCF7R_Action::get_action( $new_action_id, $post_id );
|
536 |
-
}
|
537 |
-
|
538 |
-
/**
|
539 |
-
* Get instance
|
540 |
-
*/
|
541 |
-
public static function get_instance() {
|
542 |
-
if ( null === self::$instance ) {
|
543 |
-
self::$instance = new self();
|
544 |
-
}
|
545 |
-
return self::$instance;
|
546 |
-
}
|
547 |
-
|
548 |
-
/**
|
549 |
-
* Get the banner template
|
550 |
-
*/
|
551 |
-
public function get_banner() {
|
552 |
-
if ( $this->get_option( 'last_banner_displayed' ) === $this->banner_version ) {
|
553 |
-
return;
|
554 |
-
}
|
555 |
-
ob_start();
|
556 |
-
|
557 |
-
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'banner.php';
|
558 |
-
|
559 |
-
$banner_html = ob_get_clean();
|
560 |
-
|
561 |
-
echo $banner_html;
|
562 |
-
}
|
563 |
-
|
564 |
-
/**
|
565 |
-
* Show a message containing the license details
|
566 |
-
*/
|
567 |
-
public function license_details_message() {
|
568 |
-
if ( ! self::get_activation_id() ) {
|
569 |
-
printf(
|
570 |
-
'<tr class="plugin-update-tr active" id="wpcf7-redirect-pro-update" data-slug="wpcf7-redirect-pro" data-plugin="contact-form-7-redirection-pro/wpcf7-redirect-pro.php"><td colspan="3" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p><strong>%s</strong> %s</p></div></td></tr>',
|
571 |
-
__( 'Please activate plugin license for updates', 'wpcf7-redirect' ),
|
572 |
-
self::get_settings_link()
|
573 |
-
);
|
574 |
-
|
575 |
-
}
|
576 |
-
|
577 |
-
}
|
578 |
-
|
579 |
-
/**
|
580 |
-
* Get all data related with plugin activation
|
581 |
-
*/
|
582 |
-
public static function get_activation_data() {
|
583 |
-
return get_option( 'wpcf7r_activation_data' );
|
584 |
-
}
|
585 |
-
|
586 |
-
/**
|
587 |
-
* Get date of plugin license expiration
|
588 |
-
*/
|
589 |
-
public static function get_activation_expiration() {
|
590 |
-
return get_option( 'wpcf7r_activation_expiration' );
|
591 |
-
}
|
592 |
-
|
593 |
-
/**
|
594 |
-
* A validation function to test the serial key
|
595 |
-
*/
|
596 |
-
public static function validate_serial_key() {
|
597 |
-
$instance = self::get_instance();
|
598 |
-
|
599 |
-
$serial = self::get_serial_key();
|
600 |
-
$activation_id = self::get_activation_id();
|
601 |
-
|
602 |
-
return $instance->api->validate_serial( $activation_id, $serial );
|
603 |
-
}
|
604 |
-
|
605 |
-
/**
|
606 |
-
* Get the used serial key
|
607 |
-
*/
|
608 |
-
public static function get_serial_key() {
|
609 |
-
return get_option( 'wpcf7r_serial_number' );
|
610 |
-
}
|
611 |
-
|
612 |
-
/**
|
613 |
-
* Delete the used setial key
|
614 |
-
*/
|
615 |
-
public static function delete_serial_key() {
|
616 |
-
return delete_option( 'wpcf7r_serial_number' );
|
617 |
-
}
|
618 |
-
|
619 |
-
/**
|
620 |
-
* Get a url to deactivate plugin license
|
621 |
-
*/
|
622 |
-
public static function get_deactivation_link() {
|
623 |
-
$url = self::get_plugin_settings_page_url();
|
624 |
-
|
625 |
-
$url = add_query_arg( 'wpcf7r_deactivate_license', '', $url );
|
626 |
-
|
627 |
-
return $url;
|
628 |
-
}
|
629 |
-
|
630 |
-
/**
|
631 |
-
* Get the plugin settings link
|
632 |
-
*/
|
633 |
-
public static function get_plugin_settings_page_url() {
|
634 |
-
return get_admin_url( null, 'options-general.php?page=wpc7_redirect' );
|
635 |
-
}
|
636 |
-
|
637 |
-
/**
|
638 |
-
* Get the activation id
|
639 |
-
*/
|
640 |
-
public static function get_activation_id() {
|
641 |
-
return get_option( 'wpcf7r_activation_id' );
|
642 |
-
}
|
643 |
-
|
644 |
-
/**
|
645 |
-
* Get a link to the admin settings panel
|
646 |
-
*/
|
647 |
-
public static function get_settings_link() {
|
648 |
-
return '<a href="' . self::get_plugin_settings_page_url() . '">' . __( 'Settings', 'wpcf7-redirect' ) . '</a>';
|
649 |
-
}
|
650 |
-
|
651 |
-
/**
|
652 |
-
* Close banner
|
653 |
-
*/
|
654 |
-
public function close_banner() {
|
655 |
-
if ( current_user_can( 'administrator' ) && wpcf7_validate_nonce() ) {
|
656 |
-
$this->update_option( 'last_banner_displayed', $this->banner_version );
|
657 |
-
}
|
658 |
-
}
|
659 |
-
|
660 |
-
/**
|
661 |
-
* Get specific option by key
|
662 |
-
*/
|
663 |
-
public function get_option( $key ) {
|
664 |
-
$options = $this->get_wpcf7_options();
|
665 |
-
|
666 |
-
return isset( $options[ $key ] ) ? $options[ $key ] : '';
|
667 |
-
}
|
668 |
-
|
669 |
-
/**
|
670 |
-
* Update specific option
|
671 |
-
*
|
672 |
-
* @param $key
|
673 |
-
* @param $value
|
674 |
-
*/
|
675 |
-
public function update_option( $key, $value ) {
|
676 |
-
$options = $this->get_wpcf7_options();
|
677 |
-
|
678 |
-
$options[ $key ] = $value;
|
679 |
-
|
680 |
-
$this->save_wpcf7_options( $options );
|
681 |
-
|
682 |
-
}
|
683 |
-
|
684 |
-
/**
|
685 |
-
* Get the plugin options
|
686 |
-
*/
|
687 |
-
public function get_wpcf7_options() {
|
688 |
-
return get_option( 'wpcf_redirect_options' );
|
689 |
-
}
|
690 |
-
|
691 |
-
/**
|
692 |
-
* Save the plugin options
|
693 |
-
*
|
694 |
-
* @param $options
|
695 |
-
*/
|
696 |
-
public function save_wpcf7_options( $options ) {
|
697 |
-
update_option( 'wpcf_redirect_options', $options );
|
698 |
-
}
|
699 |
-
|
700 |
-
/**
|
701 |
-
* Get a list of avaiable text functions and callbacks
|
702 |
-
*
|
703 |
-
* @param string $func
|
704 |
-
* @param string $field_type
|
705 |
-
*/
|
706 |
-
public static function get_available_text_functions( $func = '', $field_type = '' ) {
|
707 |
-
$functions = array(
|
708 |
-
'md5' => array( 'WPCF7r_Utils', 'func_md5' ),
|
709 |
-
'base64_encode' => array( 'WPCF7r_Utils', 'func_base64_encode' ),
|
710 |
-
'utf8_encode' => array( 'WPCF7r_Utils', 'func_utf8_encode' ),
|
711 |
-
'urlencode' => array( 'WPCF7r_Utils', 'func_urlencode' ),
|
712 |
-
'json_encode' => array( 'WPCF7r_Utils', 'func_json_encode' ),
|
713 |
-
'esc_html' => array( 'WPCF7r_Utils', 'func_esc_html' ),
|
714 |
-
'esc_attr' => array( 'WPCF7r_Utils', 'func_esc_attr' ),
|
715 |
-
);
|
716 |
-
|
717 |
-
if ( 'checkbox' === $field_type || 'checkbox*' === $field_type || 'all' === $field_type ) {
|
718 |
-
$functions['implode'] = array( 'WPCF7r_Utils', 'func_implode' );
|
719 |
-
}
|
720 |
-
|
721 |
-
$functions = apply_filters( 'get_available_text_functions', $functions );
|
722 |
-
|
723 |
-
if ( $func ) {
|
724 |
-
return isset( $functions[ $func ] ) ? $functions[ $func ] : '';
|
725 |
-
}
|
726 |
-
|
727 |
-
return $functions;
|
728 |
-
}
|
729 |
-
|
730 |
-
/**
|
731 |
-
* [func_utf8_encode description]
|
732 |
-
*
|
733 |
-
* @param $value
|
734 |
-
*/
|
735 |
-
public static function func_utf8_encode( $value ) {
|
736 |
-
return apply_filters( 'func_utf8_encode', utf8_encode( $value ), $value );
|
737 |
-
}
|
738 |
-
|
739 |
-
/**
|
740 |
-
* [func_base64_encode description]
|
741 |
-
*
|
742 |
-
* @param $value
|
743 |
-
*/
|
744 |
-
public static function func_base64_encode( $value ) {
|
745 |
-
return apply_filters( 'func_base64_encode', base64_encode( $value ), $value );
|
746 |
-
}
|
747 |
-
|
748 |
-
/**
|
749 |
-
* [func_base64_encode description]
|
750 |
-
*
|
751 |
-
* @param $value
|
752 |
-
*/
|
753 |
-
public static function func_urlencode( $value ) {
|
754 |
-
return apply_filters( 'func_urlencode', urlencode( $value ), $value );
|
755 |
-
}
|
756 |
-
|
757 |
-
/**
|
758 |
-
* Esc html callback
|
759 |
-
*
|
760 |
-
* @param $value
|
761 |
-
*/
|
762 |
-
public function func_esc_html( $value ) {
|
763 |
-
return apply_filters( 'func_esc_html', esc_html( $value ), $value );
|
764 |
-
}
|
765 |
-
|
766 |
-
/**
|
767 |
-
* Esc Attr callback
|
768 |
-
*
|
769 |
-
* @param $value
|
770 |
-
*/
|
771 |
-
public function func_esc_attr( $value ) {
|
772 |
-
return apply_filters( 'func_esc_attr', esc_attr( $value ), $value );
|
773 |
-
}
|
774 |
-
|
775 |
-
/**
|
776 |
-
* Json Encode callback
|
777 |
-
*
|
778 |
-
* @param $value
|
779 |
-
*/
|
780 |
-
public function func_json_encode( $value ) {
|
781 |
-
return apply_filters( 'func_json_encode', wp_json_encode( $value ), $value );
|
782 |
-
}
|
783 |
-
/**
|
784 |
-
* [func_base64_encode description]
|
785 |
-
*
|
786 |
-
* @param $value
|
787 |
-
*/
|
788 |
-
public static function func_implode( $value ) {
|
789 |
-
|
790 |
-
if ( is_array( $value ) ) {
|
791 |
-
$value = apply_filters( 'func_implode', implode( ',', $value ), $value );
|
792 |
-
}
|
793 |
-
|
794 |
-
return $value;
|
795 |
-
}
|
796 |
-
|
797 |
-
/**
|
798 |
-
* md5 function
|
799 |
-
*
|
800 |
-
* @param $value
|
801 |
-
*/
|
802 |
-
public static function func_md5( $value ) {
|
803 |
-
return apply_filters( 'func_md5', md5( $value ), $value );
|
804 |
-
}
|
805 |
-
|
806 |
-
public function make_api_test() {
|
807 |
-
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
808 |
-
parse_str( $_POST['data']['data'], $data );
|
809 |
-
|
810 |
-
if ( ! is_array( $data ) ) {
|
811 |
-
die( '-1' );
|
812 |
-
}
|
813 |
-
|
814 |
-
$action_id = isset( $_POST['data']['action_id'] ) ? (int) sanitize_text_field( $_POST['data']['action_id'] ) : '';
|
815 |
-
$cf7_id = isset( $_POST['data']['cf7_id'] ) ? (int) sanitize_text_field( $_POST['data']['cf7_id'] ) : '';
|
816 |
-
$rule_id = isset( $_POST['data']['rule_id'] ) ? $_POST['data']['rule_id'] : '';
|
817 |
-
|
818 |
-
add_filter( 'after_qs_cf7_api_send_lead', array( $this, 'after_fake_submission' ), 10, 3 );
|
819 |
-
|
820 |
-
if ( isset( $data['wpcf7-redirect']['actions'] ) ) {
|
821 |
-
$response = array();
|
822 |
-
|
823 |
-
$posted_action = reset( $data['wpcf7-redirect']['actions'] );
|
824 |
-
$posted_action = $posted_action['test_values'];
|
825 |
-
$_POST = $posted_action;
|
826 |
-
// this will create a fake form submission
|
827 |
-
$this->cf7r_form = get_cf7r_form( $cf7_id );
|
828 |
-
$this->cf7r_form->enable_action( $action_id );
|
829 |
-
|
830 |
-
$cf7_form = $this->cf7r_form->get_cf7_form_instance();
|
831 |
-
$submission = WPCF7_Submission::get_instance( $cf7_form );
|
832 |
-
|
833 |
-
if ( $submission->get_status() === 'validation_failed' ) {
|
834 |
-
$invalid_fields = $submission->get_invalid_fields();
|
835 |
-
$response['status'] = 'failed';
|
836 |
-
$response['invalid_fields'] = $invalid_fields;
|
837 |
-
} else {
|
838 |
-
$response['status'] = 'success';
|
839 |
-
$response['html'] = $this->get_test_api_results_html();
|
840 |
-
}
|
841 |
-
|
842 |
-
wp_send_json( $response );
|
843 |
-
}
|
844 |
-
}
|
845 |
-
}
|
846 |
-
/**
|
847 |
-
* Store the results from the API
|
848 |
-
*
|
849 |
-
* @param $result
|
850 |
-
* @param $record
|
851 |
-
*/
|
852 |
-
public function after_fake_submission( $result, $record, $args ) {
|
853 |
-
$this->results = $result;
|
854 |
-
$this->record = $record;
|
855 |
-
$this->request = $args;
|
856 |
-
|
857 |
-
return $result;
|
858 |
-
}
|
859 |
-
|
860 |
-
/**
|
861 |
-
* Show A preview for the action
|
862 |
-
*/
|
863 |
-
public function show_action_preview() {
|
864 |
-
if ( isset( $_GET['wpcf7r-preview'] ) ) {
|
865 |
-
$action_id = (int) $_GET['wpcf7r-preview'];
|
866 |
-
|
867 |
-
$action = WPCF7R_Action::get_action( $action_id );
|
868 |
-
|
869 |
-
$action->dynamic_params['popup-template'] = isset( $_GET['template'] ) ? sanitize_text_field( $_GET['template'] ) : '';
|
870 |
-
|
871 |
-
$action->preview();
|
872 |
-
}
|
873 |
-
}
|
874 |
-
|
875 |
-
/**
|
876 |
-
* Get action template in case field are dynamicaly changed
|
877 |
-
*/
|
878 |
-
public function get_action_template() {
|
879 |
-
$response = array();
|
880 |
-
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
881 |
-
$data = isset( $_POST['data'] ) ? $_POST['data'] : '';
|
882 |
-
|
883 |
-
if ( isset( $data['action_id'] ) ) {
|
884 |
-
$action_id = (int) $data['action_id'];
|
885 |
-
$popup_template = sanitize_text_field( $data['template'] );
|
886 |
-
|
887 |
-
$action = WPCF7R_Action::get_action( $action_id );
|
888 |
-
|
889 |
-
ob_start();
|
890 |
-
|
891 |
-
$params = array(
|
892 |
-
'popup-template' => $popup_template,
|
893 |
-
);
|
894 |
-
|
895 |
-
$action->get_action_settings( $params );
|
896 |
-
|
897 |
-
$response['action_content'] = ob_get_clean();
|
898 |
-
}
|
899 |
-
}
|
900 |
-
|
901 |
-
wp_send_json_success( $response );
|
902 |
-
}
|
903 |
-
|
904 |
-
/**
|
905 |
-
* Get the popup html
|
906 |
-
*/
|
907 |
-
public function get_test_api_results_html() {
|
908 |
-
ob_start();
|
909 |
-
|
910 |
-
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'popup-api-test.php';
|
911 |
-
|
912 |
-
return ob_get_clean();
|
913 |
-
}
|
914 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WPCF7r_Utils file.
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Contact form 7 redirect utilities
|
10 |
+
*/
|
11 |
+
class WPCF7r_Utils {
|
12 |
+
public $banner_version = 1.01;
|
13 |
+
public static $instance;
|
14 |
+
public static $actions_list = array();
|
15 |
+
public static $rendered_elements = array();
|
16 |
+
|
17 |
+
public function __construct() {
|
18 |
+
self::$instance = $this;
|
19 |
+
|
20 |
+
$this->api = new Qs_Api();
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Add a message to the session collector
|
25 |
+
*
|
26 |
+
* @param $type
|
27 |
+
* @param $message
|
28 |
+
*/
|
29 |
+
public static function add_admin_notice( $type, $message ) {
|
30 |
+
$_SESSION['wpcf7r_admin_notices'][ $type ] = $message;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Register a new type of action
|
35 |
+
*
|
36 |
+
* @param $name
|
37 |
+
* @param $title
|
38 |
+
* @param $class
|
39 |
+
*/
|
40 |
+
public static function register_wpcf7r_actions( $name, $title, $class, $order ) {
|
41 |
+
self::$actions_list[ $name ] = array(
|
42 |
+
'label' => $title,
|
43 |
+
'attr' => '',
|
44 |
+
'handler' => $class,
|
45 |
+
'order' => $order,
|
46 |
+
);
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Get action name
|
51 |
+
*
|
52 |
+
* @param $action_type
|
53 |
+
*/
|
54 |
+
public static function get_action_name( $action_type ) {
|
55 |
+
return isset( self::$actions_list[ $action_type ] ) ? self::$actions_list[ $action_type ]['label'] : $action_type;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Get the available actions
|
60 |
+
*/
|
61 |
+
public static function get_wpcf7r_actions() {
|
62 |
+
return self::$actions_list;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Duplicate all action posts and connect it to the new created form
|
67 |
+
*
|
68 |
+
* @param $new_cf7
|
69 |
+
*/
|
70 |
+
public function duplicate_form_support( $new_cf7 ) {
|
71 |
+
|
72 |
+
if ( isset( $_POST['wpcf7-copy'] ) && 'Duplicate' === $_POST['wpcf7-copy'] || ( isset( $_GET['action'] ) && 'copy' === $_GET['action'] ) ) {
|
73 |
+
|
74 |
+
$original_post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : (int) $_GET['post'];
|
75 |
+
|
76 |
+
$original_cf7 = get_cf7r_form( $original_post_id );
|
77 |
+
|
78 |
+
$original_action_posts = $original_cf7->get_actions( 'default' );
|
79 |
+
|
80 |
+
if ( $original_action_posts ) {
|
81 |
+
foreach ( $original_action_posts as $original_action_post ) {
|
82 |
+
$new_post_id = $this->duplicate_post( $original_action_post->action_post );
|
83 |
+
|
84 |
+
update_post_meta( $new_post_id, 'wpcf7_id', $new_cf7->id() );
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* After form deletion delete all its actions
|
92 |
+
*
|
93 |
+
* @param int $post_id
|
94 |
+
*/
|
95 |
+
public function delete_all_form_actions( $post_id ) {
|
96 |
+
global $post_type;
|
97 |
+
|
98 |
+
if ( get_post_type( $post_id ) === 'wpcf7_contact_form' ) {
|
99 |
+
|
100 |
+
$wpcf7r = get_cf7r_form( $post_id );
|
101 |
+
|
102 |
+
$action_posts = $wpcf7r->get_actions( 'default' );
|
103 |
+
|
104 |
+
if ( $action_posts ) {
|
105 |
+
foreach ( $action_posts as $action_post ) {
|
106 |
+
wp_delete_post( $action_post->get_id() );
|
107 |
+
}
|
108 |
+
}
|
109 |
+
};
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Dupplicate contact form and all its actions
|
115 |
+
*
|
116 |
+
* @param $action
|
117 |
+
*/
|
118 |
+
public function duplicate_post( $action ) {
|
119 |
+
global $wpdb;
|
120 |
+
|
121 |
+
// if you don't want current user to be the new post author,
|
122 |
+
// then change next couple of lines to this: $new_post_author = $post->post_author;
|
123 |
+
$current_user = wp_get_current_user();
|
124 |
+
$new_post_author = $current_user->ID;
|
125 |
+
$post_id = $action->ID;
|
126 |
+
|
127 |
+
// if post data exists, create the post duplicate
|
128 |
+
if ( isset( $action ) && null !== $action ) {
|
129 |
+
// new post data array
|
130 |
+
$args = array(
|
131 |
+
'comment_status' => $action->comment_status,
|
132 |
+
'ping_status' => $action->ping_status,
|
133 |
+
'post_author' => $new_post_author,
|
134 |
+
'post_content' => $action->post_content,
|
135 |
+
'post_excerpt' => $action->post_excerpt,
|
136 |
+
'post_name' => $action->post_name,
|
137 |
+
'post_parent' => $action->post_parent,
|
138 |
+
'post_password' => $action->post_password,
|
139 |
+
'post_status' => 'private',
|
140 |
+
'post_title' => $action->post_title,
|
141 |
+
'post_type' => $action->post_type,
|
142 |
+
'to_ping' => $action->to_ping,
|
143 |
+
'menu_order' => $action->menu_order,
|
144 |
+
);
|
145 |
+
|
146 |
+
// insert the post by wp_insert_post() function
|
147 |
+
$new_post_id = wp_insert_post( $args );
|
148 |
+
|
149 |
+
// get all current post terms ad set them to the new post draft
|
150 |
+
$taxonomies = get_object_taxonomies( $action->post_type );
|
151 |
+
|
152 |
+
// returns array of taxonomy names for post type, ex array("category", "post_tag");
|
153 |
+
if ( $taxonomies ) {
|
154 |
+
foreach ( $taxonomies as $taxonomy ) {
|
155 |
+
$post_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'slugs' ) );
|
156 |
+
wp_set_object_terms( $new_post_id, $post_terms, $taxonomy, false );
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
// duplicate all post meta just in two SQL queries
|
161 |
+
$sql = $wpdb->prepare( "SELECT meta_key, meta_value FROM {$wpdb->postmeta} WHERE post_id='%s'", $post_id );
|
162 |
+
|
163 |
+
$post_meta_infos = $wpdb->get_results( $sql );
|
164 |
+
|
165 |
+
foreach ( $post_meta_infos as $meta_info ) {
|
166 |
+
if ( '_wp_old_slug' === $meta_info->meta_key ) {
|
167 |
+
continue;
|
168 |
+
}
|
169 |
+
|
170 |
+
update_post_meta( $new_post_id, $meta_info->meta_key, maybe_unserialize( $meta_info->meta_value ) );
|
171 |
+
}
|
172 |
+
|
173 |
+
return $new_post_id;
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Set actions order
|
179 |
+
*/
|
180 |
+
public function set_action_menu_order() {
|
181 |
+
global $wpdb;
|
182 |
+
|
183 |
+
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
184 |
+
parse_str( $_POST['data']['order'], $data );
|
185 |
+
|
186 |
+
if ( ! is_array( $data ) ) {
|
187 |
+
return false;
|
188 |
+
}
|
189 |
+
|
190 |
+
// get objects per now page
|
191 |
+
$id_arr = array();
|
192 |
+
foreach ( $data as $key => $values ) {
|
193 |
+
foreach ( $values as $position => $id ) {
|
194 |
+
$id_arr[] = $id;
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
foreach ( $id_arr as $key => $post_id ) {
|
199 |
+
$menu_order = $key + 1;
|
200 |
+
$wpdb->update( $wpdb->posts, array( 'menu_order' => $menu_order ), array( 'ID' => intval( $post_id ) ) );
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
die('1');
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Render elements required by actions
|
209 |
+
*
|
210 |
+
* @return void
|
211 |
+
*/
|
212 |
+
public function render_actions_elements( $properties, $form ) {
|
213 |
+
|
214 |
+
$action_posts = wpcf7r_get_actions( 'wpcf7r_action', -1, $form->id(), 'default', array(), true );
|
215 |
+
|
216 |
+
if ( $action_posts ) {
|
217 |
+
foreach ( $action_posts as $action_post ) {
|
218 |
+
$action = WPCF7R_Action::get_action( $action_post );
|
219 |
+
|
220 |
+
if ( ! isset( self::$rendered_elements[ $action_post->ID ] ) ) {
|
221 |
+
// these actions will run once.
|
222 |
+
if ( is_object( $action ) && ! is_wp_error( $action ) && method_exists( $action, 'render_callback_once' ) ) {
|
223 |
+
$properties = $action->render_callback_once( $properties, $form );
|
224 |
+
}
|
225 |
+
|
226 |
+
self::$rendered_elements[ $action_post->ID ] = $action_post->ID;
|
227 |
+
}
|
228 |
+
|
229 |
+
// Render_callback will be called several times because of the way contact form 7 uses these properties.
|
230 |
+
// use state and db on the action to limit it to run only once.
|
231 |
+
if ( is_object( $action ) && ! is_wp_error( $action ) && method_exists( $action, 'render_callback' ) ) {
|
232 |
+
$properties = $action->render_callback( $properties, $form );
|
233 |
+
}
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
return $properties;
|
238 |
+
}
|
239 |
+
/**
|
240 |
+
* Delete an action
|
241 |
+
*/
|
242 |
+
public function delete_action_post() {
|
243 |
+
$response['status'] = 'failed';
|
244 |
+
|
245 |
+
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
246 |
+
$data = isset( $_POST['data'] ) ? $_POST['data'] : '';
|
247 |
+
|
248 |
+
if ( $data ) {
|
249 |
+
foreach ( $data as $post_to_delete ) {
|
250 |
+
if ( $post_to_delete ) {
|
251 |
+
wp_trash_post( $post_to_delete['post_id'] );
|
252 |
+
$response['status'] = 'deleted';
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
wp_send_json( $response );
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Show notices on admin panel
|
263 |
+
*/
|
264 |
+
public function show_admin_notices() {
|
265 |
+
global $wp_sessions;
|
266 |
+
|
267 |
+
if ( ! isset( $_SESSION['wpcf7r_admin_notices'] ) ) {
|
268 |
+
return;
|
269 |
+
}
|
270 |
+
|
271 |
+
foreach ( $_SESSION['wpcf7r_admin_notices'] as $notice_type => $notice ) :
|
272 |
+
?>
|
273 |
+
|
274 |
+
<div class="notice notice-error is-dismissible <?php echo $notice_type; ?>">
|
275 |
+
<p><?php echo $notice; ?></p>
|
276 |
+
</div>
|
277 |
+
|
278 |
+
<?php
|
279 |
+
endforeach;
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Send debug data to querysol support api
|
284 |
+
*
|
285 |
+
* @return void
|
286 |
+
*/
|
287 |
+
public function send_debug_info() {
|
288 |
+
if ( current_user_can( 'administrator' ) && wpcf7_validate_nonce() ) {
|
289 |
+
$data = isset( $_POST['data'] ) ? $_POST['data'] : '';
|
290 |
+
|
291 |
+
if ( $data['form_id'] ) {
|
292 |
+
$debug_data = WPCF7r_Form_Helper::get_debug_data( $data['form_id'] );
|
293 |
+
|
294 |
+
$api = new Qs_Api();
|
295 |
+
|
296 |
+
$args = array(
|
297 |
+
'headers' => array( 'Content-Type' => 'application/json; charset=utf-8' ),
|
298 |
+
);
|
299 |
+
|
300 |
+
$url = add_query_arg( 'site_url', home_url(), WPCF7_PRO_REDIRECT_DEBUG_URL );
|
301 |
+
|
302 |
+
$api->api_call( $url, json_encode( array( 'debug_data' => $debug_data ) ), $args );
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
wp_send_json_success();
|
307 |
+
}
|
308 |
+
/**
|
309 |
+
* Auto function to migrate old plugin to the new one
|
310 |
+
*
|
311 |
+
* @param $migration_action migrate_from_cf7_redirect/migrate_from_cf7_api
|
312 |
+
* @param boolean $force
|
313 |
+
*/
|
314 |
+
public static function auto_migrate( $migration_action, $force = false ) {
|
315 |
+
|
316 |
+
$instance = self::get_instance();
|
317 |
+
|
318 |
+
$cf7_forms = self::get_all_cf7_forms();
|
319 |
+
|
320 |
+
foreach ( $cf7_forms as $cf7_form_id ) {
|
321 |
+
|
322 |
+
$cf7r_form = new WPCF7R_Form( $cf7_form_id );
|
323 |
+
|
324 |
+
$instance->delete_all_form_actions( $cf7_form_id );
|
325 |
+
|
326 |
+
if ( ! $cf7r_form->has_migrated( $migration_action ) || $force ) {
|
327 |
+
$instance->convert_to_action( $cf7r_form, $migration_action, $cf7_form_id, 'default' );
|
328 |
+
|
329 |
+
$cf7r_form->update_migration( $migration_action );
|
330 |
+
}
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Get all Contact Forms 7 forms
|
336 |
+
*/
|
337 |
+
public static function get_all_cf7_forms() {
|
338 |
+
$args = array(
|
339 |
+
'post_type' => 'wpcf7_contact_form',
|
340 |
+
'posts_per_page' => -1,
|
341 |
+
'fields' => 'ids',
|
342 |
+
'suppress_filters' => true,
|
343 |
+
);
|
344 |
+
|
345 |
+
$cf7_forms = get_posts( $args );
|
346 |
+
|
347 |
+
return $cf7_forms;
|
348 |
+
}
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Duplicate an existing action and connect it with the form.
|
352 |
+
*
|
353 |
+
* @return void
|
354 |
+
*/
|
355 |
+
public function duplicate_action() {
|
356 |
+
$results['action_row'] = '';
|
357 |
+
|
358 |
+
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
359 |
+
if ( isset( $_POST['data'] ) ) {
|
360 |
+
$action_data = $_POST['data'];
|
361 |
+
|
362 |
+
$action_post_id = $action_data['post_id'];
|
363 |
+
|
364 |
+
$action_post = get_post( $action_post_id );
|
365 |
+
|
366 |
+
$new_action_post_id = $this->duplicate_post( $action_post );
|
367 |
+
|
368 |
+
update_post_meta( $new_action_post_id, 'wpcf7_id', $action_data['form_id'] );
|
369 |
+
|
370 |
+
$action = WPCF7R_Action::get_action( $new_action_post_id );
|
371 |
+
|
372 |
+
$results['action_row'] = $action->get_action_row();
|
373 |
+
}
|
374 |
+
}
|
375 |
+
|
376 |
+
wp_send_json( $results );
|
377 |
+
}
|
378 |
+
/**
|
379 |
+
* Create a new action post
|
380 |
+
*/
|
381 |
+
public function add_action_post() {
|
382 |
+
$results['action_row'] = '';
|
383 |
+
|
384 |
+
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
385 |
+
$post_id = isset( $_POST['data']['post_id'] ) ? (int) sanitize_text_field( $_POST['data']['post_id'] ) : '';
|
386 |
+
$rule_id = isset( $_POST['data']['rule_id'] ) ? sanitize_text_field( $_POST['data']['rule_id'] ) : '';
|
387 |
+
$action_type = isset( $_POST['data']['action_type'] ) ? sanitize_text_field( $_POST['data']['action_type'] ) : '';
|
388 |
+
|
389 |
+
$rule_name = __( 'New Action', 'wpcf7-redirect' );
|
390 |
+
|
391 |
+
$this->cf7r_form = get_cf7r_form( $post_id );
|
392 |
+
|
393 |
+
$actions = array();
|
394 |
+
|
395 |
+
// migrate from old api plugin
|
396 |
+
if ( 'migrate_from_cf7_api' === $action_type || 'migrate_from_cf7_redirect' === $action_type ) {
|
397 |
+
if ( ! $this->cf7r_form->has_migrated( $action_type ) ) {
|
398 |
+
$actions = $this->convert_to_action( $action_type, $post_id, $rule_name, $rule_id );
|
399 |
+
$this->cf7r_form->update_migration( $action_type );
|
400 |
+
}
|
401 |
+
} else {
|
402 |
+
$actions[] = $this->create_action( $post_id, $rule_name, $rule_id, $action_type );
|
403 |
+
}
|
404 |
+
|
405 |
+
if ( $actions ) {
|
406 |
+
foreach ( $actions as $action ) {
|
407 |
+
if ( ! is_wp_error( $action ) ) {
|
408 |
+
$results['action_row'] .= $action->get_action_row();
|
409 |
+
} else {
|
410 |
+
wp_send_json( $results );
|
411 |
+
}
|
412 |
+
}
|
413 |
+
} else {
|
414 |
+
$results['action_row'] = '';
|
415 |
+
}
|
416 |
+
}
|
417 |
+
|
418 |
+
wp_send_json( $results );
|
419 |
+
}
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Convert old plugin data to new structure
|
423 |
+
*
|
424 |
+
* @param $required_conversion
|
425 |
+
* @param $post_id
|
426 |
+
* @param $rule_name
|
427 |
+
* @param $rule_id
|
428 |
+
* @return Actions
|
429 |
+
*
|
430 |
+
* @version 1.2
|
431 |
+
*/
|
432 |
+
|
433 |
+
private function convert_to_action( $cf7r_form, $required_conversion, $post_id, $rule_id ) {
|
434 |
+
$actions = array();
|
435 |
+
|
436 |
+
if ( 'migrate_from_cf7_redirect' === $required_conversion ) {
|
437 |
+
$old_api_action = $cf7r_form->get_cf7_redirection_settings();
|
438 |
+
|
439 |
+
if ( $old_api_action ) {
|
440 |
+
// CREATE JAVSCRIPT ACTION.
|
441 |
+
if ( $old_api_action['fire_sctipt'] ) {
|
442 |
+
$javscript_action = $this->create_action( $post_id, __( 'Migrated Javascript Action From Old Plugin', 'wpcf7-redirect' ), $rule_id, 'FireScript' );
|
443 |
+
|
444 |
+
$javscript_action->set( 'script', $old_api_action['fire_sctipt'] );
|
445 |
+
$javscript_action->set( 'action_status', 'on' );
|
446 |
+
|
447 |
+
unset( $old_api_action['fire_sctipt'] );
|
448 |
+
|
449 |
+
$actions[] = $javscript_action;
|
450 |
+
}
|
451 |
+
|
452 |
+
// CREATE REDIRECT ACTION.
|
453 |
+
$action = $this->create_action( $post_id, __( 'Migrated Redirect Action From Old Plugin', 'wpcf7-redirect' ), $rule_id, 'redirect' );
|
454 |
+
|
455 |
+
$action->set( 'action_status', 'on' );
|
456 |
+
|
457 |
+
foreach ( $old_api_action as $key => $value ) {
|
458 |
+
$action->set( $key, $value );
|
459 |
+
}
|
460 |
+
|
461 |
+
$actions[] = $action;
|
462 |
+
|
463 |
+
}
|
464 |
+
} elseif ( 'migrate_from_cf7_api' === $required_conversion ) {
|
465 |
+
$old_api_action = $cf7r_form->get_cf7_api_settings();
|
466 |
+
|
467 |
+
if ( $old_api_action ) {
|
468 |
+
|
469 |
+
$old_api__wpcf7_api_data = $old_api_action['_wpcf7_api_data'];
|
470 |
+
$old_tags_map = $old_api_action['_wpcf7_api_data_map'];
|
471 |
+
|
472 |
+
if ( 'params' === $old_api__wpcf7_api_data['input_type'] ) {
|
473 |
+
$action_type = 'api_url_request';
|
474 |
+
} elseif ( 'xml' === $old_api__wpcf7_api_data['input_type'] || 'json' === $old_api__wpcf7_api_data['input_type'] ) {
|
475 |
+
$action_type = 'api_json_xml_request';
|
476 |
+
}
|
477 |
+
|
478 |
+
$action = $this->create_action( $post_id, __( 'Migrated Data from Old Plugin', 'wpcf7-redirect' ), $rule_id, $action_type );
|
479 |
+
|
480 |
+
if ( ! is_wp_error( $action ) ) {
|
481 |
+
$action->set( 'base_url', $old_api__wpcf7_api_data['base_url'] );
|
482 |
+
$action->set( 'input_type', strtolower( $old_api__wpcf7_api_data['method'] ) );
|
483 |
+
$action->set( 'record_type', strtolower( $old_api__wpcf7_api_data['input_type'] ) );
|
484 |
+
$action->set( 'show_debug', '' );
|
485 |
+
$action->set( 'action_status', $old_api__wpcf7_api_data['send_to_api'] );
|
486 |
+
|
487 |
+
$tags_map = array();
|
488 |
+
|
489 |
+
if ( $old_tags_map ) {
|
490 |
+
foreach ( $old_tags_map as $tag_key => $tag_api_key ) {
|
491 |
+
$tags_map[ $tag_key ] = $tag_api_key;
|
492 |
+
}
|
493 |
+
|
494 |
+
$action->set( 'tags_map', $tags_map );
|
495 |
+
}
|
496 |
+
|
497 |
+
if ( isset( $old_api_action['_template'] ) && $old_api_action['_template'] ) {
|
498 |
+
$action->set( 'request_template', $old_api_action['_template'] );
|
499 |
+
} elseif ( isset( $old_api_action['_json_template'] ) && $old_api_action['_json_template'] ) {
|
500 |
+
$action->set( 'request_template', $old_api_action['_json_template'] );
|
501 |
+
}
|
502 |
+
|
503 |
+
$actions[] = $action;
|
504 |
+
}
|
505 |
+
}
|
506 |
+
}
|
507 |
+
|
508 |
+
return $actions;
|
509 |
+
}
|
510 |
+
|
511 |
+
/**
|
512 |
+
* Create new post that will hold the action
|
513 |
+
*
|
514 |
+
* @param $rule_name
|
515 |
+
* @param $rule_id
|
516 |
+
* @param $action_type
|
517 |
+
* @return Actions
|
518 |
+
*/
|
519 |
+
public function create_action( $post_id, $rule_name, $rule_id, $action_type ) {
|
520 |
+
$new_action_post = array(
|
521 |
+
'post_type' => 'wpcf7r_action',
|
522 |
+
'post_title' => $rule_name,
|
523 |
+
'post_status' => 'private',
|
524 |
+
'menu_order' => 1,
|
525 |
+
'meta_input' => array(
|
526 |
+
'wpcf7_id' => $post_id,
|
527 |
+
'wpcf7_rule_id' => $rule_id,
|
528 |
+
'action_type' => $action_type,
|
529 |
+
'action_status' => 'on',
|
530 |
+
),
|
531 |
+
);
|
532 |
+
|
533 |
+
$new_action_id = wp_insert_post( $new_action_post );
|
534 |
+
|
535 |
+
return WPCF7R_Action::get_action( $new_action_id, $post_id );
|
536 |
+
}
|
537 |
+
|
538 |
+
/**
|
539 |
+
* Get instance
|
540 |
+
*/
|
541 |
+
public static function get_instance() {
|
542 |
+
if ( null === self::$instance ) {
|
543 |
+
self::$instance = new self();
|
544 |
+
}
|
545 |
+
return self::$instance;
|
546 |
+
}
|
547 |
+
|
548 |
+
/**
|
549 |
+
* Get the banner template
|
550 |
+
*/
|
551 |
+
public function get_banner() {
|
552 |
+
if ( $this->get_option( 'last_banner_displayed' ) === $this->banner_version ) {
|
553 |
+
return;
|
554 |
+
}
|
555 |
+
ob_start();
|
556 |
+
|
557 |
+
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'banner.php';
|
558 |
+
|
559 |
+
$banner_html = ob_get_clean();
|
560 |
+
|
561 |
+
echo $banner_html;
|
562 |
+
}
|
563 |
+
|
564 |
+
/**
|
565 |
+
* Show a message containing the license details
|
566 |
+
*/
|
567 |
+
public function license_details_message() {
|
568 |
+
if ( ! self::get_activation_id() ) {
|
569 |
+
printf(
|
570 |
+
'<tr class="plugin-update-tr active" id="wpcf7-redirect-pro-update" data-slug="wpcf7-redirect-pro" data-plugin="contact-form-7-redirection-pro/wpcf7-redirect-pro.php"><td colspan="3" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p><strong>%s</strong> %s</p></div></td></tr>',
|
571 |
+
__( 'Please activate plugin license for updates', 'wpcf7-redirect' ),
|
572 |
+
self::get_settings_link()
|
573 |
+
);
|
574 |
+
|
575 |
+
}
|
576 |
+
|
577 |
+
}
|
578 |
+
|
579 |
+
/**
|
580 |
+
* Get all data related with plugin activation
|
581 |
+
*/
|
582 |
+
public static function get_activation_data() {
|
583 |
+
return get_option( 'wpcf7r_activation_data' );
|
584 |
+
}
|
585 |
+
|
586 |
+
/**
|
587 |
+
* Get date of plugin license expiration
|
588 |
+
*/
|
589 |
+
public static function get_activation_expiration() {
|
590 |
+
return get_option( 'wpcf7r_activation_expiration' );
|
591 |
+
}
|
592 |
+
|
593 |
+
/**
|
594 |
+
* A validation function to test the serial key
|
595 |
+
*/
|
596 |
+
public static function validate_serial_key() {
|
597 |
+
$instance = self::get_instance();
|
598 |
+
|
599 |
+
$serial = self::get_serial_key();
|
600 |
+
$activation_id = self::get_activation_id();
|
601 |
+
|
602 |
+
return $instance->api->validate_serial( $activation_id, $serial );
|
603 |
+
}
|
604 |
+
|
605 |
+
/**
|
606 |
+
* Get the used serial key
|
607 |
+
*/
|
608 |
+
public static function get_serial_key() {
|
609 |
+
return get_option( 'wpcf7r_serial_number' );
|
610 |
+
}
|
611 |
+
|
612 |
+
/**
|
613 |
+
* Delete the used setial key
|
614 |
+
*/
|
615 |
+
public static function delete_serial_key() {
|
616 |
+
return delete_option( 'wpcf7r_serial_number' );
|
617 |
+
}
|
618 |
+
|
619 |
+
/**
|
620 |
+
* Get a url to deactivate plugin license
|
621 |
+
*/
|
622 |
+
public static function get_deactivation_link() {
|
623 |
+
$url = self::get_plugin_settings_page_url();
|
624 |
+
|
625 |
+
$url = add_query_arg( 'wpcf7r_deactivate_license', '', $url );
|
626 |
+
|
627 |
+
return $url;
|
628 |
+
}
|
629 |
+
|
630 |
+
/**
|
631 |
+
* Get the plugin settings link
|
632 |
+
*/
|
633 |
+
public static function get_plugin_settings_page_url() {
|
634 |
+
return get_admin_url( null, 'options-general.php?page=wpc7_redirect' );
|
635 |
+
}
|
636 |
+
|
637 |
+
/**
|
638 |
+
* Get the activation id
|
639 |
+
*/
|
640 |
+
public static function get_activation_id() {
|
641 |
+
return get_option( 'wpcf7r_activation_id' );
|
642 |
+
}
|
643 |
+
|
644 |
+
/**
|
645 |
+
* Get a link to the admin settings panel
|
646 |
+
*/
|
647 |
+
public static function get_settings_link() {
|
648 |
+
return '<a href="' . self::get_plugin_settings_page_url() . '">' . __( 'Settings', 'wpcf7-redirect' ) . '</a>';
|
649 |
+
}
|
650 |
+
|
651 |
+
/**
|
652 |
+
* Close banner
|
653 |
+
*/
|
654 |
+
public function close_banner() {
|
655 |
+
if ( current_user_can( 'administrator' ) && wpcf7_validate_nonce() ) {
|
656 |
+
$this->update_option( 'last_banner_displayed', $this->banner_version );
|
657 |
+
}
|
658 |
+
}
|
659 |
+
|
660 |
+
/**
|
661 |
+
* Get specific option by key
|
662 |
+
*/
|
663 |
+
public function get_option( $key ) {
|
664 |
+
$options = $this->get_wpcf7_options();
|
665 |
+
|
666 |
+
return isset( $options[ $key ] ) ? $options[ $key ] : '';
|
667 |
+
}
|
668 |
+
|
669 |
+
/**
|
670 |
+
* Update specific option
|
671 |
+
*
|
672 |
+
* @param $key
|
673 |
+
* @param $value
|
674 |
+
*/
|
675 |
+
public function update_option( $key, $value ) {
|
676 |
+
$options = $this->get_wpcf7_options();
|
677 |
+
|
678 |
+
$options[ $key ] = $value;
|
679 |
+
|
680 |
+
$this->save_wpcf7_options( $options );
|
681 |
+
|
682 |
+
}
|
683 |
+
|
684 |
+
/**
|
685 |
+
* Get the plugin options
|
686 |
+
*/
|
687 |
+
public function get_wpcf7_options() {
|
688 |
+
return get_option( 'wpcf_redirect_options' );
|
689 |
+
}
|
690 |
+
|
691 |
+
/**
|
692 |
+
* Save the plugin options
|
693 |
+
*
|
694 |
+
* @param $options
|
695 |
+
*/
|
696 |
+
public function save_wpcf7_options( $options ) {
|
697 |
+
update_option( 'wpcf_redirect_options', $options );
|
698 |
+
}
|
699 |
+
|
700 |
+
/**
|
701 |
+
* Get a list of avaiable text functions and callbacks
|
702 |
+
*
|
703 |
+
* @param string $func
|
704 |
+
* @param string $field_type
|
705 |
+
*/
|
706 |
+
public static function get_available_text_functions( $func = '', $field_type = '' ) {
|
707 |
+
$functions = array(
|
708 |
+
'md5' => array( 'WPCF7r_Utils', 'func_md5' ),
|
709 |
+
'base64_encode' => array( 'WPCF7r_Utils', 'func_base64_encode' ),
|
710 |
+
'utf8_encode' => array( 'WPCF7r_Utils', 'func_utf8_encode' ),
|
711 |
+
'urlencode' => array( 'WPCF7r_Utils', 'func_urlencode' ),
|
712 |
+
'json_encode' => array( 'WPCF7r_Utils', 'func_json_encode' ),
|
713 |
+
'esc_html' => array( 'WPCF7r_Utils', 'func_esc_html' ),
|
714 |
+
'esc_attr' => array( 'WPCF7r_Utils', 'func_esc_attr' ),
|
715 |
+
);
|
716 |
+
|
717 |
+
if ( 'checkbox' === $field_type || 'checkbox*' === $field_type || 'all' === $field_type ) {
|
718 |
+
$functions['implode'] = array( 'WPCF7r_Utils', 'func_implode' );
|
719 |
+
}
|
720 |
+
|
721 |
+
$functions = apply_filters( 'get_available_text_functions', $functions );
|
722 |
+
|
723 |
+
if ( $func ) {
|
724 |
+
return isset( $functions[ $func ] ) ? $functions[ $func ] : '';
|
725 |
+
}
|
726 |
+
|
727 |
+
return $functions;
|
728 |
+
}
|
729 |
+
|
730 |
+
/**
|
731 |
+
* [func_utf8_encode description]
|
732 |
+
*
|
733 |
+
* @param $value
|
734 |
+
*/
|
735 |
+
public static function func_utf8_encode( $value ) {
|
736 |
+
return apply_filters( 'func_utf8_encode', utf8_encode( $value ), $value );
|
737 |
+
}
|
738 |
+
|
739 |
+
/**
|
740 |
+
* [func_base64_encode description]
|
741 |
+
*
|
742 |
+
* @param $value
|
743 |
+
*/
|
744 |
+
public static function func_base64_encode( $value ) {
|
745 |
+
return apply_filters( 'func_base64_encode', base64_encode( $value ), $value );
|
746 |
+
}
|
747 |
+
|
748 |
+
/**
|
749 |
+
* [func_base64_encode description]
|
750 |
+
*
|
751 |
+
* @param $value
|
752 |
+
*/
|
753 |
+
public static function func_urlencode( $value ) {
|
754 |
+
return apply_filters( 'func_urlencode', urlencode( $value ), $value );
|
755 |
+
}
|
756 |
+
|
757 |
+
/**
|
758 |
+
* Esc html callback
|
759 |
+
*
|
760 |
+
* @param $value
|
761 |
+
*/
|
762 |
+
public function func_esc_html( $value ) {
|
763 |
+
return apply_filters( 'func_esc_html', esc_html( $value ), $value );
|
764 |
+
}
|
765 |
+
|
766 |
+
/**
|
767 |
+
* Esc Attr callback
|
768 |
+
*
|
769 |
+
* @param $value
|
770 |
+
*/
|
771 |
+
public function func_esc_attr( $value ) {
|
772 |
+
return apply_filters( 'func_esc_attr', esc_attr( $value ), $value );
|
773 |
+
}
|
774 |
+
|
775 |
+
/**
|
776 |
+
* Json Encode callback
|
777 |
+
*
|
778 |
+
* @param $value
|
779 |
+
*/
|
780 |
+
public function func_json_encode( $value ) {
|
781 |
+
return apply_filters( 'func_json_encode', wp_json_encode( $value ), $value );
|
782 |
+
}
|
783 |
+
/**
|
784 |
+
* [func_base64_encode description]
|
785 |
+
*
|
786 |
+
* @param $value
|
787 |
+
*/
|
788 |
+
public static function func_implode( $value ) {
|
789 |
+
|
790 |
+
if ( is_array( $value ) ) {
|
791 |
+
$value = apply_filters( 'func_implode', implode( ',', $value ), $value );
|
792 |
+
}
|
793 |
+
|
794 |
+
return $value;
|
795 |
+
}
|
796 |
+
|
797 |
+
/**
|
798 |
+
* md5 function
|
799 |
+
*
|
800 |
+
* @param $value
|
801 |
+
*/
|
802 |
+
public static function func_md5( $value ) {
|
803 |
+
return apply_filters( 'func_md5', md5( $value ), $value );
|
804 |
+
}
|
805 |
+
|
806 |
+
public function make_api_test() {
|
807 |
+
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
808 |
+
parse_str( $_POST['data']['data'], $data );
|
809 |
+
|
810 |
+
if ( ! is_array( $data ) ) {
|
811 |
+
die( '-1' );
|
812 |
+
}
|
813 |
+
|
814 |
+
$action_id = isset( $_POST['data']['action_id'] ) ? (int) sanitize_text_field( $_POST['data']['action_id'] ) : '';
|
815 |
+
$cf7_id = isset( $_POST['data']['cf7_id'] ) ? (int) sanitize_text_field( $_POST['data']['cf7_id'] ) : '';
|
816 |
+
$rule_id = isset( $_POST['data']['rule_id'] ) ? $_POST['data']['rule_id'] : '';
|
817 |
+
|
818 |
+
add_filter( 'after_qs_cf7_api_send_lead', array( $this, 'after_fake_submission' ), 10, 3 );
|
819 |
+
|
820 |
+
if ( isset( $data['wpcf7-redirect']['actions'] ) ) {
|
821 |
+
$response = array();
|
822 |
+
|
823 |
+
$posted_action = reset( $data['wpcf7-redirect']['actions'] );
|
824 |
+
$posted_action = $posted_action['test_values'];
|
825 |
+
$_POST = $posted_action;
|
826 |
+
// this will create a fake form submission
|
827 |
+
$this->cf7r_form = get_cf7r_form( $cf7_id );
|
828 |
+
$this->cf7r_form->enable_action( $action_id );
|
829 |
+
|
830 |
+
$cf7_form = $this->cf7r_form->get_cf7_form_instance();
|
831 |
+
$submission = WPCF7_Submission::get_instance( $cf7_form );
|
832 |
+
|
833 |
+
if ( $submission->get_status() === 'validation_failed' ) {
|
834 |
+
$invalid_fields = $submission->get_invalid_fields();
|
835 |
+
$response['status'] = 'failed';
|
836 |
+
$response['invalid_fields'] = $invalid_fields;
|
837 |
+
} else {
|
838 |
+
$response['status'] = 'success';
|
839 |
+
$response['html'] = $this->get_test_api_results_html();
|
840 |
+
}
|
841 |
+
|
842 |
+
wp_send_json( $response );
|
843 |
+
}
|
844 |
+
}
|
845 |
+
}
|
846 |
+
/**
|
847 |
+
* Store the results from the API
|
848 |
+
*
|
849 |
+
* @param $result
|
850 |
+
* @param $record
|
851 |
+
*/
|
852 |
+
public function after_fake_submission( $result, $record, $args ) {
|
853 |
+
$this->results = $result;
|
854 |
+
$this->record = $record;
|
855 |
+
$this->request = $args;
|
856 |
+
|
857 |
+
return $result;
|
858 |
+
}
|
859 |
+
|
860 |
+
/**
|
861 |
+
* Show A preview for the action
|
862 |
+
*/
|
863 |
+
public function show_action_preview() {
|
864 |
+
if ( isset( $_GET['wpcf7r-preview'] ) ) {
|
865 |
+
$action_id = (int) $_GET['wpcf7r-preview'];
|
866 |
+
|
867 |
+
$action = WPCF7R_Action::get_action( $action_id );
|
868 |
+
|
869 |
+
$action->dynamic_params['popup-template'] = isset( $_GET['template'] ) ? sanitize_text_field( $_GET['template'] ) : '';
|
870 |
+
|
871 |
+
$action->preview();
|
872 |
+
}
|
873 |
+
}
|
874 |
+
|
875 |
+
/**
|
876 |
+
* Get action template in case field are dynamicaly changed
|
877 |
+
*/
|
878 |
+
public function get_action_template() {
|
879 |
+
$response = array();
|
880 |
+
if ( current_user_can( 'wpcf7_edit_contact_form' ) && wpcf7_validate_nonce() ) {
|
881 |
+
$data = isset( $_POST['data'] ) ? $_POST['data'] : '';
|
882 |
+
|
883 |
+
if ( isset( $data['action_id'] ) ) {
|
884 |
+
$action_id = (int) $data['action_id'];
|
885 |
+
$popup_template = sanitize_text_field( $data['template'] );
|
886 |
+
|
887 |
+
$action = WPCF7R_Action::get_action( $action_id );
|
888 |
+
|
889 |
+
ob_start();
|
890 |
+
|
891 |
+
$params = array(
|
892 |
+
'popup-template' => $popup_template,
|
893 |
+
);
|
894 |
+
|
895 |
+
$action->get_action_settings( $params );
|
896 |
+
|
897 |
+
$response['action_content'] = ob_get_clean();
|
898 |
+
}
|
899 |
+
}
|
900 |
+
|
901 |
+
wp_send_json_success( $response );
|
902 |
+
}
|
903 |
+
|
904 |
+
/**
|
905 |
+
* Get the popup html
|
906 |
+
*/
|
907 |
+
public function get_test_api_results_html() {
|
908 |
+
ob_start();
|
909 |
+
|
910 |
+
include WPCF7_PRO_REDIRECT_TEMPLATE_PATH . 'popup-api-test.php';
|
911 |
+
|
912 |
+
return ob_get_clean();
|
913 |
+
}
|
914 |
+
}
|
index.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
lang/index.php
CHANGED
@@ -1,10 +1,4 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
6 |
-
|
7 |
-
exit;
|
8 |
-
|
9 |
-
}
|
10 |
-
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
modules/cf7-shortcode-password-field.php
CHANGED
@@ -1,224 +1,224 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* A base module for the following types of tags:
|
4 |
-
* [text] and [text*] # Single-line text
|
5 |
-
* [email] and [email*] # Email address
|
6 |
-
* [url] and [url*] # URL
|
7 |
-
* [tel] and [tel*] # Telephone number
|
8 |
-
*/
|
9 |
-
|
10 |
-
defined( 'ABSPATH' ) || exit;
|
11 |
-
|
12 |
-
/* form_tag handler */
|
13 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_password', 10, 0 );
|
14 |
-
|
15 |
-
function wpcf7_add_form_tag_password() {
|
16 |
-
if ( function_exists( 'wpcf7_add_form_tag' ) ) {
|
17 |
-
wpcf7_add_form_tag(
|
18 |
-
array( 'password', 'password*' ),
|
19 |
-
'wpcf7_password_form_tag_handler',
|
20 |
-
array( 'name-attr' => true )
|
21 |
-
);
|
22 |
-
}
|
23 |
-
}
|
24 |
-
|
25 |
-
function wpcf7_password_form_tag_handler( $tag ) {
|
26 |
-
if ( empty( $tag->name ) ) {
|
27 |
-
return '';
|
28 |
-
}
|
29 |
-
|
30 |
-
$validation_error = wpcf7_get_validation_error( $tag->name );
|
31 |
-
$class = wpcf7_form_controls_class( $tag->type, 'wpcf7-password' );
|
32 |
-
|
33 |
-
if ( in_array( $tag->basetype, array( 'password' ), true ) ) {
|
34 |
-
$class .= ' wpcf7-validates-as-' . $tag->basetype;
|
35 |
-
}
|
36 |
-
|
37 |
-
if ( $validation_error ) {
|
38 |
-
$class .= ' wpcf7-not-valid';
|
39 |
-
}
|
40 |
-
|
41 |
-
$atts = array();
|
42 |
-
$atts['size'] = $tag->get_size_option( '40' );
|
43 |
-
$atts['maxlength'] = $tag->get_maxlength_option();
|
44 |
-
$atts['minlength'] = $tag->get_minlength_option();
|
45 |
-
|
46 |
-
if ( $atts['maxlength'] && $atts['minlength'] ) {
|
47 |
-
$atts['pattern'] = ".{{$atts['minlength']},{$atts['maxlength']}}";
|
48 |
-
} elseif ( $atts['minlength'] ) {
|
49 |
-
$atts['pattern'] = ".{{$atts['minlength']},}";
|
50 |
-
}
|
51 |
-
|
52 |
-
if ( $atts['maxlength'] and $atts['minlength'] && $atts['maxlength'] < $atts['minlength'] ) {
|
53 |
-
unset( $atts['maxlength'], $atts['minlength'] );
|
54 |
-
}
|
55 |
-
|
56 |
-
$atts['class'] = $tag->get_class_option( $class );
|
57 |
-
$atts['id'] = $tag->get_id_option();
|
58 |
-
$atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
|
59 |
-
$atts['autocomplete'] = $tag->get_option(
|
60 |
-
'autocomplete',
|
61 |
-
'[-0-9a-zA-Z]+',
|
62 |
-
true
|
63 |
-
);
|
64 |
-
|
65 |
-
if ( $tag->has_option( 'readonly' ) ) {
|
66 |
-
$atts['readonly'] = 'readonly';
|
67 |
-
}
|
68 |
-
|
69 |
-
if ( $tag->is_required() ) {
|
70 |
-
$atts['aria-required'] = 'true';
|
71 |
-
}
|
72 |
-
|
73 |
-
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
|
74 |
-
$value = (string) reset( $tag->values );
|
75 |
-
|
76 |
-
if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
|
77 |
-
$atts['placeholder'] = $value;
|
78 |
-
$value = '';
|
79 |
-
}
|
80 |
-
|
81 |
-
$value = $tag->get_default_option( $value );
|
82 |
-
$value = wpcf7_get_hangover( $tag->name, $value );
|
83 |
-
$atts['value'] = $value;
|
84 |
-
|
85 |
-
if ( wpcf7_support_html5() ) {
|
86 |
-
$atts['type'] = $tag->basetype;
|
87 |
-
} else {
|
88 |
-
$atts['type'] = 'password';
|
89 |
-
}
|
90 |
-
|
91 |
-
$atts['name'] = $tag->name;
|
92 |
-
$atts = wpcf7_format_atts( $atts );
|
93 |
-
$html = sprintf(
|
94 |
-
'<span class="wpcf7-form-control-wrap %1$s"><input %2$s autocomplete="false"/>%3$s</span>',
|
95 |
-
sanitize_html_class( $tag->name ),
|
96 |
-
$atts,
|
97 |
-
$validation_error
|
98 |
-
);
|
99 |
-
|
100 |
-
return $html;
|
101 |
-
}
|
102 |
-
|
103 |
-
/* Validation filter */
|
104 |
-
add_filter( 'wpcf7_validate_password', 'wpcf7_password_validation_filter', 10, 2 );
|
105 |
-
add_filter( 'wpcf7_validate_password*', 'wpcf7_password_validation_filter', 10, 2 );
|
106 |
-
|
107 |
-
function wpcf7_password_validation_filter( $result, $tag ) {
|
108 |
-
$name = $tag->name;
|
109 |
-
$value = isset( $_POST[ $name ] )
|
110 |
-
? trim( wp_unslash( strtr( (string) $_POST[ $name ], "\n", ' ' ) ) )
|
111 |
-
: '';
|
112 |
-
if ( 'password' === $tag->basetype ) {
|
113 |
-
if ( $tag->is_required() and '' === $value ) {
|
114 |
-
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
115 |
-
}
|
116 |
-
$atts['maxlength'] = $tag->get_maxlength_option();
|
117 |
-
$atts['minlength'] = $tag->get_minlength_option();
|
118 |
-
if ( $atts['maxlength'] && strlen( $value ) > $atts['maxlength'] ) {
|
119 |
-
$result->invalidate( $tag, wpcf7_get_message( 'invalid_too_long' ) );
|
120 |
-
}
|
121 |
-
if ( $atts['minlength'] && strlen( $value ) < $atts['minlength'] ) {
|
122 |
-
$result->invalidate( $tag, wpcf7_get_message( 'invalid_too_short' ) );
|
123 |
-
}
|
124 |
-
}
|
125 |
-
return $result;
|
126 |
-
}
|
127 |
-
|
128 |
-
/* Messages */
|
129 |
-
add_filter( 'wpcf7_messages', 'wpcf7_password_messages', 10, 1 );
|
130 |
-
|
131 |
-
function wpcf7_password_messages( $messages ) {
|
132 |
-
$messages = array_merge(
|
133 |
-
$messages,
|
134 |
-
array(
|
135 |
-
'invalid_email' => array(
|
136 |
-
'description' =>
|
137 |
-
__( 'Email address that the sender entered is invalid', 'wpcf7-redirect' ),
|
138 |
-
'default' =>
|
139 |
-
__( 'The e-mail address entered is invalid.', 'wpcf7-redirect' ),
|
140 |
-
),
|
141 |
-
'invalid_url' => array(
|
142 |
-
'description' =>
|
143 |
-
__( 'URL that the sender entered is invalid', 'wpcf7-redirect' ),
|
144 |
-
'default' =>
|
145 |
-
__( 'The URL is invalid.', 'wpcf7-redirect' ),
|
146 |
-
),
|
147 |
-
'invalid_tel' => array(
|
148 |
-
'description' =>
|
149 |
-
__( 'Telephone number that the sender entered is invalid', 'wpcf7-redirect' ),
|
150 |
-
'default' =>
|
151 |
-
__( 'The telephone number is invalid.', 'wpcf7-redirect' ),
|
152 |
-
),
|
153 |
-
)
|
154 |
-
);
|
155 |
-
return $messages;
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Tag generator
|
160 |
-
*/
|
161 |
-
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_password', 15, 0 );
|
162 |
-
|
163 |
-
function wpcf7_add_tag_generator_password() {
|
164 |
-
$tag_generator = WPCF7_TagGenerator::get_instance();
|
165 |
-
$tag_generator->add(
|
166 |
-
'password',
|
167 |
-
__( 'password', 'wpcf7-redirect' ),
|
168 |
-
'wpcf7_tag_generator_password'
|
169 |
-
);
|
170 |
-
}
|
171 |
-
|
172 |
-
function wpcf7_tag_generator_password( $contact_form, $args = '' ) {
|
173 |
-
$args = wp_parse_args( $args, array() );
|
174 |
-
$type = $args['id'];
|
175 |
-
|
176 |
-
if ( 'password' === $type ) {
|
177 |
-
$description = __( 'Generate a form-tag for a single-line plain password input field.', 'wpcf7-redirect' );
|
178 |
-
}
|
179 |
-
|
180 |
-
?>
|
181 |
-
<div class="control-box">
|
182 |
-
<fieldset>
|
183 |
-
<table class="form-table">
|
184 |
-
<tbody>
|
185 |
-
<tr>
|
186 |
-
<th scope="row"><?php echo esc_html( __( 'Field type', 'wpcf7-redirect' ) ); ?></th>
|
187 |
-
<td>
|
188 |
-
<fieldset>
|
189 |
-
<legend class="screen-reader-text"><?php echo esc_html( __( 'Field type', 'wpcf7-redirect' ) ); ?></legend>
|
190 |
-
<label><input type="checkbox" name="required" /> <?php echo esc_html( __( 'Required field', 'wpcf7-redirect' ) ); ?></label>
|
191 |
-
</fieldset>
|
192 |
-
</td>
|
193 |
-
</tr>
|
194 |
-
<tr>
|
195 |
-
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'wpcf7-redirect' ) ); ?></label></th>
|
196 |
-
<td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /></td>
|
197 |
-
</tr>
|
198 |
-
<tr>
|
199 |
-
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Default value', 'wpcf7-redirect' ) ); ?></label></th>
|
200 |
-
<td><input type="text" name="values" class="oneline" id="<?php echo esc_attr( $args['content'] . '-values' ); ?>" /><br />
|
201 |
-
<label><input type="checkbox" name="placeholder" class="option" /> <?php echo esc_html( __( 'Use this text as the placeholder of the field', 'wpcf7-redirect' ) ); ?></label></td>
|
202 |
-
</tr>
|
203 |
-
<tr>
|
204 |
-
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'wpcf7-redirect' ) ); ?></label></th>
|
205 |
-
<td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" /></td>
|
206 |
-
</tr>
|
207 |
-
<tr>
|
208 |
-
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'wpcf7-redirect' ) ); ?></label></th>
|
209 |
-
<td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" /></td>
|
210 |
-
</tr>
|
211 |
-
</tbody>
|
212 |
-
</table>
|
213 |
-
</fieldset>
|
214 |
-
</div>
|
215 |
-
<div class="insert-box">
|
216 |
-
<input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" />
|
217 |
-
<div class="submitbox">
|
218 |
-
<input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', 'wpcf7-redirect' ) ); ?>" />
|
219 |
-
</div>
|
220 |
-
<br class="clear" />
|
221 |
-
<p class="description mail-tag"><label for="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"><?php echo sprintf( esc_html( __( 'To use the value input through this field in a mail field, you need to insert the corresponding mail-tag into the field on the Mail tab.', 'wpcf7-redirect' ) ), '<strong><span class="mail-tag"></span></strong>' ); ?><input type="text" class="mail-tag code hidden" readonly="readonly" id="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>" /></label></p>
|
222 |
-
</div>
|
223 |
-
<?php
|
224 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* A base module for the following types of tags:
|
4 |
+
* [text] and [text*] # Single-line text
|
5 |
+
* [email] and [email*] # Email address
|
6 |
+
* [url] and [url*] # URL
|
7 |
+
* [tel] and [tel*] # Telephone number
|
8 |
+
*/
|
9 |
+
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/* form_tag handler */
|
13 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_password', 10, 0 );
|
14 |
+
|
15 |
+
function wpcf7_add_form_tag_password() {
|
16 |
+
if ( function_exists( 'wpcf7_add_form_tag' ) ) {
|
17 |
+
wpcf7_add_form_tag(
|
18 |
+
array( 'password', 'password*' ),
|
19 |
+
'wpcf7_password_form_tag_handler',
|
20 |
+
array( 'name-attr' => true )
|
21 |
+
);
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
function wpcf7_password_form_tag_handler( $tag ) {
|
26 |
+
if ( empty( $tag->name ) ) {
|
27 |
+
return '';
|
28 |
+
}
|
29 |
+
|
30 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
31 |
+
$class = wpcf7_form_controls_class( $tag->type, 'wpcf7-password' );
|
32 |
+
|
33 |
+
if ( in_array( $tag->basetype, array( 'password' ), true ) ) {
|
34 |
+
$class .= ' wpcf7-validates-as-' . $tag->basetype;
|
35 |
+
}
|
36 |
+
|
37 |
+
if ( $validation_error ) {
|
38 |
+
$class .= ' wpcf7-not-valid';
|
39 |
+
}
|
40 |
+
|
41 |
+
$atts = array();
|
42 |
+
$atts['size'] = $tag->get_size_option( '40' );
|
43 |
+
$atts['maxlength'] = $tag->get_maxlength_option();
|
44 |
+
$atts['minlength'] = $tag->get_minlength_option();
|
45 |
+
|
46 |
+
if ( $atts['maxlength'] && $atts['minlength'] ) {
|
47 |
+
$atts['pattern'] = ".{{$atts['minlength']},{$atts['maxlength']}}";
|
48 |
+
} elseif ( $atts['minlength'] ) {
|
49 |
+
$atts['pattern'] = ".{{$atts['minlength']},}";
|
50 |
+
}
|
51 |
+
|
52 |
+
if ( $atts['maxlength'] and $atts['minlength'] && $atts['maxlength'] < $atts['minlength'] ) {
|
53 |
+
unset( $atts['maxlength'], $atts['minlength'] );
|
54 |
+
}
|
55 |
+
|
56 |
+
$atts['class'] = $tag->get_class_option( $class );
|
57 |
+
$atts['id'] = $tag->get_id_option();
|
58 |
+
$atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
|
59 |
+
$atts['autocomplete'] = $tag->get_option(
|
60 |
+
'autocomplete',
|
61 |
+
'[-0-9a-zA-Z]+',
|
62 |
+
true
|
63 |
+
);
|
64 |
+
|
65 |
+
if ( $tag->has_option( 'readonly' ) ) {
|
66 |
+
$atts['readonly'] = 'readonly';
|
67 |
+
}
|
68 |
+
|
69 |
+
if ( $tag->is_required() ) {
|
70 |
+
$atts['aria-required'] = 'true';
|
71 |
+
}
|
72 |
+
|
73 |
+
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
|
74 |
+
$value = (string) reset( $tag->values );
|
75 |
+
|
76 |
+
if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
|
77 |
+
$atts['placeholder'] = $value;
|
78 |
+
$value = '';
|
79 |
+
}
|
80 |
+
|
81 |
+
$value = $tag->get_default_option( $value );
|
82 |
+
$value = wpcf7_get_hangover( $tag->name, $value );
|
83 |
+
$atts['value'] = $value;
|
84 |
+
|
85 |
+
if ( wpcf7_support_html5() ) {
|
86 |
+
$atts['type'] = $tag->basetype;
|
87 |
+
} else {
|
88 |
+
$atts['type'] = 'password';
|
89 |
+
}
|
90 |
+
|
91 |
+
$atts['name'] = $tag->name;
|
92 |
+
$atts = wpcf7_format_atts( $atts );
|
93 |
+
$html = sprintf(
|
94 |
+
'<span class="wpcf7-form-control-wrap %1$s"><input %2$s autocomplete="false"/>%3$s</span>',
|
95 |
+
sanitize_html_class( $tag->name ),
|
96 |
+
$atts,
|
97 |
+
$validation_error
|
98 |
+
);
|
99 |
+
|
100 |
+
return $html;
|
101 |
+
}
|
102 |
+
|
103 |
+
/* Validation filter */
|
104 |
+
add_filter( 'wpcf7_validate_password', 'wpcf7_password_validation_filter', 10, 2 );
|
105 |
+
add_filter( 'wpcf7_validate_password*', 'wpcf7_password_validation_filter', 10, 2 );
|
106 |
+
|
107 |
+
function wpcf7_password_validation_filter( $result, $tag ) {
|
108 |
+
$name = $tag->name;
|
109 |
+
$value = isset( $_POST[ $name ] )
|
110 |
+
? trim( wp_unslash( strtr( (string) $_POST[ $name ], "\n", ' ' ) ) )
|
111 |
+
: '';
|
112 |
+
if ( 'password' === $tag->basetype ) {
|
113 |
+
if ( $tag->is_required() and '' === $value ) {
|
114 |
+
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
115 |
+
}
|
116 |
+
$atts['maxlength'] = $tag->get_maxlength_option();
|
117 |
+
$atts['minlength'] = $tag->get_minlength_option();
|
118 |
+
if ( $atts['maxlength'] && strlen( $value ) > $atts['maxlength'] ) {
|
119 |
+
$result->invalidate( $tag, wpcf7_get_message( 'invalid_too_long' ) );
|
120 |
+
}
|
121 |
+
if ( $atts['minlength'] && strlen( $value ) < $atts['minlength'] ) {
|
122 |
+
$result->invalidate( $tag, wpcf7_get_message( 'invalid_too_short' ) );
|
123 |
+
}
|
124 |
+
}
|
125 |
+
return $result;
|
126 |
+
}
|
127 |
+
|
128 |
+
/* Messages */
|
129 |
+
add_filter( 'wpcf7_messages', 'wpcf7_password_messages', 10, 1 );
|
130 |
+
|
131 |
+
function wpcf7_password_messages( $messages ) {
|
132 |
+
$messages = array_merge(
|
133 |
+
$messages,
|
134 |
+
array(
|
135 |
+
'invalid_email' => array(
|
136 |
+
'description' =>
|
137 |
+
__( 'Email address that the sender entered is invalid', 'wpcf7-redirect' ),
|
138 |
+
'default' =>
|
139 |
+
__( 'The e-mail address entered is invalid.', 'wpcf7-redirect' ),
|
140 |
+
),
|
141 |
+
'invalid_url' => array(
|
142 |
+
'description' =>
|
143 |
+
__( 'URL that the sender entered is invalid', 'wpcf7-redirect' ),
|
144 |
+
'default' =>
|
145 |
+
__( 'The URL is invalid.', 'wpcf7-redirect' ),
|
146 |
+
),
|
147 |
+
'invalid_tel' => array(
|
148 |
+
'description' =>
|
149 |
+
__( 'Telephone number that the sender entered is invalid', 'wpcf7-redirect' ),
|
150 |
+
'default' =>
|
151 |
+
__( 'The telephone number is invalid.', 'wpcf7-redirect' ),
|
152 |
+
),
|
153 |
+
)
|
154 |
+
);
|
155 |
+
return $messages;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Tag generator
|
160 |
+
*/
|
161 |
+
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_password', 15, 0 );
|
162 |
+
|
163 |
+
function wpcf7_add_tag_generator_password() {
|
164 |
+
$tag_generator = WPCF7_TagGenerator::get_instance();
|
165 |
+
$tag_generator->add(
|
166 |
+
'password',
|
167 |
+
__( 'password', 'wpcf7-redirect' ),
|
168 |
+
'wpcf7_tag_generator_password'
|
169 |
+
);
|
170 |
+
}
|
171 |
+
|
172 |
+
function wpcf7_tag_generator_password( $contact_form, $args = '' ) {
|
173 |
+
$args = wp_parse_args( $args, array() );
|
174 |
+
$type = $args['id'];
|
175 |
+
|
176 |
+
if ( 'password' === $type ) {
|
177 |
+
$description = __( 'Generate a form-tag for a single-line plain password input field.', 'wpcf7-redirect' );
|
178 |
+
}
|
179 |
+
|
180 |
+
?>
|
181 |
+
<div class="control-box">
|
182 |
+
<fieldset>
|
183 |
+
<table class="form-table">
|
184 |
+
<tbody>
|
185 |
+
<tr>
|
186 |
+
<th scope="row"><?php echo esc_html( __( 'Field type', 'wpcf7-redirect' ) ); ?></th>
|
187 |
+
<td>
|
188 |
+
<fieldset>
|
189 |
+
<legend class="screen-reader-text"><?php echo esc_html( __( 'Field type', 'wpcf7-redirect' ) ); ?></legend>
|
190 |
+
<label><input type="checkbox" name="required" /> <?php echo esc_html( __( 'Required field', 'wpcf7-redirect' ) ); ?></label>
|
191 |
+
</fieldset>
|
192 |
+
</td>
|
193 |
+
</tr>
|
194 |
+
<tr>
|
195 |
+
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'wpcf7-redirect' ) ); ?></label></th>
|
196 |
+
<td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /></td>
|
197 |
+
</tr>
|
198 |
+
<tr>
|
199 |
+
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Default value', 'wpcf7-redirect' ) ); ?></label></th>
|
200 |
+
<td><input type="text" name="values" class="oneline" id="<?php echo esc_attr( $args['content'] . '-values' ); ?>" /><br />
|
201 |
+
<label><input type="checkbox" name="placeholder" class="option" /> <?php echo esc_html( __( 'Use this text as the placeholder of the field', 'wpcf7-redirect' ) ); ?></label></td>
|
202 |
+
</tr>
|
203 |
+
<tr>
|
204 |
+
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'wpcf7-redirect' ) ); ?></label></th>
|
205 |
+
<td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" /></td>
|
206 |
+
</tr>
|
207 |
+
<tr>
|
208 |
+
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'wpcf7-redirect' ) ); ?></label></th>
|
209 |
+
<td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" /></td>
|
210 |
+
</tr>
|
211 |
+
</tbody>
|
212 |
+
</table>
|
213 |
+
</fieldset>
|
214 |
+
</div>
|
215 |
+
<div class="insert-box">
|
216 |
+
<input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" />
|
217 |
+
<div class="submitbox">
|
218 |
+
<input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', 'wpcf7-redirect' ) ); ?>" />
|
219 |
+
</div>
|
220 |
+
<br class="clear" />
|
221 |
+
<p class="description mail-tag"><label for="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"><?php echo sprintf( esc_html( __( 'To use the value input through this field in a mail field, you need to insert the corresponding mail-tag into the field on the Mail tab.', 'wpcf7-redirect' ) ), '<strong><span class="mail-tag"></span></strong>' ); ?><input type="text" class="mail-tag code hidden" readonly="readonly" id="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>" /></label></p>
|
222 |
+
</div>
|
223 |
+
<?php
|
224 |
+
}
|
modules/cf7r-shortcode-get-param-field.php
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Get params from the redirect page
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
add_shortcode( 'get_param', 'wpcf7r_get_param' );
|
9 |
-
add_shortcode( 'wpcf7r_posted_param', 'wpcf7r_get_param' );
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Collect the data from the query string by parameter
|
13 |
-
*/
|
14 |
-
function wpcf7r_get_param( $atts ) {
|
15 |
-
$atts = shortcode_atts(
|
16 |
-
array(
|
17 |
-
'param' => '',
|
18 |
-
),
|
19 |
-
$atts,
|
20 |
-
'wpcf7-redirect'
|
21 |
-
);
|
22 |
-
$param = '';
|
23 |
-
|
24 |
-
if ( isset( $_GET[ $atts['param'] ] ) && $_GET[ $atts['param'] ] ) {
|
25 |
-
$param = esc_attr( wp_kses( $_GET[ $atts['param'] ], array( '' ) ) );
|
26 |
-
}
|
27 |
-
|
28 |
-
return $param;
|
29 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Get params from the redirect page
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
add_shortcode( 'get_param', 'wpcf7r_get_param' );
|
9 |
+
add_shortcode( 'wpcf7r_posted_param', 'wpcf7r_get_param' );
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Collect the data from the query string by parameter
|
13 |
+
*/
|
14 |
+
function wpcf7r_get_param( $atts ) {
|
15 |
+
$atts = shortcode_atts(
|
16 |
+
array(
|
17 |
+
'param' => '',
|
18 |
+
),
|
19 |
+
$atts,
|
20 |
+
'wpcf7-redirect'
|
21 |
+
);
|
22 |
+
$param = '';
|
23 |
+
|
24 |
+
if ( isset( $_GET[ $atts['param'] ] ) && $_GET[ $atts['param'] ] ) {
|
25 |
+
$param = esc_attr( wp_kses( $_GET[ $atts['param'] ], array( '' ) ) );
|
26 |
+
}
|
27 |
+
|
28 |
+
return $param;
|
29 |
+
}
|
readme.txt
CHANGED
@@ -1,205 +1,214 @@
|
|
1 |
-
=== Redirection for Contact Form 7 ===
|
2 |
-
Tags: contact form 7 redirect, contact form 7 thank you page, redirect cf7, redirect contact form 7, contact form 7 success page, cf7 redirect, registration form, mailchimp, login form, conditional redirect, cms integration, conversions, save leads, paypal
|
3 |
-
Contributors: yuvalsabar, regevlio
|
4 |
-
Requires at least: 5.
|
5 |
-
Tested up to: 5.
|
6 |
-
Stable tag: 2.3.
|
7 |
-
License: GPLv3 or later
|
8 |
-
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
-
|
10 |
-
The ultimate add-on for Contact Form 7 - redirect to any page you choose after mail sent successfully, firing scripts after submission, save submissions in database, and much more options to make Contact Form 7 poweful then ever.
|
11 |
-
|
12 |
-
== Description ==
|
13 |
-
|
14 |
-
The ultimate add-on for Contact Form 7 - redirect to any page you choose after mail sent successfully, firing scripts after submission, save submissions in database, and much more options to make Contact Form 7 poweful then ever.
|
15 |
-
NOTE: This plugin requires Contact Form 7 version 4.8 or later.
|
16 |
-
|
17 |
-
== Usage ==
|
18 |
-
|
19 |
-
Simply go to your form settings, choose the "Redirect Settings" tab and set the page you want to be redirected to.
|
20 |
-
|
21 |
-
== Features ==
|
22 |
-
|
23 |
-
* Redirect to any URL
|
24 |
-
* Open page in a new tab
|
25 |
-
* Run JavaScript after form submission (great for conversion management)
|
26 |
-
* Pass fields from the form as URL query parameters
|
27 |
-
* Add Honeypot to minimize spam
|
28 |
-
* Save form submissions to your database
|
29 |
-
|
30 |
-
==
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
* **[Extension]**
|
35 |
-
* **[Extension]**
|
36 |
-
* **[Extension]**
|
37 |
-
* **[Extension]**
|
38 |
-
* **[Extension]**
|
39 |
-
* **[Extension]**
|
40 |
-
* **[Extension]**
|
41 |
-
* **[Extension]**
|
42 |
-
* **[Extension]**
|
43 |
-
* **[Extension]**
|
44 |
-
* **[Extension]**
|
45 |
-
* **[Extension]**
|
46 |
-
* **[Extension]**
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
* Security updates
|
83 |
-
*
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
*
|
89 |
-
|
90 |
-
= 2.3.
|
91 |
-
*
|
92 |
-
*
|
93 |
-
* Fixed
|
94 |
-
*
|
95 |
-
|
96 |
-
= 2.3.
|
97 |
-
*
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
*
|
103 |
-
*
|
104 |
-
|
105 |
-
|
106 |
-
*
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
* Added
|
112 |
-
* Added
|
113 |
-
*
|
114 |
-
*
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
*
|
121 |
-
*
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
*
|
131 |
-
|
132 |
-
= 2.2.
|
133 |
-
* Fixed
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
* Fixed
|
140 |
-
|
141 |
-
= 2.2.
|
142 |
-
*
|
143 |
-
*
|
144 |
-
*
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
*
|
149 |
-
|
150 |
-
=
|
151 |
-
*
|
152 |
-
|
153 |
-
|
154 |
-
*
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
*
|
166 |
-
|
167 |
-
= 1.3.
|
168 |
-
*
|
169 |
-
|
170 |
-
= 1.2
|
171 |
-
*
|
172 |
-
|
173 |
-
= 1.
|
174 |
-
*
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
*
|
195 |
-
|
196 |
-
= 1.2 =
|
197 |
-
*
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
* New feature:
|
202 |
-
*
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
* Initial release.
|
1 |
+
=== Redirection for Contact Form 7 ===
|
2 |
+
Tags: contact form 7 redirect, contact form 7 thank you page, redirect cf7, redirect contact form 7, contact form 7 success page, cf7 redirect, registration form, mailchimp, login form, conditional redirect, cms integration, conversions, save leads, paypal
|
3 |
+
Contributors: yuvalsabar, regevlio
|
4 |
+
Requires at least: 5.2.0
|
5 |
+
Tested up to: 5.8
|
6 |
+
Stable tag: 2.3.6
|
7 |
+
License: GPLv3 or later
|
8 |
+
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
+
|
10 |
+
The ultimate add-on for Contact Form 7 - redirect to any page you choose after mail sent successfully, firing scripts after submission, save submissions in database, and much more options to make Contact Form 7 poweful then ever.
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
The ultimate add-on for Contact Form 7 - redirect to any page you choose after mail sent successfully, firing scripts after submission, save submissions in database, and much more options to make Contact Form 7 poweful then ever.
|
15 |
+
NOTE: This plugin requires Contact Form 7 version 4.8 or later.
|
16 |
+
|
17 |
+
== Usage ==
|
18 |
+
|
19 |
+
Simply go to your form settings, choose the "Redirect Settings" tab and set the page you want to be redirected to.
|
20 |
+
|
21 |
+
== Features ==
|
22 |
+
|
23 |
+
* Redirect to any URL
|
24 |
+
* Open page in a new tab
|
25 |
+
* Run JavaScript after form submission (great for conversion management)
|
26 |
+
* Pass fields from the form as URL query parameters
|
27 |
+
* Add Honeypot to minimize spam
|
28 |
+
* Save form submissions to your database
|
29 |
+
|
30 |
+
== Our Extensions ==
|
31 |
+
* **[Extension]** Conditional logic for each action
|
32 |
+
* **[Extension]** Integrate your forms with your Salesforce CRM
|
33 |
+
* **[Extension]** Integrate your forms with your Hubspot CRM
|
34 |
+
* **[Extension]** Frontend Publishing - Allow your visitors to submit post types
|
35 |
+
* **[Extension]** Frontend Registration - Use contact form 7 as a registration form
|
36 |
+
* **[Extension]** Frontend Login - Use contact form 7 to login users to your website
|
37 |
+
* **[Extension]** Automatically add form submissions to your predefined list
|
38 |
+
* **[Extension]** Conditional form validations (custom error messages)
|
39 |
+
* **[Extension]** Manage email notifications by conditional logic
|
40 |
+
* **[Extension]** Fire custom JavaScript events by conditional logic
|
41 |
+
* **[Extension]** Send data to remote servers (3rd-party integration)
|
42 |
+
* **[Extension]** Send submissions to API Json/XML to remote servers
|
43 |
+
* **[Extension]** Send submissions to API POST/GET to remote servers
|
44 |
+
* **[Extension]** PayPal Integration
|
45 |
+
* **[Extension]** Stripe Integration
|
46 |
+
* **[Extension]** Create and send PDF
|
47 |
+
|
48 |
+
> Note: some features are availible only as an extension. Which means you need Redirection for Contact Form 7 Pro to unlock those features. You can [get Redirection for Contact Form 7 Pro here](https://redirection-for-contact-form7.com/product/wpcf7r-actions-bundle/)!
|
49 |
+
|
50 |
+
== Installation ==
|
51 |
+
|
52 |
+
Installing Redirection for Contact Form 7 can be done either by searching for "Redirection for Contact Form 7" via the "Plugins > Add New" screen in your WordPress dashboard, or by using the following steps:
|
53 |
+
|
54 |
+
1. Download the plugin via WordPress.org.
|
55 |
+
2. Upload the ZIP file through the "Plugins > Add New > Upload" screen in your WordPress dashboard.
|
56 |
+
3. Activate the plugin through the 'Plugins' menu in WordPress
|
57 |
+
4. Visit the settings screen and configure, as desired.
|
58 |
+
|
59 |
+
== Frequently Asked Questions ==
|
60 |
+
|
61 |
+
= Does the plugin disables Contact Form 7 Ajax? =
|
62 |
+
|
63 |
+
No, it doesn't. The plugin does not disables any of Contact Form 7 normal behavior, unlike all other plugins that do the same.
|
64 |
+
|
65 |
+
= Does this plugin uses "on_sent_ok" additional setting? =
|
66 |
+
|
67 |
+
No. One of the reasons we developed this plugin, is because on_send_ok is now deprecated, and is going to be abolished by the end of 2017. This plugin is the only redirect plugin for Contact Form 7 that has been updated to use [DOM events](https://contactform7.com/dom-events/) to perform redirect, as Contact Form 7 developer Takayuki Miyoshi recommends.
|
68 |
+
|
69 |
+
== Screenshots ==
|
70 |
+
|
71 |
+
1. Actions tab
|
72 |
+
2. Redirect Action
|
73 |
+
3. Fire JavaScript Action
|
74 |
+
4. Save Lead Actions
|
75 |
+
5. Extensions tab
|
76 |
+
|
77 |
+
== Changelog ==
|
78 |
+
|
79 |
+
= 2.3.6 =
|
80 |
+
* Fix missing definition for stripe integration extension
|
81 |
+
* Fix notice message on WP-CLI (HTTP_HOST);
|
82 |
+
* Security updates
|
83 |
+
* Ui fixes on extensions list
|
84 |
+
|
85 |
+
= 2.3.5 =
|
86 |
+
* Fix preview of checkbox fields on leads list
|
87 |
+
* Fix nonce issues on extensions page
|
88 |
+
* Fix send file to api [{fieldname}-filename] [{fieldname}-base_64_file] [{fieldname}-path]
|
89 |
+
|
90 |
+
= 2.3.4 =
|
91 |
+
* Security updates
|
92 |
+
* Fixed jQuery error when adding an action with wysiwyg Editor
|
93 |
+
* Fixed duplicate post functionality
|
94 |
+
* Added support for pdf create action
|
95 |
+
|
96 |
+
= 2.3.3 =
|
97 |
+
* Fixed undefined $_SERVER['HTTP_HOST'] on CLI calls
|
98 |
+
|
99 |
+
= 2.3.2 =
|
100 |
+
* Added columns on actions list (debug mode)
|
101 |
+
* Added compatibility for Contact Form 7 Redirection Pro migrations
|
102 |
+
* Fixed extensions download process.
|
103 |
+
* Moved Mailchimp dependencies to Mailchimp action
|
104 |
+
|
105 |
+
= 2.3.1 =
|
106 |
+
* Added index.php to directories to disable directory browsing.
|
107 |
+
* Fixed typo in popup action class name for receiving updates.
|
108 |
+
* Fixed extensions update process.
|
109 |
+
|
110 |
+
= 2.2.9 =
|
111 |
+
* Added Export leads to csv option.
|
112 |
+
* Added Duplicate action button.
|
113 |
+
* Added Preview data on leads table (Defined by marking which fields to display on the action settings).
|
114 |
+
* Added urlencode passed parameters option on redirect action.
|
115 |
+
* Fixed duplicate actions on contact form duplication.
|
116 |
+
|
117 |
+
|
118 |
+
= 2.2.8 =
|
119 |
+
* Added html support to Send Email action.
|
120 |
+
* Added file attachments support to Send Email action.
|
121 |
+
* Added reset settings button to debug tools.
|
122 |
+
* Fixed a bug: radio buttons and checkboxes are now passed correctly as url parameters.
|
123 |
+
* Fixed a bug: "Changes you made may not be saved" pop-up no longer appears when no changes have been made.
|
124 |
+
|
125 |
+
= 2.2.7 =
|
126 |
+
* Fixed extensions update check interval.
|
127 |
+
|
128 |
+
= 2.2.6 =
|
129 |
+
* Fixed support for non-ajax redirection action.
|
130 |
+
* Minor styling changes.
|
131 |
+
|
132 |
+
= 2.2.5 =
|
133 |
+
* Fixed compatibility issues with "Contact Form 7 - Conditional Fields" Plugin.
|
134 |
+
|
135 |
+
= 2.2.4 =
|
136 |
+
* Fixed a bug with jQuery.noConflict()
|
137 |
+
|
138 |
+
= 2.2.3 =
|
139 |
+
* Fixed compatability issue with "Contact Form 7 - Conditional Fields" Plugin.
|
140 |
+
|
141 |
+
= 2.2.2 =
|
142 |
+
* Fixed a bug with jQuery.noConflict()
|
143 |
+
* jQuery migrate compatibility changes
|
144 |
+
* Added debug options
|
145 |
+
|
146 |
+
= 2.2.1 =
|
147 |
+
* Fixed a bug in extension class
|
148 |
+
* Fixed a bug - accessiBe turned off by default
|
149 |
+
|
150 |
+
= 2.2.0 =
|
151 |
+
* New feature: Saving form leads in database.
|
152 |
+
* New actions system.
|
153 |
+
* Easy installation of plugin extensions.
|
154 |
+
* Complete code refactoring.
|
155 |
+
|
156 |
+
= 1.3.7 =
|
157 |
+
* Show pages hierarchy in page select dropdown.
|
158 |
+
|
159 |
+
= 1.3.6 =
|
160 |
+
* Fixed a bug: Redirection for legacy browsers (non-ajax) not working when using external url.
|
161 |
+
|
162 |
+
= 1.3.4 =
|
163 |
+
* Fixed a bug: "Changes you made may not be saved" pop-up no longer appears when no changes have been made.
|
164 |
+
* Fixed a bug: When passing all fields as parameters, "+" sign is now replaced with "%20".
|
165 |
+
* Minor code styling changes to fully meet WordPress standards.
|
166 |
+
|
167 |
+
= 1.3.3 =
|
168 |
+
* Fixed a bug: URL query parameters are now properly decoded.
|
169 |
+
|
170 |
+
= 1.3.2 =
|
171 |
+
* New feature: delay redirection in milliseconds.
|
172 |
+
|
173 |
+
= 1.3.1 =
|
174 |
+
* Fixed a bug in legacy browsers: the Pro message keep showing.
|
175 |
+
|
176 |
+
= 1.3.0 =
|
177 |
+
* Minor dev improvements.
|
178 |
+
|
179 |
+
= 1.2.9 =
|
180 |
+
* Fixed a bug: when passing specific fields as URL query parameters, not all the fields were passed.
|
181 |
+
|
182 |
+
= 1.2.8 =
|
183 |
+
* New feature: Pass specific fields from the form as URL query parameters.
|
184 |
+
* Minor dev improvements.
|
185 |
+
|
186 |
+
= 1.2.7 =
|
187 |
+
* Script field now accepts special characters, such as < and >.
|
188 |
+
|
189 |
+
= 1.2.6 =
|
190 |
+
* Added support for browsers that don't support AJAX.
|
191 |
+
* Minor CSS changes.
|
192 |
+
|
193 |
+
= 1.2.5 =
|
194 |
+
* Added error message if Contact Form 7 version is earlier than 4.8.
|
195 |
+
|
196 |
+
= 1.2.4 =
|
197 |
+
* Fixed a bug regarding sanitizing URL, causing & to change to #038;
|
198 |
+
* Unnecessary variables removed.
|
199 |
+
|
200 |
+
= 1.2.2 =
|
201 |
+
* New feature: Pass all fields from the form as URL query parameters.
|
202 |
+
* Minor CSS changes.
|
203 |
+
* Dev improvements.
|
204 |
+
|
205 |
+
= 1.2 =
|
206 |
+
* New feature: add script after the form has been sent successfully.
|
207 |
+
|
208 |
+
= 1.0.2 =
|
209 |
+
* Added full support for form duplication.
|
210 |
+
* New feature: open page in a new tab.
|
211 |
+
* Added plugin class CF7_Redirect.
|
212 |
+
|
213 |
+
= 1.0.0 =
|
214 |
* Initial release.
|
templates/banner.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Display banner
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="wpcfr-banner">
|
10 |
-
<div class="wpcfr-banner-holder">
|
11 |
-
<span class="dashicons dashicons-no close-banner" title="<?php _e( 'Close', 'wpcf7-redirect' ); ?>"></span>
|
12 |
-
<a href="https://redirection-for-contact-form7.com/" target="_blank">
|
13 |
-
<img src="<?php echo wpcf7r_get_redirect_plugin_url(); ?>/assets/images/banner.png" alt="Get pro version" />
|
14 |
-
</a>
|
15 |
-
</div>
|
16 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Display banner
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="wpcfr-banner">
|
10 |
+
<div class="wpcfr-banner-holder">
|
11 |
+
<span class="dashicons dashicons-no close-banner" title="<?php _e( 'Close', 'wpcf7-redirect' ); ?>"></span>
|
12 |
+
<a href="https://redirection-for-contact-form7.com/" target="_blank">
|
13 |
+
<img src="<?php echo wpcf7r_get_redirect_plugin_url(); ?>/assets/images/banner.png" alt="Get pro version" />
|
14 |
+
</a>
|
15 |
+
</div>
|
16 |
+
</div>
|
templates/block-html.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Displays a condition logic HTML block
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
self::conditional_groups_display( $group_block, $prefix );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Displays a condition logic HTML block
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
self::conditional_groups_display( $group_block, $prefix );
|
templates/block-title.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Displays a conditional block title
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="block-title <?php echo $active_tab_title; ?>" data-rel="<?php echo $group_block_key; ?>">
|
10 |
-
<?php $active_tab_title = ''; ?>
|
11 |
-
<span class="dashicons dashicons-edit"></span>
|
12 |
-
<span class="dashicons dashicons-yes show-on-edit" data-rel="<?php echo $group_block_key; ?>"></span>
|
13 |
-
<span class="dashicons dashicons-no show-on-edit" data-rel="<?php echo $group_block_key; ?>"></span>
|
14 |
-
<span class="dashicons dashicons-minus show-on-edit remove-block"></span>
|
15 |
-
<input type="text" name="wpcf7-redirect<?php echo $prefix; ?>[blocks][<?php echo $group_block_key; ?>][block_title]" value="<?php echo $group_block['block_title']; ?>" data-original="<?php echo $group_block['block_title']; ?>" readonly="readonly">
|
16 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Displays a conditional block title
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="block-title <?php echo $active_tab_title; ?>" data-rel="<?php echo $group_block_key; ?>">
|
10 |
+
<?php $active_tab_title = ''; ?>
|
11 |
+
<span class="dashicons dashicons-edit"></span>
|
12 |
+
<span class="dashicons dashicons-yes show-on-edit" data-rel="<?php echo $group_block_key; ?>"></span>
|
13 |
+
<span class="dashicons dashicons-no show-on-edit" data-rel="<?php echo $group_block_key; ?>"></span>
|
14 |
+
<span class="dashicons dashicons-minus show-on-edit remove-block"></span>
|
15 |
+
<input type="text" name="wpcf7-redirect<?php echo $prefix; ?>[blocks][<?php echo $group_block_key; ?>][block_title]" value="<?php echo $group_block['block_title']; ?>" data-original="<?php echo $group_block['block_title']; ?>" readonly="readonly">
|
16 |
+
</div>
|
templates/default-settings.php
CHANGED
@@ -1,69 +1,69 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Displays the list of actions
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
$rule_id = 'default';
|
9 |
-
$actions = $this->get_actions( $rule_id );
|
10 |
-
?>
|
11 |
-
|
12 |
-
<h2>
|
13 |
-
<?php _e( 'Submission Actions', 'wpcf7-redirect' ); ?>
|
14 |
-
</h2>
|
15 |
-
<?php wp_nonce_field( 'manage_cf7_redirect', 'actions-nonce' ); ?>
|
16 |
-
<legend>
|
17 |
-
<?php _e( 'You can add actions that will be fired on submission. For details and support check', 'wpcf7-redirect' ); ?> <a href="https://redirection-for-contact-form7.com/" target="_blank"><?php _e( 'official website', 'wpcf7-redirect' ); ?></a>.
|
18 |
-
</legend>
|
19 |
-
|
20 |
-
<div class="actions-list">
|
21 |
-
<div class="actions">
|
22 |
-
<table class="wp-list-table widefat fixed striped pages" data-wrapid="<?php echo $rule_id; ?>">
|
23 |
-
<thead>
|
24 |
-
<tr>
|
25 |
-
<th class="manage-column check-column">
|
26 |
-
<a href="#"><?php _e( 'No.', 'wpcf7-redirect' ); ?></a>
|
27 |
-
</th>
|
28 |
-
<th class="manage-column column-title column-primary sortable desc">
|
29 |
-
<a href="#"><?php _e( 'Title', 'wpcf7-redirect' ); ?></a>
|
30 |
-
</th>
|
31 |
-
<th class="manage-column column-primary sortable desc">
|
32 |
-
<a href="#"><?php _e( 'Type', 'wpcf7-redirect' ); ?></a>
|
33 |
-
</th>
|
34 |
-
<th class="manage-column column-primary sortable desc">
|
35 |
-
<a href="#"><?php _e( 'Active', 'wpcf7-redirect' ); ?></a>
|
36 |
-
</th>
|
37 |
-
<th class="manage-column check-column">
|
38 |
-
</th>
|
39 |
-
</tr>
|
40 |
-
</thead>
|
41 |
-
<tbody id="the_list">
|
42 |
-
<?php if ( $actions ) : ?>
|
43 |
-
<?php foreach ( $actions as $action ) : ?>
|
44 |
-
<?php echo $action->get_action_row(); ?>
|
45 |
-
<?php endforeach; ?>
|
46 |
-
<?php endif; ?>
|
47 |
-
</tbody>
|
48 |
-
</table>
|
49 |
-
</div>
|
50 |
-
<div class="add-new-action-wrap">
|
51 |
-
<select class="new-action-selector" name="new-action-selector">
|
52 |
-
<option value="" selected="selected"><?php _e( 'Choose Action', 'wpcf7-redirect' ); ?></option>
|
53 |
-
<?php foreach ( wpcf7r_get_available_actions() as $available_action_key => $available_action_label ) : ?>
|
54 |
-
<option value="<?php echo $available_action_key; ?>" <?php echo $available_action_label['attr']; ?>><?php echo $available_action_label['label']; ?></option>
|
55 |
-
<?php endforeach; ?>
|
56 |
-
|
57 |
-
<?php foreach ( wpcf7_get_extensions() as $extension ) : ?>
|
58 |
-
<?php if ( ! isset( $extension['active'] ) || ! $extension['active'] ) : ?>
|
59 |
-
<option value="<?php echo WPCF7_PRO_REDIRECT_PLUGIN_PAGE_URL . $extension['name']; ?>" data-action="purchase">
|
60 |
-
<?php echo $extension['title']; ?> (<?php _e( 'Purchase', 'wpcf7-redirect' ); ?>)
|
61 |
-
</option>
|
62 |
-
<?php endif; ?>
|
63 |
-
<?php endforeach; ?>
|
64 |
-
</select>
|
65 |
-
<a type="button" name="button" class="button-primary wpcf7-add-new-action" data-ruleid="<?php echo $rule_id; ?>" data-id="<?php echo $this->get_id(); ?>">
|
66 |
-
<?php _e( 'Add Action', 'wpcf7-redirect' ); ?>
|
67 |
-
</a>
|
68 |
-
</div>
|
69 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Displays the list of actions
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
$rule_id = 'default';
|
9 |
+
$actions = $this->get_actions( $rule_id );
|
10 |
+
?>
|
11 |
+
|
12 |
+
<h2>
|
13 |
+
<?php _e( 'Submission Actions', 'wpcf7-redirect' ); ?>
|
14 |
+
</h2>
|
15 |
+
<?php wp_nonce_field( 'manage_cf7_redirect', 'actions-nonce' ); ?>
|
16 |
+
<legend>
|
17 |
+
<?php _e( 'You can add actions that will be fired on submission. For details and support check', 'wpcf7-redirect' ); ?> <a href="https://redirection-for-contact-form7.com/" target="_blank"><?php _e( 'official website', 'wpcf7-redirect' ); ?></a>.
|
18 |
+
</legend>
|
19 |
+
|
20 |
+
<div class="actions-list">
|
21 |
+
<div class="actions">
|
22 |
+
<table class="wp-list-table widefat fixed striped pages" data-wrapid="<?php echo $rule_id; ?>">
|
23 |
+
<thead>
|
24 |
+
<tr>
|
25 |
+
<th class="manage-column cf7r-check-column">
|
26 |
+
<a href="#"><?php _e( 'No.', 'wpcf7-redirect' ); ?></a>
|
27 |
+
</th>
|
28 |
+
<th class="manage-column column-title column-primary sortable desc">
|
29 |
+
<a href="#"><?php _e( 'Title', 'wpcf7-redirect' ); ?></a>
|
30 |
+
</th>
|
31 |
+
<th class="manage-column column-primary sortable desc">
|
32 |
+
<a href="#"><?php _e( 'Type', 'wpcf7-redirect' ); ?></a>
|
33 |
+
</th>
|
34 |
+
<th class="manage-column column-primary sortable desc">
|
35 |
+
<a href="#"><?php _e( 'Active', 'wpcf7-redirect' ); ?></a>
|
36 |
+
</th>
|
37 |
+
<th class="manage-column cf7r-check-column">
|
38 |
+
</th>
|
39 |
+
</tr>
|
40 |
+
</thead>
|
41 |
+
<tbody id="the_list">
|
42 |
+
<?php if ( $actions ) : ?>
|
43 |
+
<?php foreach ( $actions as $action ) : ?>
|
44 |
+
<?php echo $action->get_action_row(); ?>
|
45 |
+
<?php endforeach; ?>
|
46 |
+
<?php endif; ?>
|
47 |
+
</tbody>
|
48 |
+
</table>
|
49 |
+
</div>
|
50 |
+
<div class="add-new-action-wrap">
|
51 |
+
<select class="new-action-selector" name="new-action-selector">
|
52 |
+
<option value="" selected="selected"><?php _e( 'Choose Action', 'wpcf7-redirect' ); ?></option>
|
53 |
+
<?php foreach ( wpcf7r_get_available_actions() as $available_action_key => $available_action_label ) : ?>
|
54 |
+
<option value="<?php echo $available_action_key; ?>" <?php echo $available_action_label['attr']; ?>><?php echo $available_action_label['label']; ?></option>
|
55 |
+
<?php endforeach; ?>
|
56 |
+
|
57 |
+
<?php foreach ( wpcf7_get_extensions() as $extension ) : ?>
|
58 |
+
<?php if ( ! isset( $extension['active'] ) || ! $extension['active'] ) : ?>
|
59 |
+
<option value="<?php echo WPCF7_PRO_REDIRECT_PLUGIN_PAGE_URL . $extension['name']; ?>" data-action="purchase">
|
60 |
+
<?php echo $extension['title']; ?> (<?php _e( 'Purchase', 'wpcf7-redirect' ); ?>)
|
61 |
+
</option>
|
62 |
+
<?php endif; ?>
|
63 |
+
<?php endforeach; ?>
|
64 |
+
</select>
|
65 |
+
<a type="button" name="button" class="button-primary wpcf7-add-new-action" data-ruleid="<?php echo $rule_id; ?>" data-id="<?php echo $this->get_id(); ?>">
|
66 |
+
<?php _e( 'Add Action', 'wpcf7-redirect' ); ?>
|
67 |
+
</a>
|
68 |
+
</div>
|
69 |
+
</div>
|
templates/extensions.php
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Displays the extensions panel
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
wp_nonce_field( 'wpcf7_redirect_page_extensions', 'wpcf7_redirect_page_extensions_nonce' );
|
9 |
-
|
10 |
-
do_action( 'before_extensions_settings_tab_title', $this );
|
11 |
-
?>
|
12 |
-
|
13 |
-
<fieldset>
|
14 |
-
<div class="fields-wrap field-wrap-page-id">
|
15 |
-
<div class="tab-wrap">
|
16 |
-
<div class="wpcf7r-tab-wrap-inner">
|
17 |
-
<div data-tab-inner>
|
18 |
-
<?php include( 'extensions/extensions-table.php' ); ?>
|
19 |
-
</div>
|
20 |
-
</div>
|
21 |
-
</div>
|
22 |
-
</div>
|
23 |
-
</fieldset>
|
24 |
-
|
25 |
-
<?php
|
26 |
-
do_action( 'after_extensions_settings_tab_title', $this );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Displays the extensions panel
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
wp_nonce_field( 'wpcf7_redirect_page_extensions', 'wpcf7_redirect_page_extensions_nonce' );
|
9 |
+
|
10 |
+
do_action( 'before_extensions_settings_tab_title', $this );
|
11 |
+
?>
|
12 |
+
|
13 |
+
<fieldset>
|
14 |
+
<div class="fields-wrap field-wrap-page-id">
|
15 |
+
<div class="tab-wrap">
|
16 |
+
<div class="wpcf7r-tab-wrap-inner">
|
17 |
+
<div data-tab-inner>
|
18 |
+
<?php include( 'extensions/extensions-table.php' ); ?>
|
19 |
+
</div>
|
20 |
+
</div>
|
21 |
+
</div>
|
22 |
+
</div>
|
23 |
+
</fieldset>
|
24 |
+
|
25 |
+
<?php
|
26 |
+
do_action( 'after_extensions_settings_tab_title', $this );
|
templates/extensions/extension-promo-box.php
CHANGED
@@ -1,81 +1,81 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render extension promo box
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
$ver = $this->get_extension_ver();
|
9 |
-
$badge = method_exists( $this, 'get_badge' ) ? $this->get_badge() : '';
|
10 |
-
?>
|
11 |
-
|
12 |
-
<div class="promo-box <?php echo $this->get_name(); ?> <?php echo $this->needs_activation() ? 'needs-activation' : ''; ?> <?php echo $this->has_update() ? 'has-update' : ''; ?> <?php echo $this->get_name(); ?> <?php echo $this->is_active() ? 'active-ext' : ''; ?>" data-extension="<?php echo $this->get_name(); ?>">
|
13 |
-
<div class="promo-box-inner">
|
14 |
-
<div class="promo-bot-title">
|
15 |
-
<div class="promo-version">
|
16 |
-
<?php if ( $ver && ! $badge ) : ?>
|
17 |
-
<small>v.<?php echo $this->get_extension_ver(); ?></small> <span class="dashicons dashicons-editor-code"></span>
|
18 |
-
<?php elseif ( $badge ) : ?>
|
19 |
-
<?php echo $badge; ?>
|
20 |
-
<?php endif; ?>
|
21 |
-
</div>
|
22 |
-
|
23 |
-
<?php if ( ! $this->is_active() ) : ?>
|
24 |
-
<div class="promo-purchase-link">
|
25 |
-
<?php if ( $this->get_aff_url() ) : ?>
|
26 |
-
<a href="<?php echo $this->get_aff_url(); ?>" class=""><?php _e( 'Activate', 'wpcf7-redirect' ); ?></a>
|
27 |
-
<?php else : ?>
|
28 |
-
<span type="button" class="btn-activate"><?php _e( 'Activate', 'wpcf7-redirect' ); ?></span>
|
29 |
-
<?php endif; ?>
|
30 |
-
</div>
|
31 |
-
<?php endif; ?>
|
32 |
-
|
33 |
-
</div>
|
34 |
-
<div class="promo-box-content">
|
35 |
-
<div class="promo-box-thumb">
|
36 |
-
<img src="<?php echo $this->get_icon(); ?>" alt="<?php $this->get_name(); ?>">
|
37 |
-
</div>
|
38 |
-
<div class="promo-box-description">
|
39 |
-
<h3><?php echo $this->get_title(); ?></h3>
|
40 |
-
|
41 |
-
<div class="description">
|
42 |
-
<?php echo $this->get_description(); ?>
|
43 |
-
</div>
|
44 |
-
|
45 |
-
<div class="promo-actions-box">
|
46 |
-
<div class="actions">
|
47 |
-
<?php if ( $this->get_aff_url() ) : ?>
|
48 |
-
<a href="<?php echo $this->get_aff_url(); ?>" class="button-primary"><?php echo $this->get_btn_text(); ?></a>
|
49 |
-
<?php else : ?>
|
50 |
-
<?php if ( ! $this->is_active() ) : ?>
|
51 |
-
<?php if ( $this->extension_file_exists() ) : ?>
|
52 |
-
<span type="button" class="btn-activate"><?php _e( 'Activate' ); ?></span>
|
53 |
-
<?php else : ?>
|
54 |
-
<a href="<?php echo $this->get_purchase_link(); ?>" class="btn-getit" target="_blank">
|
55 |
-
<span class="get-it-label"><?php _e( 'Get It', 'wpcf7-redirect' ); ?></span><span class="dashicons dashicons-arrow-down-alt"></span>
|
56 |
-
</a>
|
57 |
-
<?php endif; ?>
|
58 |
-
<?php else : ?>
|
59 |
-
<span type="button" class="button-primary btn-deactivate" ><?php _e( 'Deactivate' ); ?></span>
|
60 |
-
<?php endif; ?>
|
61 |
-
|
62 |
-
<?php if ( $this->is_active() && $this->has_update() ) : ?>
|
63 |
-
<span type="button" class="button-primary btn-update"><?php _e( 'Update' ); ?></span>
|
64 |
-
<?php endif; ?>
|
65 |
-
|
66 |
-
<div class="serial">
|
67 |
-
<input type="text" class="serial-number" value="<?php echo $this->get_serial(); ?>" placeholder="<?php _e( 'License Key', 'wpcf7-redirect' ); ?>">
|
68 |
-
<span class="button-primary btn-activate-serial" value="<?php _e( 'Save', 'wpcf7-redirect' ); ?>">
|
69 |
-
<span class="dashicons dashicons-yes"></span>
|
70 |
-
</span>
|
71 |
-
<span class="button-primary btn-close" title="<?php _e( 'Cancel', 'wpcf7-redirect' ); ?>">
|
72 |
-
<span class="dashicons dashicons-no"></span>
|
73 |
-
</span>
|
74 |
-
</div>
|
75 |
-
<?php endif; ?>
|
76 |
-
</div>
|
77 |
-
</div>
|
78 |
-
</div>
|
79 |
-
</div>
|
80 |
-
</div>
|
81 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render extension promo box
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
$ver = $this->get_extension_ver();
|
9 |
+
$badge = method_exists( $this, 'get_badge' ) ? $this->get_badge() : '';
|
10 |
+
?>
|
11 |
+
|
12 |
+
<div class="promo-box <?php echo $this->get_name(); ?> <?php echo $this->needs_activation() ? 'needs-activation' : ''; ?> <?php echo $this->has_update() ? 'has-update' : ''; ?> <?php echo $this->get_name(); ?> <?php echo $this->is_active() ? 'active-ext' : ''; ?>" data-extension="<?php echo $this->get_name(); ?>">
|
13 |
+
<div class="promo-box-inner">
|
14 |
+
<div class="promo-bot-title">
|
15 |
+
<div class="promo-version">
|
16 |
+
<?php if ( $ver && ! $badge ) : ?>
|
17 |
+
<small>v.<?php echo $this->get_extension_ver(); ?></small> <span class="dashicons dashicons-editor-code"></span>
|
18 |
+
<?php elseif ( $badge ) : ?>
|
19 |
+
<?php echo $badge; ?>
|
20 |
+
<?php endif; ?>
|
21 |
+
</div>
|
22 |
+
|
23 |
+
<?php if ( ! $this->is_active() ) : ?>
|
24 |
+
<div class="promo-purchase-link">
|
25 |
+
<?php if ( $this->get_aff_url() ) : ?>
|
26 |
+
<a href="<?php echo $this->get_aff_url(); ?>" class=""><?php _e( 'Activate', 'wpcf7-redirect' ); ?></a>
|
27 |
+
<?php else : ?>
|
28 |
+
<span type="button" class="btn-activate"><?php _e( 'Activate', 'wpcf7-redirect' ); ?></span>
|
29 |
+
<?php endif; ?>
|
30 |
+
</div>
|
31 |
+
<?php endif; ?>
|
32 |
+
|
33 |
+
</div>
|
34 |
+
<div class="promo-box-content">
|
35 |
+
<div class="promo-box-thumb">
|
36 |
+
<img src="<?php echo $this->get_icon(); ?>" alt="<?php $this->get_name(); ?>">
|
37 |
+
</div>
|
38 |
+
<div class="promo-box-description">
|
39 |
+
<h3><?php echo $this->get_title(); ?></h3>
|
40 |
+
|
41 |
+
<div class="description">
|
42 |
+
<?php echo $this->get_description(); ?>
|
43 |
+
</div>
|
44 |
+
|
45 |
+
<div class="promo-actions-box">
|
46 |
+
<div class="actions">
|
47 |
+
<?php if ( $this->get_aff_url() ) : ?>
|
48 |
+
<a href="<?php echo $this->get_aff_url(); ?>" class="button-primary"><?php echo $this->get_btn_text(); ?></a>
|
49 |
+
<?php else : ?>
|
50 |
+
<?php if ( ! $this->is_active() ) : ?>
|
51 |
+
<?php if ( $this->extension_file_exists() ) : ?>
|
52 |
+
<span type="button" class="btn-activate"><?php _e( 'Activate' ); ?></span>
|
53 |
+
<?php else : ?>
|
54 |
+
<a href="<?php echo $this->get_purchase_link(); ?>" class="btn-getit" target="_blank">
|
55 |
+
<span class="get-it-label"><?php _e( 'Get It', 'wpcf7-redirect' ); ?></span><span class="dashicons dashicons-arrow-down-alt"></span>
|
56 |
+
</a>
|
57 |
+
<?php endif; ?>
|
58 |
+
<?php else : ?>
|
59 |
+
<span type="button" class="button-primary btn-deactivate" ><?php _e( 'Deactivate' ); ?></span>
|
60 |
+
<?php endif; ?>
|
61 |
+
|
62 |
+
<?php if ( $this->is_active() && $this->has_update() ) : ?>
|
63 |
+
<span type="button" class="button-primary btn-update"><?php _e( 'Update' ); ?></span>
|
64 |
+
<?php endif; ?>
|
65 |
+
|
66 |
+
<div class="serial">
|
67 |
+
<input type="text" class="serial-number" value="<?php echo $this->get_serial(); ?>" placeholder="<?php _e( 'License Key', 'wpcf7-redirect' ); ?>">
|
68 |
+
<span class="button-primary btn-activate-serial" value="<?php _e( 'Save', 'wpcf7-redirect' ); ?>">
|
69 |
+
<span class="dashicons dashicons-yes"></span>
|
70 |
+
</span>
|
71 |
+
<span class="button-primary btn-close" title="<?php _e( 'Cancel', 'wpcf7-redirect' ); ?>">
|
72 |
+
<span class="dashicons dashicons-no"></span>
|
73 |
+
</span>
|
74 |
+
</div>
|
75 |
+
<?php endif; ?>
|
76 |
+
</div>
|
77 |
+
</div>
|
78 |
+
</div>
|
79 |
+
</div>
|
80 |
+
</div>
|
81 |
+
</div>
|
templates/extensions/extensions-table.php
CHANGED
@@ -1,21 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render extensions table
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
$extensions = $this->get_extensions();
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render extensions table
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
$extensions = $this->get_extensions();
|
9 |
+
|
10 |
+
wp_nonce_field( 'manage_cf7_redirect', '_wpcf7nonce' );
|
11 |
+
?>
|
12 |
+
|
13 |
+
<div class="extensions-list">
|
14 |
+
<div class="extensions">
|
15 |
+
<?php if ( $extensions ) : ?>
|
16 |
+
<?php foreach ( $extensions as $extension_slug => $extension ) : ?>
|
17 |
+
<div class="extension">
|
18 |
+
<?php echo $extension->get_action_promo(); ?>
|
19 |
+
</div>
|
20 |
+
<?php endforeach; ?>
|
21 |
+
<?php endif; ?>
|
22 |
+
</div>
|
23 |
+
</div>
|
templates/fields/field-button.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render button field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> wpcf7r-button <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>" data-toggle="<?php echo isset( $field['show_selector'] ) ? $field['show_selector'] : ''; ?>">
|
10 |
-
<?php if ( isset( $field['label'] ) && $field['label'] ) : ?>
|
11 |
-
<label class="wpcf7-redirect-<?php echo $field['name']; ?>"><?php echo $field['label']; ?></label>
|
12 |
-
<?php endif; ?>
|
13 |
-
<input type="button" class="button-primary wpcf7-redirect-<?php echo $field['name']; ?>-fields"
|
14 |
-
name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]"
|
15 |
-
<?php echo isset( $field['attr'] ) ? wpcf7r_implode_attributes( $field['attr'] ) : ''; ?>
|
16 |
-
value="<?php echo esc_html( $field['label'] ); ?>"
|
17 |
-
/>
|
18 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render button field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> wpcf7r-button <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>" data-toggle="<?php echo isset( $field['show_selector'] ) ? $field['show_selector'] : ''; ?>">
|
10 |
+
<?php if ( isset( $field['label'] ) && $field['label'] ) : ?>
|
11 |
+
<label class="wpcf7-redirect-<?php echo $field['name']; ?>"><?php echo $field['label']; ?></label>
|
12 |
+
<?php endif; ?>
|
13 |
+
<input type="button" class="button-primary wpcf7-redirect-<?php echo $field['name']; ?>-fields"
|
14 |
+
name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]"
|
15 |
+
<?php echo isset( $field['attr'] ) ? wpcf7r_implode_attributes( $field['attr'] ) : ''; ?>
|
16 |
+
value="<?php echo esc_html( $field['label'] ); ?>"
|
17 |
+
/>
|
18 |
+
</div>
|
templates/fields/field-checkbox.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render checkbox field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?> wpcf7r-checkbox" data-toggle="<?php echo isset( $field['show_selector'] ) ? $field['show_selector'] : ''; ?>">
|
10 |
-
<label>
|
11 |
-
<input type="checkbox" class="wpcf7-redirect-<?php echo $field['name']; ?>-fields"
|
12 |
-
name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]"
|
13 |
-
<?php checked( $field['value'], 'on', true ); ?>
|
14 |
-
data-toggle-label="<?php echo isset( $field['toggle-label'] ) ? esc_html( $field['toggle-label'] ) : ''; ?>"
|
15 |
-
/>
|
16 |
-
<span class="wpcf7r-on-off-button">
|
17 |
-
<span class="wpcf7r-toggle-button">
|
18 |
-
</span>
|
19 |
-
</span>
|
20 |
-
<strong class="checkbox-label"><?php echo esc_html( $field['label'] ); ?></strong>
|
21 |
-
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
22 |
-
</label>
|
23 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render checkbox field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?> wpcf7r-checkbox" data-toggle="<?php echo isset( $field['show_selector'] ) ? $field['show_selector'] : ''; ?>">
|
10 |
+
<label>
|
11 |
+
<input type="checkbox" class="wpcf7-redirect-<?php echo $field['name']; ?>-fields"
|
12 |
+
name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]"
|
13 |
+
<?php checked( $field['value'], 'on', true ); ?>
|
14 |
+
data-toggle-label="<?php echo isset( $field['toggle-label'] ) ? esc_html( $field['toggle-label'] ) : ''; ?>"
|
15 |
+
/>
|
16 |
+
<span class="wpcf7r-on-off-button">
|
17 |
+
<span class="wpcf7r-toggle-button">
|
18 |
+
</span>
|
19 |
+
</span>
|
20 |
+
<strong class="checkbox-label"><?php echo esc_html( $field['label'] ); ?></strong>
|
21 |
+
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
22 |
+
</label>
|
23 |
+
</div>
|
templates/fields/field-debug-log.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render debug log by requested fields
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
-
<div class="debug-log-wrap">
|
11 |
-
<?php foreach ( $field['fields'] as $debug_field_name => $debug_field_value ) : ?>
|
12 |
-
<div class="debug_log">
|
13 |
-
<h4><?php echo $debug_field_name; ?>:</h4>
|
14 |
-
<textarea rows="10">
|
15 |
-
<?php
|
16 |
-
$debug_field_value = maybe_unserialize( $debug_field_value );
|
17 |
-
|
18 |
-
if ( is_array( $debug_field_value ) || is_object( $debug_field_value ) ) {
|
19 |
-
print_r( $debug_field_value );
|
20 |
-
} else {
|
21 |
-
echo trim( esc_attr( $debug_field_value ) );
|
22 |
-
}
|
23 |
-
?>
|
24 |
-
</textarea>
|
25 |
-
</div>
|
26 |
-
<?php endforeach; ?>
|
27 |
-
</div>
|
28 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render debug log by requested fields
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
+
<div class="debug-log-wrap">
|
11 |
+
<?php foreach ( $field['fields'] as $debug_field_name => $debug_field_value ) : ?>
|
12 |
+
<div class="debug_log">
|
13 |
+
<h4><?php echo $debug_field_name; ?>:</h4>
|
14 |
+
<textarea rows="10">
|
15 |
+
<?php
|
16 |
+
$debug_field_value = maybe_unserialize( $debug_field_value );
|
17 |
+
|
18 |
+
if ( is_array( $debug_field_value ) || is_object( $debug_field_value ) ) {
|
19 |
+
print_r( $debug_field_value );
|
20 |
+
} else {
|
21 |
+
echo trim( esc_attr( $debug_field_value ) );
|
22 |
+
}
|
23 |
+
?>
|
24 |
+
</textarea>
|
25 |
+
</div>
|
26 |
+
<?php endforeach; ?>
|
27 |
+
</div>
|
28 |
+
</div>
|
templates/fields/field-download.php
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Display download field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
9 |
-
<?php if ( isset( $field['label'] ) && $field['label'] ) : ?>
|
10 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
11 |
-
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
12 |
-
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
13 |
-
</label>
|
14 |
-
<?php endif; ?>
|
15 |
-
|
16 |
-
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
17 |
-
|
18 |
-
<div class="wpcf7-subtitle">
|
19 |
-
<?php echo $field['sub_title']; ?>
|
20 |
-
</div>
|
21 |
-
|
22 |
-
<?php endif; ?>
|
23 |
-
|
24 |
-
<a href="data:application/octet-stream;base64,<?php echo esc_html( $field['value'] ); ?>" download="<?php echo $field['filename']; ?>"><?php echo $field['filename']; ?></a>
|
25 |
-
|
26 |
-
<div class="field-footer">
|
27 |
-
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
28 |
-
</div>
|
29 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Display download field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
9 |
+
<?php if ( isset( $field['label'] ) && $field['label'] ) : ?>
|
10 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
11 |
+
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
12 |
+
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
13 |
+
</label>
|
14 |
+
<?php endif; ?>
|
15 |
+
|
16 |
+
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
17 |
+
|
18 |
+
<div class="wpcf7-subtitle">
|
19 |
+
<?php echo $field['sub_title']; ?>
|
20 |
+
</div>
|
21 |
+
|
22 |
+
<?php endif; ?>
|
23 |
+
|
24 |
+
<a href="data:application/octet-stream;base64,<?php echo esc_html( $field['value'] ); ?>" download="<?php echo $field['filename']; ?>"><?php echo $field['filename']; ?></a>
|
25 |
+
|
26 |
+
<div class="field-footer">
|
27 |
+
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
28 |
+
</div>
|
29 |
+
</div>
|
templates/fields/field-editor.php
CHANGED
@@ -1,37 +1,37 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render editor field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
$field_name = "wpcf7-redirect{$prefix}[{$field['name']}]";
|
9 |
-
$css_class = "wpcf7-redirect-{$field['name']}-fields";
|
10 |
-
?>
|
11 |
-
|
12 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
13 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
14 |
-
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
15 |
-
</label>
|
16 |
-
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
17 |
-
<div class="wpcf7-subtitle">
|
18 |
-
<?php echo $field['sub_title']; ?>
|
19 |
-
</div>
|
20 |
-
<?php endif; ?>
|
21 |
-
|
22 |
-
<?php
|
23 |
-
wp_editor(
|
24 |
-
$field['value'],
|
25 |
-
'editor-' . md5( $field_name ),
|
26 |
-
$settings = array(
|
27 |
-
'textarea_name' => $field_name,
|
28 |
-
'editor_class' => $css_class,
|
29 |
-
)
|
30 |
-
);
|
31 |
-
?>
|
32 |
-
|
33 |
-
<div class="field-footer">
|
34 |
-
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
35 |
-
</div>
|
36 |
-
|
37 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render editor field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
$field_name = "wpcf7-redirect{$prefix}[{$field['name']}]";
|
9 |
+
$css_class = "wpcf7-redirect-{$field['name']}-fields";
|
10 |
+
?>
|
11 |
+
|
12 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
13 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
14 |
+
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
15 |
+
</label>
|
16 |
+
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
17 |
+
<div class="wpcf7-subtitle">
|
18 |
+
<?php echo $field['sub_title']; ?>
|
19 |
+
</div>
|
20 |
+
<?php endif; ?>
|
21 |
+
|
22 |
+
<?php
|
23 |
+
wp_editor(
|
24 |
+
$field['value'],
|
25 |
+
'editor-' . md5( $field_name ),
|
26 |
+
$settings = array(
|
27 |
+
'textarea_name' => $field_name,
|
28 |
+
'editor_class' => $css_class,
|
29 |
+
)
|
30 |
+
);
|
31 |
+
?>
|
32 |
+
|
33 |
+
<div class="field-footer">
|
34 |
+
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
35 |
+
</div>
|
36 |
+
|
37 |
+
</div>
|
templates/fields/field-json-editor.php
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render json editor field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
11 |
-
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
12 |
-
</label>
|
13 |
-
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
14 |
-
<div class="wpcf7-subtitle">
|
15 |
-
<?php echo $field['sub_title']; ?>
|
16 |
-
</div>
|
17 |
-
<?php endif; ?>
|
18 |
-
<textarea rows="10" class="json-container wpcf7-redirect-<?php echo $field['name']; ?>-fields" placeholder="<?php echo $field['placeholder']; ?>" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]"><?php echo esc_html( $field['value'] ); ?></textarea>
|
19 |
-
<div class="field-footer">
|
20 |
-
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
21 |
-
</div>
|
22 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render json editor field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
11 |
+
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
12 |
+
</label>
|
13 |
+
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
14 |
+
<div class="wpcf7-subtitle">
|
15 |
+
<?php echo $field['sub_title']; ?>
|
16 |
+
</div>
|
17 |
+
<?php endif; ?>
|
18 |
+
<textarea rows="10" class="json-container wpcf7-redirect-<?php echo $field['name']; ?>-fields" placeholder="<?php echo $field['placeholder']; ?>" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]"><?php echo esc_html( $field['value'] ); ?></textarea>
|
19 |
+
<div class="field-footer">
|
20 |
+
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
21 |
+
</div>
|
22 |
+
</div>
|
templates/fields/field-leads-mapping.php
CHANGED
@@ -1,73 +1,73 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render mapping leads field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
-
<?php if ( isset( $field['title'] ) && $field['title'] ) : ?>
|
11 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
12 |
-
<h3><?php echo esc_html( $field['label'] ); ?></h3>
|
13 |
-
|
14 |
-
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
15 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>"><?php echo esc_html( $field['sub_title'] ); ?></label>
|
16 |
-
<br/>
|
17 |
-
<?php endif; ?>
|
18 |
-
</label>
|
19 |
-
<?php endif; ?>
|
20 |
-
|
21 |
-
<div class="cf7_row">
|
22 |
-
<table class="wp-list-table widefat fixed striped pages wp-list-table-inner">
|
23 |
-
<tr>
|
24 |
-
<td>
|
25 |
-
<strong>
|
26 |
-
<?php _e( 'Form fields', 'wpcf7-redirect' ); ?>
|
27 |
-
</strong>
|
28 |
-
</td>
|
29 |
-
<td class="tags-map-api-key">
|
30 |
-
<strong>
|
31 |
-
<?php _e( 'Field Label', 'wpcf7-redirect' ); ?>
|
32 |
-
</strong>
|
33 |
-
<?php echo cf7r_tooltip( __( 'The field label', 'wpcf7-redirect' ) ); ?>
|
34 |
-
</td>
|
35 |
-
<td>
|
36 |
-
<strong>
|
37 |
-
<?php _e( 'Display on leads list', 'wpcf7-redirect' ); ?>
|
38 |
-
</strong>
|
39 |
-
<?php echo cf7r_tooltip( __( 'Should this field appear on the leads list', 'wpcf7-redirect' ) ); ?>
|
40 |
-
</td>
|
41 |
-
</tr>
|
42 |
-
<?php
|
43 |
-
if ( isset( $field['tags'] ) ) :
|
44 |
-
foreach ( $field['tags'] as $mail_tag ) :
|
45 |
-
if ( 'lead_id' === $mail_tag->name ) {
|
46 |
-
continue;
|
47 |
-
}
|
48 |
-
$save = isset( $field['value'][ $mail_tag->name ]['save'] ) ? esc_html( $field['value'][ $mail_tag->name ]['save'] ) : '';
|
49 |
-
$tag_value = isset( $field['value'][ $mail_tag->name ]['tag'] ) ? esc_html( $field['value'][ $mail_tag->name ]['tag'] ) : '';
|
50 |
-
$appear = isset( $field['value'][ $mail_tag->name ]['appear'] ) && $field['value'][ $mail_tag->name ]['appear'] ? true : false;
|
51 |
-
?>
|
52 |
-
<tr>
|
53 |
-
<td class="<?php echo $mail_tag->name; ?>"><?php echo $mail_tag->name; ?></td>
|
54 |
-
<td class="tags-map-api-key">
|
55 |
-
<input type="text" id="sf-<?php echo $mail_tag->name; ?>"
|
56 |
-
name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>][<?php echo $mail_tag->name; ?>][tag]"
|
57 |
-
class="large-text"
|
58 |
-
value="<?php echo $tag_value; ?>" />
|
59 |
-
</td>
|
60 |
-
<td>
|
61 |
-
<input type="checkbox"
|
62 |
-
name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>][<?php echo $mail_tag->name; ?>][appear]"
|
63 |
-
value="1"
|
64 |
-
<?php checked( $appear, 1 ); ?> />
|
65 |
-
</td>
|
66 |
-
</tr>
|
67 |
-
<?php
|
68 |
-
endforeach;
|
69 |
-
endif;
|
70 |
-
?>
|
71 |
-
</table>
|
72 |
-
</div>
|
73 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render mapping leads field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
+
<?php if ( isset( $field['title'] ) && $field['title'] ) : ?>
|
11 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
12 |
+
<h3><?php echo esc_html( $field['label'] ); ?></h3>
|
13 |
+
|
14 |
+
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
15 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>"><?php echo esc_html( $field['sub_title'] ); ?></label>
|
16 |
+
<br/>
|
17 |
+
<?php endif; ?>
|
18 |
+
</label>
|
19 |
+
<?php endif; ?>
|
20 |
+
|
21 |
+
<div class="cf7_row">
|
22 |
+
<table class="wp-list-table widefat fixed striped pages wp-list-table-inner">
|
23 |
+
<tr>
|
24 |
+
<td>
|
25 |
+
<strong>
|
26 |
+
<?php _e( 'Form fields', 'wpcf7-redirect' ); ?>
|
27 |
+
</strong>
|
28 |
+
</td>
|
29 |
+
<td class="tags-map-api-key">
|
30 |
+
<strong>
|
31 |
+
<?php _e( 'Field Label', 'wpcf7-redirect' ); ?>
|
32 |
+
</strong>
|
33 |
+
<?php echo cf7r_tooltip( __( 'The field label', 'wpcf7-redirect' ) ); ?>
|
34 |
+
</td>
|
35 |
+
<td>
|
36 |
+
<strong>
|
37 |
+
<?php _e( 'Display on leads list', 'wpcf7-redirect' ); ?>
|
38 |
+
</strong>
|
39 |
+
<?php echo cf7r_tooltip( __( 'Should this field appear on the leads list', 'wpcf7-redirect' ) ); ?>
|
40 |
+
</td>
|
41 |
+
</tr>
|
42 |
+
<?php
|
43 |
+
if ( isset( $field['tags'] ) ) :
|
44 |
+
foreach ( $field['tags'] as $mail_tag ) :
|
45 |
+
if ( 'lead_id' === $mail_tag->name ) {
|
46 |
+
continue;
|
47 |
+
}
|
48 |
+
$save = isset( $field['value'][ $mail_tag->name ]['save'] ) ? esc_html( $field['value'][ $mail_tag->name ]['save'] ) : '';
|
49 |
+
$tag_value = isset( $field['value'][ $mail_tag->name ]['tag'] ) ? esc_html( $field['value'][ $mail_tag->name ]['tag'] ) : '';
|
50 |
+
$appear = isset( $field['value'][ $mail_tag->name ]['appear'] ) && $field['value'][ $mail_tag->name ]['appear'] ? true : false;
|
51 |
+
?>
|
52 |
+
<tr>
|
53 |
+
<td class="<?php echo $mail_tag->name; ?>"><?php echo $mail_tag->name; ?></td>
|
54 |
+
<td class="tags-map-api-key">
|
55 |
+
<input type="text" id="sf-<?php echo $mail_tag->name; ?>"
|
56 |
+
name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>][<?php echo $mail_tag->name; ?>][tag]"
|
57 |
+
class="large-text"
|
58 |
+
value="<?php echo $tag_value; ?>" />
|
59 |
+
</td>
|
60 |
+
<td>
|
61 |
+
<input type="checkbox"
|
62 |
+
name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>][<?php echo $mail_tag->name; ?>][appear]"
|
63 |
+
value="1"
|
64 |
+
<?php checked( $appear, 1 ); ?> />
|
65 |
+
</td>
|
66 |
+
</tr>
|
67 |
+
<?php
|
68 |
+
endforeach;
|
69 |
+
endif;
|
70 |
+
?>
|
71 |
+
</table>
|
72 |
+
</div>
|
73 |
+
</div>
|
templates/fields/field-media.php
CHANGED
@@ -1,31 +1,31 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render image field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
?>
|
9 |
-
|
10 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
11 |
-
<?php if ( isset( $field['label'] ) && $field['label'] ) : ?>
|
12 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
13 |
-
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
14 |
-
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
15 |
-
</label>
|
16 |
-
<?php endif; ?>
|
17 |
-
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
18 |
-
<div class="wpcf7-subtitle">
|
19 |
-
<?php echo $field['sub_title']; ?>
|
20 |
-
</div>
|
21 |
-
<?php endif; ?>
|
22 |
-
<div class="image-container">
|
23 |
-
<img src="<?php echo esc_html( $field['value'] ); ?>" alt="" style="max-width:100px;" class="popup-image" />
|
24 |
-
<a title="Set Image" href="javascript:;" class="image-uploader-btn browser button button-hero"><?php _e( 'Select Image', 'wpcf7-redirect' ); ?></a>
|
25 |
-
<a title="Remove image" href="javascript:;" class="image-remove-btn browser button"><span class="dashicons dashicons-no-alt"></span></a>
|
26 |
-
<input type="hidden" class="wpcf7-redirect-<?php echo $field['name']; ?>-fields" placeholder="<?php echo esc_html( $field['placeholder'] ); ?>" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]" value="<?php echo esc_html( $field['value'] ); ?>" <?php echo isset( $field['input_attr'] ) ? $field['input_attr'] : ''; ?>>
|
27 |
-
</div>
|
28 |
-
<div class="field-footer">
|
29 |
-
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
30 |
-
</div>
|
31 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render image field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
?>
|
9 |
+
|
10 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
11 |
+
<?php if ( isset( $field['label'] ) && $field['label'] ) : ?>
|
12 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
13 |
+
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
14 |
+
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
15 |
+
</label>
|
16 |
+
<?php endif; ?>
|
17 |
+
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
18 |
+
<div class="wpcf7-subtitle">
|
19 |
+
<?php echo $field['sub_title']; ?>
|
20 |
+
</div>
|
21 |
+
<?php endif; ?>
|
22 |
+
<div class="image-container">
|
23 |
+
<img src="<?php echo esc_html( $field['value'] ); ?>" alt="" style="max-width:100px;" class="popup-image" />
|
24 |
+
<a title="Set Image" href="javascript:;" class="image-uploader-btn browser button button-hero"><?php _e( 'Select Image', 'wpcf7-redirect' ); ?></a>
|
25 |
+
<a title="Remove image" href="javascript:;" class="image-remove-btn browser button"><span class="dashicons dashicons-no-alt"></span></a>
|
26 |
+
<input type="hidden" class="wpcf7-redirect-<?php echo $field['name']; ?>-fields" placeholder="<?php echo esc_html( $field['placeholder'] ); ?>" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]" value="<?php echo esc_html( $field['value'] ); ?>" <?php echo isset( $field['input_attr'] ) ? $field['input_attr'] : ''; ?>>
|
27 |
+
</div>
|
28 |
+
<div class="field-footer">
|
29 |
+
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
30 |
+
</div>
|
31 |
+
</div>
|
templates/fields/field-notice.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render notice block
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="field-wrap">
|
10 |
-
<div class="field-notice field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
11 |
-
<strong>
|
12 |
-
<?php echo $field['label']; ?>
|
13 |
-
</strong>
|
14 |
-
<?php echo $field['sub_title']; ?>
|
15 |
-
</div>
|
16 |
-
|
17 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render notice block
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="field-wrap">
|
10 |
+
<div class="field-notice field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
11 |
+
<strong>
|
12 |
+
<?php echo $field['label']; ?>
|
13 |
+
</strong>
|
14 |
+
<?php echo $field['sub_title']; ?>
|
15 |
+
</div>
|
16 |
+
|
17 |
+
</div>
|
templates/fields/field-number.php
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render number field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
-
<?php if ( isset( $field['label'] ) && $field['label'] ) : ?>
|
11 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
12 |
-
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
13 |
-
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
14 |
-
</label>
|
15 |
-
<?php endif; ?>
|
16 |
-
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
17 |
-
<div class="wpcf7-subtitle">
|
18 |
-
<?php echo $field['sub_title']; ?>
|
19 |
-
</div>
|
20 |
-
<?php endif; ?>
|
21 |
-
<input type="number" class="wpcf7-redirect-<?php echo $field['name']; ?>-fields" placeholder="<?php echo esc_html( $field['placeholder'] ); ?>" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]" value="<?php echo esc_html( $field['value'] ); ?>" <?php echo isset( $field['input_attr'] ) ? $field['input_attr'] : ''; ?>>
|
22 |
-
<div class="field-footer">
|
23 |
-
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
24 |
-
</div>
|
25 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render number field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
+
<?php if ( isset( $field['label'] ) && $field['label'] ) : ?>
|
11 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
12 |
+
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
13 |
+
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
14 |
+
</label>
|
15 |
+
<?php endif; ?>
|
16 |
+
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
17 |
+
<div class="wpcf7-subtitle">
|
18 |
+
<?php echo $field['sub_title']; ?>
|
19 |
+
</div>
|
20 |
+
<?php endif; ?>
|
21 |
+
<input type="number" class="wpcf7-redirect-<?php echo $field['name']; ?>-fields" placeholder="<?php echo esc_html( $field['placeholder'] ); ?>" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]" value="<?php echo esc_html( $field['value'] ); ?>" <?php echo isset( $field['input_attr'] ) ? $field['input_attr'] : ''; ?>>
|
22 |
+
<div class="field-footer">
|
23 |
+
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
24 |
+
</div>
|
25 |
+
</div>
|
templates/fields/field-page-select.php
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render page select field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
$field_id = $field['name'] . '-' . rand( 0, 1000 );
|
9 |
-
?>
|
10 |
-
|
11 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
12 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
13 |
-
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
14 |
-
</label>
|
15 |
-
<?php
|
16 |
-
echo wp_dropdown_pages(
|
17 |
-
array(
|
18 |
-
'echo' => 0,
|
19 |
-
'name' => 'wpcf7-redirect' . $prefix . '[' . $field['name'] . ']',
|
20 |
-
'show_option_none' => $field['placeholder'],
|
21 |
-
'option_none_value' => '',
|
22 |
-
'selected' => $field['value'] ? $field['value'] : '',
|
23 |
-
'id' => $field_id,
|
24 |
-
'class' => 'wpcf7-redirect-' . $field['name'] . '-fields',
|
25 |
-
)
|
26 |
-
);
|
27 |
-
?>
|
28 |
-
<script>
|
29 |
-
var element = document.getElementById('<?php echo $field_id; ?>');
|
30 |
-
|
31 |
-
if ( ! element.value ) {
|
32 |
-
element.options[0].setAttribute('selected','selected');
|
33 |
-
}
|
34 |
-
</script>
|
35 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render page select field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
$field_id = $field['name'] . '-' . rand( 0, 1000 );
|
9 |
+
?>
|
10 |
+
|
11 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
12 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
13 |
+
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
14 |
+
</label>
|
15 |
+
<?php
|
16 |
+
echo wp_dropdown_pages(
|
17 |
+
array(
|
18 |
+
'echo' => 0,
|
19 |
+
'name' => 'wpcf7-redirect' . $prefix . '[' . $field['name'] . ']',
|
20 |
+
'show_option_none' => $field['placeholder'],
|
21 |
+
'option_none_value' => '',
|
22 |
+
'selected' => $field['value'] ? $field['value'] : '',
|
23 |
+
'id' => $field_id,
|
24 |
+
'class' => 'wpcf7-redirect-' . $field['name'] . '-fields',
|
25 |
+
)
|
26 |
+
);
|
27 |
+
?>
|
28 |
+
<script>
|
29 |
+
var element = document.getElementById('<?php echo $field_id; ?>');
|
30 |
+
|
31 |
+
if ( ! element.value ) {
|
32 |
+
element.options[0].setAttribute('selected','selected');
|
33 |
+
}
|
34 |
+
</script>
|
35 |
+
</div>
|
templates/fields/field-password.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render a password field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
-
<?php if ( isset( $field['label'] ) && $field['label'] ) : ?>
|
11 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
12 |
-
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
13 |
-
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
14 |
-
</label>
|
15 |
-
<?php endif; ?>
|
16 |
-
|
17 |
-
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
18 |
-
<div class="wpcf7-subtitle">
|
19 |
-
<?php echo $field['sub_title']; ?>
|
20 |
-
</div>
|
21 |
-
<?php endif; ?>
|
22 |
-
|
23 |
-
<input type="password" class="wpcf7-redirect-<?php echo $field['name']; ?>-fields <?php echo isset( $field['input_class'] ) ? $field['input_class'] : ''; ?>" placeholder="<?php echo esc_html( $field['placeholder'] ); ?>" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]" value="<?php echo esc_html( $field['value'] ); ?>" <?php echo isset( $field['input_attr'] ) ? $field['input_attr'] : ''; ?>>
|
24 |
-
|
25 |
-
<div class="field-footer">
|
26 |
-
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
27 |
-
</div>
|
28 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render a password field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
+
<?php if ( isset( $field['label'] ) && $field['label'] ) : ?>
|
11 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
12 |
+
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
13 |
+
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
14 |
+
</label>
|
15 |
+
<?php endif; ?>
|
16 |
+
|
17 |
+
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
18 |
+
<div class="wpcf7-subtitle">
|
19 |
+
<?php echo $field['sub_title']; ?>
|
20 |
+
</div>
|
21 |
+
<?php endif; ?>
|
22 |
+
|
23 |
+
<input type="password" class="wpcf7-redirect-<?php echo $field['name']; ?>-fields <?php echo isset( $field['input_class'] ) ? $field['input_class'] : ''; ?>" placeholder="<?php echo esc_html( $field['placeholder'] ); ?>" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]" value="<?php echo esc_html( $field['value'] ); ?>" <?php echo isset( $field['input_attr'] ) ? $field['input_attr'] : ''; ?>>
|
24 |
+
|
25 |
+
<div class="field-footer">
|
26 |
+
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
27 |
+
</div>
|
28 |
+
</div>
|
templates/fields/field-post-author-select.php
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render post author select field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-select.php';
|
9 |
-
|
10 |
-
$args = array(
|
11 |
-
'role__in' => array( 'administrator', 'editor', 'author' ),
|
12 |
-
);
|
13 |
-
|
14 |
-
$author_args = apply_filters( 'wpcf7r_get_authors_args', $args );
|
15 |
-
|
16 |
-
$authors = get_users( $author_args );
|
17 |
-
|
18 |
-
$field['options']['current_user'] = __( 'Current Logged In User', 'wpcf7-redirect' );
|
19 |
-
|
20 |
-
foreach ( $authors as $author ) {
|
21 |
-
$field['options'][ $author->ID ] = $author->data->user_nicename;
|
22 |
-
}
|
23 |
-
|
24 |
-
|
25 |
-
include $template;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render post author select field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
$template = WPCF7_PRO_REDIRECT_FIELDS_PATH . 'field-select.php';
|
9 |
+
|
10 |
+
$args = array(
|
11 |
+
'role__in' => array( 'administrator', 'editor', 'author' ),
|
12 |
+
);
|
13 |
+
|
14 |
+
$author_args = apply_filters( 'wpcf7r_get_authors_args', $args );
|
15 |
+
|
16 |
+
$authors = get_users( $author_args );
|
17 |
+
|
18 |
+
$field['options']['current_user'] = __( 'Current Logged In User', 'wpcf7-redirect' );
|
19 |
+
|
20 |
+
foreach ( $authors as $author ) {
|
21 |
+
$field['options'][ $author->ID ] = $author->data->user_nicename;
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
include $template;
|
templates/fields/field-post-type-select.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render post type select field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
$post_types = get_post_types();
|
9 |
-
?>
|
10 |
-
|
11 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
12 |
-
<?php if ( $field['label'] ) : ?>
|
13 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
14 |
-
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
15 |
-
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
16 |
-
</label>
|
17 |
-
<?php endif; ?>
|
18 |
-
|
19 |
-
<select class="" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]">
|
20 |
-
<?php foreach ( $post_types as $option_key => $option_label ) : ?>
|
21 |
-
<option value="<?php echo $option_key; ?>" <?php selected( $field['value'], $option_key ); ?>><?php echo $option_label; ?></option>
|
22 |
-
<?php endforeach; ?>
|
23 |
-
</select>
|
24 |
-
|
25 |
-
<div class="field-footer">
|
26 |
-
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
27 |
-
</div>
|
28 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render post type select field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
$post_types = get_post_types();
|
9 |
+
?>
|
10 |
+
|
11 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
12 |
+
<?php if ( $field['label'] ) : ?>
|
13 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
14 |
+
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
15 |
+
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
16 |
+
</label>
|
17 |
+
<?php endif; ?>
|
18 |
+
|
19 |
+
<select class="" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]">
|
20 |
+
<?php foreach ( $post_types as $option_key => $option_label ) : ?>
|
21 |
+
<option value="<?php echo $option_key; ?>" <?php selected( $field['value'], $option_key ); ?>><?php echo $option_label; ?></option>
|
22 |
+
<?php endforeach; ?>
|
23 |
+
</select>
|
24 |
+
|
25 |
+
<div class="field-footer">
|
26 |
+
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
27 |
+
</div>
|
28 |
+
</div>
|
templates/fields/field-preview.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render preview iFrame
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
-
<iframe data-name="preview" class="preview-iframe" src="<?php echo add_query_arg( $field['value'], admin_url() ); ?>" scrolling="no" style=" width: 100%; height: 500px; overflow: hidden;" ></iframe>
|
11 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render preview iFrame
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
+
<iframe data-name="preview" class="preview-iframe" src="<?php echo add_query_arg( $field['value'], admin_url() ); ?>" scrolling="no" style=" width: 100%; height: 500px; overflow: hidden;" ></iframe>
|
11 |
+
</div>
|
templates/fields/field-repeater.php
CHANGED
@@ -1,90 +1,90 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render a repater field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
$values = isset( $field['value'] ) && ! empty( $field['value'] ) > 0 ? $field['value'] : array( 'default' );
|
9 |
-
$base_prefix = $prefix;
|
10 |
-
$repeater_row_template = array();
|
11 |
-
?>
|
12 |
-
|
13 |
-
<?php ob_start(); ?>
|
14 |
-
|
15 |
-
<tr class="qs-repeater-row <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>" data-repeater-row-count="new_row">
|
16 |
-
<?php $prefix = $base_prefix . '[' . $field['name'] . ']' . '[new_row]'; ?>
|
17 |
-
<?php foreach ( $field['fields'] as $child_field ) : ?>
|
18 |
-
<td>
|
19 |
-
<?php
|
20 |
-
$child_field['value'] = isset( $value[ $child_field['name'] ] ) ? $value[ $child_field['name'] ] : '';
|
21 |
-
$child_field['label'] = '';
|
22 |
-
WPCF7R_Html::render_field( $child_field, $prefix );
|
23 |
-
?>
|
24 |
-
</td>
|
25 |
-
<?php endforeach; ?>
|
26 |
-
<td>
|
27 |
-
<div class="qs-repeater-action">
|
28 |
-
<span class="dashicons dashicons-plus"></span>
|
29 |
-
<span class="dashicons dashicons-minus"></span>
|
30 |
-
</div>
|
31 |
-
</td>
|
32 |
-
</tr>
|
33 |
-
|
34 |
-
<?php $repeater_single_row_template['template'] = ob_get_clean(); ?>
|
35 |
-
|
36 |
-
<div class="qs-row">
|
37 |
-
<div class="qs-col qs-col-12">
|
38 |
-
<?php if ( isset( $field['sub_title'] ) ) : ?>
|
39 |
-
<h2><?php echo esc_html( $field['sub_title'] ); ?></h2>
|
40 |
-
<?php endif; ?>
|
41 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
42 |
-
<h3><?php echo esc_html( $field['label'] ); ?> <?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?></h3>
|
43 |
-
</label>
|
44 |
-
<div>
|
45 |
-
<div class="actions">
|
46 |
-
<table class="wp-list-table widefat fixed striped pages repeater-table leads-list">
|
47 |
-
<thead>
|
48 |
-
<tr>
|
49 |
-
<?php foreach ( $values as $value_row => $value ) : ?>
|
50 |
-
<?php foreach ( $field['fields'] as $child_field ) : ?>
|
51 |
-
<th class="manage-column column-primary sortable desc">
|
52 |
-
<a href="#"><?php echo $child_field['label']; ?></a>
|
53 |
-
</th>
|
54 |
-
<?php endforeach; ?>
|
55 |
-
<th><?php _e( 'Actions', 'wpcf7-redirect' ); ?></th>
|
56 |
-
<?php break; ?>
|
57 |
-
<?php endforeach; ?>
|
58 |
-
</tr>
|
59 |
-
</thead>
|
60 |
-
|
61 |
-
<tbody id="the_list" data-repeater-template="<?php echo htmlspecialchars( wp_json_encode( $repeater_single_row_template ) ); ?>">
|
62 |
-
<?php foreach ( $values as $value_row => $value ) : ?>
|
63 |
-
<tr class="qs-repeater-row" data-repeater-row-count="<?php echo $value_row; ?>">
|
64 |
-
<?php $prefix = $base_prefix . '[' . $field['name'] . ']' . '[' . $value_row . ']'; ?>
|
65 |
-
<?php foreach ( $field['fields'] as $child_field ) : ?>
|
66 |
-
<td>
|
67 |
-
<?php
|
68 |
-
$child_field['value'] = isset( $value[ $child_field['name'] ] ) ? $value[ $child_field['name'] ] : '';
|
69 |
-
$child_field['label'] = '';
|
70 |
-
WPCF7R_Html::render_field( $child_field, $prefix );
|
71 |
-
?>
|
72 |
-
</td>
|
73 |
-
<?php endforeach; ?>
|
74 |
-
<td>
|
75 |
-
<div class="qs-repeater-action">
|
76 |
-
<span class="dashicons dashicons-plus"></span>
|
77 |
-
<span class="dashicons dashicons-minus"></span>
|
78 |
-
</div>
|
79 |
-
</td>
|
80 |
-
</tr>
|
81 |
-
<?php endforeach; ?>
|
82 |
-
</tbody>
|
83 |
-
</table>
|
84 |
-
</div>
|
85 |
-
</div>
|
86 |
-
<div class="field-footer">
|
87 |
-
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
88 |
-
</div>
|
89 |
-
</div>
|
90 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render a repater field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
$values = isset( $field['value'] ) && ! empty( $field['value'] ) > 0 ? $field['value'] : array( 'default' );
|
9 |
+
$base_prefix = $prefix;
|
10 |
+
$repeater_row_template = array();
|
11 |
+
?>
|
12 |
+
|
13 |
+
<?php ob_start(); ?>
|
14 |
+
|
15 |
+
<tr class="qs-repeater-row <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>" data-repeater-row-count="new_row">
|
16 |
+
<?php $prefix = $base_prefix . '[' . $field['name'] . ']' . '[new_row]'; ?>
|
17 |
+
<?php foreach ( $field['fields'] as $child_field ) : ?>
|
18 |
+
<td>
|
19 |
+
<?php
|
20 |
+
$child_field['value'] = isset( $value[ $child_field['name'] ] ) ? $value[ $child_field['name'] ] : '';
|
21 |
+
$child_field['label'] = '';
|
22 |
+
WPCF7R_Html::render_field( $child_field, $prefix );
|
23 |
+
?>
|
24 |
+
</td>
|
25 |
+
<?php endforeach; ?>
|
26 |
+
<td>
|
27 |
+
<div class="qs-repeater-action">
|
28 |
+
<span class="dashicons dashicons-plus"></span>
|
29 |
+
<span class="dashicons dashicons-minus"></span>
|
30 |
+
</div>
|
31 |
+
</td>
|
32 |
+
</tr>
|
33 |
+
|
34 |
+
<?php $repeater_single_row_template['template'] = ob_get_clean(); ?>
|
35 |
+
|
36 |
+
<div class="qs-row">
|
37 |
+
<div class="qs-col qs-col-12">
|
38 |
+
<?php if ( isset( $field['sub_title'] ) ) : ?>
|
39 |
+
<h2><?php echo esc_html( $field['sub_title'] ); ?></h2>
|
40 |
+
<?php endif; ?>
|
41 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
42 |
+
<h3><?php echo esc_html( $field['label'] ); ?> <?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?></h3>
|
43 |
+
</label>
|
44 |
+
<div>
|
45 |
+
<div class="actions">
|
46 |
+
<table class="wp-list-table widefat fixed striped pages repeater-table leads-list">
|
47 |
+
<thead>
|
48 |
+
<tr>
|
49 |
+
<?php foreach ( $values as $value_row => $value ) : ?>
|
50 |
+
<?php foreach ( $field['fields'] as $child_field ) : ?>
|
51 |
+
<th class="manage-column column-primary sortable desc">
|
52 |
+
<a href="#"><?php echo $child_field['label']; ?></a>
|
53 |
+
</th>
|
54 |
+
<?php endforeach; ?>
|
55 |
+
<th><?php _e( 'Actions', 'wpcf7-redirect' ); ?></th>
|
56 |
+
<?php break; ?>
|
57 |
+
<?php endforeach; ?>
|
58 |
+
</tr>
|
59 |
+
</thead>
|
60 |
+
|
61 |
+
<tbody id="the_list" data-repeater-template="<?php echo htmlspecialchars( wp_json_encode( $repeater_single_row_template ) ); ?>">
|
62 |
+
<?php foreach ( $values as $value_row => $value ) : ?>
|
63 |
+
<tr class="qs-repeater-row" data-repeater-row-count="<?php echo $value_row; ?>">
|
64 |
+
<?php $prefix = $base_prefix . '[' . $field['name'] . ']' . '[' . $value_row . ']'; ?>
|
65 |
+
<?php foreach ( $field['fields'] as $child_field ) : ?>
|
66 |
+
<td>
|
67 |
+
<?php
|
68 |
+
$child_field['value'] = isset( $value[ $child_field['name'] ] ) ? $value[ $child_field['name'] ] : '';
|
69 |
+
$child_field['label'] = '';
|
70 |
+
WPCF7R_Html::render_field( $child_field, $prefix );
|
71 |
+
?>
|
72 |
+
</td>
|
73 |
+
<?php endforeach; ?>
|
74 |
+
<td>
|
75 |
+
<div class="qs-repeater-action">
|
76 |
+
<span class="dashicons dashicons-plus"></span>
|
77 |
+
<span class="dashicons dashicons-minus"></span>
|
78 |
+
</div>
|
79 |
+
</td>
|
80 |
+
</tr>
|
81 |
+
<?php endforeach; ?>
|
82 |
+
</tbody>
|
83 |
+
</table>
|
84 |
+
</div>
|
85 |
+
</div>
|
86 |
+
<div class="field-footer">
|
87 |
+
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
88 |
+
</div>
|
89 |
+
</div>
|
90 |
+
</div>
|
templates/fields/field-rule-blocks.php
CHANGED
@@ -1,38 +1,38 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render a block of rules
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
if ( ! conditional_logic_enabled() ) {
|
9 |
-
return;
|
10 |
-
}
|
11 |
-
?>
|
12 |
-
|
13 |
-
<div class="conditional-logic-blocks <?php echo $field['has_conditional_logic'] ? 'active' : ''; ?>">
|
14 |
-
<div class="conditional-groups-wrap">
|
15 |
-
<div class="conditional-groups-tabs">
|
16 |
-
<div class="conditional-group-blocks">
|
17 |
-
<div class="qs-row">
|
18 |
-
<div class="qs-col qs-col-12">
|
19 |
-
<div class="wpcfr-rule-groups">
|
20 |
-
<?php
|
21 |
-
$active_tab = 'active';
|
22 |
-
foreach ( $field['blocks'] as $group_block ) :
|
23 |
-
WPCF7R_Html::get_block_html( 'block_1', $group_block, $active_tab, true, $prefix );
|
24 |
-
$active_tab = false;
|
25 |
-
endforeach;
|
26 |
-
?>
|
27 |
-
</div>
|
28 |
-
</div>
|
29 |
-
<div class="qs-col qs-col-12">
|
30 |
-
<div class="groups-actions">
|
31 |
-
<a href="#" class="button-primary wpcfr-add-group"><?php _e( 'OR', 'wpcf7-redirect' ); ?></a>
|
32 |
-
</div>
|
33 |
-
</div>
|
34 |
-
</div>
|
35 |
-
</div>
|
36 |
-
</div>
|
37 |
-
</div>
|
38 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render a block of rules
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
if ( ! conditional_logic_enabled() ) {
|
9 |
+
return;
|
10 |
+
}
|
11 |
+
?>
|
12 |
+
|
13 |
+
<div class="conditional-logic-blocks <?php echo $field['has_conditional_logic'] ? 'active' : ''; ?>">
|
14 |
+
<div class="conditional-groups-wrap">
|
15 |
+
<div class="conditional-groups-tabs">
|
16 |
+
<div class="conditional-group-blocks">
|
17 |
+
<div class="qs-row">
|
18 |
+
<div class="qs-col qs-col-12">
|
19 |
+
<div class="wpcfr-rule-groups">
|
20 |
+
<?php
|
21 |
+
$active_tab = 'active';
|
22 |
+
foreach ( $field['blocks'] as $group_block ) :
|
23 |
+
WPCF7R_Html::get_block_html( 'block_1', $group_block, $active_tab, true, $prefix );
|
24 |
+
$active_tab = false;
|
25 |
+
endforeach;
|
26 |
+
?>
|
27 |
+
</div>
|
28 |
+
</div>
|
29 |
+
<div class="qs-col qs-col-12">
|
30 |
+
<div class="groups-actions">
|
31 |
+
<a href="#" class="button-primary wpcfr-add-group"><?php _e( 'OR', 'wpcf7-redirect' ); ?></a>
|
32 |
+
</div>
|
33 |
+
</div>
|
34 |
+
</div>
|
35 |
+
</div>
|
36 |
+
</div>
|
37 |
+
</div>
|
38 |
+
</div>
|
templates/fields/field-tags-map.php
CHANGED
@@ -1,76 +1,76 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render tags mapping for API field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
$defaults_name = isset( $field['defaults_name'] ) ? $field['defaults_name'] : 'tags_defaults';
|
9 |
-
$selected = selected( '1', '1', false );
|
10 |
-
?>
|
11 |
-
|
12 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
13 |
-
<?php if ( isset( $field['title'] ) && $field['title'] ) : ?>
|
14 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
15 |
-
<h3><?php echo esc_html( $field['label'] ); ?></h3>
|
16 |
-
|
17 |
-
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
18 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>"><?php echo esc_html( $field['sub_title'] ); ?></label>
|
19 |
-
<br/>
|
20 |
-
<?php endif; ?>
|
21 |
-
</label>
|
22 |
-
<?php endif; ?>
|
23 |
-
|
24 |
-
<div class="cf7_row">
|
25 |
-
<table class="wp-list-table widefat fixed striped pages wp-list-table-inner">
|
26 |
-
<tr>
|
27 |
-
<td><strong><?php _e( 'Form Field Name', 'wpcf7-redirect' ); ?></strong></td>
|
28 |
-
<?php if ( 'test_tags_map' !== $field['name'] ) : ?>
|
29 |
-
<td class="tags-map-api-key"><strong><?php _e( 'Matching 3rd-Party Field Name', 'wpcf7-redirect' ); ?></strong><?php echo cf7r_tooltip( __( 'The Matching 3rd-Party field name as your api provider required', 'wpcf7-redirect' ) ); ?></td>
|
30 |
-
<?php endif; ?>
|
31 |
-
<?php if ( 'test_tags_map' !== $field['name'] ) : ?>
|
32 |
-
<td><strong><?php _e( 'Defaults', 'wpcf7-redirect' ); ?></strong><?php echo cf7r_tooltip( __( 'Send default values if not selected by the user', 'wpcf7-redirect' ) ); ?></td>
|
33 |
-
<?php else : ?>
|
34 |
-
<td><strong><?php _e( 'Value', 'wpcf7-redirect' ); ?></strong><?php echo cf7r_tooltip( __( 'Which value to send', 'wpcf7-redirect' ) ); ?></td>
|
35 |
-
<?php endif; ?>
|
36 |
-
<?php if ( 'test_tags_map' !== $field['name'] && isset( $field['tags_functions'] ) ) : ?>
|
37 |
-
<td><strong><?php _e( 'Function', 'wpcf7-redirect' ); ?></strong><?php echo cf7r_tooltip( __( 'Perform actions on the submitted value', 'wpcf7-redirect' ) ); ?></td>
|
38 |
-
<?php endif; ?>
|
39 |
-
</tr>
|
40 |
-
<?php
|
41 |
-
if ( isset( $field['tags'] ) && $field['tags'] ) :
|
42 |
-
foreach ( $field['tags'] as $mail_tag ) :
|
43 |
-
?>
|
44 |
-
<tr>
|
45 |
-
<td class="<?php echo $mail_tag->name; ?>"><?php echo $mail_tag->name; ?></td>
|
46 |
-
<?php if ( 'test_tags_map' !== $field['name'] ) : ?>
|
47 |
-
<td class="tags-map-api-key">
|
48 |
-
<input type="text" id="sf-<?php echo $mail_tag->name; ?>"
|
49 |
-
name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>][<?php echo $mail_tag->name; ?>]"
|
50 |
-
class="large-text"
|
51 |
-
value="<?php echo isset( $field['value'][ $mail_tag->name ] ) ? esc_html( $field['value'][ $mail_tag->name ] ) : ''; ?>" />
|
52 |
-
</td>
|
53 |
-
<?php endif; ?>
|
54 |
-
<td>
|
55 |
-
<?php $selected_value = isset( $field[ $defaults_name ][ "{$mail_tag->name}" ] ) ? $field[ $defaults_name ][ "{$mail_tag->name}" ] : ''; ?>
|
56 |
-
<input type="text" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $defaults_name; ?>][<?php echo $mail_tag->name; ?>]" value="<?php echo $selected_value; ?>" />
|
57 |
-
</td>
|
58 |
-
<?php if ( 'test_tags_map' !== $field['name'] && isset( $field['tags_functions'] ) ) : ?>
|
59 |
-
<td>
|
60 |
-
<?php $selected_function = isset( $field['tags_functions'][ "{$mail_tag->name}" ] ) ? $field['tags_functions'][ "{$mail_tag->name}" ] : ''; ?>
|
61 |
-
<select class="" name="wpcf7-redirect<?php echo $prefix; ?>[tags_functions][<?php echo $mail_tag->name; ?>]">
|
62 |
-
<?php $functions = WPCF7r_Utils::get_available_text_functions( '', $mail_tag->type ); ?>
|
63 |
-
<option value="" <?php echo ! $selected_function ? "selected='selected'" : ''; ?>><?php _e( 'Select' ); ?></option>
|
64 |
-
<?php foreach ( array_keys( $functions ) as $function_name ) : ?>
|
65 |
-
<option value="<?php echo $function_name; ?>" <?php selected( $selected_function, $function_name, true ); ?>><?php echo $function_name; ?></option>
|
66 |
-
<?php $selected = ''; ?>
|
67 |
-
<?php endforeach; ?>
|
68 |
-
</select>
|
69 |
-
</td>
|
70 |
-
<?php endif; ?>
|
71 |
-
</tr>
|
72 |
-
<?php endforeach; ?>
|
73 |
-
<?php endif; ?>
|
74 |
-
</table>
|
75 |
-
</div>
|
76 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render tags mapping for API field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
$defaults_name = isset( $field['defaults_name'] ) ? $field['defaults_name'] : 'tags_defaults';
|
9 |
+
$selected = selected( '1', '1', false );
|
10 |
+
?>
|
11 |
+
|
12 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
13 |
+
<?php if ( isset( $field['title'] ) && $field['title'] ) : ?>
|
14 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
15 |
+
<h3><?php echo esc_html( $field['label'] ); ?></h3>
|
16 |
+
|
17 |
+
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
18 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>"><?php echo esc_html( $field['sub_title'] ); ?></label>
|
19 |
+
<br/>
|
20 |
+
<?php endif; ?>
|
21 |
+
</label>
|
22 |
+
<?php endif; ?>
|
23 |
+
|
24 |
+
<div class="cf7_row">
|
25 |
+
<table class="wp-list-table widefat fixed striped pages wp-list-table-inner">
|
26 |
+
<tr>
|
27 |
+
<td><strong><?php _e( 'Form Field Name', 'wpcf7-redirect' ); ?></strong></td>
|
28 |
+
<?php if ( 'test_tags_map' !== $field['name'] ) : ?>
|
29 |
+
<td class="tags-map-api-key"><strong><?php _e( 'Matching 3rd-Party Field Name', 'wpcf7-redirect' ); ?></strong><?php echo cf7r_tooltip( __( 'The Matching 3rd-Party field name as your api provider required', 'wpcf7-redirect' ) ); ?></td>
|
30 |
+
<?php endif; ?>
|
31 |
+
<?php if ( 'test_tags_map' !== $field['name'] ) : ?>
|
32 |
+
<td><strong><?php _e( 'Defaults', 'wpcf7-redirect' ); ?></strong><?php echo cf7r_tooltip( __( 'Send default values if not selected by the user', 'wpcf7-redirect' ) ); ?></td>
|
33 |
+
<?php else : ?>
|
34 |
+
<td><strong><?php _e( 'Value', 'wpcf7-redirect' ); ?></strong><?php echo cf7r_tooltip( __( 'Which value to send', 'wpcf7-redirect' ) ); ?></td>
|
35 |
+
<?php endif; ?>
|
36 |
+
<?php if ( 'test_tags_map' !== $field['name'] && isset( $field['tags_functions'] ) ) : ?>
|
37 |
+
<td><strong><?php _e( 'Function', 'wpcf7-redirect' ); ?></strong><?php echo cf7r_tooltip( __( 'Perform actions on the submitted value', 'wpcf7-redirect' ) ); ?></td>
|
38 |
+
<?php endif; ?>
|
39 |
+
</tr>
|
40 |
+
<?php
|
41 |
+
if ( isset( $field['tags'] ) && $field['tags'] ) :
|
42 |
+
foreach ( $field['tags'] as $mail_tag ) :
|
43 |
+
?>
|
44 |
+
<tr>
|
45 |
+
<td class="<?php echo $mail_tag->name; ?>"><?php echo $mail_tag->name; ?></td>
|
46 |
+
<?php if ( 'test_tags_map' !== $field['name'] ) : ?>
|
47 |
+
<td class="tags-map-api-key">
|
48 |
+
<input type="text" id="sf-<?php echo $mail_tag->name; ?>"
|
49 |
+
name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>][<?php echo $mail_tag->name; ?>]"
|
50 |
+
class="large-text"
|
51 |
+
value="<?php echo isset( $field['value'][ $mail_tag->name ] ) ? esc_html( $field['value'][ $mail_tag->name ] ) : ''; ?>" />
|
52 |
+
</td>
|
53 |
+
<?php endif; ?>
|
54 |
+
<td>
|
55 |
+
<?php $selected_value = isset( $field[ $defaults_name ][ "{$mail_tag->name}" ] ) ? $field[ $defaults_name ][ "{$mail_tag->name}" ] : ''; ?>
|
56 |
+
<input type="text" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $defaults_name; ?>][<?php echo $mail_tag->name; ?>]" value="<?php echo $selected_value; ?>" />
|
57 |
+
</td>
|
58 |
+
<?php if ( 'test_tags_map' !== $field['name'] && isset( $field['tags_functions'] ) ) : ?>
|
59 |
+
<td>
|
60 |
+
<?php $selected_function = isset( $field['tags_functions'][ "{$mail_tag->name}" ] ) ? $field['tags_functions'][ "{$mail_tag->name}" ] : ''; ?>
|
61 |
+
<select class="" name="wpcf7-redirect<?php echo $prefix; ?>[tags_functions][<?php echo $mail_tag->name; ?>]">
|
62 |
+
<?php $functions = WPCF7r_Utils::get_available_text_functions( '', $mail_tag->type ); ?>
|
63 |
+
<option value="" <?php echo ! $selected_function ? "selected='selected'" : ''; ?>><?php _e( 'Select' ); ?></option>
|
64 |
+
<?php foreach ( array_keys( $functions ) as $function_name ) : ?>
|
65 |
+
<option value="<?php echo $function_name; ?>" <?php selected( $selected_function, $function_name, true ); ?>><?php echo $function_name; ?></option>
|
66 |
+
<?php $selected = ''; ?>
|
67 |
+
<?php endforeach; ?>
|
68 |
+
</select>
|
69 |
+
</td>
|
70 |
+
<?php endif; ?>
|
71 |
+
</tr>
|
72 |
+
<?php endforeach; ?>
|
73 |
+
<?php endif; ?>
|
74 |
+
</table>
|
75 |
+
</div>
|
76 |
+
</div>
|
templates/fields/field-taxonomy.php
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render taxonomy select field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
$taxonomiies = get_taxonomies();
|
9 |
-
?>
|
10 |
-
|
11 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
12 |
-
<?php if ( $field['label'] ) : ?>
|
13 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
14 |
-
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
15 |
-
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
16 |
-
</label>
|
17 |
-
<?php endif; ?>
|
18 |
-
<select class="" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]">
|
19 |
-
<?php foreach ( $taxonomiies as $option_key => $option_label ) : ?>
|
20 |
-
<option value="<?php echo $option_key; ?>" <?php selected( $field['value'], $option_key ); ?>><?php echo $option_label; ?></option>
|
21 |
-
<?php endforeach; ?>
|
22 |
-
</select>
|
23 |
-
<div class="field-footer">
|
24 |
-
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
25 |
-
</div>
|
26 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render taxonomy select field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
$taxonomiies = get_taxonomies();
|
9 |
+
?>
|
10 |
+
|
11 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
12 |
+
<?php if ( $field['label'] ) : ?>
|
13 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
14 |
+
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
15 |
+
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
16 |
+
</label>
|
17 |
+
<?php endif; ?>
|
18 |
+
<select class="" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]">
|
19 |
+
<?php foreach ( $taxonomiies as $option_key => $option_label ) : ?>
|
20 |
+
<option value="<?php echo $option_key; ?>" <?php selected( $field['value'], $option_key ); ?>><?php echo $option_label; ?></option>
|
21 |
+
<?php endforeach; ?>
|
22 |
+
</select>
|
23 |
+
<div class="field-footer">
|
24 |
+
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
25 |
+
</div>
|
26 |
+
</div>
|
templates/fields/field-text.php
CHANGED
@@ -1,41 +1,41 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Display text field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
$name = isset( $field['name'] ) ? $field['name'] : '';
|
9 |
-
$class = isset( $field['class'] ) ? $field['class'] : '';
|
10 |
-
$label = isset( $field['label'] ) ? $field['label'] : '';
|
11 |
-
$tooltip = isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : '';
|
12 |
-
$sub_title = isset( $field['sub_title'] ) ? $field['sub_title'] : '';
|
13 |
-
$input_class = isset( $field['input_class'] ) ? $field['input_class'] : '';
|
14 |
-
$input_attr = isset( $field['input_attr'] ) ? $field['input_attr'] : '';
|
15 |
-
$footer = isset( $field['footer'] ) ? $field['footer'] : '';
|
16 |
-
$placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
|
17 |
-
$value = isset( $field['value'] ) ? $field['value'] : '';
|
18 |
-
|
19 |
-
?>
|
20 |
-
<div class="field-wrap field-wrap-<?php echo esc_html( $name ); ?> <?php echo $class; ?>">
|
21 |
-
<?php if ( $label ) : ?>
|
22 |
-
<label for="wpcf7-redirect-<?php echo $name; ?>">
|
23 |
-
<strong><?php echo esc_html( $label ); ?></strong>
|
24 |
-
<?php echo $tooltip;?>
|
25 |
-
</label>
|
26 |
-
<?php endif; ?>
|
27 |
-
|
28 |
-
<?php if ( $sub_title ) : ?>
|
29 |
-
|
30 |
-
<div class="wpcf7-subtitle">
|
31 |
-
<?php echo esc_html( $sub_title ); ?>
|
32 |
-
</div>
|
33 |
-
|
34 |
-
<?php endif; ?>
|
35 |
-
|
36 |
-
<input type="text" class="wpcf7-redirect-<?php echo esc_html( $name ); ?>-fields <?php echo esc_html( $input_class ); ?>" placeholder="<?php echo esc_html( $placeholder ); ?>" name="wpcf7-redirect<?php echo esc_html( $prefix ); ?>[<?php echo esc_html( $name ); ?>]" value="<?php echo esc_html( $value ); ?>" <?php echo esc_html( $input_attr ); ?>>
|
37 |
-
|
38 |
-
<div class="field-footer">
|
39 |
-
<?php echo $footer; ?>
|
40 |
-
</div>
|
41 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Display text field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
$name = isset( $field['name'] ) ? $field['name'] : '';
|
9 |
+
$class = isset( $field['class'] ) ? $field['class'] : '';
|
10 |
+
$label = isset( $field['label'] ) ? $field['label'] : '';
|
11 |
+
$tooltip = isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : '';
|
12 |
+
$sub_title = isset( $field['sub_title'] ) ? $field['sub_title'] : '';
|
13 |
+
$input_class = isset( $field['input_class'] ) ? $field['input_class'] : '';
|
14 |
+
$input_attr = isset( $field['input_attr'] ) ? $field['input_attr'] : '';
|
15 |
+
$footer = isset( $field['footer'] ) ? $field['footer'] : '';
|
16 |
+
$placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
|
17 |
+
$value = isset( $field['value'] ) ? $field['value'] : '';
|
18 |
+
|
19 |
+
?>
|
20 |
+
<div class="field-wrap field-wrap-<?php echo esc_html( $name ); ?> <?php echo $class; ?>">
|
21 |
+
<?php if ( $label ) : ?>
|
22 |
+
<label for="wpcf7-redirect-<?php echo $name; ?>">
|
23 |
+
<strong><?php echo esc_html( $label ); ?></strong>
|
24 |
+
<?php echo $tooltip;?>
|
25 |
+
</label>
|
26 |
+
<?php endif; ?>
|
27 |
+
|
28 |
+
<?php if ( $sub_title ) : ?>
|
29 |
+
|
30 |
+
<div class="wpcf7-subtitle">
|
31 |
+
<?php echo esc_html( $sub_title ); ?>
|
32 |
+
</div>
|
33 |
+
|
34 |
+
<?php endif; ?>
|
35 |
+
|
36 |
+
<input type="text" class="wpcf7-redirect-<?php echo esc_html( $name ); ?>-fields <?php echo esc_html( $input_class ); ?>" placeholder="<?php echo esc_html( $placeholder ); ?>" name="wpcf7-redirect<?php echo esc_html( $prefix ); ?>[<?php echo esc_html( $name ); ?>]" value="<?php echo esc_html( $value ); ?>" <?php echo esc_html( $input_attr ); ?>>
|
37 |
+
|
38 |
+
<div class="field-footer">
|
39 |
+
<?php echo $footer; ?>
|
40 |
+
</div>
|
41 |
+
</div>
|
templates/fields/field-textarea.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render a textarea field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
$name = isset( $field['name'] ) ? $field['name'] : '';
|
9 |
-
$class = isset( $field['class'] ) ? $field['class'] : '';
|
10 |
-
$label = isset( $field['label'] ) ? $field['label'] : '';
|
11 |
-
$tooltip = isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : '';
|
12 |
-
$sub_title = isset( $field['sub_title'] ) ? $field['sub_title'] : '';
|
13 |
-
$input_class = isset( $field['input_class'] ) ? $field['input_class'] : '';
|
14 |
-
$input_attr = isset( $field['input_attr'] ) ? $field['input_attr'] : '';
|
15 |
-
$footer = isset( $field['footer'] ) ? $field['footer'] : '';
|
16 |
-
$placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
|
17 |
-
$value = isset( $field['value'] ) ? $field['value'] : '';
|
18 |
-
|
19 |
-
?>
|
20 |
-
<div class="field-wrap field-wrap-<?php echo esc_html( $name ); ?> <?php echo esc_html( $class ); ?>">
|
21 |
-
<label for="wpcf7-redirect-<?php echo esc_html( $name ); ?>">
|
22 |
-
<strong><?php echo esc_html( $label ); ?></strong>
|
23 |
-
</label>
|
24 |
-
<?php if ( $sub_title ) : ?>
|
25 |
-
<div class="wpcf7-subtitle">
|
26 |
-
<?php echo esc_html( $sub_title ); ?>
|
27 |
-
</div>
|
28 |
-
<?php endif; ?>
|
29 |
-
<textarea rows="10" class="wpcf7-redirect-<?php echo esc_html( $name ); ?>-fields" placeholder="<?php echo esc_html( $placeholder ); ?>" name="wpcf7-redirect<?php echo esc_html( $prefix ); ?>[<?php echo esc_html( $name ); ?>]"><?php echo esc_html( $value ); ?></textarea>
|
30 |
-
<div class="field-footer">
|
31 |
-
<?php echo $footer ; ?>
|
32 |
-
</div>
|
33 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render a textarea field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
$name = isset( $field['name'] ) ? $field['name'] : '';
|
9 |
+
$class = isset( $field['class'] ) ? $field['class'] : '';
|
10 |
+
$label = isset( $field['label'] ) ? $field['label'] : '';
|
11 |
+
$tooltip = isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : '';
|
12 |
+
$sub_title = isset( $field['sub_title'] ) ? $field['sub_title'] : '';
|
13 |
+
$input_class = isset( $field['input_class'] ) ? $field['input_class'] : '';
|
14 |
+
$input_attr = isset( $field['input_attr'] ) ? $field['input_attr'] : '';
|
15 |
+
$footer = isset( $field['footer'] ) ? $field['footer'] : '';
|
16 |
+
$placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
|
17 |
+
$value = isset( $field['value'] ) ? $field['value'] : '';
|
18 |
+
|
19 |
+
?>
|
20 |
+
<div class="field-wrap field-wrap-<?php echo esc_html( $name ); ?> <?php echo esc_html( $class ); ?>">
|
21 |
+
<label for="wpcf7-redirect-<?php echo esc_html( $name ); ?>">
|
22 |
+
<strong><?php echo esc_html( $label ); ?></strong>
|
23 |
+
</label>
|
24 |
+
<?php if ( $sub_title ) : ?>
|
25 |
+
<div class="wpcf7-subtitle">
|
26 |
+
<?php echo esc_html( $sub_title ); ?>
|
27 |
+
</div>
|
28 |
+
<?php endif; ?>
|
29 |
+
<textarea rows="10" class="wpcf7-redirect-<?php echo esc_html( $name ); ?>-fields" placeholder="<?php echo esc_html( $placeholder ); ?>" name="wpcf7-redirect<?php echo esc_html( $prefix ); ?>[<?php echo esc_html( $name ); ?>]"><?php echo esc_html( $value ); ?></textarea>
|
30 |
+
<div class="field-footer">
|
31 |
+
<?php echo $footer ; ?>
|
32 |
+
</div>
|
33 |
+
</div>
|
templates/fields/field-upload.php
CHANGED
@@ -1,31 +1,31 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render upload field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
?>
|
9 |
-
|
10 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
11 |
-
<?php if ( isset( $field['label'] ) && $field['label'] ) : ?>
|
12 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
13 |
-
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
14 |
-
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
15 |
-
</label>
|
16 |
-
<?php endif; ?>
|
17 |
-
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
18 |
-
<div class="wpcf7-subtitle">
|
19 |
-
<?php echo $field['sub_title']; ?>
|
20 |
-
</div>
|
21 |
-
<?php endif; ?>
|
22 |
-
<div class="image-container file-container">
|
23 |
-
<input value="<?php echo esc_html( $field['value'] ); ?>" alt="" type="text" class="file-url" />
|
24 |
-
<a title="Set File" href="javascript:;" class="image-uploader-btn browser button button-hero"><?php _e( 'Select File', 'wpcf7-redirect' ); ?></a>
|
25 |
-
<a title="Remove File" href="javascript:;" class="image-remove-btn browser button"><span class="dashicons dashicons-no-alt"></span></a>
|
26 |
-
<input type="hidden" class="wpcf7-redirect-<?php echo $field['name']; ?>-fields" placeholder="<?php echo esc_html( $field['placeholder'] ); ?>" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]" value="<?php echo esc_html( $field['value'] ); ?>" <?php echo isset( $field['input_attr'] ) ? $field['input_attr'] : ''; ?>>
|
27 |
-
</div>
|
28 |
-
<div class="field-footer">
|
29 |
-
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
30 |
-
</div>
|
31 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render upload field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
?>
|
9 |
+
|
10 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
11 |
+
<?php if ( isset( $field['label'] ) && $field['label'] ) : ?>
|
12 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
13 |
+
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
14 |
+
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
15 |
+
</label>
|
16 |
+
<?php endif; ?>
|
17 |
+
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
18 |
+
<div class="wpcf7-subtitle">
|
19 |
+
<?php echo $field['sub_title']; ?>
|
20 |
+
</div>
|
21 |
+
<?php endif; ?>
|
22 |
+
<div class="image-container file-container">
|
23 |
+
<input value="<?php echo esc_html( $field['value'] ); ?>" alt="" type="text" class="file-url" />
|
24 |
+
<a title="Set File" href="javascript:;" class="image-uploader-btn browser button button-hero"><?php _e( 'Select File', 'wpcf7-redirect' ); ?></a>
|
25 |
+
<a title="Remove File" href="javascript:;" class="image-remove-btn browser button"><span class="dashicons dashicons-no-alt"></span></a>
|
26 |
+
<input type="hidden" class="wpcf7-redirect-<?php echo $field['name']; ?>-fields" placeholder="<?php echo esc_html( $field['placeholder'] ); ?>" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]" value="<?php echo esc_html( $field['value'] ); ?>" <?php echo isset( $field['input_attr'] ) ? $field['input_attr'] : ''; ?>>
|
27 |
+
</div>
|
28 |
+
<div class="field-footer">
|
29 |
+
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
30 |
+
</div>
|
31 |
+
</div>
|
templates/fields/field-url.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Render url field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
11 |
-
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
12 |
-
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
13 |
-
</label>
|
14 |
-
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
15 |
-
<div class="wpcf7-subtitle">
|
16 |
-
<?php echo $field['sub_title']; ?>
|
17 |
-
</div>
|
18 |
-
<?php endif; ?>
|
19 |
-
<input type="url" class="wpcf7-redirect-<?php echo $field['name']; ?>-fields" placeholder="<?php echo esc_html( $field['placeholder'] ); ?>" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]" value="<?php echo esc_html( $field['value'] ); ?>">
|
20 |
-
<div class="field-footer">
|
21 |
-
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
22 |
-
</div>
|
23 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Render url field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?>">
|
10 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
11 |
+
<strong><?php echo esc_html( $field['label'] ); ?></strong>
|
12 |
+
<?php echo isset( $field['tooltip'] ) ? cf7r_tooltip( $field['tooltip'] ) : ''; ?>
|
13 |
+
</label>
|
14 |
+
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
15 |
+
<div class="wpcf7-subtitle">
|
16 |
+
<?php echo $field['sub_title']; ?>
|
17 |
+
</div>
|
18 |
+
<?php endif; ?>
|
19 |
+
<input type="url" class="wpcf7-redirect-<?php echo $field['name']; ?>-fields" placeholder="<?php echo esc_html( $field['placeholder'] ); ?>" name="wpcf7-redirect<?php echo $prefix; ?>[<?php echo $field['name']; ?>]" value="<?php echo esc_html( $field['value'] ); ?>">
|
20 |
+
<div class="field-footer">
|
21 |
+
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
22 |
+
</div>
|
23 |
+
</div>
|
templates/fields/index.php
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
<?php
|
2 |
-
defined( 'ABSPATH' ) || exit;
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit;
|
templates/fields/section.php
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Wrapper for each field
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?> qs-section clearfix" <?php echo isset( $field['attr'] ) ? $field['attr'] : ''; ?>>
|
10 |
-
<?php if ( isset( $field['title'] ) && $field['title'] ) : ?>
|
11 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
12 |
-
<h3 class="" data-tab-target="section-inner-wrap-<?php echo $field['name']; ?>"><span class="dashicons dashicons-plus-alt"></span> <?php echo esc_html( $field['title'] ); ?></h3>
|
13 |
-
</label>
|
14 |
-
<?php endif; ?>
|
15 |
-
|
16 |
-
<div class="section-inner-wrap" data-tab="section-inner-wrap-<?php echo $field['name']; ?>">
|
17 |
-
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
18 |
-
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
19 |
-
<h4><?php echo $field['sub_title']; ?></h4>
|
20 |
-
</label>
|
21 |
-
<?php endif; ?>
|
22 |
-
<div> </div>
|
23 |
-
|
24 |
-
<?php foreach ( $field['fields'] as $child_field ) : ?>
|
25 |
-
<?php WPCF7R_Html::render_field( $child_field, $prefix ); ?>
|
26 |
-
<?php endforeach; ?>
|
27 |
-
|
28 |
-
<div class="field-footer">
|
29 |
-
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
30 |
-
</div>
|
31 |
-
</div>
|
32 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Wrapper for each field
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="field-wrap field-wrap-<?php echo $field['name']; ?> <?php echo isset( $field['class'] ) ? $field['class'] : ''; ?> qs-section clearfix" <?php echo isset( $field['attr'] ) ? $field['attr'] : ''; ?>>
|
10 |
+
<?php if ( isset( $field['title'] ) && $field['title'] ) : ?>
|
11 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
12 |
+
<h3 class="" data-tab-target="section-inner-wrap-<?php echo $field['name']; ?>"><span class="dashicons dashicons-plus-alt"></span> <?php echo esc_html( $field['title'] ); ?></h3>
|
13 |
+
</label>
|
14 |
+
<?php endif; ?>
|
15 |
+
|
16 |
+
<div class="section-inner-wrap" data-tab="section-inner-wrap-<?php echo $field['name']; ?>">
|
17 |
+
<?php if ( isset( $field['sub_title'] ) && $field['sub_title'] ) : ?>
|
18 |
+
<label for="wpcf7-redirect-<?php echo $field['name']; ?>">
|
19 |
+
<h4><?php echo $field['sub_title']; ?></h4>
|
20 |
+
</label>
|
21 |
+
<?php endif; ?>
|
22 |
+
<div> </div>
|
23 |
+
|
24 |
+
<?php foreach ( $field['fields'] as $child_field ) : ?>
|
25 |
+
<?php WPCF7R_Html::render_field( $child_field, $prefix ); ?>
|
26 |
+
<?php endforeach; ?>
|
27 |
+
|
28 |
+
<div class="field-footer">
|
29 |
+
<?php echo isset( $field['footer'] ) ? $field['footer'] : ''; ?>
|
30 |
+
</div>
|
31 |
+
</div>
|
32 |
+
</div>
|
templates/index.php
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
<?php
|
2 |
-
defined( 'ABSPATH' ) || exit;
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit;
|
templates/popup-api-test.php
CHANGED
@@ -1,74 +1,74 @@
|
|
1 |
-
<?php
|
2 |
-
defined( 'ABSPATH' ) || exit;
|
3 |
-
?>
|
4 |
-
|
5 |
-
<div class="wpcfr-popup-wrap wpcfr-popup-hidden <?php echo $template; ?> middle-center">
|
6 |
-
<div class="wpcfr-popup-wrap-inner">
|
7 |
-
<span class="dashicons dashicons-no-alt wpcfr-close-popup top-right"></span>
|
8 |
-
<div class="wpcfr-popup-wrap-content">
|
9 |
-
<h3>
|
10 |
-
<?php _e( 'Record', 'wpcf7-redirect' ); ?>
|
11 |
-
</h3>
|
12 |
-
<div class="wrapper">
|
13 |
-
<textarea name="name" rows="8" cols="80">
|
14 |
-
<?php
|
15 |
-
ob_start();
|
16 |
-
|
17 |
-
print_r( $this->record );
|
18 |
-
|
19 |
-
echo esc_html( ob_get_clean() );
|
20 |
-
?>
|
21 |
-
</textarea>
|
22 |
-
</div>
|
23 |
-
<h3>
|
24 |
-
<?php _e( 'Request', 'wpcf7-redirect' ); ?>
|
25 |
-
</h3>
|
26 |
-
<div class="wrapper">
|
27 |
-
<textarea name="name" rows="8" cols="80">
|
28 |
-
<?php
|
29 |
-
ob_start();
|
30 |
-
|
31 |
-
print_r( $this->request );
|
32 |
-
|
33 |
-
echo esc_html( ob_get_clean() );
|
34 |
-
?>
|
35 |
-
</textarea>
|
36 |
-
</div>
|
37 |
-
<h3>
|
38 |
-
<?php _e( 'Response', 'wpcf7-redirect' ); ?>
|
39 |
-
</h3>
|
40 |
-
<div class="wrapper">
|
41 |
-
<?php if ( is_wp_error( $this->results ) ) : ?>
|
42 |
-
<span class="err"><?php _e( 'Error!' ); ?></span>
|
43 |
-
<textarea name="name" rows="8" cols="80">
|
44 |
-
<?php
|
45 |
-
ob_start();
|
46 |
-
|
47 |
-
print_r( $this->results );
|
48 |
-
|
49 |
-
echo esc_html( ob_get_clean() );
|
50 |
-
?>
|
51 |
-
</textarea>
|
52 |
-
<?php else : ?>
|
53 |
-
<div class="field-wrap">
|
54 |
-
<div class="label">
|
55 |
-
<label>
|
56 |
-
<?php _e( 'Response code', 'wpcf7-redirect' ); ?>
|
57 |
-
</label>
|
58 |
-
<span><?php echo $this->results['response']['message']; ?>(<?php echo $this->results['response']['code']; ?>)</span>
|
59 |
-
</div>
|
60 |
-
<textarea name="name" rows="8" cols="80">
|
61 |
-
<?php
|
62 |
-
ob_start();
|
63 |
-
|
64 |
-
print_r( $this->results );
|
65 |
-
|
66 |
-
echo esc_html( ob_get_clean() );
|
67 |
-
?>
|
68 |
-
</textarea>
|
69 |
-
</div>
|
70 |
-
<?php endif; ?>
|
71 |
-
</div>
|
72 |
-
</div>
|
73 |
-
</div>
|
74 |
-
</div>
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit;
|
3 |
+
?>
|
4 |
+
|
5 |
+
<div class="wpcfr-popup-wrap wpcfr-popup-hidden <?php echo $template; ?> middle-center">
|
6 |
+
<div class="wpcfr-popup-wrap-inner">
|
7 |
+
<span class="dashicons dashicons-no-alt wpcfr-close-popup top-right"></span>
|
8 |
+
<div class="wpcfr-popup-wrap-content">
|
9 |
+
<h3>
|
10 |
+
<?php _e( 'Record', 'wpcf7-redirect' ); ?>
|
11 |
+
</h3>
|
12 |
+
<div class="wrapper">
|
13 |
+
<textarea name="name" rows="8" cols="80">
|
14 |
+
<?php
|
15 |
+
ob_start();
|
16 |
+
|
17 |
+
print_r( $this->record );
|
18 |
+
|
19 |
+
echo esc_html( ob_get_clean() );
|
20 |
+
?>
|
21 |
+
</textarea>
|
22 |
+
</div>
|
23 |
+
<h3>
|
24 |
+
<?php _e( 'Request', 'wpcf7-redirect' ); ?>
|
25 |
+
</h3>
|
26 |
+
<div class="wrapper">
|
27 |
+
<textarea name="name" rows="8" cols="80">
|
28 |
+
<?php
|
29 |
+
ob_start();
|
30 |
+
|
31 |
+
print_r( $this->request );
|
32 |
+
|
33 |
+
echo esc_html( ob_get_clean() );
|
34 |
+
?>
|
35 |
+
</textarea>
|
36 |
+
</div>
|
37 |
+
<h3>
|
38 |
+
<?php _e( 'Response', 'wpcf7-redirect' ); ?>
|
39 |
+
</h3>
|
40 |
+
<div class="wrapper">
|
41 |
+
<?php if ( is_wp_error( $this->results ) ) : ?>
|
42 |
+
<span class="err"><?php _e( 'Error!' ); ?></span>
|
43 |
+
<textarea name="name" rows="8" cols="80">
|
44 |
+
<?php
|
45 |
+
ob_start();
|
46 |
+
|
47 |
+
print_r( $this->results );
|
48 |
+
|
49 |
+
echo esc_html( ob_get_clean() );
|
50 |
+
?>
|
51 |
+
</textarea>
|
52 |
+
<?php else : ?>
|
53 |
+
<div class="field-wrap">
|
54 |
+
<div class="label">
|
55 |
+
<label>
|
56 |
+
<?php _e( 'Response code', 'wpcf7-redirect' ); ?>
|
57 |
+
</label>
|
58 |
+
<span><?php echo $this->results['response']['message']; ?>(<?php echo $this->results['response']['code']; ?>)</span>
|
59 |
+
</div>
|
60 |
+
<textarea name="name" rows="8" cols="80">
|
61 |
+
<?php
|
62 |
+
ob_start();
|
63 |
+
|
64 |
+
print_r( $this->results );
|
65 |
+
|
66 |
+
echo esc_html( ob_get_clean() );
|
67 |
+
?>
|
68 |
+
</textarea>
|
69 |
+
</div>
|
70 |
+
<?php endif; ?>
|
71 |
+
</div>
|
72 |
+
</div>
|
73 |
+
</div>
|
74 |
+
</div>
|
templates/save-form.php
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Please save your form message
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
?>
|
8 |
-
|
9 |
-
<fieldset>
|
10 |
-
<div class="fields-wrap field-wrap-page-id">
|
11 |
-
<div class="tab-wrap">
|
12 |
-
<div class="wpcf7r-tab-wrap-inner">
|
13 |
-
<div data-tab-inner>
|
14 |
-
<h3>
|
15 |
-
<?php _e( 'Please save your form', 'wpcf7-redirect' ); ?>
|
16 |
-
</h3>
|
17 |
-
</div>
|
18 |
-
</div>
|
19 |
-
</div>
|
20 |
-
</div>
|
21 |
-
</fieldset>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Please save your form message
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
?>
|
8 |
+
|
9 |
+
<fieldset>
|
10 |
+
<div class="fields-wrap field-wrap-page-id">
|
11 |
+
<div class="tab-wrap">
|
12 |
+
<div class="wpcf7r-tab-wrap-inner">
|
13 |
+
<div data-tab-inner>
|
14 |
+
<h3>
|
15 |
+
<?php _e( 'Please save your form', 'wpcf7-redirect' ); ?>
|
16 |
+
</h3>
|
17 |
+
</div>
|
18 |
+
</div>
|
19 |
+
</div>
|
20 |
+
</div>
|
21 |
+
</fieldset>
|
templates/settings.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Displays the settings panel
|
4 |
-
*/
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) || exit;
|
7 |
-
|
8 |
-
wp_nonce_field( 'wpcf7_redirect_page_metaboxes', 'wpcf7_redirect_page_metaboxes_nonce' );
|
9 |
-
|
10 |
-
do_action( 'before_redirect_settings_tab_title', $this->cf7_post );
|
11 |
-
?>
|
12 |
-
|
13 |
-
<fieldset>
|
14 |
-
<div class="fields-wrap field-wrap-page-id">
|
15 |
-
<div class="tab-wrap">
|
16 |
-
<div class="wpcf7r-tab-wrap-inner">
|
17 |
-
<div data-tab-inner>
|
18 |
-
<div class="qs-row">
|
19 |
-
<?php include( 'default-settings.php' ); ?>
|
20 |
-
</div>
|
21 |
-
</div>
|
22 |
-
</div>
|
23 |
-
</div>
|
24 |
-
</div>
|
25 |
-
</fieldset>
|
26 |
-
|
27 |
-
<?php
|
28 |
-
do_action( 'after_redirect_settings_tab_form', $this->cf7_post );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Displays the settings panel
|
4 |
+
*/
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) || exit;
|
7 |
+
|
8 |
+
wp_nonce_field( 'wpcf7_redirect_page_metaboxes', 'wpcf7_redirect_page_metaboxes_nonce' );
|
9 |
+
|
10 |
+
do_action( 'before_redirect_settings_tab_title', $this->cf7_post );
|
11 |
+
?>
|
12 |
+
|
13 |
+
<fieldset>
|
14 |
+
<div class="fields-wrap field-wrap-page-id">
|
15 |
+
<div class="tab-wrap">
|
16 |
+
<div class="wpcf7r-tab-wrap-inner">
|
17 |
+
<div data-tab-inner>
|
18 |
+
<div class="qs-row">
|
19 |
+
<?php include( 'default-settings.php' ); ?>
|
20 |
+
</div>
|
21 |
+
</div>
|
22 |
+
</div>
|
23 |
+
</div>
|
24 |
+
</div>
|
25 |
+
</fieldset>
|
26 |
+
|
27 |
+
<?php
|
28 |
+
do_action( 'after_redirect_settings_tab_form', $this->cf7_post );
|
wpcf7-redirect.php
CHANGED
@@ -1,83 +1,83 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Plugin Name: Redirection for Contact Form 7
|
4 |
-
* Plugin URI: https://redirection-for-contact-form7.com/
|
5 |
-
* Description: The ultimate add-on for Contact Form 7 - redirect to any page after submission, fire scripts, save submissions in database, and much more options to make Contact Form 7 poweful than ever.
|
6 |
-
* Version: 2.3.
|
7 |
-
* Author: Query Solutions
|
8 |
-
* Author URI: https://redirection-for-contact-form7.com/
|
9 |
-
* Contributors: querysolutions, yuvalsabar, regevlio
|
10 |
-
* Requires at least: 5.1
|
11 |
-
*
|
12 |
-
* Text Domain: wpcf7-redirect
|
13 |
-
* Domain Path: /lang
|
14 |
-
*
|
15 |
-
* @package Redirection for Contact Form 7
|
16 |
-
* @category Contact Form 7 Add-on
|
17 |
-
* @author Query Solutions
|
18 |
-
*/
|
19 |
-
|
20 |
-
defined( 'ABSPATH' ) || exit;
|
21 |
-
|
22 |
-
if ( ! defined( 'CF7_REDIRECT_DEBUG' ) ) {
|
23 |
-
define( 'CF7_REDIRECT_DEBUG', get_option( 'wpcf_debug' ) ? true : false );
|
24 |
-
}
|
25 |
-
|
26 |
-
define( 'WPCF7_PRO_REDIRECT_PLUGIN_VERSION', '2.3.
|
27 |
-
define( 'WPCF7_PRO_MIGRATION_VERSION', '1' );
|
28 |
-
define( 'WPCF7_PRO_REDIRECT_CLASSES_PATH', plugin_dir_path( __FILE__ ) . 'classes/' );
|
29 |
-
|
30 |
-
require_once WPCF7_PRO_REDIRECT_CLASSES_PATH . 'class-wpcf7r-action.php';
|
31 |
-
require_once WPCF7_PRO_REDIRECT_CLASSES_PATH . 'class-wpcf7r-utils.php';
|
32 |
-
require_once WPCF7_PRO_REDIRECT_CLASSES_PATH . 'class-wpcf7r-actions.php';
|
33 |
-
require_once 'class-wpcf7-redirect.php';
|
34 |
-
|
35 |
-
add_action( 'admin_init', 'wpcf7r_activation_process' );
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Handle plugin upgrade migration
|
39 |
-
*/
|
40 |
-
function wpcf7r_activation_process() {
|
41 |
-
if ( get_option( 'wpcf7_redirect_version' ) !== WPCF7_PRO_REDIRECT_PLUGIN_VERSION ) {
|
42 |
-
$extensions_url = admin_url( 'admin.php?page=wpc7_redirect' );
|
43 |
-
|
44 |
-
update_option( 'wpcf7_redirect_dismiss_banner', 0 );
|
45 |
-
|
46 |
-
update_option( 'wpcf7_redirect_version', WPCF7_PRO_REDIRECT_PLUGIN_VERSION );
|
47 |
-
|
48 |
-
update_option(
|
49 |
-
'wpcf7_redirect_notifications',
|
50 |
-
array(
|
51 |
-
'notice-success wpcf7r-notice' => '<p><span class="dashicons dashicons-feedback"></span> <a href="' . $extensions_url . '"> Redirection for Contact Form 7 - check out our new forms extensions - don\'t miss it!</a></p><p>Also, we will be happy if you can take a few moments and <a href="https://wordpress.org/support/plugin/wpcf7-redirect/reviews/" target="_blank">rate our plugin</a>.</p>',
|
52 |
-
)
|
53 |
-
);
|
54 |
-
}
|
55 |
-
|
56 |
-
if ( get_option( 'wpcf7_migration_completed' ) !== WPCF7_PRO_MIGRATION_VERSION ) {
|
57 |
-
WPCF7r_Utils::auto_migrate( 'migrate_from_cf7_redirect' );
|
58 |
-
|
59 |
-
update_option( 'wpcf7_migration_completed', WPCF7_PRO_MIGRATION_VERSION );
|
60 |
-
}
|
61 |
-
|
62 |
-
}
|
63 |
-
|
64 |
-
require_once( plugin_dir_path( __FILE__ ) . 'wpcf7r-functions.php' );
|
65 |
-
|
66 |
-
/**
|
67 |
-
* WPCF7R initialization
|
68 |
-
*/
|
69 |
-
function wpcf7_redirect_pro_init() {
|
70 |
-
// globals
|
71 |
-
global $cf7_redirect;
|
72 |
-
|
73 |
-
// initialize
|
74 |
-
if ( ! isset( $cf7_redirect ) ) {
|
75 |
-
$cf7_redirect = new Wpcf7_Redirect();
|
76 |
-
$cf7_redirect->init();
|
77 |
-
}
|
78 |
-
|
79 |
-
// return
|
80 |
-
return $cf7_redirect;
|
81 |
-
}
|
82 |
-
|
83 |
-
wpcf7_redirect_pro_init();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Redirection for Contact Form 7
|
4 |
+
* Plugin URI: https://redirection-for-contact-form7.com/
|
5 |
+
* Description: The ultimate add-on for Contact Form 7 - redirect to any page after submission, fire scripts, save submissions in database, and much more options to make Contact Form 7 poweful than ever.
|
6 |
+
* Version: 2.3.6
|
7 |
+
* Author: Query Solutions
|
8 |
+
* Author URI: https://redirection-for-contact-form7.com/
|
9 |
+
* Contributors: querysolutions, yuvalsabar, regevlio
|
10 |
+
* Requires at least: 5.1
|
11 |
+
*
|
12 |
+
* Text Domain: wpcf7-redirect
|
13 |
+
* Domain Path: /lang
|
14 |
+
*
|
15 |
+
* @package Redirection for Contact Form 7
|
16 |
+
* @category Contact Form 7 Add-on
|
17 |
+
* @author Query Solutions
|
18 |
+
*/
|
19 |
+
|
20 |
+
defined( 'ABSPATH' ) || exit;
|
21 |
+
|
22 |
+
if ( ! defined( 'CF7_REDIRECT_DEBUG' ) ) {
|
23 |
+
define( 'CF7_REDIRECT_DEBUG', get_option( 'wpcf_debug' ) ? true : false );
|
24 |
+
}
|
25 |
+
|
26 |
+
define( 'WPCF7_PRO_REDIRECT_PLUGIN_VERSION', '2.3.6' );
|
27 |
+
define( 'WPCF7_PRO_MIGRATION_VERSION', '1' );
|
28 |
+
define( 'WPCF7_PRO_REDIRECT_CLASSES_PATH', plugin_dir_path( __FILE__ ) . 'classes/' );
|
29 |
+
|
30 |
+
require_once WPCF7_PRO_REDIRECT_CLASSES_PATH . 'class-wpcf7r-action.php';
|
31 |
+
require_once WPCF7_PRO_REDIRECT_CLASSES_PATH . 'class-wpcf7r-utils.php';
|
32 |
+
require_once WPCF7_PRO_REDIRECT_CLASSES_PATH . 'class-wpcf7r-actions.php';
|
33 |
+
require_once 'class-wpcf7-redirect.php';
|
34 |
+
|
35 |
+
add_action( 'admin_init', 'wpcf7r_activation_process' );
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Handle plugin upgrade migration
|
39 |
+
*/
|
40 |
+
function wpcf7r_activation_process() {
|
41 |
+
if ( get_option( 'wpcf7_redirect_version' ) !== WPCF7_PRO_REDIRECT_PLUGIN_VERSION ) {
|
42 |
+
$extensions_url = admin_url( 'admin.php?page=wpc7_redirect' );
|
43 |
+
|
44 |
+
update_option( 'wpcf7_redirect_dismiss_banner', 0 );
|
45 |
+
|
46 |
+
update_option( 'wpcf7_redirect_version', WPCF7_PRO_REDIRECT_PLUGIN_VERSION );
|
47 |
+
|
48 |
+
update_option(
|
49 |
+
'wpcf7_redirect_notifications',
|
50 |
+
array(
|
51 |
+
'notice-success wpcf7r-notice' => '<p><span class="dashicons dashicons-feedback"></span> <a href="' . $extensions_url . '"> Redirection for Contact Form 7 - check out our new forms extensions - don\'t miss it!</a></p><p>Also, we will be happy if you can take a few moments and <a href="https://wordpress.org/support/plugin/wpcf7-redirect/reviews/" target="_blank">rate our plugin</a>.</p>',
|
52 |
+
)
|
53 |
+
);
|
54 |
+
}
|
55 |
+
|
56 |
+
if ( get_option( 'wpcf7_migration_completed' ) !== WPCF7_PRO_MIGRATION_VERSION ) {
|
57 |
+
WPCF7r_Utils::auto_migrate( 'migrate_from_cf7_redirect' );
|
58 |
+
|
59 |
+
update_option( 'wpcf7_migration_completed', WPCF7_PRO_MIGRATION_VERSION );
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
require_once( plugin_dir_path( __FILE__ ) . 'wpcf7r-functions.php' );
|
65 |
+
|
66 |
+
/**
|
67 |
+
* WPCF7R initialization
|
68 |
+
*/
|
69 |
+
function wpcf7_redirect_pro_init() {
|
70 |
+
// globals
|
71 |
+
global $cf7_redirect;
|
72 |
+
|
73 |
+
// initialize
|
74 |
+
if ( ! isset( $cf7_redirect ) ) {
|
75 |
+
$cf7_redirect = new Wpcf7_Redirect();
|
76 |
+
$cf7_redirect->init();
|
77 |
+
}
|
78 |
+
|
79 |
+
// return
|
80 |
+
return $cf7_redirect;
|
81 |
+
}
|
82 |
+
|
83 |
+
wpcf7_redirect_pro_init();
|
wpcf7r-functions.php
CHANGED
@@ -1,800 +1,808 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Functions file
|
4 |
-
*
|
5 |
-
* @package Redirection for Contact Form 7
|
6 |
-
* @category Contact Form 7 Add-on
|
7 |
-
* @author Query Solutions
|
8 |
-
* @version 0.1.0
|
9 |
-
*/
|
10 |
-
|
11 |
-
defined( 'ABSPATH' ) || exit;
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Get the list of available Extensions
|
15 |
-
*
|
16 |
-
* @return array - $extensions - extensions array.
|
17 |
-
*/
|
18 |
-
function wpcf7_get_extensions() {
|
19 |
-
$extensions = wpcf7_redirect_get_all_extensions_list();
|
20 |
-
|
21 |
-
$installed_extensions = wpcf7r_get_available_actions();
|
22 |
-
|
23 |
-
foreach ( $extensions as $key => $extension ) {
|
24 |
-
foreach ( $installed_extensions as $installed_extension ) {
|
25 |
-
if ( class_exists( $extension['classname'] ) || $installed_extension['handler'] === $extension['classname'] || ( isset( $extension['type'] ) && 'affiliate' === $extension['type'] ) ) {
|
26 |
-
$extensions[ $key ]['active'] = true;
|
27 |
-
}
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
return apply_filters( 'wpcf7_get_extensions', $extensions );
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Verify nonce
|
36 |
-
*
|
37 |
-
* @return void
|
38 |
-
*/
|
39 |
-
function wpcf7_validate_nonce() {
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
),
|
64 |
-
'
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
),
|
72 |
-
'wpcf7r-
|
73 |
-
'name' => 'wpcf7r-
|
74 |
-
'filename' => 'class-wpcf7r-
|
75 |
-
'title' => __( '
|
76 |
-
'description' => __( '
|
77 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
78 |
-
'classname' => '
|
79 |
-
),
|
80 |
-
'wpcf7r-
|
81 |
-
'name' => 'wpcf7r-
|
82 |
-
'filename' => 'class-wpcf7r-
|
83 |
-
'title' => __( '
|
84 |
-
'description' => __( '
|
85 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
86 |
-
'classname' => '
|
87 |
-
),
|
88 |
-
'wpcf7r-
|
89 |
-
'name' => 'wpcf7r-
|
90 |
-
'filename' => 'class-wpcf7r-action-
|
91 |
-
'title' => __( '
|
92 |
-
'description' => __( 'Collect payments with your Contact Form 7 form. Setup product details and custom
|
93 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
94 |
-
'classname' => '
|
95 |
-
),
|
96 |
-
'wpcf7r-
|
97 |
-
'name' => 'wpcf7r-
|
98 |
-
'filename' => 'class-wpcf7r-
|
99 |
-
'title' => __( '
|
100 |
-
'description' => __( '
|
101 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
102 |
-
'classname' => '
|
103 |
-
),
|
104 |
-
'wpcf7r-
|
105 |
-
'name' => 'wpcf7r-
|
106 |
-
'filename' => 'class-wpcf7r-action-
|
107 |
-
'title' => __( '
|
108 |
-
'description' => __( '
|
109 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
110 |
-
'classname' => '
|
111 |
-
),
|
112 |
-
'wpcf7r-
|
113 |
-
'name' => 'wpcf7r-
|
114 |
-
'filename' => 'class-wpcf7r-action-
|
115 |
-
'title' => __( '
|
116 |
-
'description' => __( '
|
117 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
118 |
-
'classname' => '
|
119 |
-
),
|
120 |
-
'wpcf7r-
|
121 |
-
'name' => 'wpcf7r-
|
122 |
-
'filename' => 'class-wpcf7r-action-
|
123 |
-
'title' => __( '
|
124 |
-
'description' => __( '
|
125 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
126 |
-
'classname' => '
|
127 |
-
),
|
128 |
-
'wpcf7r-
|
129 |
-
'name' => 'wpcf7r-
|
130 |
-
'filename' => 'class-wpcf7r-action-
|
131 |
-
'title' => __( '
|
132 |
-
'description' => __( 'Create
|
133 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
134 |
-
'classname' => '
|
135 |
-
),
|
136 |
-
'wpcf7r-
|
137 |
-
'name' => 'wpcf7r-
|
138 |
-
'filename' => 'class-wpcf7r-action-
|
139 |
-
'title' => __( 'Custom
|
140 |
-
'description' => __( 'Create
|
141 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
142 |
-
'classname' => '
|
143 |
-
),
|
144 |
-
'wpcf7r-
|
145 |
-
'name' => 'wpcf7r-
|
146 |
-
'filename' => 'class-wpcf7r-action-
|
147 |
-
'title' => __( '
|
148 |
-
'description' => __( '
|
149 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
150 |
-
'classname' => '
|
151 |
-
),
|
152 |
-
'wpcf7r-
|
153 |
-
'name' => 'wpcf7r-
|
154 |
-
'filename' => 'class-wpcf7r-action-
|
155 |
-
'title' => __( '
|
156 |
-
'description' => __( '
|
157 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
158 |
-
'classname' => '
|
159 |
-
),
|
160 |
-
'wpcf7r-
|
161 |
-
'name' => 'wpcf7r-
|
162 |
-
'filename' => 'class-wpcf7r-action-
|
163 |
-
'title' => __( '
|
164 |
-
'description' => __( 'Send your leads to
|
165 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
166 |
-
'classname' => '
|
167 |
-
),
|
168 |
-
'wpcf7r-
|
169 |
-
'name' => 'wpcf7r-
|
170 |
-
'filename' => 'wpcf7r-action-
|
171 |
-
'title' => __( '
|
172 |
-
'description' => __( '
|
173 |
-
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/
|
174 |
-
'classname' => '
|
175 |
-
),
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
*
|
209 |
-
*
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
*
|
231 |
-
*
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
*
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
}
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
*
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
*
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
*
|
356 |
-
*
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
*
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
*
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
*
|
496 |
-
*
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
$
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
'
|
522 |
-
'
|
523 |
-
'
|
524 |
-
'
|
525 |
-
'
|
526 |
-
'
|
527 |
-
'
|
528 |
-
'
|
529 |
-
'
|
530 |
-
'
|
531 |
-
'
|
532 |
-
'
|
533 |
-
'
|
534 |
-
'
|
535 |
-
'
|
536 |
-
'
|
537 |
-
'
|
538 |
-
'
|
539 |
-
'
|
540 |
-
'
|
541 |
-
'
|
542 |
-
'
|
543 |
-
'
|
544 |
-
'
|
545 |
-
'
|
546 |
-
'
|
547 |
-
'
|
548 |
-
'
|
549 |
-
'
|
550 |
-
'
|
551 |
-
'
|
552 |
-
'
|
553 |
-
'
|
554 |
-
'
|
555 |
-
'
|
556 |
-
'
|
557 |
-
'
|
558 |
-
'
|
559 |
-
'
|
560 |
-
'
|
561 |
-
'
|
562 |
-
'
|
563 |
-
'
|
564 |
-
'
|
565 |
-
'
|
566 |
-
'
|
567 |
-
'
|
568 |
-
'
|
569 |
-
'
|
570 |
-
'
|
571 |
-
'
|
572 |
-
'
|
573 |
-
'
|
574 |
-
'
|
575 |
-
'
|
576 |
-
'
|
577 |
-
'
|
578 |
-
'
|
579 |
-
'
|
580 |
-
'
|
581 |
-
'
|
582 |
-
'
|
583 |
-
'
|
584 |
-
'
|
585 |
-
'
|
586 |
-
'
|
587 |
-
'
|
588 |
-
'
|
589 |
-
'
|
590 |
-
'
|
591 |
-
'
|
592 |
-
'
|
593 |
-
'
|
594 |
-
'
|
595 |
-
'
|
596 |
-
'
|
597 |
-
'
|
598 |
-
'
|
599 |
-
'
|
600 |
-
'
|
601 |
-
'
|
602 |
-
'
|
603 |
-
'
|
604 |
-
'
|
605 |
-
'
|
606 |
-
'
|
607 |
-
'
|
608 |
-
'
|
609 |
-
'
|
610 |
-
'
|
611 |
-
'
|
612 |
-
'
|
613 |
-
'
|
614 |
-
'
|
615 |
-
'
|
616 |
-
'
|
617 |
-
'
|
618 |
-
'
|
619 |
-
'
|
620 |
-
'
|
621 |
-
'
|
622 |
-
'
|
623 |
-
'
|
624 |
-
'
|
625 |
-
'
|
626 |
-
'
|
627 |
-
'
|
628 |
-
'
|
629 |
-
'
|
630 |
-
'
|
631 |
-
'
|
632 |
-
'
|
633 |
-
'
|
634 |
-
'
|
635 |
-
'
|
636 |
-
'
|
637 |
-
'
|
638 |
-
'
|
639 |
-
'
|
640 |
-
'
|
641 |
-
'
|
642 |
-
'
|
643 |
-
'
|
644 |
-
'
|
645 |
-
'
|
646 |
-
'
|
647 |
-
'
|
648 |
-
'
|
649 |
-
'
|
650 |
-
'
|
651 |
-
'
|
652 |
-
'
|
653 |
-
'
|
654 |
-
'
|
655 |
-
'
|
656 |
-
'
|
657 |
-
'
|
658 |
-
'
|
659 |
-
'
|
660 |
-
'
|
661 |
-
'
|
662 |
-
'
|
663 |
-
'
|
664 |
-
'
|
665 |
-
'
|
666 |
-
'
|
667 |
-
'
|
668 |
-
'
|
669 |
-
'
|
670 |
-
'
|
671 |
-
'
|
672 |
-
'
|
673 |
-
'
|
674 |
-
'
|
675 |
-
'
|
676 |
-
'
|
677 |
-
'
|
678 |
-
'
|
679 |
-
'
|
680 |
-
'
|
681 |
-
'
|
682 |
-
'
|
683 |
-
'
|
684 |
-
'
|
685 |
-
'
|
686 |
-
'
|
687 |
-
'
|
688 |
-
'
|
689 |
-
'
|
690 |
-
'
|
691 |
-
'
|
692 |
-
'
|
693 |
-
'
|
694 |
-
'
|
695 |
-
'
|
696 |
-
'
|
697 |
-
'
|
698 |
-
'
|
699 |
-
'
|
700 |
-
'
|
701 |
-
'
|
702 |
-
'
|
703 |
-
'
|
704 |
-
'
|
705 |
-
'
|
706 |
-
'
|
707 |
-
'
|
708 |
-
'
|
709 |
-
'
|
710 |
-
'
|
711 |
-
'
|
712 |
-
'
|
713 |
-
'
|
714 |
-
'
|
715 |
-
'
|
716 |
-
'
|
717 |
-
'
|
718 |
-
'
|
719 |
-
'
|
720 |
-
'
|
721 |
-
'
|
722 |
-
'
|
723 |
-
'
|
724 |
-
'
|
725 |
-
'
|
726 |
-
'
|
727 |
-
'
|
728 |
-
'
|
729 |
-
'
|
730 |
-
'
|
731 |
-
'
|
732 |
-
'
|
733 |
-
'
|
734 |
-
'
|
735 |
-
'
|
736 |
-
'
|
737 |
-
'
|
738 |
-
'
|
739 |
-
'
|
740 |
-
'
|
741 |
-
'
|
742 |
-
'
|
743 |
-
'
|
744 |
-
'
|
745 |
-
'
|
746 |
-
'
|
747 |
-
'
|
748 |
-
'
|
749 |
-
'
|
750 |
-
'
|
751 |
-
'
|
752 |
-
'
|
753 |
-
'
|
754 |
-
'
|
755 |
-
'
|
756 |
-
'
|
757 |
-
'
|
758 |
-
'
|
759 |
-
'
|
760 |
-
'
|
761 |
-
'
|
762 |
-
'
|
763 |
-
'
|
764 |
-
'
|
765 |
-
'
|
766 |
-
'
|
767 |
-
'
|
768 |
-
'
|
769 |
-
'
|
770 |
-
'
|
771 |
-
'
|
772 |
-
'
|
773 |
-
'
|
774 |
-
'
|
775 |
-
'
|
776 |
-
'
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
'
|
796 |
-
'
|
797 |
-
'
|
798 |
-
'
|
799 |
-
|
800 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Functions file
|
4 |
+
*
|
5 |
+
* @package Redirection for Contact Form 7
|
6 |
+
* @category Contact Form 7 Add-on
|
7 |
+
* @author Query Solutions
|
8 |
+
* @version 0.1.0
|
9 |
+
*/
|
10 |
+
|
11 |
+
defined( 'ABSPATH' ) || exit;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Get the list of available Extensions
|
15 |
+
*
|
16 |
+
* @return array - $extensions - extensions array.
|
17 |
+
*/
|
18 |
+
function wpcf7_get_extensions() {
|
19 |
+
$extensions = wpcf7_redirect_get_all_extensions_list();
|
20 |
+
|
21 |
+
$installed_extensions = wpcf7r_get_available_actions();
|
22 |
+
|
23 |
+
foreach ( $extensions as $key => $extension ) {
|
24 |
+
foreach ( $installed_extensions as $installed_extension ) {
|
25 |
+
if ( class_exists( $extension['classname'] ) || $installed_extension['handler'] === $extension['classname'] || ( isset( $extension['type'] ) && 'affiliate' === $extension['type'] ) ) {
|
26 |
+
$extensions[ $key ]['active'] = true;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
return apply_filters( 'wpcf7_get_extensions', $extensions );
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Verify nonce
|
36 |
+
*
|
37 |
+
* @return void
|
38 |
+
*/
|
39 |
+
function wpcf7_validate_nonce() {
|
40 |
+
$nonce = isset( $_REQUEST['wpcf7r_nonce'] ) && $_REQUEST['wpcf7r_nonce'] ? $_REQUEST['wpcf7r_nonce'] : '';
|
41 |
+
|
42 |
+
$verified = wp_verify_nonce( $nonce , 'manage_cf7_redirect');
|
43 |
+
|
44 |
+
if ( $verified ) {
|
45 |
+
return $verified;
|
46 |
+
}
|
47 |
+
|
48 |
+
header( 'HTTP/1.0 403 Forbidden' );
|
49 |
+
die( 'You are not allowed to access.' );
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Get all available extensions definitions.
|
55 |
+
*
|
56 |
+
* @return void
|
57 |
+
*/
|
58 |
+
function wpcf7_redirect_get_all_extensions_list() {
|
59 |
+
$defaults = array(
|
60 |
+
// 'special-offer' => array(
|
61 |
+
// 'name' => 'accessibie-plugin',
|
62 |
+
// 'title' => __( 'Website Accessibility', 'wpcf7-redirect' ),
|
63 |
+
// 'description' => __( 'Get an immediate and accurate answer to whether or not your site is compliant with web accessibility legislation for free!', 'wpcf7-redirect' ),
|
64 |
+
// 'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/accessibe-full-logo.svg',
|
65 |
+
// 'external_url' => admin_url( '/admin.php?page=' . qs_get_plugin_display_name() ),
|
66 |
+
// 'btn_text' => __( 'Scan for Problems!', 'wpcf7-redirect' ),
|
67 |
+
// 'type' => 'affiliate',
|
68 |
+
// 'target' => '',
|
69 |
+
// 'badge' => __( 'New', 'wpcf7-redirect' ),
|
70 |
+
// 'classname' => '',
|
71 |
+
// ),
|
72 |
+
'wpcf7r-conditional-logic' => array(
|
73 |
+
'name' => 'wpcf7r-conditional-logic',
|
74 |
+
'filename' => 'class-wpcf7r-conditions.php',
|
75 |
+
'title' => __( 'Conditional Logic', 'wpcf7-redirect' ),
|
76 |
+
'description' => __( 'Powerful conditional rules management. Set if/or rules for each of your actions.', 'wpcf7-redirect' ),
|
77 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/icon7.png',
|
78 |
+
'classname' => 'WPCF7_Redirect_Conditional_Logic',
|
79 |
+
),
|
80 |
+
'wpcf7r-create-pdf' => array(
|
81 |
+
'name' => 'wpcf7r-create-pdf',
|
82 |
+
'filename' => 'class-wpcf7r-create-pdf',
|
83 |
+
'title' => __( 'Create PDF', 'wpcf7-redirect' ),
|
84 |
+
'description' => __( 'Easily create and send PDF files generated automaticaly.', 'wpcf7-redirect' ),
|
85 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/pdf-icon.png',
|
86 |
+
'classname' => 'WPCF7R_Action_Create_pdf',
|
87 |
+
),
|
88 |
+
'wpcf7r-paypal' => array(
|
89 |
+
'name' => 'wpcf7r-paypal',
|
90 |
+
'filename' => 'class-wpcf7r-action-paypal.php',
|
91 |
+
'title' => __( 'PayPal Integration', 'wpcf7-redirect' ),
|
92 |
+
'description' => __( 'Collect payments with your Contact Form 7 form. Setup product details and custom paypal fields.', 'wpcf7-redirect' ),
|
93 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/paypal.png',
|
94 |
+
'classname' => 'WPCF7R_Action_redirect_to_paypal',
|
95 |
+
),
|
96 |
+
'wpcf7r-stripe' => array(
|
97 |
+
'name' => 'wpcf7r-stripe',
|
98 |
+
'filename' => 'class-wpcf7r-stripe.php',
|
99 |
+
'title' => __( 'Stripe Integration', 'wpcf7-redirect' ),
|
100 |
+
'description' => __( 'Collect payments with your Contact Form 7 form. Setup product details and custom stripe fields.', 'wpcf7-redirect' ),
|
101 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/stripe.png',
|
102 |
+
'classname' => 'WPCF7R_Action_Stripe_Integration',
|
103 |
+
),
|
104 |
+
'wpcf7r-api' => array(
|
105 |
+
'name' => 'wpcf7r-api',
|
106 |
+
'filename' => 'class-wpcf7r-action-api-url.php',
|
107 |
+
'title' => __( 'API Integrations', 'wpcf7-redirect' ),
|
108 |
+
'description' => __( 'RESTful POST/GET/PUT/DELETE send to remote server (json/xml/params)', 'wpcf7-redirect' ),
|
109 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/icon7.png',
|
110 |
+
'classname' => 'WPCF7R_Action_api_url_request',
|
111 |
+
),
|
112 |
+
'wpcf7r-custom-errors' => array(
|
113 |
+
'name' => 'wpcf7r-custom-errors',
|
114 |
+
'filename' => 'class-wpcf7r-action-custom-errors.php',
|
115 |
+
'title' => __( 'Custom Validations', 'wpcf7-redirect' ),
|
116 |
+
'description' => __( 'Manage your form error messages by defining each field with its own message.', 'wpcf7-redirect' ),
|
117 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/icon11.png',
|
118 |
+
'classname' => 'WPCF7R_Action_custom_errors',
|
119 |
+
),
|
120 |
+
'wpcf7r-popup' => array(
|
121 |
+
'name' => 'wpcf7r-popup',
|
122 |
+
'filename' => 'class-wpcf7r-action-popup.php',
|
123 |
+
'title' => __( 'Thank You Popup', 'wpcf7-redirect' ),
|
124 |
+
'description' => __( 'Display popup message after form submission success.', 'wpcf7-redirect' ),
|
125 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/icon3.png',
|
126 |
+
'classname' => 'WPCF7R_Action_Popup',
|
127 |
+
),
|
128 |
+
'wpcf7r-create-post' => array(
|
129 |
+
'name' => 'wpcf7r-create-post',
|
130 |
+
'filename' => 'class-wpcf7r-action-create-post.php',
|
131 |
+
'title' => __( 'Create Posts', 'wpcf7-redirect' ),
|
132 |
+
'description' => __( 'Create any post with post meta and taxonomy assigments.', 'wpcf7-redirect' ),
|
133 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/icon12.png',
|
134 |
+
'classname' => 'WPCF7R_Action_Create_Post',
|
135 |
+
),
|
136 |
+
'wpcf7r-login' => array(
|
137 |
+
'name' => 'wpcf7r-login',
|
138 |
+
'filename' => 'class-wpcf7r-action-login.php',
|
139 |
+
'title' => __( 'Custom Login Forms', 'wpcf7-redirect' ),
|
140 |
+
'description' => __( 'Create custom login forms.', 'wpcf7-redirect' ),
|
141 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/icon13.png',
|
142 |
+
'classname' => 'WPCF7R_Action_login',
|
143 |
+
),
|
144 |
+
'wpcf7r-register' => array(
|
145 |
+
'name' => 'wpcf7r-register',
|
146 |
+
'filename' => 'class-wpcf7r-action-register.php',
|
147 |
+
'title' => __( 'Custom Registration Forms', 'wpcf7-redirect' ),
|
148 |
+
'description' => __( 'Create registration form instead of WordPress default registration screen.', 'wpcf7-redirect' ),
|
149 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/icon8.png',
|
150 |
+
'classname' => 'WPCF7R_Action_Register',
|
151 |
+
),
|
152 |
+
'wpcf7r-mailchimp' => array(
|
153 |
+
'name' => 'wpcf7r-mailchimp',
|
154 |
+
'filename' => 'class-wpcf7r-action-mailchimp.php',
|
155 |
+
'title' => __( 'Subscribe to Mailchimp', 'wpcf7-redirect' ),
|
156 |
+
'description' => __( 'Subscribe users to Mailchimp. Auto subscribe submitted forms.', 'wpcf7-redirect' ),
|
157 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/icon1.png',
|
158 |
+
'classname' => 'WPCF7R_Action_Mailchimp',
|
159 |
+
),
|
160 |
+
'wpcf7r-salesforce' => array(
|
161 |
+
'name' => 'wpcf7r-salesforce',
|
162 |
+
'filename' => 'class-wpcf7r-action-salesforce.php',
|
163 |
+
'title' => __( 'Salesforce Integration', 'wpcf7-redirect' ),
|
164 |
+
'description' => __( 'Send your leads to Salesforce.', 'wpcf7-redirect' ),
|
165 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/salesforce.png',
|
166 |
+
'classname' => 'WPCF7R_Action_Salesforce',
|
167 |
+
),
|
168 |
+
'wpcf7r-hubspot' => array(
|
169 |
+
'name' => 'wpcf7r-hubspot',
|
170 |
+
'filename' => 'class-wpcf7r-action-hubspot.php',
|
171 |
+
'title' => __( 'Hubspot Integration', 'wpcf7-redirect' ),
|
172 |
+
'description' => __( 'Send your leads to hubspot.', 'wpcf7-redirect' ),
|
173 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/hubspot.png',
|
174 |
+
'classname' => 'WPCF7R_Action_Hubspot',
|
175 |
+
),
|
176 |
+
'wpcf7r-actions-bundle' => array(
|
177 |
+
'name' => 'wpcf7r-actions-bundle',
|
178 |
+
'filename' => 'wpcf7r-action-bundle.php',
|
179 |
+
'title' => __( 'Actions Bundle', 'wpcf7-redirect' ),
|
180 |
+
'description' => __( 'Get it all.', 'wpcf7-redirect' ),
|
181 |
+
'icon' => WPCF7_PRO_REDIRECT_BUILD_PATH . 'images/bundle.png',
|
182 |
+
'classname' => 'WPCF7R_Action_Bundle',
|
183 |
+
),
|
184 |
+
);
|
185 |
+
|
186 |
+
$api = new Qs_Api();
|
187 |
+
|
188 |
+
$extensions_from_api = $api->get_extensions_definitions();
|
189 |
+
|
190 |
+
return $extensions_from_api ? $extensions_from_api : $defaults;
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Get promotion banner
|
195 |
+
*
|
196 |
+
* @return void
|
197 |
+
*/
|
198 |
+
function wpcf7r_get_discount_banner() {
|
199 |
+
$api = new Qs_Api();
|
200 |
+
|
201 |
+
$promotion_banner = $api->get_promotion_banner();
|
202 |
+
|
203 |
+
return $promotion_banner;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Get the promotion banner version.
|
208 |
+
*
|
209 |
+
* @return int - banner version.
|
210 |
+
*/
|
211 |
+
function wpcf7r_get_banner_version() {
|
212 |
+
return get_option( 'wpcf7r_banner_version' );
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Turn file path into base64 file.
|
217 |
+
*
|
218 |
+
* @param [string] $path - the path of the file to encode.
|
219 |
+
* @return string $base64 - encoded file.
|
220 |
+
*/
|
221 |
+
function wpcf7r_base_64_file( $path ) {
|
222 |
+
|
223 |
+
$data = file_get_contents( $path );
|
224 |
+
$base64 = base64_encode( $data );
|
225 |
+
|
226 |
+
return $base64;
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Geberal function for getting form actions
|
231 |
+
*
|
232 |
+
* @param [string] $post_type - the type of the action.
|
233 |
+
* @param [string] $count - how many actions to return.
|
234 |
+
* @param [string] $post_id - the contact form 7 id.
|
235 |
+
* @param [string] $rule_id - the action rule id.
|
236 |
+
* @param [string] $extra_args - extra arguments to filter the results.
|
237 |
+
* @param [bool] $active - active actions or non active actions.
|
238 |
+
*
|
239 |
+
* @return [array] - $actions - an array containing actions posts.
|
240 |
+
*/
|
241 |
+
function wpcf7r_get_actions( $post_type, $count, $post_id, $rule_id, $extra_args, $active ) {
|
242 |
+
$actions = array();
|
243 |
+
|
244 |
+
$args = array(
|
245 |
+
'post_type' => $post_type,
|
246 |
+
'posts_per_page' => $count,
|
247 |
+
'post_status' => 'private',
|
248 |
+
'orderby' => 'menu_order',
|
249 |
+
'order' => 'ASC',
|
250 |
+
'meta_query' => array(
|
251 |
+
array(
|
252 |
+
'key' => 'wpcf7_id',
|
253 |
+
'value' => $post_id,
|
254 |
+
),
|
255 |
+
array(
|
256 |
+
'key' => 'wpcf7_rule_id',
|
257 |
+
'value' => $rule_id,
|
258 |
+
),
|
259 |
+
),
|
260 |
+
);
|
261 |
+
|
262 |
+
$args = array_merge( $args, $extra_args );
|
263 |
+
|
264 |
+
if ( $active ) {
|
265 |
+
$args['meta_query'][] = array(
|
266 |
+
'key' => 'action_status',
|
267 |
+
'value' => 'on',
|
268 |
+
);
|
269 |
+
}
|
270 |
+
|
271 |
+
$actions = get_posts( $args );
|
272 |
+
|
273 |
+
return $actions;
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Check if conditional logic extention is enabled
|
278 |
+
*/
|
279 |
+
function conditional_logic_enabled() {
|
280 |
+
return class_exists( 'WPCF7_Redirect_Conditional_Logic' );
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Serach for the file in the available directories
|
285 |
+
*
|
286 |
+
* @param $filename - the name of the fle to return;
|
287 |
+
* @return [mixed] - path if the file exists/fals if not.
|
288 |
+
*/
|
289 |
+
function wpcf7r_get_addon_path( $filename ) {
|
290 |
+
if ( file_exists( WPCF7_PRO_REDIRECT_ACTIONS_PATH . $filename ) ) {
|
291 |
+
return WPCF7_PRO_REDIRECT_ACTIONS_PATH . $filename;
|
292 |
+
} elseif ( file_exists( WPCF7_PRO_REDIRECT_ADDONS_PATH . $filename ) ) {
|
293 |
+
return WPCF7_PRO_REDIRECT_ADDONS_PATH . $filename;
|
294 |
+
}
|
295 |
+
|
296 |
+
return false;
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Get an array and transform it to html attributes
|
301 |
+
*
|
302 |
+
* @param $attributes
|
303 |
+
*/
|
304 |
+
function wpcf7r_implode_attributes( $attributes ) {
|
305 |
+
$result = join(
|
306 |
+
' ',
|
307 |
+
array_map(
|
308 |
+
function( $key ) use ( $attributes ) {
|
309 |
+
if ( is_bool( $attributes[ $key ] ) ) {
|
310 |
+
return $attributes[ $key ] ? $key : '';
|
311 |
+
}
|
312 |
+
return $key . '="' . $attributes[ $key ] . '"';
|
313 |
+
},
|
314 |
+
array_keys( $attributes )
|
315 |
+
)
|
316 |
+
);
|
317 |
+
|
318 |
+
return $result;
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Send emails as HTML
|
323 |
+
*/
|
324 |
+
function wpcf7r_send_emails_as_html() {
|
325 |
+
return 'text/html';
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
* Helper function
|
330 |
+
*
|
331 |
+
* @param $name
|
332 |
+
* @param $title
|
333 |
+
* @param $class
|
334 |
+
* @param $order
|
335 |
+
*/
|
336 |
+
function register_wpcf7r_actions( $name, $title, $class, $order = 0 ) {
|
337 |
+
WPCF7r_Utils::register_wpcf7r_actions( $name, $title, $class, $order );
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Get a list of available actions
|
342 |
+
*/
|
343 |
+
function wpcf7r_get_available_actions() {
|
344 |
+
$actions = WPCF7r_Utils::get_wpcf7r_actions();
|
345 |
+
|
346 |
+
array_multisort( array_column( $actions, 'order' ), SORT_ASC, $actions );
|
347 |
+
|
348 |
+
return apply_filters( 'wpcf7r_get_available_actions', $actions );
|
349 |
+
}
|
350 |
+
|
351 |
+
/**
|
352 |
+
* Get an instance of contact form 7 redirect form
|
353 |
+
*
|
354 |
+
* @param $form_id
|
355 |
+
* @param $submission
|
356 |
+
* @param $validation_obj
|
357 |
+
*/
|
358 |
+
function get_cf7r_form( $form_id, $submission = '', $validation_obj = '' ) {
|
359 |
+
return new WPCF7R_Form( $form_id, $submission, $validation_obj );
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Create HTML tooltip
|
364 |
+
*
|
365 |
+
* @param $tip
|
366 |
+
*/
|
367 |
+
function cf7r_tooltip( $tip ) {
|
368 |
+
$tip = esc_attr( $tip );
|
369 |
+
|
370 |
+
return '<i class="dashicons dashicons-editor-help qs-tooltip"><span class="qs-tooltip-inner">' . $tip . '</span></i>';
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* Get plugin base url
|
375 |
+
*/
|
376 |
+
function wpcf7r_get_redirect_plugin_url() {
|
377 |
+
return WPCF7_PRO_REDIRECT_BASE_URL;
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Get the value of a single block field
|
382 |
+
*
|
383 |
+
* @param $key
|
384 |
+
* @param $block_key
|
385 |
+
* @param $fields
|
386 |
+
*/
|
387 |
+
function block_field_value( $key, $block_key, $fields ) {
|
388 |
+
return isset( $fields['blocks'][ $block_key ][ $key ] ) ? $fields['blocks'][ $block_key ][ $key ] : '';
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Remove old plugin notice
|
393 |
+
*/
|
394 |
+
function wpcf7_remove_old_plugin_notice() {
|
395 |
+
?>
|
396 |
+
|
397 |
+
<div class="wpcf7-redirect-error error notice">
|
398 |
+
<h3>
|
399 |
+
<?php esc_html_e( 'Redirection for Contact Form 7', 'wpcf7-redirect' ); ?>
|
400 |
+
</h3>
|
401 |
+
<p>
|
402 |
+
<?php esc_html_e( 'Error: It is recommended to deactivate and remove Redirection for Contact Form 7 plugin for the PRO version to work.', 'wpcf7-redirect' ); ?>
|
403 |
+
</p>
|
404 |
+
</div>
|
405 |
+
|
406 |
+
<?php
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* A notice to remove the free plugin
|
411 |
+
*/
|
412 |
+
function wpcf7_remove_contact_form_7_to_api() {
|
413 |
+
?>
|
414 |
+
|
415 |
+
<div class="wpcf7-redirect-error error notice">
|
416 |
+
<h3>
|
417 |
+
<?php esc_html_e( 'Redirection for Contact Form 7', 'wpcf7-redirect' ); ?>
|
418 |
+
</h3>
|
419 |
+
<p>
|
420 |
+
<?php esc_html_e( 'Error: It is recommended to deactivate and remove Contact Form 7 to API plugin.', 'wpcf7-redirect' ); ?>
|
421 |
+
</p>
|
422 |
+
</div>
|
423 |
+
|
424 |
+
<?php
|
425 |
+
}
|
426 |
+
|
427 |
+
/**
|
428 |
+
* Get CF7 version
|
429 |
+
*/
|
430 |
+
function wpcf7_get_cf7_ver() {
|
431 |
+
if ( is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) {
|
432 |
+
$wpcf7_path = WPCF7_PRO_REDIRECT_PLUGINS_PATH . 'contact-form-7/wp-contact-form-7.php';
|
433 |
+
$wpcf7_data = get_plugin_data( $wpcf7_path, false, false );
|
434 |
+
|
435 |
+
return $wpcf7_data['Version'];
|
436 |
+
}
|
437 |
+
|
438 |
+
return false;
|
439 |
+
}
|
440 |
+
|
441 |
+
/**
|
442 |
+
* Show admin notices
|
443 |
+
*/
|
444 |
+
function wpcf7r_admin_notice() {
|
445 |
+
$ver = wpcf7_get_cf7_ver() ? wpcf7_get_cf7_ver() : '';
|
446 |
+
|
447 |
+
if ( $ver < 4.8 ) {
|
448 |
+
?>
|
449 |
+
|
450 |
+
<div class="wpcf7-redirect-error error notice">
|
451 |
+
<h3>
|
452 |
+
<?php esc_html_e( 'Redirection for Contact Form 7', 'wpcf7-redirect' ); ?>
|
453 |
+
</h3>
|
454 |
+
<p>
|
455 |
+
<?php esc_html_e( 'Error: Contact Form 7 version is too old. Redirection for Contact Form 7 is compatible from version 4.8 and above. Please update Contact Form 7.', 'wpcf7-redirect' ); ?>
|
456 |
+
</p>
|
457 |
+
</div>
|
458 |
+
|
459 |
+
<?php
|
460 |
+
} else {
|
461 |
+
// If CF7 isn't installed and activated, throw an error.
|
462 |
+
?>
|
463 |
+
<div class="wpcf7-redirect-error error notice">
|
464 |
+
<h3>
|
465 |
+
<?php esc_html_e( 'Contact Form Redirection', 'wpcf7-redirect' ); ?>
|
466 |
+
</h3>
|
467 |
+
<p>
|
468 |
+
<?php esc_html_e( 'Error: Please install and activate Contact Form 7.', 'wpcf7-redirect' ); ?>
|
469 |
+
</p>
|
470 |
+
</div>
|
471 |
+
|
472 |
+
<?php
|
473 |
+
}
|
474 |
+
}
|
475 |
+
|
476 |
+
add_shortcode( 'qs_date', 'qs_date' );
|
477 |
+
|
478 |
+
/**
|
479 |
+
* Shortcode for creating date
|
480 |
+
*/
|
481 |
+
function qs_date( $atts ) {
|
482 |
+
$atts = shortcode_atts(
|
483 |
+
array(
|
484 |
+
'format' => 'Ydm',
|
485 |
+
),
|
486 |
+
$atts,
|
487 |
+
'wpcf7-redirect'
|
488 |
+
);
|
489 |
+
|
490 |
+
return gmdate( $atts['format'], time() );
|
491 |
+
}
|
492 |
+
|
493 |
+
/**
|
494 |
+
* Check if WPCF7 Debug
|
495 |
+
*
|
496 |
+
* @return [boolean]
|
497 |
+
*/
|
498 |
+
function is_wpcf7r_debug() {
|
499 |
+
return defined( 'CF7_REDIRECT_DEBUG' ) && CF7_REDIRECT_DEBUG ? true : false;
|
500 |
+
}
|
501 |
+
|
502 |
+
/**
|
503 |
+
* Check if the current page is the edit contact form 7 page.
|
504 |
+
*
|
505 |
+
* @return [boolean] - true if this is the edit screen.
|
506 |
+
*/
|
507 |
+
function wpcf7r_is_wpcf7_edit() {
|
508 |
+
global $post;
|
509 |
+
|
510 |
+
$wpcf7_page = isset( $_GET['page'] ) && 'wpcf7' === $_GET['page'] && isset( $_GET['post'] ) && $_GET['post'];
|
511 |
+
$wpcf7_page_new_page = isset( $_GET['page'] ) && 'wpcf7-new' === $_GET['page'];
|
512 |
+
$wpcf7_post = isset( $post->post_type ) && 'wpcf7_contact_form' === $post->post_type ? true : false;
|
513 |
+
|
514 |
+
return $wpcf7_page_new_page || $wpcf7_page || $wpcf7_post;
|
515 |
+
}
|
516 |
+
/**
|
517 |
+
* Get an array of available countries
|
518 |
+
*/
|
519 |
+
function wpcf73_get_country_list() {
|
520 |
+
$country_array = array(
|
521 |
+
'AF' => __( 'Afghanistan', 'wpcf7-redirect' ),
|
522 |
+
'AL' => __( 'Albania', 'wpcf7-redirect' ),
|
523 |
+
'DZ' => __( 'Algeria', 'wpcf7-redirect' ),
|
524 |
+
'AS' => __( 'American Samoa', 'wpcf7-redirect' ),
|
525 |
+
'AD' => __( 'Andorra', 'wpcf7-redirect' ),
|
526 |
+
'AO' => __( 'Angola', 'wpcf7-redirect' ),
|
527 |
+
'AI' => __( 'Anguilla', 'wpcf7-redirect' ),
|
528 |
+
'AQ' => __( 'Antarctica', 'wpcf7-redirect' ),
|
529 |
+
'AG' => __( 'Antigua and Barbuda', 'wpcf7-redirect' ),
|
530 |
+
'AR' => __( 'Argentina', 'wpcf7-redirect' ),
|
531 |
+
'AM' => __( 'Armenia', 'wpcf7-redirect' ),
|
532 |
+
'AW' => __( 'Aruba', 'wpcf7-redirect' ),
|
533 |
+
'AU' => __( 'Australia', 'wpcf7-redirect' ),
|
534 |
+
'AT' => __( 'Austria', 'wpcf7-redirect' ),
|
535 |
+
'AZ' => __( 'Azerbaijan', 'wpcf7-redirect' ),
|
536 |
+
'BS' => __( 'Bahamas', 'wpcf7-redirect' ),
|
537 |
+
'BH' => __( 'Bahrain', 'wpcf7-redirect' ),
|
538 |
+
'BD' => __( 'Bangladesh', 'wpcf7-redirect' ),
|
539 |
+
'BB' => __( 'Barbados', 'wpcf7-redirect' ),
|
540 |
+
'BY' => __( 'Belarus', 'wpcf7-redirect' ),
|
541 |
+
'BE' => __( 'Belgium', 'wpcf7-redirect' ),
|
542 |
+
'BZ' => __( 'Belize', 'wpcf7-redirect' ),
|
543 |
+
'BJ' => __( 'Benin', 'wpcf7-redirect' ),
|
544 |
+
'BM' => __( 'Bermuda', 'wpcf7-redirect' ),
|
545 |
+
'BT' => __( 'Bhutan', 'wpcf7-redirect' ),
|
546 |
+
'BO' => __( 'Bolivia', 'wpcf7-redirect' ),
|
547 |
+
'BA' => __( 'Bosnia and Herzegovina', 'wpcf7-redirect' ),
|
548 |
+
'BW' => __( 'Botswana', 'wpcf7-redirect' ),
|
549 |
+
'BV' => __( 'Bouvet Island', 'wpcf7-redirect' ),
|
550 |
+
'BR' => __( 'Brazil', 'wpcf7-redirect' ),
|
551 |
+
'BQ' => __( 'British Antarctic Territory', 'wpcf7-redirect' ),
|
552 |
+
'IO' => __( 'British Indian Ocean Territory', 'wpcf7-redirect' ),
|
553 |
+
'VG' => __( 'British Virgin Islands', 'wpcf7-redirect' ),
|
554 |
+
'BN' => __( 'Brunei', 'wpcf7-redirect' ),
|
555 |
+
'BG' => __( 'Bulgaria', 'wpcf7-redirect' ),
|
556 |
+
'BF' => __( 'Burkina Faso', 'wpcf7-redirect' ),
|
557 |
+
'BI' => __( 'Burundi', 'wpcf7-redirect' ),
|
558 |
+
'KH' => __( 'Cambodia', 'wpcf7-redirect' ),
|
559 |
+
'CM' => __( 'Cameroon', 'wpcf7-redirect' ),
|
560 |
+
'CA' => __( 'Canada', 'wpcf7-redirect' ),
|
561 |
+
'CT' => __( 'Canton and Enderbury Islands', 'wpcf7-redirect' ),
|
562 |
+
'CV' => __( 'Cape Verde', 'wpcf7-redirect' ),
|
563 |
+
'KY' => __( 'Cayman Islands', 'wpcf7-redirect' ),
|
564 |
+
'CF' => __( 'Central African Republic', 'wpcf7-redirect' ),
|
565 |
+
'TD' => __( 'Chad', 'wpcf7-redirect' ),
|
566 |
+
'CL' => __( 'Chile', 'wpcf7-redirect' ),
|
567 |
+
'CN' => __( 'China', 'wpcf7-redirect' ),
|
568 |
+
'CX' => __( 'Christmas Island', 'wpcf7-redirect' ),
|
569 |
+
'CC' => __( 'Cocos [Keeling] Islands', 'wpcf7-redirect' ),
|
570 |
+
'CO' => __( 'Colombia', 'wpcf7-redirect' ),
|
571 |
+
'KM' => __( 'Comoros', 'wpcf7-redirect' ),
|
572 |
+
'CG' => __( 'Congo - Brazzaville', 'wpcf7-redirect' ),
|
573 |
+
'CD' => __( 'Congo - Kinshasa', 'wpcf7-redirect' ),
|
574 |
+
'CK' => __( 'Cook Islands', 'wpcf7-redirect' ),
|
575 |
+
'CR' => __( 'Costa Rica', 'wpcf7-redirect' ),
|
576 |
+
'HR' => __( 'Croatia', 'wpcf7-redirect' ),
|
577 |
+
'CU' => __( 'Cuba', 'wpcf7-redirect' ),
|
578 |
+
'CY' => __( 'Cyprus', 'wpcf7-redirect' ),
|
579 |
+
'CZ' => __( 'Czech Republic', 'wpcf7-redirect' ),
|
580 |
+
'CI' => __( 'Côte d’Ivoire', 'wpcf7-redirect' ),
|
581 |
+
'DK' => __( 'Denmark', 'wpcf7-redirect' ),
|
582 |
+
'DJ' => __( 'Djibouti', 'wpcf7-redirect' ),
|
583 |
+
'DM' => __( 'Dominica', 'wpcf7-redirect' ),
|
584 |
+
'DO' => __( 'Dominican Republic', 'wpcf7-redirect' ),
|
585 |
+
'NQ' => __( 'Dronning Maud Land', 'wpcf7-redirect' ),
|
586 |
+
'DD' => __( 'East Germany', 'wpcf7-redirect' ),
|
587 |
+
'EC' => __( 'Ecuador', 'wpcf7-redirect' ),
|
588 |
+
'EG' => __( 'Egypt', 'wpcf7-redirect' ),
|
589 |
+
'SV' => __( 'El Salvador', 'wpcf7-redirect' ),
|
590 |
+
'GQ' => __( 'Equatorial Guinea', 'wpcf7-redirect' ),
|
591 |
+
'ER' => __( 'Eritrea', 'wpcf7-redirect' ),
|
592 |
+
'EE' => __( 'Estonia', 'wpcf7-redirect' ),
|
593 |
+
'ET' => __( 'Ethiopia', 'wpcf7-redirect' ),
|
594 |
+
'FK' => __( 'Falkland Islands', 'wpcf7-redirect' ),
|
595 |
+
'FO' => __( 'Faroe Islands', 'wpcf7-redirect' ),
|
596 |
+
'FJ' => __( 'Fiji', 'wpcf7-redirect' ),
|
597 |
+
'FI' => __( 'Finland', 'wpcf7-redirect' ),
|
598 |
+
'FR' => __( 'France', 'wpcf7-redirect' ),
|
599 |
+
'GF' => __( 'French Guiana', 'wpcf7-redirect' ),
|
600 |
+
'PF' => __( 'French Polynesia', 'wpcf7-redirect' ),
|
601 |
+
'TF' => __( 'French Southern Territories', 'wpcf7-redirect' ),
|
602 |
+
'FQ' => __( 'French Southern and Antarctic Territories', 'wpcf7-redirect' ),
|
603 |
+
'GA' => __( 'Gabon', 'wpcf7-redirect' ),
|
604 |
+
'GM' => __( 'Gambia', 'wpcf7-redirect' ),
|
605 |
+
'GE' => __( 'Georgia', 'wpcf7-redirect' ),
|
606 |
+
'DE' => __( 'Germany', 'wpcf7-redirect' ),
|
607 |
+
'GH' => __( 'Ghana', 'wpcf7-redirect' ),
|
608 |
+
'GI' => __( 'Gibraltar', 'wpcf7-redirect' ),
|
609 |
+
'GR' => __( 'Greece', 'wpcf7-redirect' ),
|
610 |
+
'GL' => __( 'Greenland', 'wpcf7-redirect' ),
|
611 |
+
'GD' => __( 'Grenada', 'wpcf7-redirect' ),
|
612 |
+
'GP' => __( 'Guadeloupe', 'wpcf7-redirect' ),
|
613 |
+
'GU' => __( 'Guam', 'wpcf7-redirect' ),
|
614 |
+
'GT' => __( 'Guatemala', 'wpcf7-redirect' ),
|
615 |
+
'GG' => __( 'Guernsey', 'wpcf7-redirect' ),
|
616 |
+
'GN' => __( 'Guinea', 'wpcf7-redirect' ),
|
617 |
+
'GW' => __( 'Guinea-Bissau', 'wpcf7-redirect' ),
|
618 |
+
'GY' => __( 'Guyana', 'wpcf7-redirect' ),
|
619 |
+
'HT' => __( 'Haiti', 'wpcf7-redirect' ),
|
620 |
+
'HM' => __( 'Heard Island and McDonald Islands', 'wpcf7-redirect' ),
|
621 |
+
'HN' => __( 'Honduras', 'wpcf7-redirect' ),
|
622 |
+
'HK' => __( 'Hong Kong SAR China', 'wpcf7-redirect' ),
|
623 |
+
'HU' => __( 'Hungary', 'wpcf7-redirect' ),
|
624 |
+
'IS' => __( 'Iceland', 'wpcf7-redirect' ),
|
625 |
+
'IN' => __( 'India', 'wpcf7-redirect' ),
|
626 |
+
'ID' => __( 'Indonesia', 'wpcf7-redirect' ),
|
627 |
+
'IR' => __( 'Iran', 'wpcf7-redirect' ),
|
628 |
+
'IQ' => __( 'Iraq', 'wpcf7-redirect' ),
|
629 |
+
'IE' => __( 'Ireland', 'wpcf7-redirect' ),
|
630 |
+
'IM' => __( 'Isle of Man', 'wpcf7-redirect' ),
|
631 |
+
'IL' => __( 'Israel', 'wpcf7-redirect' ),
|
632 |
+
'IT' => __( 'Italy', 'wpcf7-redirect' ),
|
633 |
+
'JM' => __( 'Jamaica', 'wpcf7-redirect' ),
|
634 |
+
'JP' => __( 'Japan', 'wpcf7-redirect' ),
|
635 |
+
'JE' => __( 'Jersey', 'wpcf7-redirect' ),
|
636 |
+
'JT' => __( 'Johnston Island', 'wpcf7-redirect' ),
|
637 |
+
'JO' => __( 'Jordan', 'wpcf7-redirect' ),
|
638 |
+
'KZ' => __( 'Kazakhstan', 'wpcf7-redirect' ),
|
639 |
+
'KE' => __( 'Kenya', 'wpcf7-redirect' ),
|
640 |
+
'KI' => __( 'Kiribati', 'wpcf7-redirect' ),
|
641 |
+
'KW' => __( 'Kuwait', 'wpcf7-redirect' ),
|
642 |
+
'KG' => __( 'Kyrgyzstan', 'wpcf7-redirect' ),
|
643 |
+
'LA' => __( 'Laos', 'wpcf7-redirect' ),
|
644 |
+
'LV' => __( 'Latvia', 'wpcf7-redirect' ),
|
645 |
+
'LB' => __( 'Lebanon', 'wpcf7-redirect' ),
|
646 |
+
'LS' => __( 'Lesotho', 'wpcf7-redirect' ),
|
647 |
+
'LR' => __( 'Liberia', 'wpcf7-redirect' ),
|
648 |
+
'LY' => __( 'Libya', 'wpcf7-redirect' ),
|
649 |
+
'LI' => __( 'Liechtenstein', 'wpcf7-redirect' ),
|
650 |
+
'LT' => __( 'Lithuania', 'wpcf7-redirect' ),
|
651 |
+
'LU' => __( 'Luxembourg', 'wpcf7-redirect' ),
|
652 |
+
'MO' => __( 'Macau SAR China', 'wpcf7-redirect' ),
|
653 |
+
'MK' => __( 'Macedonia', 'wpcf7-redirect' ),
|
654 |
+
'MG' => __( 'Madagascar', 'wpcf7-redirect' ),
|
655 |
+
'MW' => __( 'Malawi', 'wpcf7-redirect' ),
|
656 |
+
'MY' => __( 'Malaysia', 'wpcf7-redirect' ),
|
657 |
+
'MV' => __( 'Maldives', 'wpcf7-redirect' ),
|
658 |
+
'ML' => __( 'Mali', 'wpcf7-redirect' ),
|
659 |
+
'MT' => __( 'Malta', 'wpcf7-redirect' ),
|
660 |
+
'MH' => __( 'Marshall Islands', 'wpcf7-redirect' ),
|
661 |
+
'MQ' => __( 'Martinique', 'wpcf7-redirect' ),
|
662 |
+
'MR' => __( 'Mauritania', 'wpcf7-redirect' ),
|
663 |
+
'MU' => __( 'Mauritius', 'wpcf7-redirect' ),
|
664 |
+
'YT' => __( 'Mayotte', 'wpcf7-redirect' ),
|
665 |
+
'FX' => __( 'Metropolitan France', 'wpcf7-redirect' ),
|
666 |
+
'MX' => __( 'Mexico', 'wpcf7-redirect' ),
|
667 |
+
'FM' => __( 'Micronesia', 'wpcf7-redirect' ),
|
668 |
+
'MI' => __( 'Midway Islands', 'wpcf7-redirect' ),
|
669 |
+
'MD' => __( 'Moldova', 'wpcf7-redirect' ),
|
670 |
+
'MC' => __( 'Monaco', 'wpcf7-redirect' ),
|
671 |
+
'MN' => __( 'Mongolia', 'wpcf7-redirect' ),
|
672 |
+
'ME' => __( 'Montenegro', 'wpcf7-redirect' ),
|
673 |
+
'MS' => __( 'Montserrat', 'wpcf7-redirect' ),
|
674 |
+
'MA' => __( 'Morocco', 'wpcf7-redirect' ),
|
675 |
+
'MZ' => __( 'Mozambique', 'wpcf7-redirect' ),
|
676 |
+
'MM' => __( 'Myanmar [Burma]', 'wpcf7-redirect' ),
|
677 |
+
'NA' => __( 'Namibia', 'wpcf7-redirect' ),
|
678 |
+
'NR' => __( 'Nauru', 'wpcf7-redirect' ),
|
679 |
+
'NP' => __( 'Nepal', 'wpcf7-redirect' ),
|
680 |
+
'NL' => __( 'Netherlands', 'wpcf7-redirect' ),
|
681 |
+
'AN' => __( 'Netherlands Antilles', 'wpcf7-redirect' ),
|
682 |
+
'NT' => __( 'Neutral Zone', 'wpcf7-redirect' ),
|
683 |
+
'NC' => __( 'New Caledonia', 'wpcf7-redirect' ),
|
684 |
+
'NZ' => __( 'New Zealand', 'wpcf7-redirect' ),
|
685 |
+
'NI' => __( 'Nicaragua', 'wpcf7-redirect' ),
|
686 |
+
'NE' => __( 'Niger', 'wpcf7-redirect' ),
|
687 |
+
'NG' => __( 'Nigeria', 'wpcf7-redirect' ),
|
688 |
+
'NU' => __( 'Niue', 'wpcf7-redirect' ),
|
689 |
+
'NF' => __( 'Norfolk Island', 'wpcf7-redirect' ),
|
690 |
+
'KP' => __( 'North Korea', 'wpcf7-redirect' ),
|
691 |
+
'VD' => __( 'North Vietnam', 'wpcf7-redirect' ),
|
692 |
+
'MP' => __( 'Northern Mariana Islands', 'wpcf7-redirect' ),
|
693 |
+
'NO' => __( 'Norway', 'wpcf7-redirect' ),
|
694 |
+
'OM' => __( 'Oman', 'wpcf7-redirect' ),
|
695 |
+
'PC' => __( 'Pacific Islands Trust Territory', 'wpcf7-redirect' ),
|
696 |
+
'PK' => __( 'Pakistan', 'wpcf7-redirect' ),
|
697 |
+
'PW' => __( 'Palau', 'wpcf7-redirect' ),
|
698 |
+
'PS' => __( 'Palestinian Territories', 'wpcf7-redirect' ),
|
699 |
+
'PA' => __( 'Panama', 'wpcf7-redirect' ),
|
700 |
+
'PZ' => __( 'Panama Canal Zone', 'wpcf7-redirect' ),
|
701 |
+
'PG' => __( 'Papua New Guinea', 'wpcf7-redirect' ),
|
702 |
+
'PY' => __( 'Paraguay', 'wpcf7-redirect' ),
|
703 |
+
'YD' => __( 'Yemen, Democratic', 'wpcf7-redirect' ),
|
704 |
+
'PE' => __( 'Peru', 'wpcf7-redirect' ),
|
705 |
+
'PH' => __( 'Philippines', 'wpcf7-redirect' ),
|
706 |
+
'PN' => __( 'Pitcairn Islands', 'wpcf7-redirect' ),
|
707 |
+
'PL' => __( 'Poland', 'wpcf7-redirect' ),
|
708 |
+
'PT' => __( 'Portugal', 'wpcf7-redirect' ),
|
709 |
+
'PR' => __( 'Puerto Rico', 'wpcf7-redirect' ),
|
710 |
+
'QA' => __( 'Qatar', 'wpcf7-redirect' ),
|
711 |
+
'RO' => __( 'Romania', 'wpcf7-redirect' ),
|
712 |
+
'RU' => __( 'Russia', 'wpcf7-redirect' ),
|
713 |
+
'RW' => __( 'Rwanda', 'wpcf7-redirect' ),
|
714 |
+
'RE' => __( 'Réunion', 'wpcf7-redirect' ),
|
715 |
+
'BL' => __( 'Saint Barthélemy', 'wpcf7-redirect' ),
|
716 |
+
'SH' => __( 'Saint Helena', 'wpcf7-redirect' ),
|
717 |
+
'KN' => __( 'Saint Kitts and Nevis', 'wpcf7-redirect' ),
|
718 |
+
'LC' => __( 'Saint Lucia', 'wpcf7-redirect' ),
|
719 |
+
'MF' => __( 'Saint Martin', 'wpcf7-redirect' ),
|
720 |
+
'PM' => __( 'Saint Pierre and Miquelon', 'wpcf7-redirect' ),
|
721 |
+
'VC' => __( 'Saint Vincent and the Grenadines', 'wpcf7-redirect' ),
|
722 |
+
'WS' => __( 'Samoa', 'wpcf7-redirect' ),
|
723 |
+
'SM' => __( 'San Marino', 'wpcf7-redirect' ),
|
724 |
+
'SA' => __( 'Saudi Arabia', 'wpcf7-redirect' ),
|
725 |
+
'SN' => __( 'Senegal', 'wpcf7-redirect' ),
|
726 |
+
'RS' => __( 'Serbia', 'wpcf7-redirect' ),
|
727 |
+
'CS' => __( 'Serbia and Montenegro', 'wpcf7-redirect' ),
|
728 |
+
'SC' => __( 'Seychelles', 'wpcf7-redirect' ),
|
729 |
+
'SL' => __( 'Sierra Leone', 'wpcf7-redirect' ),
|
730 |
+
'SG' => __( 'Singapore', 'wpcf7-redirect' ),
|
731 |
+
'SK' => __( 'Slovakia', 'wpcf7-redirect' ),
|
732 |
+
'SI' => __( 'Slovenia', 'wpcf7-redirect' ),
|
733 |
+
'SB' => __( 'Solomon Islands', 'wpcf7-redirect' ),
|
734 |
+
'SO' => __( 'Somalia', 'wpcf7-redirect' ),
|
735 |
+
'ZA' => __( 'South Africa', 'wpcf7-redirect' ),
|
736 |
+
'GS' => __( 'South Georgia and the South Sandwich Islands', 'wpcf7-redirect' ),
|
737 |
+
'KR' => __( 'South Korea', 'wpcf7-redirect' ),
|
738 |
+
'ES' => __( 'Spain', 'wpcf7-redirect' ),
|
739 |
+
'LK' => __( 'Sri Lanka', 'wpcf7-redirect' ),
|
740 |
+
'SD' => __( 'Sudan', 'wpcf7-redirect' ),
|
741 |
+
'SR' => __( 'Suriname', 'wpcf7-redirect' ),
|
742 |
+
'SJ' => __( 'Svalbard and Jan Mayen', 'wpcf7-redirect' ),
|
743 |
+
'SZ' => __( 'Swaziland', 'wpcf7-redirect' ),
|
744 |
+
'SE' => __( 'Sweden', 'wpcf7-redirect' ),
|
745 |
+
'CH' => __( 'Switzerland', 'wpcf7-redirect' ),
|
746 |
+
'SY' => __( 'Syria', 'wpcf7-redirect' ),
|
747 |
+
'ST' => __( 'São Tomé and Príncipe', 'wpcf7-redirect' ),
|
748 |
+
'TW' => __( 'Taiwan', 'wpcf7-redirect' ),
|
749 |
+
'TJ' => __( 'Tajikistan', 'wpcf7-redirect' ),
|
750 |
+
'TZ' => __( 'Tanzania', 'wpcf7-redirect' ),
|
751 |
+
'TH' => __( 'Thailand', 'wpcf7-redirect' ),
|
752 |
+
'TL' => __( 'Timor-Leste', 'wpcf7-redirect' ),
|
753 |
+
'TG' => __( 'Togo', 'wpcf7-redirect' ),
|
754 |
+
'TK' => __( 'Tokelau', 'wpcf7-redirect' ),
|
755 |
+
'TO' => __( 'Tonga', 'wpcf7-redirect' ),
|
756 |
+
'TT' => __( 'Trinidad and Tobago', 'wpcf7-redirect' ),
|
757 |
+
'TN' => __( 'Tunisia', 'wpcf7-redirect' ),
|
758 |
+
'TR' => __( 'Turkey', 'wpcf7-redirect' ),
|
759 |
+
'TM' => __( 'Turkmenistan', 'wpcf7-redirect' ),
|
760 |
+
'TC' => __( 'Turks and Caicos Islands', 'wpcf7-redirect' ),
|
761 |
+
'TV' => __( 'Tuvalu', 'wpcf7-redirect' ),
|
762 |
+
'UM' => __( 'U.S. Minor Outlying Islands', 'wpcf7-redirect' ),
|
763 |
+
'PU' => __( 'U.S. Miscellaneous Pacific Islands', 'wpcf7-redirect' ),
|
764 |
+
'VI' => __( 'U.S. Virgin Islands', 'wpcf7-redirect' ),
|
765 |
+
'UG' => __( 'Uganda', 'wpcf7-redirect' ),
|
766 |
+
'UA' => __( 'Ukraine', 'wpcf7-redirect' ),
|
767 |
+
'SU' => __( 'Union of Soviet Socialist Republics', 'wpcf7-redirect' ),
|
768 |
+
'AE' => __( 'United Arab Emirates', 'wpcf7-redirect' ),
|
769 |
+
'GB' => __( 'United Kingdom', 'wpcf7-redirect' ),
|
770 |
+
'US' => __( 'United States', 'wpcf7-redirect' ),
|
771 |
+
'ZZ' => __( 'Unknown or Invalid Region', 'wpcf7-redirect' ),
|
772 |
+
'UY' => __( 'Uruguay', 'wpcf7-redirect' ),
|
773 |
+
'UZ' => __( 'Uzbekistan', 'wpcf7-redirect' ),
|
774 |
+
'VU' => __( 'Vanuatu', 'wpcf7-redirect' ),
|
775 |
+
'VA' => __( 'Vatican City', 'wpcf7-redirect' ),
|
776 |
+
'VE' => __( 'Venezuela', 'wpcf7-redirect' ),
|
777 |
+
'VN' => __( 'Vietnam', 'wpcf7-redirect' ),
|
778 |
+
'WK' => __( 'Wake Island', 'wpcf7-redirect' ),
|
779 |
+
'WF' => __( 'Wallis and Futuna', 'wpcf7-redirect' ),
|
780 |
+
'EH' => __( 'Western Sahara', 'wpcf7-redirect' ),
|
781 |
+
'YE' => __( 'Yemen', 'wpcf7-redirect' ),
|
782 |
+
'ZM' => __( 'Zambia', 'wpcf7-redirect' ),
|
783 |
+
'ZW' => __( 'Zimbabwe', 'wpcf7-redirect' ),
|
784 |
+
'AX' => __( 'Åland Islands', 'wpcf7-redirect' ),
|
785 |
+
);
|
786 |
+
|
787 |
+
return $country_array;
|
788 |
+
}
|
789 |
+
|
790 |
+
/**
|
791 |
+
* Get a list of languages
|
792 |
+
*/
|
793 |
+
function wpcf7_get_languages_list() {
|
794 |
+
return array(
|
795 |
+
'en' => __( 'American English', 'wpcf7-redirect' ),
|
796 |
+
'ar' => __( 'Arabic', 'wpcf7-redirect' ),
|
797 |
+
'nl' => __( 'Dutch', 'wpcf7-redirect' ),
|
798 |
+
'fr' => __( 'French', 'wpcf7-redirect' ),
|
799 |
+
'de' => __( 'German', 'wpcf7-redirect' ),
|
800 |
+
'he' => __( 'Hebrew', 'wpcf7-redirect' ),
|
801 |
+
'it' => __( 'Italian', 'wpcf7-redirect' ),
|
802 |
+
'ja' => __( 'Japanese', 'wpcf7-redirect' ),
|
803 |
+
'pt' => __( 'Portuguese', 'wpcf7-redirect' ),
|
804 |
+
'ru' => __( 'Russian', 'wpcf7-redirect' ),
|
805 |
+
'es' => __( 'Spanish', 'wpcf7-redirect' ),
|
806 |
+
'tw' => __( 'Twi', 'wpcf7-redirect' ),
|
807 |
+
);
|
808 |
+
}
|