Last active
April 27, 2024 11:30
-
-
Save nickpagz/9f883ab36af94d7e382e9818e19e634e to your computer and use it in GitHub Desktop.
Install Adminer for use with Studio
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 | |
/* | |
Plugin Name: Admin Bar Link for Adminer | |
Description: Adds a link to the WordPress admin bar to access the database via Adminer. | |
Version: 1.0 | |
Author: Nick Pagazani | |
Plugin URI: https://github.com/nickpagz/adminer-for-studio | |
*/ | |
add_action( 'admin_bar_menu', function ($wp_admin_bar ) { | |
if ( ! is_user_logged_in() || ! is_admin_bar_showing() ) return; | |
$wp_admin_bar->add_node( | |
array( | |
'id' => 'adminer-access', | |
'title' => 'Open Adminer', | |
'href' => get_home_url() . '/wp-content/database/studio-adminer.php?sqlite=&username=&db=%2Fvar%2Fwww%2Fhtml%2Fwp-content%2Fdatabase%2F.ht.sqlite', | |
'meta' => array( | |
'title' => 'View DB', | |
'class' => 'adminer-database-link', | |
'target' => '_blank', | |
) | |
) | |
); | |
}, 100 ); |
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
#!/bin/bash | |
# Define base directory | |
BASE_DIR="./wp-content/database" | |
MU_PLUGINS_DIR="./wp-content/mu-plugins" | |
# Create directory if it doesn't exist | |
mkdir -p $BASE_DIR | |
mkdir -p $MU_PLUGINS_DIR | |
# Download and setup Adminer | |
echo "Downloading Adminer..." | |
curl -sL https://www.adminer.org/latest.php -o $BASE_DIR/adminer.php | |
# Download and setup your GitHub repository | |
echo "Downloading and setting up Adminer plugins..." | |
curl -sL https://github.com/nickpagz/adminer-for-studio/archive/refs/heads/trunk.zip -o temp.zip | |
unzip -qo temp.zip -d temp_folder | |
rm -f temp_folder/adminer-for-studio-trunk/.gitignore | |
rm -f temp_folder/adminer-for-studio-trunk/README.md | |
mv temp_folder/adminer-for-studio-trunk/* $BASE_DIR | |
rm -rf temp.zip temp_folder | |
echo "Downloading and setting up MU-Plugin..." | |
curl -sL "https://gist.githubusercontent.com/nickpagz/9f883ab36af94d7e382e9818e19e634e/raw/adminer-for-studio.php" -o $MU_PLUGINS_DIR/adminer-for-studio.php | |
# Display the database URL | |
echo "Setup complete. Click on the Open Adminer link in wp-admin to view the database. If prompted for credentials, simply click on Login." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment