Skip to content

Commit 3244fc6

Browse files
committed
Merge branch '0.4.14'
2 parents b36a836 + 43656d8 commit 3244fc6

File tree

3 files changed

+75
-8
lines changed

3 files changed

+75
-8
lines changed

includes/class-jacobin-core-shortcodes.php

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Jacobin Core Register Shortcodes
4-
*
4+
*
55
* @package Jacobin_Core
66
* @subpackage Jacobin_Core\Includes
77
* @since 0.1.3
@@ -27,7 +27,7 @@ function __construct() {
2727
add_action( 'init', array( $this, 'detect_shortcode_ui' ) );
2828
add_action( 'init', array( $this, 'register_shortcodes' ) );
2929
add_action( 'init', array( $this, 'register_shortcode_ui' ) );
30-
30+
3131
}
3232

3333
/**
@@ -70,12 +70,14 @@ public function shortcode_ui_notices() {
7070
public function register_shortcodes() {
7171
add_shortcode( 'embed-timeline', array( $this, 'embed_timeline_shortcode' ) );
7272
add_shortcode( 'embed-chart', array( $this, 'embed_chart_shortcode' ) );
73+
add_shortcode( 'embed-script', array( $this, 'embed_script_shortcode' ) );
7374
}
7475

7576
/**
7677
* Register Shortcode with Shortcode UI
7778
*
7879
* @since 0.1.3
80+
* @since 0.4.14
7981
*
8082
* @param string $shortcode_tag
8183
* @param function $shortcode_function
@@ -84,6 +86,39 @@ public function register_shortcodes() {
8486
public function register_shortcode_ui() {
8587
add_action( 'register_shortcode_ui', array( $this, 'embed_timeline_shortcode_ui' ) );
8688
add_action( 'register_shortcode_ui', array( $this, 'embed_chart_shortcode_ui' ) );
89+
add_action( 'register_shortcode_ui', array( $this, 'embed_script_shortcode_ui' ) );
90+
}
91+
92+
/**
93+
* Callback for the `embed_script` shortcode
94+
* It renders the shortcode based on supplied attributes.
95+
*
96+
* @example `[embed-script src={url} defer=defer]`
97+
*
98+
* @since 0.4.14
99+
*
100+
* @param string $atts
101+
* @param string $content
102+
* @param string $shortcode_tag
103+
*/
104+
public function embed_script_shortcode( $atts, $content, $shortcode_tag ) {
105+
106+
$atts = shortcode_atts(
107+
array(
108+
'src' => '',
109+
'defer' => 'defer',
110+
'type' => 'text/javascript',
111+
),
112+
$atts,
113+
$shortcode_tag
114+
);
115+
116+
return sprintf( '<script scr="%s" defer="%s" type="%s"></script>',
117+
esc_url( $atts['src'] ),
118+
esc_attr( $atts['defer'] ),
119+
esc_attr( $atts['type'] )
120+
);
121+
87122
}
88123

89124
/**
@@ -108,7 +143,7 @@ public function embed_timeline_shortcode( $attr, $content, $shortcode_tag ) {
108143

109144
// Output buffering here.
110145
ob_start();
111-
146+
112147
include_once ( 'views/embed-timeline.php' );
113148

114149
return ob_get_clean();
@@ -136,7 +171,7 @@ public function embed_chart_shortcode( $attr, $content, $shortcode_tag ) {
136171

137172
// Output buffering here.
138173
ob_start();
139-
174+
140175
include_once ( 'views/embed-chart.php' );
141176

142177
return ob_get_clean();
@@ -201,6 +236,34 @@ public function embed_chart_shortcode_ui() {
201236
shortcode_ui_register_for_shortcode( 'embed-chart', $shortcode_ui_args );
202237
}
203238

239+
/**
240+
* Embed Script Shortcode UI
241+
*
242+
* @since 0.4.14
243+
*
244+
*/
245+
public function embed_script_shortcode_ui() {
246+
$fields = array(
247+
array(
248+
'label' => esc_html__( 'Script URL', 'jacobin-core' ),
249+
'attr' => 'src',
250+
'type' => 'url',
251+
),
252+
);
253+
254+
/*
255+
* Define the Shortcode UI arguments.
256+
*/
257+
$shortcode_ui_args = array(
258+
'label' => esc_html__( 'Embed Script', 'jacobin-core' ),
259+
'listItemImage' => 'dashicons-editor-code',
260+
'post_type' => array( 'post' ),
261+
'attrs' => $fields,
262+
);
263+
264+
shortcode_ui_register_for_shortcode( 'embed-script', $shortcode_ui_args );
265+
}
266+
204267
}
205268

206269
new Jacobin_Register_Shortcodes();

jacobin-core-functionality.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Text Domain: jacobin-core
1111
* Domain Path: /languages
1212
*
13-
* Version: 0.4.13
13+
* Version: 0.4.14
1414
*
1515
* @package Core_Functionality
1616
*/
@@ -60,7 +60,7 @@
6060
* @return object Jacobin_Core
6161
*/
6262
function Jacobin_Core () {
63-
$instance = Jacobin_Core::instance( __FILE__, '0.4.13' );
63+
$instance = Jacobin_Core::instance( __FILE__, '0.4.14' );
6464

6565
return $instance;
6666
}

readme.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ This section describes how to install the plugin and get it working.
2525

2626
== Changelog ==
2727

28+
### 0.4.14 Febrary 27, 2018
29+
* #443 Added shortcode for non-admin users to embed scripts. @link https://github.com/positiondev/jacobin/issues/443
30+
@link https://codex.wordpress.org/Roles_and_Capabilities#unfiltered_html
31+
2832
### 0.4.13 February 23, 2018
29-
* Fixed excerpt in featured content response @link https://github.com/positiondev/jacobin/issues/438
30-
* Fixed custom taxonomy responses. Reverted changes made in 0.4.10 and instead modified `status-internal` rest $args @link https://github.com/positiondev/jacobin/issues/439
33+
* #438 Fixed excerpt in featured content response @link https://github.com/positiondev/jacobin/issues/438
34+
* #439 Fixed custom taxonomy responses. Reverted changes made in 0.4.10 and instead modified `status-internal` rest $args @link https://github.com/positiondev/jacobin/issues/439
3135

3236
### 0.4.12 February 14, 2018
3337
* Added DB performance functions

0 commit comments

Comments
 (0)