Sunday 3 March 2019

Disable plugin updates in WordPress with hook

There may be a time/requirement/situation when you have to disable the plugin updates in backend, to do that we would be using the following hook:
add_filter( 'site_transient_update_plugins', 'your-custom-function' );
Waning: Below steps are only for those who knows and have Idea of customization in WordPress, also before proceeding its strongly recommended to take full theme/website backup, and to make such changes only use FTP or cPanel.

To disable the update we would be using the following steps:

1) Go to WordPress themes folder either through FTP or through cPanel or your local server.
2) Now find the theme name which is active and look for "functions.php" file in it and open that in your code editor. (I believe before that you have already taken the backup of theme.)
3) Now add the following code at the very bottom of your functions.php file.

function stop_plugin_updates( $value ) {
    unset( $value->response['name-of-plugin/plugin-file-name-with-file-extension'] );
    return $value;
}
add_filter( 'site_transient_update_plugins', 'stop_plugin_updates' );  
4) Now go to your admin side and look for plugins which is showing plugin update message.
5) Now go to plugins folder through FTP or local server of the project and look for plugin which is showing the updates in admin; copy the name of the plugin exactly in the same format as shown in the plugin folder and add in place of "name-of-plugin".
6) Now open that plugin folder and look for a file which contains all information like: name of plugin, version , author etc; now in place of "plugin-file-name-with-file-extension" on above code add file name with extension.
7) Now save the file (On FTP you have to upload to server).
8) Go to admin side and see plugin has stopped to show updates warning.

Video demonstration of above steps:



Version at the time of demonstration:
1) WordPress: Version 5.1
2) Local server: WampServer Version 3.1.7 64bit
3) Code Editor: Sublime Text Version 3.1.1 Build 3176
4) OS: Window 7 Home basic.
Read more

Sunday 12 August 2018

Redirect to Checkout / custom page on Add to Cart button click – WooCommerce

There may be time when client would ask you to redirect user to checkout or cart page directly when users click on add to cart button.

For the similar situations WooCommerce provide predefined settings and filter hook which you can use to achieve the results.

To redirect the users, you can follow below steps:
1) I believe you have WordPress and WooCommerce already setup, now you can go to WooCommerce > Settings > Products tab.
2) Now look for "Add to cart behaviour" and there you will find the two settings: first is "Redirect to the cart page after successful addition" and second would be "Enable AJAX add to cart buttons on archives".
3) Now suppose if you want no redirection and want user to stay on the page without page reload, you can select the second checkbox "Enable AJAX add to cart buttons on archives" and you are done.
4) If you want users to redirect to cart page after user click on add to cart you can select the first option "Redirect to the cart page after successful addition" and you are done.
5) And if you have requirement to sent the user to checkout/custom page after user click on add to cart button, please uncheck both the options there follow the next step.
6) Now open your theme's functions.php file and copy/paste the below code.
function my_custom_add_to_cart_redirect( $url ) {  
 // for checkout page 
 $url = wc_get_checkout_url(); 
 
 // for custom/home page in our case.
 // $url = home_url(); 
 return $url;
}
add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' );

Below is the video demonstration for above mentioned points.




Version at the time of demonstration:
1) WordPress: v4.9.8
2) Localserver: WampServer Version 2.5
3) WooCommerce: v3.4.4
4) Twenty Sixteen Theme: v1.5

Read more

Monday 6 August 2018

Plugin that helps to keep all WordPress emails logs going through the site.

There are some situations while developing the website for client you might face issues related to email failures through WordPress. 

In that case it becomes very handy if you have errors log to let you know the error/bugs/issues you are facing with emails settings.

For this Christian Zöller has posted a plugin WP Mail Logging which keeps the emails errors logs for you so that you can debug the issue also have records of the forms submission if it does not reach to you in emails notification.

Below is the video demonstration for above mentioned points.




Version at the time of demonstration:
1) WordPress: 4.9.8
2) Localserver: XAMPP Control Panel v3.2.2
3) Contact Form 7 v5.0.3
4) WP Mail Logging v1.8.4


Read more

Sunday 5 August 2018

Add URL redirection or 301 Redirect through .htaccess file

To add URL redirection from old to new URL you can add by using the below mentioned code;

Redirect 301 old_URL new_URL

Here "old_URL" means relative path for example your old URL was something like: www.example.com/about/ so you have to write only "/about/" do not include full url path and always exclude domain name in the URL.

And "new_URL" to have to mention full path/absolute part like "www.example.com/about-us/"

You can find the .htaccess file in WordPress root folder directory (Or project root folder) or create there if not present.

Example:
old_URL: http://www.wordpresslocal.com/about-old/
new_URL: http://www.wordpresslocal.com/about-us/

Code which need to add in .htaccess file is:

Redirect 301 /about-old/ http://www.wordpresslocal.com/about-us/


Below is the video demonstration for above mentioned points.




Version at the time of demonstration
1) WordPress: 4.9.8
2) Localserver: XAMPP Control Panel v3.2.2
3) Visual Studio Code v1.25
Read more

Friday 20 October 2017

Redirect to new page from dropdown selected value

If you would like to open your select option tags values links in new tab, you can use the below mentioned code using jQuery.



  ;(function($){
    $('select').change(function(){
    var getValue = $(this).val();
    window.open(getValue, '_blank');
    })
  }(jQuery));


Below is the demonstration of above mentioned code on CodePen.




Read more

Create admin through using FTP: WordPress

There may be some scenarios when you have to implement the changes in website content for WP where client do not have administrator credentials with him which he can share or he has forget about it or there would could be other reasons he don't have the credentials,

If you have cPanel details you can manage the things from there, and if client only shares FTP details, in that case you can follow the below steps to create a new Administrator user:
  1. Connect through valid FTP details:
  2. Visit the website and through view source code confirm the Active theme in your WP.
  3. Through FTP go to your active theme functions.php file and at the very end use the following code with proper admin details you would like to have.

  4.   function wpb_admin_account(){
       $user = 'Username';
       $pass = 'Password';
       $email = 'email@domain.com';
       if ( !username_exists( $user )  && !email_exists( $email ) ) {
       $user_id = wp_create_user( $user, $pass, $email );
       $user = new WP_User( $user_id );
       $user->set_role( 'administrator' );
       } 
      }
      add_action('init','wpb_admin_account');
    
    


  5. And do not forget to use unique username and email (as with same details you can't have other WP users).
  6. After user has been created do not forget to use delete this code from your functions.php file.
  7. And you are done!

Below is the video demonstration for above mentioned points.



Version at the time of demonstration
WP: 4.8.2


Read more

Sunday 8 October 2017

How to open multiple Skype on Windows 10 OS

I am sure you know that Skype provide the functionality to run multiple Skype Windows (means you can login to multiple Skype IDs at one time on different Skype Windows), so that you don't miss any communication/updates, sometimes in your workplace you want to login to different Skype IDs simultaneously.

To open the multiple Skype IDs please follow the below steps:
Please Note: Below mentioned steps are for Window 10 OS.

  1. Open the following folder in your system "C:\Program Files (x86)\Skype\Phone".
  2. Right click on the file name "Skype.exe" a popup menu will appear, please go to "Sent To" and click on "Desktop (create shortcut)" now a Skype icon will appear on the Desktop.
  3. Go to your Desktop, right click on Skype icon and from appeared popup click on "Properties" option. 
  4. In Shortcut tab you will see a "Target" field, in this field write the this code/line at very last with one space [ /secondary ] (Please not do not delete anything just write this at very last), after writing this line would appear something like this [ "C:\Program Files (x86)\Skype\Phone\Skype.exe" /secondary ].
  5. Apply these changes and double click on Skype icon on desktop and you are done!.


Below video is for the demonstration for the points mentioned above for better understanding.


Version at the time of demonstration:
Windows: Window 10 OS
Skype: 7.40.0.103
Read more

Saturday 7 October 2017

How to customise bbPress — WordPress Plugins?

This tutorial is related to how to prepare the bbPress WP plugin for customisation, if you have requirement to make changes in the bbPress default provided designs and you don't know how to make the basic setup to make the customisation for this plugin. Then please follow the below instructions:

  1. Login using your WP credentials. 
  2. Install bbPress Plugin through add plugin.
  3. Made the basic settings/ create few test forums.
  4. To start making UI customisation go to following directory of your WordPress "\wp-content\plugins\bbpress\templates\default\bbpress" and copy the appropriate file you want to make change in our case its "loop-forums.php".
  5. Copy the file and paste it in your theme which is active and open in your preferred code editor.
  6. To confirm if we have appropriate or desired file make some testing like echo something and if you seeing the results then you are done if not then you have the wrong file, so find the appropriate and start coding.

Below I have mentioned a demonstration video of above mentioned points for visual go through.



Version at the time of demonstration:
WordPress: 4.8.2
bbPress: 2.5.14
Apache server: 2.4.9
PHP  5.5.12
MySQL: 5.6.17
Read more

Friday 6 October 2017

How to make changes in your hosts file: Windows OS?

In some client requirements client asks to change the hosting server of websites, in those cases before making the CNAME/nameserver changes in domain settings, we made changes in the host file of local system to upload the website to new server before making everything live or making such changes in the live/production server.

To make changes in your host file in Window OS, please follow the below steps:

  1. Click on start menu and type "notepad".
  2. Right click on it notepad and select the option "Run as administrator".
  3. Now press "CTRL+O" to open the file.
  4. In file name input box copy this line "C:\Windows\System32\drivers\etc\hosts" and press enter.
  5. As the hosts file has been open now scroll till the end.
  6. At the very bottom you need to define two things, first is the IP of hosting server and second is the domain name, in our case (demonstration) I have one website running "www.amitwalia.info" which is hosted on google and one hosting which is localhost (implemented using WAMP).
  7. Now Localhost in most of the case point to "127.0.0.1" IP, in our example I will divert the www.amitwalia,info website to our localhost IP.
  8. Now in your hosts file at the very bottom first specify the new hosting server IP then mention the domain name like mentioned below.

  9. 127.0.0.1       www.example.com

  10. Now save the file and go to your browser, clear the caches and visit your www.example.com
  11. And you are done! You can also use this method to block some websites on your system.



Please find below the video demonstration of the points mentioned above as a quick review.



Read more

Thursday 5 October 2017

How to increase number of file uploading from 1 to 10 on filezilla on Windows OS

If you are uploading large number of files using Filezilla to your production/development servers, you would like to upload upto 10 files at once then please follow the below steps:


  1. Open Filezilla and go to "Edit" and click on "Settings".
  2. A window will open there find "Transfer" option on left side and click on it.
  3. On right section you will see the "Concurrent Transfer" as first section there you can specify the number of concurrent transfer at one time. Please note value should be between 1-10.
  4. You are done.

Please find the video tutorial for demonstration of above mentioned points.


Version at the time of demonstration
Filezilla: 3.37.1

Read more