Skip to content

Instantly share code, notes, and snippets.

View vandanojan's full-sized avatar

Vanda Nojan | وندا نوژن vandanojan

View GitHub Profile
<?php
function fix_wp_sitemap_whitespace($input) {
$allowed = false;
$found = false;
foreach (headers_list() as $header) {
if (preg_match("/^content-type:\s+(text\/(html|application\/(xhtml\+xml|atom\+xml|xml)))/i", $header)) {
$allowed = true;
@vandanojan
vandanojan / lottie-json-file-as-background-in-elementor.html
Created March 27, 2024 06:34
To set a Lottie json file as background in Elementor Section/Container
<!--
First, create an Elementor section/container and set its CSS id as #lottie.
Then, add an HTML block below it and copy/paste the following code.
Upload your Lottie JSON file to the WordPress library and replace "path-to-lottie-file" in the code with the file URL.
-->
<style>
#lottie {
position: relative;
}
@vandanojan
vandanojan / Server -IP-Address-Retrieval-Script.php
Created March 24, 2024 15:44
This PHP script checks if the exec() function is enabled on the server. If so, it retrieves the server's IP address using the hostname -i command and returns it
<?php
if (function_exists('exec')) {
$ip_from_exec = exec('hostname -i');
echo "IP Address (via exec): $ip_from_exec";
} else {
echo "exec() function is not enabled on this server.";
}
?>
@vandanojan
vandanojan / Server-Real-IP-Address.php
Last active March 24, 2024 15:44
Server's Real IP Address
<?php
$this_server_real_ip_address = "";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.ipify.org"); //or replace the URL with https://www.showmyip.com/
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$this_server_real_ip_address = curl_exec($ch);
@vandanojan
vandanojan / v2rayng-cloudflare-tunnel-fragment-config.json
Last active January 12, 2024 09:47
Cloudflare Tunnel (Fragmentation) Sample Config (for V2rayNG)
{
"log": {
"access": "",
"error": "",
"loglevel": "warning"
},
"inbounds": [
{
"tag": "socks",
"port": 10808,
@vandanojan
vandanojan / Re-enable-Right-Click-Option-on-Web-Page.js
Last active January 12, 2025 16:30
To re-enable the right click (context) menu, it is enough to copy the code, type "javascript:" in the address bar of your browser and then paste the copied code, i.e., javascript:[CODE]
function enableContextMenu(aggressive = true) {
void (document.ondragstart = null);
void (document.onselectstart = null);
void (document.onclick = null);
void (document.onmousedown = null);
void (document.onmouseup = null);
void (document.body.oncontextmenu = null);
enableRightClickLight(document);
if (aggressive) {
enableRightClick(document);
@vandanojan
vandanojan / woocommerce-sold-product-number-display
Created January 24, 2022 03:43
Displaying the number of products sold in Woocommerce
add_action( 'woocommerce_single_product_summary', 'wp_product_sold_count', 11 );
function wp_product_sold_count() {
global $product;
$total_sold = $product->get_total_sales();
if ( $total_sold )
echo '' . sprintf( __( 'Total Sales: %s', 'woocommerce' ), $total_sold ) . '';
}
@vandanojan
vandanojan / HTML-Minification.php
Last active March 24, 2024 15:48
To minify HTML, add the following code snippet to the end of your theme's functions.php
class FLHM_HTML_Compression
{
protected $flhm_compress_css = true;
protected $flhm_compress_js = true;
protected $flhm_info_comment = true;
protected $flhm_remove_comments = true;
protected $html;
public function __construct($html)
{
if (!empty($html))
@vandanojan
vandanojan / remove thumbnail in single posts
Created October 5, 2021 02:09
WordPress: How To Remove Featured Images in Single Posts
function my_post_image_html( $html, $post_id, $post_image_id ) {
if(is_single()) {
return '';
} else
return $html;
}
add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
@vandanojan
vandanojan / woocommerce remove quantity selector for all products
Created September 30, 2021 23:37
woocommerce: remove quantity selector for all products
/**
* Remove Quantity Selector for All Products
*/
function wc_remove_all_quantity_fields( $return, $product ) {
return true;
}
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 );