|
Server IP : 10.106.20.8 / Your IP : 216.73.216.148 Web Server : Apache System : Linux webm008.cluster106.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : sixiemesrc ( 611999) PHP Version : 8.0.30 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/sixiemesrc/new/wp-content/languages/../plugins/query-monitor/classes/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php declare(strict_types = 1);
/**
* Plugin CLI command.
*
* @package query-monitor
*/
class QM_CLI extends QM_Plugin {
/**
* @param string $file
*/
protected function __construct( $file ) {
# Register command
WP_CLI::add_command( 'qm enable', array( $this, 'enable' ) );
# Parent setup:
parent::__construct( $file );
}
/**
* Enable QM by creating the symlink for db.php
*
* @return void
*/
public function enable() {
$drop_in = WP_CONTENT_DIR . '/db.php';
if ( file_exists( $drop_in ) ) {
$contents = file_get_contents( $drop_in );
if ( false !== $contents && false !== strpos( $contents, 'new QM_DB' ) ) {
WP_CLI::success( "Query Monitor's wp-content/db.php is already in place" );
exit( 0 );
} else {
WP_CLI::error( 'Unknown wp-content/db.php is already in place' );
}
}
if ( defined( 'QM_DB_SYMLINK' ) && ! QM_DB_SYMLINK ) {
WP_CLI::warning( 'Creation of symlink prevented by QM_DB_SYMLINK constant.' );
exit( 0 );
}
if ( ! function_exists( 'symlink' ) ) {
WP_CLI::error( 'The symlink function is not available' );
}
if ( symlink( $this->plugin_path( 'wp-content/db.php' ), $drop_in ) ) {
WP_CLI::success( 'wp-content/db.php symlink created' );
exit( 0 );
} else {
WP_CLI::error( 'Failed to create wp-content/db.php symlink' );
}
}
/**
* @param string $file
* @return self
*/
public static function init( ?string $file = null ) {
static $instance = null;
if ( ! $instance ) {
$instance = new QM_CLI( $file );
}
return $instance;
}
}