Tutorial by Examples

WordPress shortcodes were introduced in 2.5 Here is come example of shortcode [button] to use shortcode direct into theme you have to use do_shortcode() <?php echo do_shortcode('[button]'); ?> To customize the button, we could simply add something like: [button type="twitter&qu...
The simplest shortcode is the self-closing one. We’re going to create a simple link to our Twitter account, and then add it in a blog post. All the code goes in functions.php, which is located in /wp-content/themes/your-theme/. If you don’t have one, just create it and put the code in it. <?php...
Creating a self-closing shortcode with parameters <?php function button_shortcode( $type ) { extract( shortcode_atts( array( 'type' => 'value' ), $type ) ); // check what type user entered switch ($type) { case 'twitter': ...
enclosing shortcode The enclosing shortcode allows you to embed content within your shortcode, just like BBCode if you’ve ever used that. <?php function button_shortcode( $attr, $content = null ) { return '<a href="http://twitter.com/filipstefansson" class="twitter-button&qu...
By default, WordPress does not support shortcodes within Sidebar Widgets. It only expands the shortcodes within the content of a Post, Page, or custom post type. To add shortcode support to sidebar widgets, you can install a plugin, or use the below code: add_filter( 'widget_text', 'shortcode_unaut...
When it comes to validate some rules which are not generic data validation e.g ensuring a field is required or some range of values but they are specific to your business logic then you can create your own Custom Validator. To create a custom validation attribute, you just need to inherit Validation...
Just like you handle get requests in Express with app.get method, you can use app.post method to handle post requests. But before you can handle POST requests, you will need to use the body-parser middleware. It simply parses the body of POST, PUT, DELETE and other requests. Body-Parser middleware...
In the example we will start tomcat 7 using maven plugin, optionally add user/password protection for REST end point. Also adding feature of building war. Add below section in plugin section of pom for tomcat <plugin> <groupId>org.apache.tomcat.maven</g...
In your functions.php you can register new sidebars with this code /** * Registers sidebars * * @param array Array with default or specified array values * @since 1.0.0 */ if ( function_exists( 'register_sidebar' ) ) { register_sidebar( array ( 'name' => e...
Step 1: Install Node.js The build pipeline you will be building is based in Node.js so you must ensure in the first instance that you have this installed. For instructions on how to install Node.js you can checkout the SO docs for that here Step 2: Initialise your project as an node module Open y...
It is possible to send a message or data to all avaible connections. This can be achieved by first initializing the server and then using the socket.io object to find all sockets and then emit as you normally would emit to a single socket var io = require('socket.io')(80) // 80 is the HTTP port io...
It is possible to emit a message or data to all users except the one making the request: var io = require('socket.io')(80); io.on('connection', function (socket) { socket.broadcast.emit('user connected'); });
The following example demonstrates the concept of storing view state. Let us keep a counter, which is incremented each time the page is posted back by clicking a button on the page. A label control shows the value in the counter. The markup file code is as follows: <%@ Page Language="C#&qu...
Java Config The configuration class needs only to be a class that is on the classpath of your application and visible to your applications main class. class MyApp { public static void main(String[] args) throws Exception { AnnotationConfigApplicationContext appContext = ...
jHipster allows you to bootstrap a Spring Boot web application with a REST API back-end and a AngularJS and Twitter Bootstrap front-end. More on jHipster here: jHipster Documentation Install brew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/inst...
class My_Plugin() { function __construct() { add_action( 'wp_enqueue_scripts', array( $this, 'init_fe_assets' ) ); } public function init_fe_assests() { wp_enqueue_style( 'my-plugin', plugin_dir_url( __FILE__ ) . 'assets/css/frontend/plugin.css', array(), '0.0.1', true ); ...
The Gson library provides Gson.class which handles all conversion between Java and JSON objects. An instance of this class can be created by invoking default constructor. You usually would like to have one Gson instance for the most part of operations in your program. Gson gson = new Gson(); Fir...
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...
Edmx model internel public partial class ItemRequest { public int RequestId { get; set; } //... } Adding data annotation to this - if we modify this model directly, when a update to the model is made, the changes are lost . so To add a attribute in this case 'Required' Create a new...
Example from phptherightway.com <?php class Singleton { /** * @var Singleton The reference to *Singleton* instance of this class */ private static $instance; /** * Returns the *Singleton* instance of this class. * * @return Singleton The *Sing...

Page 865 of 1336