/** * Single Issue shortcode. * GET /repos/:owner/:repo/issues/:number * * @param $atts * @return string */ function ghissue_shortcode($atts) { $a = shortcode_atts(array('username' => get_option('wpgithub_defaultuser', 'seinoxygen'), 'repository' => get_option('wpgithub_defaultrepo', 'wp-github'), 'number' => ''), $atts); // Init the cache system. $cache = new WpGithubCache(); // Set custom timeout in seconds. $cache->timeout = get_option('wpgithub_cache_time', 600); $issue = $cache->get($a['username'] . '.' . $a['repository'] . '.issue.' . $a['number'] . '.json'); if ($issue == NULL) { $github = new Github($a['username'], $a['repository'], null, $a['number']); $issue = $github->get_issue(); $cache->set($a['username'] . '.' . $a['repository'] . '.issue.' . $a['number'] . '.json', $issue); } if (is_object($issue)) { $html = '<div class="wp-github wpg-issue">'; $html .= '<span class="wp-github-state ' . $issue->state . '">' . $issue->state . '</span>'; $html .= '<span class="wp-github-nb">#' . $issue->number . '</span>'; $html .= '<a target="_blank" href="' . $issue->html_url . '" title="' . $issue->title . '"> ' . $issue->title . '</a>'; $html .= '</div>'; } else { $html = $issue; } return $html; }