This repository was archived by the owner on Oct 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshortcodes.php
More file actions
85 lines (54 loc) · 1.97 KB
/
shortcodes.php
File metadata and controls
85 lines (54 loc) · 1.97 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
/* REGISTER SHORTCODES AND CALLBACKS */
function wpghpl_milestones_func( $atts ) {
$gh = new WPGHPL_Github();
if (!$gh->has_settings)
return $gh->missing_settings_msg;
$milestones = $gh->get_milestones($atts);
return WPGHPL\format_milestones( $milestones );
}
add_shortcode( 'gh_milestones', 'wpghpl_milestones_func' );
function wpghpl_issues_func( $atts, $gh=NULL ) {
$show_body = ( !empty($atts['show_body']) ) ? $atts['show_body'] : FALSE;
#if a search term was entered do nothing.
if ( !empty($_GET['gh_searchterm']) )
return;
$gh = ($gh) ? $gh : new WPGHPL_Github();
if (!$gh->has_settings)
return $gh->missing_settings_msg;
$issues = $gh->get_issues($atts);
$return = WPGHPL\format_issues($issues, $show_body);
if (!empty($atts['per_page'])) {
$gh->per_page = $atts['per_page'];
$return = WPGHPL\prepend_page_count($return, $gh, count($issues) );
}
$return = WPGHPL\append_page_links($return, $gh);
return $return;
}
add_shortcode( 'gh_issues', 'wpghpl_issues_func' );
function wpghpl_searchform_func( $atts ) {
$placeholder = ( !empty($atts['placeholder']) ) ? $atts['placeholder'] : FALSE;
$show_body = ( !empty($atts['show_body']) ) ? $atts['show_body'] : FALSE;
$gh = new WPGHPL_Github();
if (!$gh->has_settings)
return $gh->missing_settings_msg;
$results = NULL;
$msg = 'Enter a search term to begin.';
$return = WPGHPL\build_search_form($placeholder);
if ( !empty($_GET['gh_searchterm'] )) {
if (strlen( $_GET['gh_searchterm'] ) < 2) {
$msg = 'Search term is too short!';
$results = 0;
} else {
$atts['term'] = $_GET['gh_searchterm'];
$issues = $gh->search_issues( $atts );
$results = count($issues);
$msg = "Results: " . $results;
}
}
$return .= '<div class="gh_searchform__msg">' . $msg . '</div>';
$return .= (!empty($issues)) ? WPGHPL\format_issues($issues, $show_body) : NULL;
// $return .= append_page_links($return, $gh);
return $return;
}
add_shortcode( 'gh_searchform', 'wpghpl_searchform_func' );