Skip to content

Instantly share code, notes, and snippets.

@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 / 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');
$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 / 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
@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 / 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 / Dynamic Hook used in "woocommerce_product_get_price"
Last active August 22, 2019 10:12
Some of Dynamics hooks used in the woocommerce
In woo-commerce there are lot of filter they are dynamically generated for the multiple function use.
So these hooks are hard to find and can't be found while searching the woocommerce folder.
The below hook is the one of the dynamic hooks used in the woocommerce
1) get_property hooks for the woocommerce product class (woocommerce_product_get_price).
=========================================================
All the get_functions in the WooCommerce product class, like $product->get_price(),
use the get_prop() method under the dynamic filter hook
This is part of the WC_Data class that WC_Product extends.
@junaidtk
junaidtk / Make outer 100% Height
Created September 30, 2019 10:43
Give parent div 100% height for floated inner elements
When we apply the float to inner elements and the outer div is not taking the height. Then you can use below snippets.
<div class="containing-div">
<div class="floating-div">
<ul>
<li>List Item One</li>
<li>List Item Two</li>
<li>List Item Three</li>
<li>List Item Four</li>
</ul>
@junaidtk
junaidtk / jQuery submit()
Created October 11, 2019 03:55
jQuery submit() doesn't include its value.
If we are using the button in the form for submitting the data, then it will work if we click the button.
If we are using the jQuery.submit() function for submiting the form. Then the button value doesn't submit.
For working form with the button value without an issue you just need to configure the a hidden input
and add all the button property to the hidden field.
Below is the code for configuring the form.
$("input[type=submit], input[type=button], button").click(function(e) {
var self= $(this),
Introduced in the PHP 5.
PHP will call this method, when ever we create a new object. So it is used for the any initialisation before object start.
Parent constructors are not called implicitly in the child class. In order to get the parent constructors in child class
we need to add the statement parent::__construct() within the child constructor.
If the child doesn't contain any __construct(), then the parent class __construct() method will be inherited.
<?php
class grandpa{