heading.php
2.78 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
su_add_shortcode(
array(
'id' => 'heading',
'callback' => 'su_shortcode_heading',
'name' => __( 'Heading', 'shortcodes-ultimate' ),
'type' => 'wrap',
'group' => 'content',
'atts' => array(
'style' => array(
'type' => 'select',
'values' => su_get_available_styles_for( 'heading' ),
'default' => 'default',
'name' => __( 'Style', 'shortcodes-ultimate' ),
'desc' => __( 'Choose style for this heading', 'shortcodes-ultimate' ),
),
'size' => array(
'type' => 'slider',
'min' => 7,
'max' => 48,
'step' => 1,
'default' => 13,
'name' => __( 'Size', 'shortcodes-ultimate' ),
'desc' => __( 'Select heading size (pixels)', 'shortcodes-ultimate' ),
),
'align' => array(
'type' => 'select',
'values' => array(
'left' => __( 'Left', 'shortcodes-ultimate' ),
'center' => __( 'Center', 'shortcodes-ultimate' ),
'right' => __( 'Right', 'shortcodes-ultimate' ),
),
'default' => 'center',
'name' => __( 'Align', 'shortcodes-ultimate' ),
'desc' => __( 'Heading text alignment', 'shortcodes-ultimate' ),
),
'margin' => array(
'type' => 'slider',
'min' => 0,
'max' => 200,
'step' => 10,
'default' => 20,
'name' => __( 'Margin', 'shortcodes-ultimate' ),
'desc' => __( 'Bottom margin (pixels)', 'shortcodes-ultimate' ),
),
'id' => array(
'name' => __( 'HTML Anchor (ID)', 'shortcodes-ultimate' ),
'desc' => __( 'Anchors lets you link directly to a heading on a page.', 'shortcodes-ultimate' ),
'default' => '',
),
'class' => array(
'type' => 'extra_css_class',
'name' => __( 'Extra CSS class', 'shortcodes-ultimate' ),
'desc' => __( 'Additional CSS class name(s) separated by space(s)', 'shortcodes-ultimate' ),
'default' => '',
),
),
'content' => __( 'Heading text', 'shortcodes-ultimate' ),
'desc' => __( 'Styled heading', 'shortcodes-ultimate' ),
'icon' => 'h-square',
'image' => su_get_plugin_url() . 'admin/images/shortcodes/heading.svg',
)
);
function su_shortcode_heading( $atts = null, $content = null ) {
$atts = shortcode_atts(
array(
'style' => 'default',
'size' => 13,
'align' => 'center',
'margin' => '20',
'id' => '',
'class' => '',
),
$atts,
'heading'
);
su_query_asset( 'css', 'su-shortcodes' );
return '<div class="su-heading su-heading-style-' . esc_attr( $atts['style'] ) . ' su-heading-align-' . esc_attr( $atts['align'] ) . su_get_css_class( $atts ) . '" id="' . esc_attr( $atts['id'] ) . '" style="font-size:' . intval( $atts['size'] ) . 'px;margin-bottom:' . esc_attr( $atts['margin'] ) . 'px"><div class="su-heading-inner">' . do_shortcode( $content ) . '</div></div>';
}