-
Notifications
You must be signed in to change notification settings - Fork 2
/
podio-webforms.php
70 lines (61 loc) · 2.29 KB
/
podio-webforms.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
<?php
/*
Plugin Name: Podio Webforms
Plugin URI: https://wordpress.org/plugins/podio-webforms/
Description: Easily add your Podio Webforms anywhere in WordPress via shortcode. Don't worry about all that Podio Webform code, and you don't have to switch to the HTML Editor to paste anything. Just go to your Podio app's webform page and find your code (no need to copy and paste). Look at the code and find the https://podio.com/webforms/<strong>9876543/123456</strong>.js part, and create a shortcode like this: <strong>[podioform appid='9876543' formid='123456']</strong>. <em>That's it.</em> Optionally, can add [podioform ... showfooter='no'].
Version: 1.2
Author: TourKick (Clifford P)
Author URI: https://tourkick.com/?utm_source=wordpressdotorg&utm_medium=podiowebformsplugin&utm_content=authoruri&utm_campaign=podiowebformsplugin
License: GPL version 3 or any later version
License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/
function pf_podioform( $atts ) {
$defaults = array(
'appid' => '',
'formid' => '',
'showfooter' => 'yes',
'footerlink' => 'https://podio.com/r/enlaREvfxo9M-sl8uX4EtA',
// Cliff's referral link instead of the default https://podio.com
// Feel free to use your own if you wish
);
$atts = shortcode_atts( $defaults, $atts, 'podioform' );
// Only Allow Numbers (Also for protection)
$appid = preg_replace( '/[^0-9]/', '', $atts['appid'] );
$formid = preg_replace( '/[^0-9]/', '', $atts['formid'] );
if (
empty( $appid )
|| empty( $formid )
) {
return '';
}
// footer text
if ( 'yes' === $atts['showfooter'] ) {
$footer = sprintf(
'<div class="podio-webform-container">
A webform by <a href="%s" class="podio-webform-inner" rel="nofollow">Podio</a>
</div>',
esc_url( $atts['footerlink'] )
);
} else {
$footer = '';
}
$noscript = esc_html_x( 'Please fill out the form', 'Message within <noscript>', 'podio-webforms' );
// output
return sprintf(
'<!-- BEGIN Podio web form -->
<script src="https://podio.com/webforms/%1$d/%2$d.js"></script>
<script type="text/javascript">
_podioWebForm.render("%2$d")
</script>
<noscript>
<a href="https://podio.com/webforms/%1$d/%2$d" target="_blank">%3$s</a>
</noscript>
%4$s
<!-- END Podio web form -->',
$appid,
$formid,
$noscript,
$footer
);
}
add_shortcode( 'podioform', 'pf_podioform' );