Tutorial by Examples: call

function my_init_function() { // do something here } add_action( 'init', 'my_init_function' ); Using the name of the function to hook a set of instructions. With the init hook, the set of instructions will be executed right after wordpress has finished loading the necessary components. ...
class MyClass { static function my_init_method() { // do something here } } add_action( 'init', array( 'MyClass', 'my_init_method' ) ); Using a static method of a class to hook a set of instructions. With the init hook, the set of instructions will be executed right after w...
class MyClass { function my_init_method() { // do something here } } $obj = new MyClass(); add_action( 'init', array( $obj, 'my_init_method' ) ); Using a method of an object to hook a set of instructions. With the init hook, the set of instructions will be executed right...
When using instances of QML files by directly declaring them, every property creates a binding. This is explained in the above examples. This is how you dynamically create components: var component = Qt.createComponent("Popup.qml"); var popup = component.createObject(parent, {"widt...
To track so called "virtual pageviews", use the ga('send') method right after your asynchronous request: Syntax: ga('send', 'pageview', 'path to your virtual page'); Example (Simple Link): <a href="http://example.com/my.pdf" onClick="ga('send', 'pageview', '/virtu...
AdfmfContainerUtilities.invokeContainerJavaScriptFunction(AdfmfJavaUtilities.getFeatureId(), <function>, new Object[] { }); "function" is the desired js function to be invoked
page.js var context = { items: [ {id: 1, name: "Foo"}, {id: 2, name: "Bar"}, {id: 3, name: "Joe"} ] } exports.loaded = function(args){ var page = args.object; page.bindingContext = context; } exports.showEntry = functi...
This example serves as a complement to other examples which talk about how to use the lifecycle methods and when the method will be called. This example summarize Which methods (componentWillMount, componentWillReceiveProps, etc) will be called and in which sequence will be different for a componen...
Cgo enables the creation of Go packages that call C code. To use cgo write normal Go code that imports a pseudo-package "C". The Go code can then refer to types such as C.int, or functions such as C.Add. The import of "C" is immediately preceded by a comment, that comment, call...
Here is our function to create a simple ajax call written in vanilla javascript (not es2015): function ajax(url, callback) { var xhr; if(typeof XMLHttpRequest !== 'undefined') xhr = new XMLHttpRequest(); else { var versions = ["MSXML2.XmlHttp.5.0", ...
When publishing Sitecore item programmatically the developer should keep in mind that Sitecore could be configured for several publishing targets, as well that several languages could be defined for item. ID targetDatabaseFieldId = ID.Parse("{39ECFD90-55D2-49D8-B513-99D15573DE41}"); ...
With Ruby you can modify the structure of the program in execution time. One way to do it, is by defining methods dynamically using the method method_missing. Let's say that we want to be able to test if a number is greater than other number with the syntax 777.is_greater_than_123?. # open Numeric...
A thing to look out for when using the toString method in Kotlin is the handling of null in combination with the String?. For example you want to get text from an EditText in Android. You would have a piece of code like: // Incorrect: val text = view.textField?.text.toString() ?: "" ...
class my_model(models.Model): _name = "my.model" name = fields.Char('Name') @api.multi def foo_manipulate_records_1(self): """ function returns list of tuples (id,name) """ return [(i.id,i.name) for i in self] @...
One of the features that we can use with Threadpools is the submit() method which allow us to know when the thread as finish his work. We can do this thanks to the Future object, which return us an object from the Callable that we can use to our own objetives. Here is an example about how to use th...
Another good practice to check when our threads have finished without block the thread waiting to recover the Future object from our Callable is to create our own implemetation for Runnables, using it together with the execute() method. In the next example, I show a custom class which implements Ru...
var expect = require("chai").expect; describe('Suite Name', function() { describe('#method()', function() { it('should run without an error', function(done) { testSomething(err => { expect(err).to.not.be.equal(null) done() }) }) }) }) ...
Adding a Product to a Shopping Cart The following example demonstrates how to Add a product (or anything) to a Database Table asynchronously, using AJAX, and TypeScript. declare var document; declare var xhr: XMLHttpRequest; window.onLoad = () => { Start(); }; function Start() { ...
If you want to instantiate an instance of user control inside ASPX code behind page, you need to write user control declaration on Page_Load event as follows: public partial class Default : System.Web.UI.Page { protected void Page_Load(Object sender, EventArgs e) { Control contr...
Where a method to be tested uses information from one call to pass on to subsequent calls, one approach that can be used to ensure the methods are called in the expected order is to setup the expectations to reflect this flow of data. Given the method to test: public void MethodToTest() { va...

Page 12 of 18