Compare md5 encrypted password with submitted password

Find below code to check md5 encrypted password with submitted password.

$password = “avinash”;
$store_password = md5($password);

$submit_password =$_POST[‘submit_password’];
$sub_password = md5($submit_password);

if($sub_password==$store_password){

echo “Success password”;

}

Basic steps to start codeIgniter application

Basic steps to start codeIgniter application
1. Download the codeigniter from official website. https://www.codeigniter.com/
2. Downloaded folder extract and rename the folder name and place in side htdocs folder in your local server.
3. See the application folder, here you can observe MVC structure like controllers,models and views.
4. Inside Application folder that has config folder available , you have to config base_url and index_page.
Path: application/config/config.php
5. Configure your web application databse details at : application/config/database.php
6. In Codeigniter routing is very important. Default route for web application.
$route[‘default_controller’] = “Welcome”;
$route[‘404_override’] = ”;

For handling the form data you have to ser TRUE instead of FALSE in config.php
Global XSS Filtering.
$config[‘global_xss_filtering’] = TRUE;

7. Set the autoload libraries,database and helpers like form,url…

array_slice function for array pagination

array_slice function we will use for array pagination to get some part of array

$items = array(1,2,3,4,5,6,7,8,9,10);
$limit = 3;

$qty_items = count($items);
$qty_pages = ceil($qty_items / $limit);

$curr_page = isset($_GET[‘page’]) ? $_GET[‘page’] : 1;
$next_page = $curr_page < $qty_pages ? $curr_page + 1 : null;
$prev_page = $curr_page > 1 ? $curr_page – 1 : null;

$offset = ($curr_page – 1) * $limit;
$items = array_slice($items, $offset, $limit);

$items // Array of elements

$offset // how many elements leave at the time of fetching

$limit //get number of elements from array

Pagination code

for($i = 1; $i <= $qty_pages; $i++){

echo $i;

}

ceil() function return integer number.

Check plugin is activated or not in wordpress

Please find below code to check plugin is activated or not.

include_once( ABSPATH . ‘wp-admin/includes/plugin.php’ );
if ( is_plugin_active( ‘plugin-folder/plugin-file.php’ ) ) {
// activated.
}

Get root directory path : ABSPATH // root path

Get current plugin path : plugin_dir_path( __FILE__ )

 

Get variation product quantity in admin product list page

add_filter(‘woocommerce_admin_stock_html’, ‘admin_product_data’,10,2);
function admin_product_data($stock_html,$product) {
global $wpdb;
if( $product->is_type( ‘variable’ ) ) {
$query = “SELECT sum(meta_value)
FROM $wpdb->posts AS p, $wpdb->postmeta AS s
WHERE p.post_parent = %d
AND p.post_type = ‘product_variation’
AND p.post_status = ‘publish’
AND p.id = s.post_id
AND s.meta_key = ‘_stock'”;

$product_qty = $wpdb->get_var($wpdb->prepare($query,$product->id));
$stock_html = ‘<mark class=”instock”>’. __(‘In stock’, ‘woocommerce’ ) . ‘</mark>’.’ (‘.$product_qty.’)’;
}
return $stock_html;
}

Call to a member function get() on a non-object in /woocommerce/emails/email-order-items.php

This kind of error mostly generate at the time using WC()->session->get in email-order-items.php file.

When we trying to save woo-commerce orders with some status like cancelled or completed or processed  from admin dashboard it will through error.

I don’t know exact possibilities of this error but in my case it’s getting. I hope it may helps.

WordPress website redirection possibilities

For redirecting website having below possibilities.

  1. Check .htaccess file it may having 301 redirection.
  2. functions.php having some wp_redirect functions.
  3. Check in wp-config.php define “WP_HOME” & “WP_SITEURL”.
  4. finally check for 301 redirection plugin activated or not.