'pexlechris_adminer_avoid_conflicts_with_other_plugins.php',
'version' => '3.0.3',
'option_name' => 'pexlechris_adminer_mu_plugin_version',
]);
require_once WP_PLUGIN_DIR . '/pexlechris-adminer/pluggable-functions.php';
add_filter('plugin_action_links_pexlechris-adminer/pexlechris-adminer.php', 'pexlechris_adminer_add_open_wp_adminer_link_in_plugin_action_links', 15, 2);
function pexlechris_adminer_add_open_wp_adminer_link_in_plugin_action_links($links)
{
$url = esc_url(site_url() . '/' . PEXLECHRIS_ADMINER_SLUG);
$anchor = '' . __('Open WP Adminer', 'pexlechris-adminer') . '';
$new = [$anchor];
return array_merge($new, $links);
}
/**
* @since 2.2.0
* @since 3.0.0 MU Plugin version controlled by option pexlechris_adminer_mu_plugin_version
*/
add_action( 'admin_init', 'pexlechris_adminer_copy_adminer_mu_plugin', 1 );
function pexlechris_adminer_copy_adminer_mu_plugin() {
extract(PEXLECHRIS_ADMINER_MU_PLUGIN_DATA);
$option = get_option( $option_name, null );
if( $option === null) {
// continue to updating mu plugin
}elseif( empty($option) ){ // 0 or empty string
return;
}elseif( version_compare( $version, $option ) > 0 ){
// continue to updating mu plugin
}else{
return;
}
$from = PEXLECHRIS_ADMINER_DIR . '/' . $file . '.txt';
$to = WPMU_PLUGIN_DIR . '/' . $file;
if( file_exists($to) ){
unlink($to);
}
wp_mkdir_p(WPMU_PLUGIN_DIR);
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
$WP_Filesystem_Direct = new WP_Filesystem_Direct([]);
$WP_Filesystem_Direct->copy($from, $to);
update_option($option_name, $version);
}
/**
* @since 2.2.0
*/
register_deactivation_hook(__FILE__, 'pexlechris_adminer_delete_adminer_mu_plugin');
function pexlechris_adminer_delete_adminer_mu_plugin()
{
extract(PEXLECHRIS_ADMINER_MU_PLUGIN_DATA);
$mu_plugin = WPMU_PLUGIN_DIR . '/' . $file;
if (file_exists($mu_plugin)) {
unlink($mu_plugin);
}
delete_option($option_name);
}
add_action( 'plugins_loaded', 'pexlechris_maybe_set_wp_admin_constant', 1 );
function pexlechris_maybe_set_wp_admin_constant()
{
if( !pexlechris_is_current_url_the_wp_adminer_url() ) return;
if( !have_current_user_access_to_pexlechris_adminer() ) return;
if( defined('WP_ADMIN') ) return;
define('WP_ADMIN', true); // adminer is an admin tool, so must be considered as admin interface
}
add_action( 'plugins_loaded', 'pexlechris_adminer_load_plugin_textdomain', 1 );
function pexlechris_adminer_load_plugin_textdomain() {
load_plugin_textdomain(
'pexlechris-adminer',
false,
'pexlechris-adminer/languages'
);
}
//INIT
function determine_if_pexlechris_adminer_will_be_included()
{
if( have_current_user_access_to_pexlechris_adminer() ){
/**
* @hooked pexlechris_adminer_before_adminer_loads, priority: 10
* @hooked pexlechris_adminer_disable_display_errors_before_adminer_loads, priority: 100
*/
do_action('pexlechris_adminer_before_adminer_loads');
include 'inc/adminer_includer.php';
exit;
}else{
do_action('pexlechris_adminer_current_user_has_not_access');
}
}
if( pexlechris_is_current_url_the_wp_adminer_url() )
{
add_action('plugins_loaded', 'determine_if_pexlechris_adminer_will_be_included', 2);
}
//POSITION 1
add_action('admin_bar_menu', 'pexlechris_adminer_register_in_wp_admin_bar' , 50);
function pexlechris_adminer_register_in_wp_admin_bar($wp_admin_bar) {
if( have_current_user_access_to_pexlechris_adminer() ){
$args = array(
'id' => 'wp_adminer',
'title' => esc_html__('WP Adminer', 'pexlechris-adminer'),
'href' => esc_url(site_url() . '/' . PEXLECHRIS_ADMINER_SLUG),
"meta" => array(
"target" => "_blank"
)
);
$wp_admin_bar->add_node($args);
}
}
//POSITION 2
add_action('admin_menu', 'register_pexlechris_adminer_as_tool');
function register_pexlechris_adminer_as_tool(){
add_submenu_page(
'tools.php',
esc_html__('WP Adminer', 'pexlechris-adminer'),
esc_html__('WP Adminer', 'pexlechris-adminer'),
implode(',', pexlechris_adminer_access_capabilities()),
PEXLECHRIS_ADMINER_SLUG,
'pexlechris_adminer_tools_page_content',
3
);
}
//IN TOOLS
if( !function_exists('pexlechris_adminer_tools_page_content') ){
function pexlechris_adminer_tools_page_content(){
?>
define('PEXLECHRIS_ADMINER_HAVE_ACCESS_ONLY_IN_WP_DB', false);"
);
}
}
}
add_action('pexlechris_adminer_before_adminer_loads', 'pexlechris_adminer_disable_display_errors_before_adminer_loads', 100);
function pexlechris_adminer_disable_display_errors_before_adminer_loads()
{
/**
* @since 2.1.0 firstly set
* @since 2.1.1 move after action pexlechris_adminer_before_adminer_loads
* @since 2.2.0 moved to a wp action with priority 100
*/
ini_set('display_errors', 0);
/**
* @since 3.0.0
*/
add_filter( 'doing_it_wrong_trigger_error', '__return_false' );
}