forked from libreform/wp-libre-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-libre-form.php
109 lines (88 loc) · 3.16 KB
/
wp-libre-form.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
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
<?php
/**
* Plugin name: WP Libre Form
* Plugin URI: https://github.com/hencca/wp-libre-form
* Description: A minimal HTML form builder for WordPress; made for developers
* Version: 1.4.3
* Author: @anttiviljami
* Author URI: https://github.com/anttiviljami/
* License: GPLv3
* License URI: https://www.gnu.org/licenses/gpl.html
* Text Domain: wp-libre-form
*
* This plugin is a simple html form maker for WordPress.
*/
/** Copyright 2017 Viljami Kuosmanen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 3, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
if ( ! class_exists( 'WP_Libre_Form' ) ) :
define( 'WPLF_VERSION', '1.5.0-beta' );
class WP_Libre_Form {
public static $instance;
public static function init() {
if ( is_null( self::$instance ) ) {
self::$instance = new WP_Libre_Form();
}
return self::$instance;
}
private function __construct() {
require_once 'classes/class-cpt-wplf-form.php';
require_once 'classes/class-cpt-wplf-submission.php';
require_once 'inc/wplf-ajax.php';
// default functionality
require_once 'inc/wplf-form-actions.php';
require_once 'inc/wplf-form-validation.php';
// init our plugin classes
CPT_WPLF_Form::init();
CPT_WPLF_Submission::init();
add_action( 'after_setup_theme', array( $this, 'init_polylang_support' ) );
add_action( 'plugins_loaded', array( $this, 'load_our_textdomain' ) );
// flush rewrites on activation since we have slugs for our cpts
register_activation_hook( __FILE__, array( 'WP_Libre_Form', 'flush_rewrites' ) );
register_deactivation_hook( __FILE__, 'flush_rewrite_rules' );
}
/**
* Plugin activation hook
*/
public static function flush_rewrites() {
CPT_WPLF_Form::register_cpt();
CPT_WPLF_Submission::register_cpt();
flush_rewrite_rules();
}
/**
* Load our plugin textdomain
*/
public static function load_our_textdomain() {
$loaded = load_plugin_textdomain( 'wp-libre-form', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
if ( ! $loaded ) {
$loaded = load_muplugin_textdomain( 'wp-libre-form', dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
}
}
/**
* Enable Polylang support
*/
public function init_polylang_support() {
if ( apply_filters( 'wplf_load_polylang', true ) && class_exists( 'Polylang' ) ) {
require_once 'classes/class-wplf-polylang.php';
WPLF_Polylang::init();
}
}
/**
* Public version of wplf_form
*/
public function wplf_form( $id, $content = '', $xclass = '' ) {
return CPT_WPLF_Form::wplf_form( $id, $content, $xclass );
}
}
endif;
// init the plugin
WP_Libre_Form::init();