Shortcode to insert video on page

function video_shortcode($atts) { // Extract attributes $atts = shortcode_atts( array( 'src' => ”, // Video URL 'width' => '600', // Default width 'height' => '400' // Default height ), $atts, 'video' ); // Create video tag $output = '

Read More

Dashboard link “Go to website” open in new tab

/** * Dashboard: Visit Site link new tab */ add_action( 'admin_bar_menu', 'shatel_view', 999 ); function shatel_view( $wp_admin_bar ) { $all_toolbar_nodes = $wp_admin_bar->get_nodes(); foreach ( $all_toolbar_nodes as $node ) { if($node->id == 'site-name' || $node->id == 'view-site') { $args = $node; $args->meta = array('target' => '_blank'); $wp_admin_bar->add_node( $args ); } } } This function modifies the […]

Read More

Hide fields in checkout based on specific products

To remove a custom field from checkout in WooCommerce when a specific product is in the cart, you can use the woocommerce_checkout_fields function and remove the field based on the product. Here is a sample code that can help you: add_filter( 'woocommerce_checkout_fields', 'remove_custom_field_based_on_product' ); function remove_custom_field_based_on_product( $fields ) { // Insert the product ID here that the […]

Read More

How to add code snippets to a WordPress website

Code snippets are small code segments that can be easily integrated into a website or application. They allow you to add functionality or easily modify existing functionality. Code snippets play an important role in the development process, from customizing the look of a website to adding new functionality that is not included in the default installation. 1. functions.php file The […]

Read More

Disable the search function

function fb_filter_query( $query, $error = true ) { if ( is_search() ) { $query->is_search = false; $query->query_vars[s] = false; $query->query[s] = false; // to error if ( $error == true ) $query->is_404 = true; } } add_action( ‘parse_query’, ‘fb_filter_query’ ); add_filter( ‘get_search_form’, create_function( ‘$a’, “return null;” ) );   Wenn du die Suchfunktion auf deiner […]

Read More

Protect your website from attacks

global $user_ID; if($user_ID) { if(!current_user_can('administrator')) { if (strlen($_SERVER['REQUEST_URI']) > 255 || stripos($_SERVER['REQUEST_URI'], “eval()”) || stripos($_SERVER['REQUEST_URI'], “CONCAT”) || VER['REQUEST_URI'], “UNION+SELECT”) ||. stripos($_SERVER['REQUEST_URI'], “base64”)) { @header(“HTTP/1.1 414 Request-URI Too Long”); @header(“Connection: Close”); @exit; User who visits the website is an administrator. If the user […]

Read More

Prevent scanning for authors

To prevent WordPress pages from being scanned for authors, you can add a function in the theme's functions.php file. Here is an example of such a function: function block_author_scans() { if( is_author() ) { global $wp_query; $wp_query->set_404(); status_header(404); nocache_headers(); } } add_action( 'wp', 'block_author_scans' ); This function checks if the current page is an author page, […]

Read More

Hide certain payment methods in the checkout for certain products

In this example, you need to customize the hide_payment_method_for_specific_products function by changing the product IDs and the names of the payment methods you want to hide according to your requirements. Add this function to your theme's functions.php and it will hide the selected payment methods based on the product IDs. Please note that this is just an example and you […]

Read More

The date() function in PHP

The date() function in PHP is used to format and display the current date and time. It accepts a formatting pattern as an argument and returns a string that represents the date and time according to the specified pattern. Here is a more detailed description of the date() function as well as some formatting examples that are common for Germany. Syntax […]

Read More