.
*/
namespace HTML_Forms;
use wpdb;
function _bootstrap() {
load_plugin_textdomain( 'html-forms', '', dirname( __FILE__ ) . '/languages' );
$settings = hf_get_settings();
$forms = new Forms( __FILE__, $settings );
$forms->hook();
// hook actions
$email_action = new Actions\Email();
$email_action->hook();
if( is_admin() ) {
if( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
$admin = new Admin\Admin( __FILE__ );
$admin->hook();
}
}
}
function _install() {
/** @var wpdb */
global $wpdb;
$table = $wpdb->prefix . 'hf_submissions';
$wpdb->query("CREATE TABLE IF NOT EXISTS {$table}(
`id` INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
`form_id` INT UNSIGNED NOT NULL,
`data` TEXT NOT NULL,
`user_agent` TEXT NULL,
`ip_address` VARCHAR(255) NULL,
`referer_url` VARCHAR(255) NULL,
`submitted_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);");
}
define( 'HTML_FORMS_VERSION', '1.0.3' );
if( ! function_exists( 'hf_get_form' ) ) {
require __DIR__ . '/vendor/autoload.php';
}
register_activation_hook( __FILE__, 'HTML_Forms\\_install');
add_action( 'plugins_loaded', 'HTML_Forms\\_bootstrap', 10 );