Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/hostinge.../includes
File: Hooks.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Hostinger;
[2] Fix | Delete
[3] Fix | Delete
use Hostinger\Admin\PluginSettings;
[4] Fix | Delete
use Hostinger\WpHelper\Utils;
[5] Fix | Delete
[6] Fix | Delete
defined( 'ABSPATH' ) || exit;
[7] Fix | Delete
[8] Fix | Delete
class Hooks {
[9] Fix | Delete
public function __construct() {
[10] Fix | Delete
// XMLRpc / Force SSL
[11] Fix | Delete
add_filter( 'xmlrpc_enabled', array( $this, 'check_xmlrpc_enabled' ) );
[12] Fix | Delete
add_filter( 'wp_headers', array( $this, 'check_pingback' ) );
[13] Fix | Delete
add_filter( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
[14] Fix | Delete
}
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* @return void
[18] Fix | Delete
*/
[19] Fix | Delete
public function plugins_loaded() {
[20] Fix | Delete
$utils = new Utils();
[21] Fix | Delete
$plugin_settings = new PluginSettings();
[22] Fix | Delete
$settings = $plugin_settings->get_plugin_settings();
[23] Fix | Delete
[24] Fix | Delete
if ( defined( 'WP_CLI' ) && \WP_CLI ) {
[25] Fix | Delete
return;
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
// Xmlrpc.
[29] Fix | Delete
if ( $settings->get_disable_xml_rpc() && $utils->isThisPage( 'xmlrpc.php' ) ) {
[30] Fix | Delete
exit( 'Disabled' );
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
// SSL redirect.
[34] Fix | Delete
if ( $settings->get_force_https() && ! is_ssl() ) {
[35] Fix | Delete
if ( isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ) {
[36] Fix | Delete
$host = sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) );
[37] Fix | Delete
[38] Fix | Delete
if ( $settings->get_force_www() && strpos( $host, 'www.' ) === false ) {
[39] Fix | Delete
$host = 'www.' . $host;
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
wp_safe_redirect( 'https://' . $host . sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 301 );
[43] Fix | Delete
exit;
[44] Fix | Delete
}
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
// Force www.
[48] Fix | Delete
if ( $settings->get_force_www() ) {
[49] Fix | Delete
if ( isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ) {
[50] Fix | Delete
$host = sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) );
[51] Fix | Delete
[52] Fix | Delete
if ( strpos( $host, 'www.' ) === false ) {
[53] Fix | Delete
wp_safe_redirect( 'https://www.' . $host . sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 301 );
[54] Fix | Delete
exit;
[55] Fix | Delete
}
[56] Fix | Delete
}
[57] Fix | Delete
}
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* @param mixed $headers
[62] Fix | Delete
*
[63] Fix | Delete
* @return mixed
[64] Fix | Delete
*/
[65] Fix | Delete
public function check_pingback( $headers ) {
[66] Fix | Delete
$plugin_settings = new PluginSettings();
[67] Fix | Delete
$settings = $plugin_settings->get_plugin_settings();
[68] Fix | Delete
[69] Fix | Delete
if ( $settings->get_disable_xml_rpc() ) {
[70] Fix | Delete
unset( $headers['X-Pingback'] );
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
return $headers;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* @return bool
[78] Fix | Delete
*/
[79] Fix | Delete
public function check_xmlrpc_enabled(): bool {
[80] Fix | Delete
$plugin_settings = new PluginSettings();
[81] Fix | Delete
$settings = $plugin_settings->get_plugin_settings();
[82] Fix | Delete
[83] Fix | Delete
if ( $settings->get_disable_xml_rpc() ) {
[84] Fix | Delete
return false;
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
return true;
[88] Fix | Delete
}
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function