-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtttt-step-small.php
More file actions
40 lines (30 loc) · 1.22 KB
/
tttt-step-small.php
File metadata and controls
40 lines (30 loc) · 1.22 KB
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
<?php namespace IET_OU\WP_Generic_Plugins;
/*
Plugin Name: TTTT Small Guide Step
Plugin URI:
Description: Shortcode for Tricky Topics Guide - ` [tttt_small step="1"] Title [/tttt_small] `
Author: RF
Author URI: -
Version: 1.0
@copyright © 2017 The Open University (UK).
@author RF, 18 July 2017.
*/
class TTTT_Small_Step_Plugin {
const SHORTCODE = 'tttt_small';
const IMAGE_URL = '/images/guide/small-guide-step-%s.jpg';
const TPL = '<div id="step-%s" class="tttt-small-step"><img src="%s" title="Step: %s" /><div><ol start="%s"><li>%s</li></ol></div></div>';
public function __construct() {
add_shortcode( self::SHORTCODE, [ &$this, 'shortcode_tttt_small' ] );
}
public function shortcode_tttt_small( $attrs = [], $content = null ) {
$inp = (object) shortcode_atts( [
'step' => null,
'page_link' => null,
], $attrs );
$link_open = $inp->page_link ? '<a href="/' . $inp->page_link . '/">' : '';
$link_close = $inp->page_link ? '</a>' : '';
$image_url = get_stylesheet_directory_uri() . sprintf( self::IMAGE_URL, $inp->step );
return $link_open . sprintf( self::TPL, $inp->step, $image_url, $inp->step, $inp->step, $content ) . $link_close;
}
}
$plugin = new TTTT_Small_Step_Plugin();