-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
54 lines (48 loc) · 1.64 KB
/
index.php
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
<?php
/*
Plugin Name: Show Excerpt
Plugin URI: http://frique.me/
Description: Shortcode [excerpt] will print the Excerpt in a configurable tag.
Version: 1.0
Author: Berend // frique.me
Author URI: http://frique.me/
*/
// The shortcode
function showexcerpt_shortcode( $attributes, $content ) {
// Defaults
$defaults['tag'] = 'p';
$defaults['styled'] = true;
$defaults['class'] = '';
// Merge supplied attributes with defaults
$attributes = shortcode_atts(
$defaults,
$attributes,
'excerpt'
);
// Return
if ( get_the_excerpt() ) {
$return = '<' . esc_attr( $attributes['tag'] ) . ' class="excerpt' . ( ( $attributes['styled'] ) ? ' excerpt--styled' : '' ) . ( ( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : '' ) '">';
$return .= get_the_excerpt();
$return .= '</' . esc_attr( $attributes['tag'] ) . '>';
return $return;
}
return '';
}
add_shortcode( 'excerpt', 'showexcerpt_shortcode' );
// Add button to admin text editor (HTML tab)
function showexcerpt_addeditorbutton() {
?>
<script type="text/javascript">
QTags.addButton(
"quicktag-showexcerpt", // Button id-attribute
"[excerpt]", // Button text
"[excerpt]", // Opening tag
"", // Closing tag
"", // Shortcut key
"<?php __( 'Insert excerpt', 'showexcerpt' ); ?>", // Button title-attribute
300 // Priority
);
</script>
<?php
}
add_action( 'admin_print_footer_scripts', 'showexcerpt_addeditorbutton' );