-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcf7-repeatable-fields.php
71 lines (65 loc) · 2.28 KB
/
cf7-repeatable-fields.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
<?php
/**
* Plugin Name: Contact Form 7 - Repeatable Fields
* Plugin URI: https://github.com/felipeelia/cf7-repeatable-fields
* Description: An add-on plugin for Contact Form 7 that adds a repeatable group of fields functionality.
* Version: 2.0.2
* Requires at least: 6.0
* Requires PHP: 7.2
* Requires Plugins: contact-form-7
* Author: Felipe Elia
* Author URI: https://felipeelia.dev/
* Text Domain: cf7-repeatable-fields
* Domain Path: /languages
* License: GPLv2 or later
*
* @package CF7_Repeatable_Fields
*/
defined( 'ABSPATH' ) || exit;
define( 'CF7_REPEATABLE_FIELDS_VERSION', '2.0.2' );
define( 'CF7_REPEATABLE_FIELDS_FILE', __FILE__ );
define( 'CF7_REPEATABLE_FIELDS_DIR', __DIR__ );
/**
* Run after all plugins are loaded. If CF7 is active loads the main class, otherwise show a notice.
*/
function wpcf7_repeatable_fields_init() {
if ( class_exists( 'WPCF7_ContactForm' ) ) {
require CF7_REPEATABLE_FIELDS_DIR . '/class-cf7-repeatable-fields.php';
CF7_Repeatable_Fields::get_instance();
} else {
add_action( 'admin_notices', 'wpcf7_repeatable_fields_admin_notice' );
}
}
add_action( 'plugins_loaded', 'wpcf7_repeatable_fields_init' );
/**
* Notice asking for CF7.
*/
function wpcf7_repeatable_fields_admin_notice() {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
$plugin_info = get_plugin_data( CF7_REPEATABLE_FIELDS_FILE );
?>
<div class="notice notice-error is-dismissible">
<p>
<?php
printf(
/* translators: 1: Plugin name; 2: Contact Form 7 link */
esc_html__( 'In order to %1$s work, %2$s needs to be installed and activated.', 'cf7-repeatable-fields' ),
'<strong>' . esc_html( $plugin_info['Name'] ) . '</strong>',
'<a href="http://contactform7.com/" target="_blank">' . esc_html__( 'Contact Form 7', 'cf7-repeatable-fields' ) . '</a>'
);
$screen = get_current_screen();
if ( 'plugins' !== $screen->id ) {
if ( file_exists( WP_PLUGIN_DIR . '/contact-form-7/wp-contact-form-7.php' ) ) {
$url = 'plugins.php';
} else {
$url = 'plugin-install.php?tab=search&s=Contact+form+7';
}
echo ' <a href="' . esc_url( admin_url( $url ) ) . '">' . esc_html__( 'Do it now?', 'cf7-repeatable-fields' ) . '</a>';
}
?>
</p>
</div>
<?php
}