Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
データベースからGitHubについての情報を読み出し、Wordpress用の簡易ウィジェットを作成するためのPython3のプログラム。
<?php
function create_githubrepo_widget() {
global $wpdb;
$sql = 'select name, html_url, description from gitrepo';
$rows = $wpdb->get_results($sql, ARRAY_A);
$snippet = '<div style="width:305px;margin: 0 auto;">';
foreach($rows as $row) {
$url = $row["html_url"];
$name = $row["name"];
if ($name == "pandanote-info.github.io") {
$url = "https://sidestory.pandanote.info/";
$name = "sidestory.pandanote.info";
}
$snippet .= '<a class="pandanote-info-github" href="'.$url.'"><span style="color:#1E3E8A;font-weight:bold;font-size:130%;">'.$name.'</span></a><br/>'.$row["description"].'<hr/>';
}
return $snippet . '</div><div class="clear"></div>';
}
add_shortcode('create-githubrepo-widget','create_githubrepo_widget');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.