Since version 5.6+ PHP is verifying peer certificates and host names by default when using SSL/TLS. This is causing problems on some servers / websites, where the config has not been setup correctly. If you can not fix the setup yourself, make sure to talk to your server host to fix that issue.
For PHPMailer (Github) there is a workaround:
1 2 3 4 5 6 7 |
$mail->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) ); |
This should only be a workaround until your configuration has been fixed. You are suppressing certificate verification and compromising your security!
As WordPress is using PHPMailer as its main email library, this can be tweaked by using the phpmailer_init hook:
1 2 3 4 5 6 7 8 9 10 11 |
add_action( 'phpmailer_init', 'configure_smtp' ); function configure_smtp( $phpmailer ){ $phpmailer->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) ); } |
Add this to your themes functions.php.
1 2 3 4 5 6 7 8 9 |
$phpmailer = new PHPMailer(); $phpmailer->isSMTP(); $phpmailer->CharSet = 'UTF-8'; $phpmailer->SMTPSecure = "ssl"; // or tls $phpmailer->SMTPAuth = true; $phpmailer->Username = _APP_EMAIL_FROM; $phpmailer->Password = _APP_EMAIL_PASS; $phpmailer->XMailer =' '; $phpmailer->Host= "correct email host"; |
And here is how phpmailer->smtpOptions should be used, on a properly configured server:
1 2 3 4 5 6 7 8 9 |
phpmailer->smtpOptions = array( 'ssl' => array( 'peer_name' => 'your.domain.com', 'verify_peer_name' => true, 'capath' => '/path/to/authority/certificates/directory' # Usually /etc/ssl/certs or /usr/lib/ssl/certs/ 'local_cert' => '/path/to/your.domain.com.crt', # Should be a combined cert & key in pem format 'verify_peer' => true, ) ); |
SSL changes in PHP 5.6: http://php.net/manual/en/migration56.openssl.php
SSL context options in PHP: http://php.net/manual/en/context.ssl.php
Enjoy coding…
Chrome 45+ is glitching on WordPress admin menus.
1 2 3 4 5 6 7 8 9 |
function chromefix_inline_css() { if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Chrome' ) !== false ) { wp_add_inline_style( 'wp-admin', '#adminmenu { transform: translateZ(0); }' ); } } add_action('admin_enqueue_scripts', 'chromefix_inline_css'); |
Online Course Academy. Video Learning platform for universities in the Netherlands.
WooCommerce provides great functionality, but loads a lot of resources even if not needed.
If a site loads longer than 5-7 seconds, potential customers already loose interest :)
Add this to your functions.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
add_action( 'wp_enqueue_scripts', 'cleanup_woocommerce_includes', 99 ); function cleanup_woocommerce_includes(){ //check that woo exists if ( function_exists( 'is_woocommerce' ) ) { if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {} /*Styles*/ wp_dequeue_style( 'woocommerce_frontend_styles' ); wp_dequeue_style( 'woocommerce_fancybox_styles' ); wp_dequeue_style( 'woocommerce_chosen_styles' ); wp_dequeue_style( 'woocommerce_prettyPhoto_css' ); wp_dequeue_style( 'woocommerce-layout' ); wp_dequeue_style( 'woocommerce-smallscreen' ); wp_dequeue_style( 'woocommerce-general' ); wp_dequeue_style( 'wc-bto-styles' ); /*Scripts*/ wp_dequeue_script( 'wc-cart' ); wp_dequeue_script( 'wc-cart-fragments' ); wp_deregister_script( 'wc-add-to-cart' ); wp_dequeue_script( 'wc-add-to-cart' ); wp_deregister_script( 'wc-add-to-cart-variation' ); wp_dequeue_script( 'wc-add-to-cart-variation' ); wp_dequeue_script( 'wc-checkout' ); wp_dequeue_script( 'wc-single-product' ); wp_dequeue_script( 'jquery-blockui' ); wp_dequeue_script( 'wc_price_slider' ); wp_dequeue_script( 'wc-chosen' ); wp_dequeue_script( 'woocommerce' ); wp_dequeue_script( 'prettyPhoto' ); wp_dequeue_script( 'prettyPhoto-init' ); wp_dequeue_script( 'jquery-placeholder' ); wp_dequeue_script( 'fancybox' ); wp_dequeue_script( 'jqueryui' ); } } } |
Like always, make sure that nothing breaks. If things break or are required by certain pages add an exception for that!
Check WordPress Condional Tags.
Sources:
1 2 |
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) ); remove_action('wp_head', 'wc_generator_tag'); |
Simple add this to your wp-config.php
1 2 |
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']); define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']); |
Use the MU-Domain-Mapping plugin for that.
With inline content being loaded via ajax, you are loosing a lot of interesting usage data. These can be tracked using Google Analytics Events or by sending a Pageview.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
(function($) { track = { config:{ pageName : "Your Page", eventSelector : ".trackEvent a, .trackEvent", pageviewSelector : ".trackPage a, .trackPage", }, init : function(){ $("body").delegate(this.config.eventSelector ,"click", function(){ // Navigation / Readmore / Apply / FAQ / Contact / Share var cat = $(this).attr("data-track-cat") || "Navigation"; var action = $(this).attr("data-track-action") || "Click"; var label = $(this).attr("data-track-label") || $(this).text() ; this.sendEvent(cat, action, label); }); $("body").delegate(this.config.pageviewSelector, "click", function(){ var label = $(this).text() +" - "+ this.config.pageName var page = "/"+label.split(' ').join('-').toLowerCase()+"/"; this.sendPageview(page,label); }); }, sendEvent: function(cat, action, label){ ga('send', 'event', { 'eventCategory' : cat , 'eventAction' : action, 'eventLabel' : label, 'eventValue' : 1 }); }, sendPageview : function(page,label){ ga('send', { 'hitType': 'pageview', 'page' : page , 'title' : label }); } }; /* INIT */ track.init(); })(jQuery); |
The above allows to automate tracking by attaching simple classes and use HTML5 data attributes to assign category, action and label. Direct tracking is also possible. Lets split it up :)
1 2 3 4 5 6 7 8 9 |
$("body").delegate(".trackEvent a, .trackEvent","click", function(){ // Navigation / Readmore / Apply / FAQ / Contact / Share var cat = $(this).attr("data-track-cat") || "Navigation"; var action = $(this).attr("data-track-action") || "Click"; var label = $(this).attr("data-track-label") || $(this).text() ; this.sendEvent(cat, action, label); }); |
This monitors links with the class .trackEVENT attached and fills the event data using HTML5 data attributes. All attributes have default values assigned.
A possible link would look like this:
1 |
<a href="#" class=".trackEvent" data-track-cat="Subscribe" data-track-action="View" data-track-label="All my news!">Subscribe to my news!</a> |
The sendEvent function than sends this to Google Analytics.
1 2 3 4 5 6 7 8 |
$("body").delegate(".trackPage a, .trackPage", "click", function(){ var label = $(this).text() +" - "+ this.pageName var page = "/"+label.split(' ').join('-').toLowerCase()+"/"; this.sendPageview(page,label); }); |
Much simpler, this just gets the element text and submits the click as a new Pageview. The label gets the pagename attached and the actual page url is constructed from the label. The sendPageview function than sends this to Google Analytics.
1 2 3 |
track.sendEvent(cat, action, label); track.sendPageview(page, label); |
Really simple and effective way within a simple OnePager or a bigger web application. BTW I am using delegation to make sure that also links within AJAX content can be tracked.
We often have some posts that we would like to promote and keep at the first page of the blog. When you are using pagination, the sticky posts will be added to the standard posts, making the post count per page uneven.
If you want to keep your posts per page count consistent, there is a way to do that.
1 2 3 4 5 6 7 8 9 10 11 |
global $paged; if (!isset($paged) || !$paged){ $paged = 1; } // Set posts per page $posts_per_page = 8; // Get sticky posts $sticky = get_option( 'sticky_posts' ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
// First page and has stickies if($paged == 1 && !empty($sticky)) { $args = array( 'post_type' => 'post', 'paged' => $paged, // Adjust posts per page by subtracting the amount of stickies 'posts_per_page' => $posts_per_page - count($sticky) ); }else{ $args = array( 'post_type' => 'post', 'paged' => $paged, 'posts_per_page' => $posts_per_page, // making sure the 2nd page starts with the right post 'offset' => (($paged-1)*$posts_per_page) - count($sticky) ); } // Do query query_posts($args); |
They built screensiz.es to quickly find the screen specifications of the most popular devices and monitors currently on the market.
Finally identical inputs across different browsers and devices — both desktop and mobile.
iCheck is verified to work in Internet Explorer 6+, Firefox 2+, Opera 9+, Google Chrome and Safari browsers.
Mobile browsers (like Opera mini, Chrome mobile, Safari mobile, Android browser, Silk and others) are also supported. Tested on iOS (iPad, iPhone, iPod), Android, BlackBerry and Windows Phone devices.
We are getting closer to Boostrap 4 and I really love what we are getting with the first alpha version.