This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We can add new admin user by using below code. it will be helpfull if we forget the admin details of the website. | |
add_action('init', 'add_new_admin_user'); | |
function add_new_admin_user() { | |
$username = 'testuser'; | |
$email = '[email protected]'; | |
$password = 'password'; | |
$user_id = username_exists( $username ); | |
if ( !$user_id && email_exists($email) == false ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(isset($_POST['submit'])){ | |
var_dump($_POST); | |
} | |
?> | |
<form method="post"> | |
<input type="test" name="test"> | |
<input type="test2" name="test2"> | |
<div class="ttt" style="display: none;"> | |
<input type="j1" name="j1" value="ttt"> | |
<input type="j2" name="j2" value="yyy"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For setting up the paypal checkout in woocommerce, we must have a paypal account. | |
The following are the steps to test paypal sandbox checkout in the woocommerce. | |
1. first we need to create a paypal account. | |
2. Then we goes to the https://developer.paypal.com/ page and check the sandbox area. Where we can see the buyer account and facilitator account. | |
3. Here we can add new buyer and facilitator account if required. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This code will display all hooks used in a page for wordpress website. | |
$debug_tags = array(); | |
add_action( 'all', function ( $tag ) { | |
global $debug_tags; | |
if ( in_array( $tag, $debug_tags ) ) { | |
return; | |
} | |
echo "<pre>" . $tag . "</pre>"; | |
$debug_tags[] = $tag; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In javascript, to check a variable contain a valid data or not, we can use the below code. | |
var value; | |
if(value){ | |
// do something | |
} | |
If the variable doesn't contain a valid value it may have following 6 type of content. | |
This checking will valid if the variable is already defined. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For creating a new post types in wordpress admin panel we can use below function in init hook. | |
function theme_posttype() { | |
register_post_type('portfolio', array('label' => 'Works', | |
'description' => '', | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'capability_type' => 'page', | |
'hierarchical' => false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
<a href="http://www.example.com/">A link</a> | |
The output will display like below. |