úterý 2. srpna 2016

pátek 19. února 2016

How to change Woocommerce default ajax loader icon in Cart and Checkout

This little snippet will going to change your loader icon in WooCommerce Cart and Checkout.

In Cart you should see this icon when you update Shipping.
In Checkout you see this when you update Shipping or Sending an Order.

You should first create a new gif icon you want to use.
I'm using this generator: PreLoaders.NET

This is our .gif which size is 128px*128px. WooCommerce default loader is only 16px*16px which is pretty small.

The following code will change the loader in Cart and Checkout. If you need it only on CheckOut, delete the is_cart from if syntax. Add the code to you themes functions.php file.

add_filter('woocommerce_ajax_loader_url', 'woo_custom_cart_loader');
function woo_custom_cart_loader() {
 
 global $woocommerce;
 
 if(is_checkout() || is_cart()){
  return __(get_template_directory_uri().'/images/loader-ajax-new.gif', 'woocommerce');
    }
 else
  return __(get_template_directory_uri().'/images/ajax-loader@2x.gif', 'woocommerce');
}

The second thing you need to do is to increase the size of the loader icon, we told that this icon is only 16px*16px. So after uploading image to the themes /images folder or your custom places head to these files:

To increase the Cart loader icon: /wp-content/plugins/woocommerce/assets/js/frontend/cart.min.js

To increase the CheckOut loader icon: /wp-content/plugins/woocommerce/assets/js/frontend/checkout.min.js

Search for 16px and change them to 128px. If you upgrade WooCommerce these changes are going to be lost :) so change them again! :)

čtvrtek 11. února 2016

Cleaning JavaScript Malware On Your Linux Server (Removing Javascript Between Two Points)

So, I think everyone has faced this issue who has an own VPS server. Our problem was that sometimes every or some of JS files got infected. It can be a mass to delete the malware code from the files manually.

So with the help of this article I have created my own code: Linux Academy

The problem was that this code worked when the exploit code has began and ended with the same value. But our newest infection was a little bit tricky. Every JS files has a different malware comment value in it. So I cant use the code from Linux Academy anymore.

Sucuri have wroted about this infection: Link

The hackers injected encrypted code at the end of all legitimate .js files. Which seems like this (image from Sucuri):
I have struggled with this infection for a time. And I want to share my solution, which can remove this from every JS file within less then 5 seconds. Every command is called recursivily, so if you run it on public_html/ or www/ folder it will include wp-admin, wp-content, everything. The pattern in our case is a regular expression [a-z0-9]{32} means lowercase letters and numbers and exactly 32 times.

1. Search if there is a JS infection on your server, the -l switch will list only the file names
 find . -name "*.js" | xargs grep -E "\/\*[a-z0-9]{32}\*\/" -l | sort  

2. Add a new line character before the pattern, this is very important, sed can only delete lines from files upwards.
 find . -name "*.js" -exec sed -i "s/\/\*[a-z0-9]\{32\}\*\//\n&/g" '{}' \;  

3. Finally delete the malware code from all infected JS files:
 find . -name "*.js" -exec sed -i "/[a-z0-9]\{32\}/,/[a-z0-9]\{32\}/d" '{}' \;  

Before you try this please test it on one file, i have a CentOS server installed.
I have found three backdoors installed with the help of access_logs and blocked the IPs in our firewall.
/wp-content/plugins/yith-woocommerce-ajax-search/widgets/class44a.php
/wp-content/languages/admin-network-hu_HU182a1.php
/wp-cont.php

I hope this helps someone.

Regards, Peter

neděle 3. května 2015

Update Facebook Sharer Cache automatically on Page Load

So I have this problem on my one of my clients website. The Facebook cache was not updateed correctly. And no images was loaded. I know that in every 24 hour the cache is updated. But I need this to be done automatically on page load now. This solution is good for WordPress and WooCommerce too. Add this to your functions.php file and the Sharer Cache will be updated on page load.
add_action( 'wp_footer', 'fb_sharer_updater', 5 );

if(!function_exists('fb_sharer_updater')) {
    function fb_sharer_updater() {
        global $post;
            
            echo '<script type="text/javascript">
    jQuery.post(
    "https://graph.facebook.com",
    {
     id: "'.  get_permalink() .'",
     scrape: true
    },
    function(response){
     console.log(response);
    }
   );';
            echo '</script>';
            
        
    }
}
You need to wait approx 5seconds, then the new scrape info is added to FB cache. Open Developer Console and you will see additional information:
Object {url: "http://theblackcat.sk/produkt/plazove-saty-texas-s-5995/", type: "article", title: "Plážové šaty Texas S-5995 - TheBlackCat.sk", locale: Object, image: Array[1]…}
description: "Ľahučké plážové šaty so vzorom, s viazaním na boku. Plážové šaty odporúčame ku všetkým bikinám Texas 2015 ako doplnka."
id: "1532012490185775"
image: Array[1]
locale: Object
site_name: "TheBlackCat.sk"
title: "Plážové šaty Texas S-5995 - TheBlackCat.sk"
type: "article"
updated_time: "2015-05-03T14:23:15+0000"
url: "http://theblackcat.sk/produkt/plazove-saty-texas-s-5995/"
__proto__: Object

sobota 31. ledna 2015

Adding TinyCon library to WooCommerce - Show products in cart count on the favicon

I just came across with a solution for implementing TinyCon with WooCommerce. I use this super-easy, leightweight library to display cart quantity on the favicon.

You need to edit file footer.php in your theme, you find this in most cases:

    /wp-content/themes/xxxxxx/footer.php

What you need to add first is the TinyCon JS library. Download it from [Github][1].

Then you need to call this library and add the cart quantity to display it on the favicon. Add this code before the </body> tag.

My code with explanation:

 <?php global $woocommerce;  //you need this for het the cart quantity
    $my_cart_count = $woocommerce->cart->cart_contents_count; //get the quantity
    ?>
     <script src="<?php bloginfo('stylesheet_directory'); ?>/includes/js/tinycon.min.js" type="text/javascript"></script> //call the TinyCon library
     <script type="text/javascript">
    Tinycon.setOptions({
        width: 7,
        height: 9,
        font: '10px arial',
        colour: '#ffffff',
        background: '#e01c1f',
        fallback: true
    });
     </script>
    <?php if ($my_cart_count > 0) :             //if cart has products in it display bubble by default.
    ?>
    <script type="text/javascript">
   
    Tinycon.setBubble(<?php echo $my_cart_count; ?>);
   
    </script>
    <?php
    endif;
    ?>
    // this part is needed if you use AJAX add to cart in WooCommerce, this will ensure when if you click on AJAX add to cart button the bubble is updated correctly.
    <script type="text/javascript">
     var darab =  <?php echo $my_cart_count; ?>;
     
     jQuery('.add_to_cart_button').bind('click',function() {
       
     darab = darab + 1 ;
     
     Tinycon.setBubble(darab); 
    });
   
    </script>


  [1]: https://github.com/tommoor/tinycon

čtvrtek 15. ledna 2015

WooCommerce + WordPress new line issue with Mandrill

As I stated in previous topic after installing Mandrill my WordPress text/plain emails doesnt contain new line breaks, because they are coded with /n/r code.

There is an option in settings of Mandrill, that you can:
Replace all line feeds ("\n") by <br/>in the message body?

But if you enable this the WooCommerce emails are going to be ugly, because they are already HTML emails, not just plain text emails, which are sended out by WordPress by default.

To solve the issue you need to use the mandrill_playload hook which is just fired before an email sents out.
add_filter('mandrill_payload', 'customFilterName');
 More about this filter: http://blog.mandrill.com/own-your-wordpress-email-with-mandrill.html

What you need to do is select the type of emails with tags which are plain/text emails only.

You need to get the tags from your Mandrill admin.


As you can see, these are the tags in my case.

The wp_WC_Email->send work just fine, because this is the tag for WooCommerce store emails, these are coded with text/html.

What I needed to add is: wp_userpro_mail, wp_template-contact.php and wp_wp_new_user_notification, because these are encoded only in text/plain.

To bypass this and insert correct line breaks tags you just to need to add the following to your functions.php in your theme.

 /*************************************************************************/
 /*WPMandrill playload, add <br> to emails*/
 /*************************************************************************/
 function wd_mandrill_woo_order( $message ) {
      $tags = $message['tags']['automatic'];
   if ( (in_array( 'wp_template-contact.php', $tags )) || (in_array( 'wp_userpro_mail', $tags )) || (in_array( 'wp_wp_new_user_notification', $tags )) ) {
     $message['html'] = nl2br( $message['html'] );
   }
   return $message;
 }
 add_filter( 'mandrill_payload', 'wd_mandrill_woo_order' );

The key functions here is the nl2br which just returns string with '<br />' or '<br>' inserted before all newlines (\r\n, \n\r, \n and \r).

After this little code snippet every system emails from WordPress are correctly displayed :)))

Maybe someone is facing the same issue and I helped him with this :).

WooCommerce emails ending up in SPAM - Enable wpMandrill in WordPress and WooCommerce

So, we have a VPS server with e-mail server installed.

By default e-mails from Wordpress and WooCommerce are send out with wp_mail() function. We have problems with that because our store emails are ended up in SPAM folder.

I have read and troubleshoot couple of hours. Added DKIM and SPF to domain, etc.

But I think this is never gonna get end.

Finally I have found service SMTP server Mandrill, which is developed and maintained by folks from MailChimp :). This thing is amazing, you can track openings, clicks, everything... what was the content of the email. It was delivered or not?

For installing the plugin you just need to download wpMandrill plugin within Wordpress or from WP plugin page.

After install you just need to go to: Settings -> Mandrill 
There is a good guide on this page: https://connect.mailchimp.com/how-to/53

  1. First you are asked to create an API key. Register and visit this page: https://mandrillapp.com/settings
  2. Click on + New API key button
  3. Then setup the plugin.
After installing everything just works out of the box. Our store emails are now correctly received in Gmail INBOX and not in the SPAM folder.

Mandrill is able to send 12 000 emails/month for free, but the pricing above that is also good :).

If you ever face the issue that your WooCommerce store emails are ended up in SPAM, you aren't able to get it work as me install Mandrill, take a seat, and enjoy your work! :)

One issue what I have found and going to cover in other topic is this:
WordPress standard emails (password reset, etc.) are plain-text-ish with /n/r code. They look better when we check "Replace all line feeds ("\n") by
in the message body"
Woocommerce sends nice HTML. They look worse when we check "Replace all line feeds ("\n") by
in the message body"




úterý 27. května 2014

Watch Dogs freezes when clicking on New Game

I have installed Watch Dogs through UPlay. Everything installed fine, then I have launched the game make some changes in settings and clicked New Game.

Now Watch Dogs freezes out and cannot continue.

As a former MS Technical Supporter my first way taked too Event Viewer :).

Here I have found the following:

A hibát okozó alkalmazás neve: Watch_Dogs.exe, verzió: 0.1.0.1, időbélyeg: 0x537507a1
A hibát okozó modul neve: MSVCR100.dll, verzió: 10.0.40219.1, időbélyeg: 0x4d5f034a
Kivételkód: 0xc0000005
Hiba pozíciója: 0x000000000003c1be
A hibát okozó folyamat azonosítója: 0x19d8
A hibát okozó alkalmazás indításának időpontja: 0x01cf79da732f09e5
A hibát okozó alkalmazás elérési útja: E:\Uplay\games\Watch_Dogs\bin\Watch_Dogs.exe
A hibát okozó modul elérési útja: C:\WINDOWS\SYSTEM32\MSVCR100.dll
Jelentés azonosítója: df8603ad-e5cd-11e3-802f-1c6f65caa9f3
A hibát okozó csomag teljes neve: 
A hibát okozó csomag relatív alkalmazásazonosítója: 

What means that the problem is whit VCredist.

sobota 9. listopadu 2013

How to remove K2 /item/ and item ID from URL

You need to open Joomla Administrator backend.

Go to: Components - K2 - Parameters
Search for the Advanced Tab then turn on Advanced SEF.

See the picture.



Enjoy your clean URLs:
com/shop/item/6-name is replaced with this:
com/shop/name

úterý 29. října 2013

pátek 18. října 2013

After upgrading to Windows 8.1 iCloud sync is not working in Outlook 2010

If you click on iCloud folder or Contacts in Outlook 2010 the following error message appears:
"The set of folders cannot be opened. The information store could not be opened."

Solution:

  • You need to uninstall the iCloud Control Panel completely from Control Panel.
  • Restart PC.
  • Install the newest iCloud Control Panel. Log-in.
  • Sync is working now again!!!

středa 16. října 2013

Windows 8 language pack won't install

This problem is caused by corrupted files in WinSXS folder. This folder is very important for the system.
You should manage to fix issues in there with a simple command in Windows 8.

Steps:

  • Press Win + X then choose Command Prompt (Admin) - we need admin priviligies to run the command.
    You now should see a black box with a prompt, please enter the following command:
    dism /online /cleanup-image /restorehealth
  • It should take very long time to do that (30~60 minutes, it's depend on the corruption).
  • You can find the log file in folder: %windir%\Logs\DISM\dism.logPlease scroll to the bottom, if there was no error you should see something like:


Checking System Update Readiness.


Summary:
Operation: Detect and Repair
Operation result: 0x0
Last Successful Step: Entire operation completes.
Total Detected Corruption: 0
CBS Manifest Corruption: 0
CBS Metadata Corruption: 0
CSI Manifest Corruption: 0
CSI Metadata Corruption: 0
CSI Payload Corruption: 0
Total Repaired Corruption: 0
CBS Manifest Repaired: 0
CSI Manifest Repaired: 0
CSI Payload Repaired: 0
CSI Store Metadata refreshed: True


If there was an error you can see which files are corrupted and how much of them the system can fix. You need to replace the corrupted files with the correct ones but this is for another topic.

How to install Creative Live! Cam Vista IM (VF0260) on Windows 7

Many people have problems installing this webcam from Creative.

Suddenly Creative have dropped the support for this webcam and there are no Windows 7 drivers for this webcam.

With little magic we can install this webcam on Windows 7 OS.

Steps you need to do:

  • Download the driver for Vista.
  • Download 7-ZIP or Win-RAR, click with right-click on LCVA_PCDrv_US_1_11_02.exe file then choose Extract here...
  • Open the folder and find setup.exe file.
  • Click on the .exe with right click and choose Properties.
  • After that you need to set the Compatibility mode. Click on Compatibility, choose Windows Vista (Serivce Pack 2). Click OK.
  • Run the installer with setup.exe. Wait then Reboot the system.
  • The Windows Live! Cam Vista IM (VF0260) now should work flawlessly :).


Enjoy!

středa 9. října 2013

If downloading or upgrading apps from Windows Store i get error code 0x80240437

This problem is caused by corrupted Software Distribution folder.

Steps for troubleshooting:


  • You need to stop BITS and Windows Update services:
    Press Win + R and type services.msc command then hit ENTER.
    Find Windows Update and Background Intellingent Transfer Service. Stop these services.
  • Then go to: %windir% and rename folder SoftwareDistribution to SoftwareDistribution2
  • Go back to services and turn on the disabled services.
  • Check Windows Store and install/upgrade apps again!