' . $this->get_file_path( true ) . '
'
);
echo '' . esc_html( $rules ) . ''; } elseif ( $is_nginx ) { printf( /* translators: %s is a file name. */ esc_html__( 'If you choose to use rewrite rules, the file %s will be created and must be included into the server’s configuration file (then restart the server).', 'imagify' ), '
' . $this->get_file_path( true ) . '
'
);
}
}
/**
* Add rules on plugin activation.
*
* @since 1.9
*/
public function activate() {
$conf = $this->get_server_conf();
if ( ! $conf ) {
return;
}
if ( ! get_imagify_option( 'display_nextgen' ) ) {
return;
}
if ( self::OPTION_VALUE !== get_imagify_option( 'display_nextgen_method' ) ) {
return;
}
if ( is_wp_error( $conf->is_file_writable() ) ) {
return;
}
$conf->add();
}
/**
* Remove rules on plugin deactivation.
*
* @since 1.9
*/
public function deactivate() {
$conf = $this->get_server_conf();
if ( ! $conf ) {
return;
}
if ( ! get_imagify_option( 'display_nextgen' ) ) {
return;
}
if ( self::OPTION_VALUE !== get_imagify_option( 'display_nextgen_method' ) ) {
return;
}
$file_path = $conf->get_file_path();
$filesystem = \Imagify_Filesystem::get_instance();
if ( ! $filesystem->exists( $file_path ) ) {
return;
}
if ( ! $filesystem->is_writable( $file_path ) ) {
return;
}
$conf->remove();
}
/**
* Get the path to the directory conf file.
*
* @since 1.9
*
* @param bool $relative True to get a path relative to the site’s root.
*
* @return string|bool The file path. False on failure.
*/
public function get_file_path( $relative = false ) {
if ( ! $this->get_server_conf() ) {
return false;
}
$file_path = $this->get_server_conf()->get_file_path();
if ( $relative ) {
return \Imagify_Filesystem::get_instance()->make_path_relative( $file_path );
}
return $file_path;
}
/**
* Get the server conf instance.
*
* @since 1.9
*
* @return WriteFileInterface
*/
protected function get_server_conf() {
global $is_apache, $is_iis7, $is_nginx;
if ( isset( $this->server_conf ) ) {
return $this->server_conf;
}
if ( $is_apache ) {
$this->server_conf = new Apache();
} elseif ( $is_iis7 ) {
$this->server_conf = new IIS();
} elseif ( $is_nginx ) {
$this->server_conf = new Nginx();
}
return $this->server_conf;
}
}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e