-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-phplist-shortcode-plugin.php
56 lines (46 loc) · 1.7 KB
/
class-phplist-shortcode-plugin.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
<?php
/**
* Plugin Name: PhpList shortcode
* Plugin URI: https://github.com/nfreear/wp-eab-plugins
* Description: Embed a phpList subscribe form, via a WordPress shortcode - [phplist] Intro text... [/phplist]
* Author: Nick Freear
* Author URI: https://github.com/nfreear
* Version: 1.0.0-alpha
*
* @package Nfreear\WP_Plugins
* @license https://nfreear.mit-license.org MIT License
* @copyright © Nick Freear, 03-, 05-April-2018.
*/
class PhpList_Shortcode_Plugin {
const SHORTCODE = 'phplist';
const ID = 1;
const URL = 'https://lists.headstar.com/?p=subscribe&id=%s&embed=wp';
const LABEL = 'Subscribe to the Bulletin.';
const TEMPLATE = "%s\n<div class='phplist-embed'>\n<div>%s</div>\n<iframe src='%s' scrolling='no' title='%s'></iframe>\n</div>";
public function __construct() {
add_shortcode( self::SHORTCODE, array( &$this, 'shortcode' ) );
}
public function shortcode( $attrs = array(), $content = null ) {
$input = (object) shortcode_atts(
array(
'id' => self::ID,
'url' => self::URL,
'label' => self::LABEL,
), $attrs
);
$iframe_url = sprintf( $input->url, $input->id );
$iframe_embed = sprintf( self::TEMPLATE, self::stylesheet(), $content, $iframe_url, $input->label );
return $iframe_embed;
}
protected static function stylesheet() {
return <<<EOS
<style>
.phplist-embed { line-height: 1.5em; position: relative; }
.phplist-embed div { background: #fff; color: #222; height: 99px; width: 100%; position: relative; z-index: 10; }
.phplist-embed iframe { border: 0; overflow: hidden; height: 575px; width: 100%; position: relative; top: -99px; }
</style>
EOS;
}
}
$wp_plugin = new PhpList_Shortcode_Plugin();
// End.