Skip to content

Instantly share code, notes, and snippets.

@junaidtk
junaidtk / Usage of JSON
Created July 1, 2019 12:48
JSON data and Its usage.
Json means java script object notation.
Json is used for transfering the data from cleint side to server or vice versa.
Json formate is text only so it can easily send to and from server.
In Json data is key value pair, with data separated by comma and
curly braces hold object data and square bracket hold array data.
Key must be string and written in double quotes.
Value must be one of the following
* a string
@junaidtk
junaidtk / Character set and Encoding
Created June 17, 2019 06:03
Unicode and Character Sets (No Excuses!)
What is character Set and Encoding
===================================
Character encoding are the important concept in process of converting byte streams into characters.
There are two things which are important in converting byte to character "character set and an encoding"
================= ####### ================= ####### ==================
In the earlier stage of computer encoding
There are diffrent methods of representing the character.
@junaidtk
junaidtk / How to check the Wordpress plugin activate and update
Last active September 15, 2024 02:20
Update and Activation Hook plugin.
The below code is plugin codes used for adding new functionality setup
while updating the plugin or activating the plugin.
This is simple plugin code and it will add transient while updating or activating the plugin.
Clear transient once we finished the operation.
=======================================================================================
<?php
/*Plugin Name: Wordpress Update
$wpdb->get_row()
====================
get_row() returns single row of data from database table.
eg:
<?php
$mycustomer = $wpdb->get_row(“SELECT * FROM laundry_customers WHERE ID = 1”);
echo $mycustomer -> customer_name;
?>
$wpdb->get_results()
@junaidtk
junaidtk / PHP7 Features for common uses
Created June 13, 2019 05:17
Noticeable features in PHP7
1)Constant Array
===============
Now the constant data types in php can be defined as numerically indexed array and associative array.
So below line of code can be coded like as new constant array.
old
------
<?php
define('COLOR_RED', '#f44141');
@junaidtk
junaidtk / Output Buffer Memory
Created March 15, 2019 06:15
Use of ob_start() and ob_get_clean()
The ob_start() and ob_get_clean() are used hold the value in the inter buffer memory.
Normal Buffering functions used are.
ob_start();
---------------
This function will turn on the out buffer While buffering is ON no output is sent from script (other then headers),
instead the output is stored in internal buffer.
ob_get_clean();
@junaidtk
junaidtk / Post type menu in admin submenu
Created February 8, 2019 03:48
Add post type menu as admin_sub_menu
// 1. when registering a custom post type set show_in_menu to false,
function ttlm_register_team_custom_type() {
$labels = array(
'name' => _x( 'Teams', 'post type general name', 'your-plugin-textdomain' ),
'singular_name' => _x( 'Team', 'post type singular name', 'your-plugin-textdomain' ),
'menu_name' => _x( 'Teams', 'admin menu', 'your-plugin-textdomain' ),
'name_admin_bar' => _x( 'Team', 'add new on admin bar', 'your-plugin-textdomain' ),
'add_new' => _x( 'Add New', 'team', 'your-plugin-textdomain' ),
'add_new_item' => __( 'Add New Team', 'your-plugin-textdomain' ),
'new_item' => __( 'New Team', 'your-plugin-textdomain' ),
@junaidtk
junaidtk / esc_html and reverse
Created January 29, 2019 03:50
wordpresss esc_html and its reverse opperation.
esc_html():
It is wordpress function used to convert the html element to html entity.
Refer the below eg:
$html = esc_html( '<a href="http://www.example.com/">A link</a>' );
so $html contain
&lt;a href=&quot;http://www.example.com/&quot;&gt;A link&lt;/a&gt;
The output will display like below.
@junaidtk
junaidtk / Static methods and properties
Last active January 23, 2019 09:33
Static methods and properties in PHP OOP
Static means they are unchanging.
static function means, it is a function namespaced by the name of its class.
To make a function static, we need to add the key work static in the function definition.
Like
public static function(){
// Statement.
@junaidtk
junaidtk / Isotop filtering for portfolio section
Created January 17, 2019 17:16
Portfolio section as masonry isotop
<div class="container-fluid">
<div class="row">
<!-- <div class="section-head text-center col-sm-12">
<h4>My Work</h4>
<p>...</p>
</div> -->
<?php
$terms = get_terms( array(
'taxonomy' => 'work-category',
'hide_empty' => false,