Simple Table Of Contents

add_filter( ‘the_content’, function ( $content ) { // This snippet requires the DOMDocument class to be available. if ( ! class_exists( ‘DOMDocument’ ) ) { return $content; } if ( !is_single() || !in_the_loop() || !is_main_query() ) { return $content; }…Continue reading

Disable jQuery Migrate

add_action( ‘wp_default_scripts’, function ( $scripts ) { if ( ! is_admin() && isset( $scripts->registered[‘jquery’] ) ) { $script = $scripts->registered[‘jquery’]; if ( ! empty( $script->deps ) ) { $script->deps = array_diff( $script->deps, array( ‘jquery-migrate’ ) ); } } }, 150…Continue reading

Limit Uploaded Image Size

add_filter( ‘wp_handle_upload’, function ( $file ) { $max_width = 1920; $max_height = 1920; // Check if the file is an image. $mime_type = mime_content_type( $file[‘file’] ); if ( strpos( $mime_type, ‘image’ ) === false ) { return $file; } //…Continue reading

Open External Links in a New Tab

add_filter( ‘the_content’, function ( $content ) { // This snippet requires the DOMDocument class to be available. if ( ! class_exists( ‘DOMDocument’ ) ) { return $content; } if ( !is_single() || !in_the_loop() || !is_main_query() ) { return $content; }…Continue reading

Maintenance Mode

add_action( ‘init’, function() { if ( ! current_user_can( ‘manage_options’ ) && ! is_admin() && ! is_login() ) { wp_die( ‘This website is currently undergoing scheduled maintenance. Please try again later.’ ); } } );Continue reading

Custom API Keys

/** * Returns the Stripe Secret key. */ function get_secret_key( $key ) { return ‘sk_live_123’; } add_filter( ‘simpay_stripe_api_secret_key’, ‘get_secret_key’ ); add_filter( ‘simpay_secret_key’, ‘get_secret_key’ ); /** * Returns the Stripe Publishable key. */ function get_publishable_key( $key ) { return ‘pk_live_123’; }…Continue reading

RT7 Official – Maintenance Mode (copy)

function custom_maintenance_mode() { if ( ! is_user_logged_in() ) { header( ‘HTTP/1.1 503 Service Temporarily Unavailable’ ); header( ‘Content-Type: text/html; charset=utf-8’ ); header( ‘Retry-After: 3600’ ); // You can change this value to set a different retry time (in seconds). ?>…Continue reading

Require Downloadable fields – Downloadable product template

add_filter( ‘wcvendors_pro_product_form_download_files_path’, ‘make_required’ ); add_filter( ‘wcvendors_pro_product_form_product_attributes_path’, ‘make_required’ ); add_filter( ‘wcv_product_dowlnoad_limit’, ‘make_required’ ); add_filter( ‘wcv_product_download_expiry’, ‘make_required’ ); function make_required( $field ){ $field[‘custom_attributes’] = array( ‘required’ => ” ); return $field; }Continue reading

Untitled Snippet

function obtener_sismos_recientes() { // URL de la API $url = ‘https://ultimosismo.igp.gob.pe/ultimo-sismo/ajaxb/2024?_=1694788511856’; // Obtener los datos de la API $respuesta = wp_remote_get($url); if (is_wp_error($respuesta)) { return ‘No se pudieron obtener los datos de los sismos.’; } $cuerpo = wp_remote_retrieve_body($respuesta); $datos =…Continue reading