Skip to content

Instantly share code, notes, and snippets.

@otakupahp
Last active December 13, 2022 14:25
Show Gist options
  • Save otakupahp/ae5ac700a0dc2ae782fb7b1e54d441c9 to your computer and use it in GitHub Desktop.
Save otakupahp/ae5ac700a0dc2ae782fb7b1e54d441c9 to your computer and use it in GitHub Desktop.
WP MU Misc Plugins
<?php
/*
Plugin Name: OtakuPahp Security Measures
Description: Some Wordpress Hacks to improve site security
Author: Pablo Hernandez (OtakuPahp)
Author URI: https://otakupahp.llc
Version: 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Disable REST API user endpoints.
*
* @param array $endpoints The original endpoints.
* @return array The updated endpoints.
* @since 1.0.0
*/
function smntcs_rest_endpoints( $endpoints ) {
if ( isset( $endpoints['/wp/v2/users'] ) ) {
unset( $endpoints['/wp/v2/users'] );
}
if ( isset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] ) ) {
unset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] );
}
return $endpoints;
}
add_filter( 'rest_endpoints', 'smntcs_rest_endpoints' );
/**
* If you want to deactivate XMLRPC.PHP copy the folowing code
* at the end of your .htaccess file
*/
/*
# Block WordPress xmlrpc.php requests
<Files xmlrpc.php>
order deny,allow
deny from all
</Files>
*/
<?php
/**
* Plugin Name: OtakuPahp WC Hacks
* Description: Some WooCommerce Hacks
* Author: Pablo Hernandez (OtakuPahp)
* Author URI: https://otakupahp.llc
* Version: 1.0.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Add a shortcode to replace for current product ID
add_shortcode('otk_product_id', function() {
return get_the_ID();
});
// Hack elementor to use our shortcode
add_action( 'elementor/frontend/the_content', function( $content ) {
return str_replace( array('[otk_product_id]','%5Botk_product_id%5D'), get_the_ID(), $content );
} );
@otakupahp
Copy link
Author

Any of these plugins could be set at the mu-plugins folder of WP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment