データベースからGitHubについての情報を読み出し、Wordpress用の簡易ウィジェットを作成するためのPython3のプログラム。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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