BLog
Want to Learn About Coding?
WooCommerce: Redirect single product pages to home page
/** * @snippet WooCommerce Redirect single product pages to home page */ add_action( 'wp', 'ts_redirect_product_pages', 99 ); function ts_redirect_product_pages() { if ( is_product() ) { wp_safe_redirect( home_url() ); exit; }...
Chain three asynchronous calls using jQuery promises
$.ajax() .then(function(){ return $.ajax() //second ajax call }) .then(function(){ return $.ajax() //third ajax call }) .done(function(resp){ //handle final response here })
Linux fsck command
The system utility fsck (file system consistency check) is a tool for checking the consistency of a file system in Unix and Unix-like operating systems, such as Linux, macOS, and FreeBSD. fsck -y /dev/sda1 Emergency help: -p Automatic repair (no questions) -n Make no...
Clone disk/partition to external HDD/SSD with ‘dd’ command in Linux
To clone HDD/partition with dd command, the destination HDD/partition must be equal or larger in size than the source. sudo dd if=/dev/sda5 of=/dev/sdb2 conv=sync,noerror bs=64K status=progress if=/dev/sda5/path/to/the/source/disk...
Add footer to the WordPress page template
<?php wp_footer(); ?>
Add header to the WordPress page template
<?php wp_head(); ?>
Add menu to page.php in WordPress template
<?php wp_nav_menu( array( 'theme_location' => 'primary-menu', ) ); ?> To add menu to the page.php in WordPress template add th
Add php files in WordPress plugin
//include php files include( plugin_dir_path( __FILE__ ) . 'assets/backend/post-tipe-candidates.php'); include( plugin_dir_path( __FILE__ ) . 'assets/backend/acf-candidate.php');
Add back-end CSS to WordPress
//add backend css $myCssFileSrc = plugins_url( '/assets/css/style-backend.css', __FILE__ ); wp_enqueue_style( 'style-backend.css', $myCssFileSrc );
Create WordPress plugin
<?php /* Plugin Name: Aerotech Configuration Plugin Plugin URI: http://programmer.iz.rs Description: Changes the output from The Other Plugin using a bit of code Author: Milan Grujic Version: 1.0.0 Author URI: http://programmer.iz.rs License: GPL2 */
Woocommerec hide add to chart on category or product
add_action('woocommerce_single_product_summary', 'remove_product_description_add_cart_button', 1 ); function remove_product_description_add_cart_button() { // function for deleting ... // Set HERE your category ID, slug or name (or an array) $categories =...
WordPress allow an user role to create a new user with a lower capabilities
/** * Helper function get getting roles that the user is allowed to create/edit/delete. * * @param WP_User $user * @return array */ function wpse_188863_get_allowed_roles( $user ) { $allowed = array(); if ( in_array( 'administrator', $user->roles ) ) { // Admin can...