Skip to content

Commit

Permalink
show debug information
Browse files Browse the repository at this point in the history
  • Loading branch information
fukata committed Dec 13, 2017
1 parent 9c80c9e commit 2fc8d07
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
12 changes: 11 additions & 1 deletion FlickrPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ private static function addEvents() {
add_action('admin_footer-post-new.php', array('FpPostEvent', 'loadJSBridgeParams'));

require_once(self::getDir().'/FpAdminSettingEvent.php');
add_action('admin_enqueue_scripts', array('FpAdminSettingEvent', 'loadUIScripts'));
add_action('admin_menu', array('FpAdminSettingEvent', 'addMenu'));
add_filter('whitelist_options', array('FpAdminSettingEvent', 'addWhitelistOptions'));

Expand Down Expand Up @@ -393,10 +394,19 @@ public static function getThumbnailSizeSuffix($size='') {
return self::$SIZE_TO_SUFFIX_MAPS[ self::getThumbnailSize() ];
}
}

public static function isThumbnailSize($size='') {
return array_key_exists($size, self::$SIZE_TO_SUFFIX_MAPS);
}

public static function getDebugInfoText() {
$debug_items = array();
$debug_items[] = "WordPress version: " . get_bloginfo('version');
$debug_items[] = "wp-flickr-press version: " . FlickrPress::VERSION;
$debug_items[] = "PHP version: " . @phpversion();
$debug_items[] = " ├ safe_mode: " . (@ini_get('safe_mode') ? 'ON' : 'OFF');
$debug_items[] = " └ curl: " . (@function_exists('curl_init') ? 'ENABLED' : 'DISABLED');
return implode("\n", $debug_items);
}
}
?>
24 changes: 24 additions & 0 deletions FpAdminSettingEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
class FpAdminSettingEvent {
private function __construct() {}

public static function loadUIScripts() {
wp_enqueue_script('clipboard.js', FlickrPress::getPluginUrl('libs/clipboard.js/clipboard.min.js'), array(), FlickrPress::VERSION);
}

public static function addMenu() {
$page = add_options_page(FlickrPress::NAME.' Options', FlickrPress::NAME, 'manage_options', __FILE__, array('FpAdminSettingEvent','generateOptionForm'));
}
Expand Down Expand Up @@ -475,6 +479,26 @@ function callback_oauth(token) {
</p>
</td>
</tr>
<tr valign="top">
<th scope="row">
<p><?php echo __('DEBUG', FlickrPress::TEXT_DOMAIN) ?></p>
</th>
<td>
<p><?php echo __('Please paste below information when create issue.', FlickrPress::TEXT_DOMAIN) ?></p>
<textarea id="wpfp-debug-info-text" rows="10" style="width: 100%;" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"><?php echo FlickrPress::getDebugInfoText() ?></textarea>
<button class="btn" id="wpfp-debug-info-copy-btn" type="button" data-clipboard-target="#wpfp-debug-info-text"><?php echo __('Copy to clipboard', FlickrPress::TEXT_DOMAIN) ?></button>
<p id="wpfp-debug-info-copy-result"></p>
<script>
var clipboard = new Clipboard(document.getElementById('wpfp-debug-info-copy-btn'));
clipboard.on('success', function(e) {
document.getElementById('wpfp-debug-info-copy-result').innerHTML = "<?php echo __('Copied!', FlickrPress::TEXT_DOMAIN) ?>";
});
clipboard.on('error', function(e) {
document.getElementById('wpfp-debug-info-copy-result').innerHTML = "<?php echo __('This browser not support copy command. Please paste manually.', FlickrPress::TEXT_DOMAIN) ?>";
});
</script>
</td>
</tr>
<tr valign="top">
<th scope="row">
<p><?php echo __('DONATE(bitcoin)', FlickrPress::TEXT_DOMAIN) ?></p>
Expand Down
Binary file modified languages/wp-flickr-press-ja.mo
Binary file not shown.
14 changes: 13 additions & 1 deletion languages/wp-flickr-press-ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,16 @@ msgid "This UI is old version. Currently have new search UI please try new versi
msgstr "この検索UIはメンテナンスされていません。現在、新しい検索UIが「メディアを挿入」から利用可能なのでそちらをご利用ください。"

msgid "Multiple Mode"
msgstr "複数選択"
msgstr "複数選択"

msgid "DEBUG"
msgstr "デバッグ情報"

msgid "Please paste below information when create issue."
msgstr "バグ報告をする時に下記の情報をコピー&ペーストして一緒に載せてもらえると調査が早くなります。"

msgid "Copied!"
msgstr "クリップボードにコピーしました。"

msgid "This browser not support copy command. Please paste manually."
msgstr "このブラウザでは対応していません。手動でコピーしてください。"
7 changes: 7 additions & 0 deletions libs/clipboard.js/clipboard.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2fc8d07

Please sign in to comment.