| 1 |
<?php |
| 2 |
/** |
| 3 |
* Register the plugin shortcode provider. |
| 4 |
* |
| 5 |
* @package civist |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Register the plugin shortcode provider. |
| 10 |
*/ |
| 11 |
class Civist_Shortcode { |
| 12 |
/** |
| 13 |
* The plugin slug. |
| 14 |
* |
| 15 |
* @var string |
| 16 |
*/ |
| 17 |
private $plugin_slug; |
| 18 |
|
| 19 |
/** |
| 20 |
* The Civist_Shortcode class constructor. |
| 21 |
* |
| 22 |
* @param string $plugin_slug The slug of the plugin. |
| 23 |
*/ |
| 24 |
public function __construct( $plugin_slug ) { |
| 25 |
$this->plugin_slug = $plugin_slug; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Registers the plugin shortcode provider. |
| 30 |
*/ |
| 31 |
public function register_shortcode() { |
| 32 |
add_shortcode( $this->plugin_slug, array( $this, 'shortcode_provider' ) ); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Handle shortcode. |
| 37 |
* |
| 38 |
* @param string $atts The shortcode attributes. |
| 39 |
*/ |
| 40 |
public function shortcode_provider( $atts ) { |
| 41 |
global $wp_embed; |
| 42 |
$atts = shortcode_atts( |
| 43 |
array( |
| 44 |
'src' => '', |
| 45 |
'mode' => 'default', |
| 46 |
), |
| 47 |
$atts |
| 48 |
); |
| 49 |
return $wp_embed->shortcode( |
| 50 |
array( |
| 51 |
'mode' => $atts['mode'], |
| 52 |
), |
| 53 |
$atts['src'] |
| 54 |
); |
| 55 |
} |
| 56 |
} |
| 57 |
|