Skip to content

Commit

Permalink
added settings page for github api token
Browse files Browse the repository at this point in the history
  • Loading branch information
pjaudiomv committed Jan 22, 2020
1 parent dcd14cc commit 8a8baa9
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 14 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ Ex. [bmlt_versions drupal="0"] would not display drupal link.



# MORE INFORMATION

[https://github.com/bmlt-enabled/bmlt-versions](https://github.com/bmlt-enabled/bmlt-versions)

# Installation

This section describes how to install the plugin and get it working.

1. Upload the entire BMLT Versions Plugin folder to the /wp-content/plugins/ directory
2. Activate the plugin through the Plugins menu in WordPress
3. Add [bmlt_versions] shortcode to your Wordpress page/post.
3. Add the GitHub API Token to the BMLT Versions settings page WordPress Dashboard->Settings->BMLT Versions
4. Add [bmlt_versions] shortcode to your Wordpress page/post.


# Changelog

= 1.3.0 =

* Added settings page for GitHub API Token.

= 1.2.2 =

* Cleanup.
Expand Down
51 changes: 44 additions & 7 deletions bmlt-versions/bmlt-versions.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
/*
Plugin Name: BMLT Versions
Plugin URI: https://wordpress.org/plugins/bmlt-versions/
Plugin URI: https://github.com/bmlt-enabled/bmlt-versions/
Description: A simple content generator to display the versions and links of the various BMLT components. Add [bmlt_versions] to a page or a post to generate the list.
Author: BMLT Authors
Author URI: https://bmlt.app
Version: 1.2.2
Version: 1.3.0
Install: Drop this directory into the "wp-content/plugins/" directory and activate it.
*/
/* Disallow direct access to the plugin file */
Expand All @@ -23,10 +23,44 @@ class bmltVersions

public function __construct()
{
add_shortcode('bmlt_versions', array(
&$this,
"bmltVersionsFunc"
));
if (is_admin()) {
// Back end
add_action("admin_menu", array(&$this, "bmltVersionsOptionsPage"));
add_action("admin_init", array(&$this, "bmltVersionsRegisterSettings"));
} else {
// Front end
add_shortcode('bmlt_versions', array(&$this, "bmltVersionsFunc"));
}
}
function bmltVersionsRegisterSettings() {
add_option( 'bmltVersionsGithubApiKey', 'Github API Key.');
register_setting( 'bmltVersionsOptionGroup', 'bmltVersionsGithubApiKey', 'bmltVersionsCallback' );
}

function bmltVersionsOptionsPage()
{
add_options_page('BMLT Versions', 'BMLT Versions', 'manage_options', 'bmlt-versions', array(
&$this,
'bmltVersionsAdminOptionsPage'
));
}
public function bmltVersionsAdminOptionsPage()
{
?>
<div>
<h2>BMLT Versions</h2>
<form method="post" action="options.php">
<?php settings_fields( 'bmltVersionsOptionGroup' ); ?>
<table>
<tr valign="top">
<th scope="row"><label for="bmltVersionsGithubApiKey">GitHub API Token</label></th>
<td><input type="text" id="bmltVersionsGithubApiKey" name="bmltVersionsGithubApiKey" value="<?php echo get_option('bmltVersionsGithubApiKey'); ?>" /></td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
<?php
}

public function bmltVersions()
Expand Down Expand Up @@ -136,6 +170,7 @@ public function bmltVersionsFunc($atts = [])
$content .= '<a href ="https://wordpress.org/plugins/contacts-bmlt/">Contacts Plugin - ' . $contacts_date . '</a>';
$content .= '</li>';
}

if ($yap) {
$content .= '<li class="bmlt_versions_li_yap">';
$yap_version = $this->githubLatestReleaseVersion('yap');
Expand Down Expand Up @@ -179,11 +214,13 @@ public function githubLatestReleaseDate($repo)

public function get($url, $cookies = null)
{
$gitHubApiKey = get_option('bmltVersionsGithubApiKey');

$args = array(
'timeout' => '120',
'headers' => array(
'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0) +bmltVersions',
'Authorization' => 'token API_KEY_HERE'
'Authorization' => "token $gitHubApiKey"
),
'cookies' => isset($cookies) ? $cookies : null
);
Expand Down
9 changes: 7 additions & 2 deletions bmlt-versions/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Contributors: pjaudiomv, radius314
Tags: bmlt, meeting list
Tested up to: 5.3.2
Stable tag: 1.2.2
Stable tag: 1.3.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -29,11 +29,16 @@ This section describes how to install the plugin and get it working.

1. Upload the entire BMLT Versions Plugin folder to the /wp-content/plugins/ directory
2. Activate the plugin through the Plugins menu in WordPress
3. Add [bmlt_versions] shortcode to your Wordpress page/post.
3. Add the GitHub API Token to the BMLT Versions settings page WordPress Dashboard->Settings->BMLT Versions
4. Add [bmlt_versions] shortcode to your Wordpress page/post.


== Changelog ==

= 1.3.0 =

* Added settings page for GitHub API Token.

= 1.2.2 =

* Cleanup.
Expand Down

0 comments on commit 8a8baa9

Please sign in to comment.