WP Simple Pay: Block Duplicate Email Addresses

/** * @link https://library.wpcode.com/snippet/ro8xmx35/ */ add_action( ‘simpay_before_payment_create’, /** * @param \WP_REST_Request WordPress REST API request. */ function( $request ) { // Retrieve form values. $fields = $request->get_param( ‘form_values’ ); $email = $fields[‘simpay_email’]; // Search for customers based on email. $customers…Continue reading

Add author name to article schema if its missing

add_filter( ‘aioseo_schema_output’, ‘add_author_name_when_missing’ ); function add_author_name_when_missing( $schema ) { if ( is_single() && ‘post’ == get_post_type() ) { global $post; $author_id = $post->post_author; $author_name = get_the_author_meta( ‘display_name’, $author_id ); foreach ( $schema as &$schemaItem ) { if ( isset($schemaItem[‘@type’]) &&…Continue reading

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