Monday, November 7, 2016

PHP: Replace space in front of capitals in a string (Regex)

I have a number of strings which contain words which are bunched together and I need to seperate them up.

For example ThisWasCool - This Was Cool MyHomeIsHere - My Home Is Here

$String = 'TheCambodia';
$Words = preg_replace('/(?<!\ )[A-Z]/', ' $0', $String);
echo $Words;

Output: The Cambodia

Wednesday, October 26, 2016

How to display image from "image selection" field in transformation

You can use following sample code:

<img src="<%# GetDocumentUrl("Image", "") %>" />

Login failed for user 'IIS APPPOOL\DefaultAppPool'

If you don't change, each app pool has it's own identity. In your case, just add a new user to your database SmallBakery with the name IIS APPPOOL\SmallBakery using SQL Management Studio. You find the users list in the "Security/Users" subnode of your database. This should look something like that:

For testing, let the user be member of the db_owner role. If that works, remove this role and just let it be member of db_datareader and db_datawriter.

This way, each app pool (perhaps each website, if they all use their own app pool) only has access to the corresponding database.

If you use Default Web Site so you add "IIS APPPOOL\DefaultAppPool"

SQL Server can't login with newly created user

SQL Server was not configured to allow mixed authentication.

Here are steps to fix:

  1. Right-click on SQL Server instance at root of Object Explorer, click on Properties
  2. Select Security from the left pane.
  3. Select the SQL Server and Windows Authentication mode radio button, and click OK

  1. Right-click on the SQL Server instance, select Restart (alternatively, open up Services and restart the SQL Server service).

Monday, October 24, 2016

How to exclude column save into database for Contact Form 7 DB

When you submitted form data into database default Contact Form DB will insert all your data form into your database so if you want to exclude field something like Google Recaptcha not insert into database.

You just go to Contact Form 7 DB --> Options then click on Save Tab. Add filed name that you want to exclude after "/.*wpcf7.*/,_wpnonce".


Thursday, October 20, 2016

How to add Facebook Open Graph (og) meta tags to blog detail page in Kentico

We can use Head HTML Code WebPart in your Page Template and using macros to populate your tags content.

+ Configure the WebPart
     - Configure the webpart: fbgraph
     -  Web part title: Facebook Open Graph
     -  HTML code

<meta property="og:title" content="{% BlogPostTitle %}" />
<meta property="og:site_name" content="Kentico 9" />
<meta property="og:url" content="{% CurrentDocument.AbsoluteURL #%}" />
<meta property="og:description" content="{% StripTags(BlogPostSummary) %}" />
<meta property="og:image" content="http://{% domain %}/getattachment/{% BlogPostTeaser %}/.aspx" />
<meta property="og:type" content="article" />

Wednesday, September 28, 2016

Prevent hover on touch screen devices

There are 2 simple ways to check for touch support with JavaScript:
  1. You can use Modernizr.js library. Latest versions of Modernizr (2.6.2 for sure) automatically checks for touch support and attaches a .no-touch class to HTML tag, if device doesn’t support touch.
  2. If you do not want to use Modernizr, you can add small piece of JavaScript below, which will do exactly the same thing.

//touch events support and if not supported, attach .no-touch class to the HTML tag.

if (!("ontouchstart" in document.documentElement)) {
   document.documentElement.className += " no-touch";

Tuesday, September 13, 2016

CSS3 box-shadow Inset bottom only

If you would like put the inner shadow only bottom box. you can use css3 to adjust shadow


<div class="box"></div>

 CSS {

    -moz-box-shadow: inset 0 -10px 10px -10px #000000;
    -webkit-box-shadow: inset 0 -10px 10px -10px #000000;
    box-shadow: inset 0 -10px 10px -10px #000000;


Wednesday, August 31, 2016

Contact Form 7: Redirecting on a condition in Additional Settings

Redirecting without a condition When you use the WordPress plugin “Contact Form 7” you can redirect the user to another page after submitting the answers by the following code:

on_sent_ok: "location.replace('');"

Redirecting on a condition If you want to make the redirecting depending on a specific answer, you can use the following code:

on_sent_ok: " if (document.getElementById('type').value=='yes') 
} else { location.replace('') }"


on_sent_ok: "var Iso = $("input[name=radio-option]:checked").val() ; 
if(Iso == 'General enquiry' ){ location = '/contact/enquiry/thank-general-enquiry/'; } 
if(Iso == 'Special enquiry' ){ location = '/contact/enquiry/thanks-special-enquiry/'; } 
if(Iso == 'Interest enquiry' ){ location = '/contact/enquiry/thanks-interest-enquiry/'; }"

Tuesday, May 3, 2016

How to style style ordered list numbers?

Today I would like to show how to add background-color, border-radius and color to ordered list. if you make your look at nice on your website so it easy way to to like below:



1. CSS


    body {
  counter-reset: item;

 ol {
  list-style: none;

 li {
  counter-increment: item;
  margin-bottom: 5px;

 li:before {

  margin-right: 10px;
  content: counter(item);
  background: lightblue;
  border-radius: 100%;
  color: white;
  width: 1.2em;
  text-align: center;
  display: inline-block;



Working Demo

Friday, April 15, 2016

Fixed FTP credentials for WordPress to connect to my local server

I try to update WordPress or download plugins in I am directed to a page asking for the following information:

Connection Information
To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Here is solution how to fix it

define('FS_METHOD','direct'); to wp-config.php

Wednesday, April 6, 2016

WordPress: Fixed the Exceeds the Maximum Upload Error

Some host set the default upload size for WordPress to 2MB which is extremely low. This can cause an error when you try to upload files that are larger than this size.  After you locate the php.ini file you just need to change two values. Search for these two parameters below and set the value to be 32M and save.

upload_max_filesize = 32M
post_max_size = 32M

Tuesday, March 22, 2016

Creating a sticky header bar using jQuery

Many websites use a “sticky” feature in their main navigation menu. The menu scrolls with the page, then sticks to the top once it reaches the top of the viewport. This tutorial show you sample code jQuery create Sticky Header.

<div class="wrapper">
    <div class="header_placeholder"></div>
    <header id="header"></header>

2. CSS

#header {
    min-height: 85px;
    background-color: #fff;
    border-bottom: 8px solid #005bac;
    position: relative;
#header .is-sticky {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;

 var stickyHeader = {
  onReady: function () {
  doScroll:function() {
   $(window).scroll(function () {
  doSticky: function () {
   var $header = $('#header'),
   headerHeight = $header.height(),
   window_y = $(window).scrollTop();

   if (window_y > headerHeight) {
    if (!$header.hasClass('is-sticky')) {
     $header.addClass('is-sticky').css('top', -headerHeight)
      'top': 0
   } else {
    if ($header.hasClass('is-sticky')) {

Working Demo

Saturday, March 19, 2016

Custom Excerpt Function WordPress

By default WordPress excerpts are set to 55 words and there is an excerpt_length filter which allows you to change this default value to your length of choice. But what if you wanted a different excerpt length on your post type or somewhere in page you need create custom function for set limit.

function get_excerpt($limit) {
 $excerpt = explode(' ', get_the_excerpt(), $limit);
  if (count($excerpt)>=$limit) {
   $excerpt = implode(" ",$excerpt).'...';
  } else {
   $excerpt = implode(" ",$excerpt);
 $excerpt = preg_replace('`[[^]]*]`','',$excerpt);
 return $excerpt;

function get_content($limit) {
 $content = explode(' ', get_the_content(), $limit);
 if (count($content)>=$limit) {
  $content = implode(" ",$content).'...';
 } else {
  $content = implode(" ",$content);
 $content = preg_replace('/[.+]/','', $content);
 $content = apply_filters('the_content', $content);
 $content = str_replace(']]>', ']]>', $content);
 return $content;

Monday, January 25, 2016

Hiding the Spinner arrow key on Input Type Number on Firefox and Chrome

input[type=number] {-moz-appearance: textfield;}

::-webkit-inner-spin-button { -webkit-appearance: none;margin:0;}

::-webkit-outer-spin-button { -webkit-appearance: none;;margin:0;}

Thursday, January 7, 2016

Display custom fields on order details page in Woocommerce

You can use WordPress function "get_post_meta" to echo out your custom field in "order-details.php" template.

<?php echo get_post_meta( $order->id, 'custom-field-name', true ); ?>