Skip to content

Commit f324e85

Browse files
committed
Add hook docs
Fixes #45.
1 parent 7b41a7e commit f324e85

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

includes/class-gistpress.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,14 @@ public function shortcode( array $rawattr ) {
199199

200200
if ( is_feed() ) {
201201
$html = sprintf( '<a href="%s" target="_blank"><em>%s</em></a>', esc_url( $url ), __( 'View this code snippet on GitHub.', 'gistpress' ) );
202+
203+
/**
204+
* Filter what is shown in feeds.
205+
*
206+
* @since 2.0.0
207+
*
208+
* @param string $html Markup to show in feeds.
209+
*/
202210
return apply_filters( 'gistpress_feed_html', $html );
203211
}
204212

@@ -214,6 +222,16 @@ public function shortcode( array $rawattr ) {
214222
wp_enqueue_style( 'gistpress' );
215223
}
216224

225+
/**
226+
* Filter the output HTML.
227+
*
228+
* @since 2.0.0
229+
*
230+
* @param string $html The output HTML.
231+
* @param string $url The URL to the Gist.
232+
* @param array $attr Shortcode attributes, standardized.
233+
* @param int $id Post ID.
234+
*/
217235
$html = apply_filters( 'gistpress_html', $html, $url, $attr, get_the_ID() );
218236

219237
foreach ( $attr as $key => $value ) {
@@ -485,6 +503,13 @@ public function process_gist_html( $html, array $args ) {
485503
}
486504
}
487505

506+
/**
507+
* Filter the classes applied to a line of the Gist.
508+
*
509+
* @since 2.0.0
510+
*
511+
* @param array $classes List of HTML class values.
512+
*/
488513
$classes = apply_filters( 'gistpress_line_classes', $classes );
489514
$class = ( ! empty( $classes ) && is_array( $classes ) ) ? ' class="' . implode ( ' ', $classes ) . '"' : '';
490515

@@ -611,12 +636,47 @@ protected function rebuild_shortcode( array $rawattr ) {
611636
* @return array Standardized and sanitized shortcode attributes.
612637
*/
613638
protected function standardize_attributes( array $rawattr ) {
639+
/**
640+
* Filter the shortcode attributes defaults.
641+
*
642+
* @since 2.0.0
643+
*
644+
* @param array $gistpress_shortcode_defaults {
645+
* Shortcode attributes defaults.
646+
*
647+
* @type bool $embed_stylesheet Filterable value to include style sheet or not.
648+
* @type string $file File name within gist.
649+
* @type array $highlight Lines to highlight.
650+
* @type string $highlight_color Filterable hex color code.
651+
* @type string $id Gist ID.
652+
* @type int $lines Number of lines to show.
653+
* @type int $lines_start Which line number to start from.
654+
* @type bool $show_line_numbers Show line numbers or not, default true.
655+
* @type bool $show_meta Show meta information or not, default true.
656+
* }
657+
*/
614658
$defaults = apply_filters(
615659
'gistpress_shortcode_defaults',
616660
array(
661+
662+
/**
663+
* Filter to include the style sheet or not.
664+
*
665+
* @since 2.0.0
666+
*
667+
* @param bool $gistpress_stylesheet_default Default is true.
668+
*/
617669
'embed_stylesheet' => apply_filters( 'gistpress_stylesheet_default', true ),
618670
'file' => '',
619671
'highlight' => array(),
672+
673+
/**
674+
* Filter to set highlight color.
675+
*
676+
* @since 2.0.0
677+
*
678+
* @param string $gistpress_highlight_color Hex color code, default is `#ffc`.
679+
*/
620680
'highlight_color' => apply_filters( 'gistpress_highlight_color', '#ffc' ),
621681
'id' => '',
622682
'lines' => '',

0 commit comments

Comments
 (0)