| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
die( '-1' ); |
| 5 |
} |
| 6 |
|
| 7 |
class WpGradeShortcode_Heading extends WpGradeShortcode { |
| 8 |
|
| 9 |
public function __construct( $settings = array() ) { |
| 10 |
$this->self_closed = true; |
| 11 |
$this->name = 'Heading'; |
| 12 |
$this->code = 'heading'; |
| 13 |
$this->icon = 'icon-header'; |
| 14 |
$this->direct = false; |
| 15 |
|
| 16 |
$this->params = array( |
| 17 |
'subtitle' => array( |
| 18 |
'type' => 'text', |
| 19 |
'name' => 'Subtitle', |
| 20 |
'admin_class' => 'span7 push1' |
| 21 |
), |
| 22 |
'title' => array( |
| 23 |
'type' => 'text', |
| 24 |
'name' => 'Title', |
| 25 |
'admin_class' => 'span7 push1' |
| 26 |
), |
| 27 |
); |
| 28 |
|
| 29 |
// allow the theme or other plugins to "hook" into this shortcode's params |
| 30 |
$this->params = apply_filters( 'pixcodes_filter_params_for_' . strtolower( $this->name ), $this->params ); |
| 31 |
|
| 32 |
add_shortcode( 'heading', array( $this, 'add_shortcode' ) ); |
| 33 |
} |
| 34 |
|
| 35 |
public function add_shortcode( $atts, $content ) { |
| 36 |
//create an array with only the registered params - dynamic since we filter them and have no way of knowing for sure |
| 37 |
$extract_params = array(); |
| 38 |
if (isset($this->params)) { |
| 39 |
foreach ($this->params as $key => $value) { |
| 40 |
$extract_params[$key] = ''; |
| 41 |
} |
| 42 |
} |
| 43 |
extract( shortcode_atts( $extract_params, $atts ) ); |
| 44 |
|
| 45 |
/** |
| 46 |
* Template localization between plugin and theme |
| 47 |
*/ |
| 48 |
$located = locate_template( "templates/shortcodes/{$this->code}.php", false, false ); |
| 49 |
if ( ! $located ) { |
| 50 |
$located = dirname( __FILE__ ) . '/templates/' . $this->code . '.php'; |
| 51 |
} |
| 52 |
// load it |
| 53 |
ob_start(); |
| 54 |
require $located; |
| 55 |
|
| 56 |
return ob_get_clean(); |
| 57 |
} |
| 58 |
} |
| 59 |
|