Example of Creating Basic Factory and Service in AngularJS

[code] mainApp2.factory(‘MathService’, function() { var factory = {}; factory.multiply = function(a, b) { return a * b; }; return factory; }); mainApp2.service(‘CalcService’, function(MathServic){ this.square = function(a) { return MathService.multiply(a,a); }; }); mainApp2.controller(‘CalcController’, function($scope, CalcService) { $scope.square = function() { $scope.result = CalcService.square($scope.number); }; }); [/code] [code] <div ng-app=”mainApp2″ ng-controller=”CalcController”> <p>Enter a number: <input type=”number” ng-model=”number” […]

How to Install Sass in Windows

Since I was in introduced to using Sass, I never want to go back to the traditional way of coding stylesheets. Here are the steps to starting using Sass:   Sample Command

How to Add Category Options for Custom Post Types

Adding category options for your custom post type is so easy. If you want your custom posts and the default posts to share the same categories, simply insert the ff. line of code below: Where: h-articles is the id of your custom post type. However, if you want to create a separate set of categories […]

How to Style WP Nav Menu

If you’re creating your own theme and use adding a menu using the standard WordPress function wp_nav_menu(), you will have to style it using CSS in order to make it like the usual navigation menu. This function will return a list of menus you defined or added in Appearance -> Menus. This looks fine if […]

How to Create a Tab

Jquery has already made a tab function that’s very easy to use. But if you have problem using such function and you’re considering of other function to achieve the same output, you can try my own jquery tab function. To call: Add the tab and its contents:

Calling Ajax in WordPress

There are so many ways to call ajax in WordPress, but below is how I do it. 🙂 Add the following functions in PHP file. Add the following functions in JS file.

Display PHP Errors

The following code snippet will show php errors and warnings if there is any.

Plugin Class

Since I know that I will be making more plugins for the rest of my life, I decided to create a class that does the basic task that most of my plugins need, namely: adding scripts and styles to the dashboard pates and/or website pages. Copy the Plugin Class from WDT-Framework