Mar 14, 2016

WordPress jQuery UI tabs is not a function

When working with jQuery UI you get an error message:

Uncaught TypeError: jQuery(...).tabs is not a function(…)

This is because WordPress' function
wp_enqueue_script( 'jquery-ui' );
doesn't actually enqueue the tabs widget, only the core of jQuery UI.

So after that you need to add:
wp_enqueue_script( 'jquery-ui-tabs' );

See this link below for more info:

Default Scripts Included and Registered by WordPress
https://developer.wordpress.org/reference/functions/wp_enqueue_script/


Feb 18, 2016

Using Wordpress AJAX on Frontend

wp_ajax_* callback functions will return 0 if they are called on the frontend by anonymous users.

This is because of security reasons, but Wordpress has prefixes for "unsecure" calls: wp_ajax_nopriv_*.

Both of the hooks need to be defined to work with logged in and anonymous users.

In functions.php define:
add_action( 'wp_ajax_call_stuff', 'my_callback' );
add_action( 'wp_ajax_nopriv_call_stuff', 'my_callback' );
function my_callback() {
    print_r($_POST);
    exit;
}

Another thing to add is the ajaxurl variable, which is not included on the frontend by default. You can do this in many ways, but I figured the best thing to do is to use wp_localize_script().
wp_localize_script('my_main_script', 'myPrefix', array( 'ajaxurl' => admin_url( 'admin-ajax.php')));

Then, you can call the AJAX request like this:
jQuery.post(myPrefix.ajaxurl, {
  'action': 'call_stuff',
  'whatever': '1'
 }, 
 function(response){
  alert('The server responded: ' + response);
 }
);

Oct 3, 2015

It's time to make HTTPS default

It's time to make a move. 

When developing websites we are focusing on modern standards, like HTML5, CSS3, we put great attention to detail on design, UX and SEO.


It's time we do one more thing when building for the web.
It's time to enable SSL on the websites we make. No matter what the content is, even if it just a simple portfiolio. Keeping your clients privacy and maintaining security is YOUR responsibility. If you need a reason - even if it's just managing the content, you're probably forcing your clients to send their passwords in plain text when logging in the CMS.

It's time to make HTTPS the default.

Reasons for and "against" are covered in this article, but basically having SSL enabled websites lead to:
  • Better security
  • Better privacy for your users
  • Better referral data
  • Google ranks you better


Usually the thing that is holding us back are expenses. Buying a SSL certificate is not cheap, although it's only slightly more expensive than owning a domain name.
However, there are a lot of options, even free ones.
You can use Cloudflare, which can serve like a SSL proxy between your server and the client.
StartCom provides free SSL certificates, but their free license does not include commercial use. But there are good news.

In November, the Internet Security Research Group (ISRG) is launching Let's Encrypt, a free service for all.

Aug 20, 2015

Android stuck in bootloop

Upgrading and downgrading to/from Lollipop (Android 5) has caused some issues. Searching for a fix usually yields tutorials on how to do a factory reset i.e. wipe the whole device, which I do not want to do.

For me an easier fix worked.

It turns out that this whole ordeal is caused by Google Now launcher not starting. Some suggest trying someone calling you, which wouldn't work if you can't enter your PIN number.

Using ADB however, you can open up settings and do some things that could fix the problem.

adb shell am start -n com.android.settings/.Settings

In the settings you can go to 'applications' there swipe right to the 'disabled' category - where you can find 'Google Search' and you can enable it again.
One can probably install an alternative launcher - and if that works the disabling of the google launcher (aka 'Google Search') should not be a problem.

http://android.stackexchange.com/a/82049

This will fix the non-working home button and notifications not showing up. 
adb shell am start -n com.google.android.setupwizard/.SetupWizardTestActivity
Complete the wizard, stuff works again.
 http://forum.xda-developers.com/google-nexus-5/general/guide-dirty-flash-lpv-to-lrx21o-t2940358/post56756143#post56756143[1]

Jul 29, 2015

Opencart 2.x Main banner (slideshow) speed change

Open file /catalog/view/theme/default/template/module/slideshow.tpl and change the red value (in miliseconds):

$('#slideshow<?php echo $module; ?>').owlCarousel({
        items: 6,
        autoPlay: 5000,
        singleItem: true,
        navigation: true,
        navigationText: ['<i class="fa fa-chevron-left fa-5x"></i>', '<i class="fa fa-chevron-right fa-5x"></i>'],
        pagination: true
});