* * * Plugin Name: Adminer * Plugin URI: https://wordpress.org/plugins/adminer/ * Text Domain: adminer * Domain Path: /languages * Description: Adminer (formerly phpMinAdmin) is a full-featured MySQL management tool written in PHP. This plugin include this tool in WordPress for a fast management of your database. * Author: Frank Bültge * Author URI: http://bueltge.de/ * Version: 1.4.4 * License: GPLv3+ */ // avoid direct calls to this file, because now WP core and framework has been used if ( ! function_exists( 'add_action' ) ) { echo "Hi there! I'm just a part of plugin, not much I can do when called directly."; exit; } define( 'ADMINER_BASE_FILE', plugin_basename( __FILE__ ) ); add_action( 'plugins_loaded', array( 'AdminerForWP', 'get_object' ) ); class AdminerForWP { private static $classobj; protected $pagehook; public function __construct() { if ( ! is_admin() ) { return; } if ( is_multisite() && ! function_exists( 'is_plugin_active_for_network' ) ) { require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); } add_action( 'init', array( $this, 'register_styles' ) ); add_action( 'init', array( $this, 'on_init' ) ); add_action( 'admin_init', array( $this, 'text_domain' ) ); } /** * Handler for the action 'init'. Instantiates this class. * * @since 1.2.2 * @access public * @return \AdminerForWP $classobj */ public static function get_object() { if ( NULL === self::$classobj ) { self::$classobj = new self; } return self::$classobj; } /** * Call functions on init of WP * * @return void */ public function on_init() { // active for MU ? if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) { add_action( 'network_admin_menu', array( $this, 'on_network_admin_menu' ) ); } else { add_action( 'admin_menu', array( $this, 'on_admin_menu' ) ); } } public function text_domain() { load_plugin_textdomain( 'adminer', FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); } public function register_styles() { wp_register_style( 'adminer-settings', plugins_url( 'css/settings.css', __FILE__ ) ); if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) { add_action( 'admin_bar_menu', array( $this, 'add_wp_admin_bar_item' ), 20 ); } } public function on_load_page() { add_thickbox(); wp_enqueue_style( 'adminer-settings' ); add_action( 'contextual_help', array( $this, 'contextual_help' ), 10, 3 ); } public function on_admin_menu() { if ( current_user_can( 'import' ) ) { wp_enqueue_style( 'adminer-menu' ); $menutitle = __( 'Adminer', 'adminer' ); $this->pagehook = add_management_page( __( 'Adminer', 'adminer' ), $menutitle, 'import', plugin_basename( __FILE__ ), array( $this, 'on_show_page' ) ); add_action( 'load-' . $this->pagehook, array( $this, 'on_load_page' ) ); } } public function on_network_admin_menu() { if ( current_user_can( 'import' ) ) { wp_enqueue_style( 'adminer-menu' ); $menutitle = __( 'Adminer', 'adminer' ); $this->pagehook = add_submenu_page( 'settings.php', __( 'Adminer', 'adminer' ), $menutitle, 'import', plugin_basename( __FILE__ ), array( $this, 'on_show_page' ) ); add_action( 'load-' . $this->pagehook, array( $this, 'on_load_page' ) ); } } public function add_wp_admin_bar_item( $wp_admin_bar ) { if ( is_super_admin() ) { $args = array( 'parent' => 'network-admin', 'secondary' => FALSE, 'id' => 'network-adminer', 'title' => __( 'Adminer' ), 'href' => network_admin_url( 'settings.php?page=adminer/adminer.php' ), ); $wp_admin_bar->add_node( $args ); } } public function contextual_help( $contextual_help, $screen_id, $screen ) { if ( 'tools_page_adminer/adminer' !== $screen_id ) { return FALSE; } $contextual_help = '
';
$contextual_help .= __(
'Start the Thickbox inside the Adminer-tool with the button ›Start Adminer inside‹.',
'adminer'
);
$contextual_help .= '
';
$contextual_help .= __(
'Alternatively, you can use the button for use ›Adminer in a new Tab‹.', 'adminer'
);
$contextual_help .= '
' . __( 'Documentation on Plugin Directory', 'adminer' ); $contextual_help .= ' · ' . __( 'Donate', 'adminer' ); $contextual_help .= ' · ' . __( 'Blog of Plugin author', 'adminer' ); $contextual_help .= ' · ' . __( 'Adminer website
', 'adminer' ); return $contextual_help; } /** * Strip slashes for different var * * @param array|string $value optional * * @return array|null $value */ public static function gpc_strip_slashes( $value = NULL ) { // crazy check, WP change the rules and also Adminer core // result; we must check wrong to the php doc if ( ! get_magic_quotes_gpc() ) { if ( NULL !== $value ) { $value = self::array_map_recursive( 'stripslashes_deep', $value ); } // stripslashes_deep or stripslashes $_REQUEST = self::array_map_recursive( 'stripslashes_deep', $_REQUEST ); $_GET = self::array_map_recursive( 'stripslashes_deep', $_GET ); $_POST = self::array_map_recursive( 'stripslashes_deep', $_POST ); $_COOKIE = self::array_map_recursive( 'stripslashes_deep', $_COOKIE ); } return $value; } /** * Deeper array_map() * * @param string $callback Callback function to map * @param array , string $value Array to map * * @see http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/ * @return array, string */ public static function array_map_recursive( $callback, $values ) { $r = NULL; if ( is_string( $values ) ) { $r = $callback( $values ); } elseif ( is_array( $values ) ) { $r = array(); foreach ( $values as $k => $v ) { $r[ $k ] = is_scalar( $v ) ? $callback( $v ) : self::array_map_recursive( $callback, $v ); } } return $r; } /** * Return page content for start Adminer * * @return void */ public function on_show_page() { if ( '' === DB_USER ) { $db_user = __( 'empty', 'adminer' ); } else { $db_user = DB_USER; } if ( '' === DB_PASSWORD ) { $db_password = __( 'empty', 'adminer' ); } else { $db_password = DB_PASSWORD; } if ( ! defined( 'WP_PLUGIN_DIR' ) ) { define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); } // full path, no trailing slash ?>