Completed
Push — master ( 957be0...c9782b )
by David
08:25
created

Wordlift_Shortcode::render()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
nc 1
dl 0
loc 1
1
<?php
2
3
/**
4
 * A base abstract class for shortcodes which registers the shortcode binding it
5
 * to the render method and provides a function to enqueue the scripts.
6
 *
7
 * @since 3.5.4
8
 */
9
abstract class Wordlift_Shortcode {
10
11
	/**
12
	 * The shortcode, set by extending classes.
13
	 */
14
	const SHORTCODE = NULL;
15
16
	/**
17
	 * Create a shortcode instance by registering the shortcode with the render
18
	 * function.
19
	 *
20
	 * @since 3.5.4
21
	 */
22
	public function __construct() {
23
24
		add_shortcode( static::SHORTCODE, array( $this, 'render' ) );
25
26
	}
27
28
	/**
29
	 * Render the shortcode.
30
	 *
31
	 * @since 3.5.4
32
	 *
33
	 * @param array $atts An array of shortcode attributes as set by the editor.
34
	 *
35
	 * @return string The output html code.
36
	 */
37
	public abstract function render( $atts );
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
38
39
	/**
40
	 * Enqueue scripts. Called by the shortcode implementations in their render
41
	 * method.
42
	 *
43
	 * @since 3.5.4
44
	 */
45
	protected function enqueue_scripts() {
46
47
		wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
48
		wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array( 'angularjs' ) );
49
		wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui.min.js', array(
50
			'jquery',
51
			'angularjs',
52
			'angularjs-touch'
53
		) );
54
55
	}
56
57
}
58