-
Notifications
You must be signed in to change notification settings - Fork 4
/
select-multiselect-cf7.php
66 lines (57 loc) · 1.97 KB
/
select-multiselect-cf7.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
<?php
/*
Plugin Name: Select and Multi-Select Field for Contact Form 7
Description: This plugin uses jQuery plugin called Select2 for select boxes which allows searching and infinite scrolling for the select boxes option.
Author: Yash Baldawa
Author URI: https://github.com/baldawayash15
Text Domain: yb-sml
Domain Path: /languages
Version: 1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
//Block direct access to the main plugin file.
defined( 'ABSPATH' ) or die();
class YB_Selct_Multiselct_Plugin{
public function __construct(){
add_action( 'plugins_loaded', array( $this, 'yb_load_plugin_textdomain' ) );
if(class_exists('WPCF7')){
$this->yb_plugin_constants();
require_once YB_SM_PATH . 'includes/autoload.php';
}else{
add_action( 'admin_notices', array( $this, 'wpcf7_selct_multiselct_not_active' ) );
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
}
public function yb_load_plugin_textdomain() {
load_plugin_textdomain( 'yb-sml', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/*
register admin notice if contact form 7 is not active.
*/
public function wpcf7_selct_multiselct_not_active(){
?>
<div class="error">
<p>Sorry, but <strong>Contact Form 7 - Select and Multi-Select</strong> requires <strong><a href="//wordpress.org/plugins/contact-form-7/">Contact Form 7</a></strong>.</p>
</div>
<?php
}
/*
set plugin constants
*/
public function yb_plugin_constants(){
if ( ! defined( 'YB_SM_PATH' ) ) {
define( 'YB_SM_PATH', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'YB_SM_URL' ) ) {
define( 'YB_SM_URL', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'YB_SM_BASENAME' ) ) {
define( 'YB_SM_BASENAME', plugin_basename( __FILE__ ) );
}
}
}
// Instantiate the plugin class.
$YB_SM_Plugin = new YB_Selct_Multiselct_Plugin();