-
Notifications
You must be signed in to change notification settings - Fork 0
/
embed-pdf-wpforms.php
68 lines (61 loc) · 1.88 KB
/
embed-pdf-wpforms.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
<?php
/**
* Plugin Name: Embed PDF for WPForms
* Plugin URI: https://breakfastco.xyz/embed-pdf-wpforms/
* Description: Add-on for WPForms. Provides a PDF Viewer field.
* Author: Breakfast
* Author URI: https://breakfastco.xyz
* Version: 1.1.3
* License: GPLv3
* Text Domain: embed-pdf-wpforms
*
* @author Corey Salzano <[email protected]>
* @package embed-pdf-wpforms
*/
defined( 'ABSPATH' ) || exit;
if ( ! defined( 'EMBED_PDF_WPFORMS_PATH' ) ) {
define( 'EMBED_PDF_WPFORMS_PATH', __FILE__ );
}
if ( ! defined( 'EMBED_PDF_WPFORMS_VERSION' ) ) {
define( 'EMBED_PDF_WPFORMS_VERSION', '1.1.3' );
}
if ( ! function_exists( 'embed_pdf_wpforms_init' ) ) {
add_action( 'wpforms_loaded', 'embed_pdf_wpforms_init', 5 );
/**
* Loads the plugin files and features.
*
* @return void
*/
function embed_pdf_wpforms_init() {
if ( ! class_exists( 'WPForms_Field' ) ) {
return;
}
require_once dirname( EMBED_PDF_WPFORMS_PATH ) . '/includes/class-wpforms-field-pdf-viewer.php';
new WPForms_Field_PDF_Viewer();
// Add our field type to the list of allowed fields in wpforms_get_form_fields().
add_filter( 'wpforms_get_form_fields_allowed', 'embed_pdf_wpforms_field_types' );
}
/**
* Adds our field type to the list of field types WPForms recognizes as
* valid.
*
* @param array $allowed_form_fields Allow list of field types.
* @return array
*/
function embed_pdf_wpforms_field_types( $allowed_form_fields ) {
$allowed_form_fields[] = 'pdf_viewer';
return $allowed_form_fields;
}
}
if ( ! function_exists( 'embed_pdf_wpforms_load_textdomain' ) ) {
// Add compatibility with language packs.
add_action( 'init', 'embed_pdf_wpforms_load_textdomain' );
/**
* Loads translated strings.
*
* @return void
*/
function embed_pdf_wpforms_load_textdomain() {
load_plugin_textdomain( 'embed-pdf-wpforms', false, dirname( EMBED_PDF_WPFORMS_PATH ) . '/languages' );
}
}