Skip to content

Instantly share code, notes, and snippets.

View mohammadmursaleen's full-sized avatar

Mohammad Mursaleen mohammadmursaleen

View GitHub Profile
@mohammadmursaleen
mohammadmursaleen / update_wordpress_user_password.php
Created May 7, 2019 05:06
Update user password using functions.php file in WordPress
<?php
add_action('init' , 'mm_update_user' , 0);
function mm_update_user(){
$user = get_user_by( 'login', 'developer' ); // Replace 'developer' with username
$user_id = $user->ID;
$password = 'sfsdfsdfsdf123SFSD#';
@mohammadmursaleen
mohammadmursaleen / wpcontent_zip.php
Created June 1, 2017 07:31
Zip Using FTP - Place this file in same directory
<?php
echo shell_exec("zip -r wp-content.zip wp-content");
@mohammadmursaleen
mohammadmursaleen / purchased_by_order_column.php
Created May 26, 2017 10:33
WooCommerce - Add purchased by column in order list
<?php
add_filter( 'manage_shop_order_posts_columns', 'show_purchased_by_shop_order_columns' , 100 );
add_action( 'manage_shop_order_posts_custom_column', 'show_purchased_by_render_shop_order_columns', 2 );
add_filter( 'manage_edit-shop_order_sortable_columns', 'show_purchased_by_shop_order_sortable_columns' );
/**
* Define custom columns for orders.
* @param array $columns
* @return array
@mohammadmursaleen
mohammadmursaleen / admin_posts_list_filter.php
Created May 24, 2017 06:28
WordPress Plugin - Admin Post list table filter using post meta values
<?php
/*
Plugin Name: Admin Filter BY Custom Fields
Version: 1.0
Author: Mohammad Mursaleen
*/
add_action( 'restrict_manage_posts', 'obj_admin_posts_filter_restrict_manage_posts' );
/**
* First create the dropdown
@mohammadmursaleen
mohammadmursaleen / email_notification_customize.php
Last active December 29, 2023 15:21
WordPress Plugin - Dynamically Generate Password and send in email Notification to Admin and New user
<?php
/*
Plugin Name: New Register Email Customizer
Description: Changes the copy in the email sent out to new users
Author: Mohammad Mursaleen
*/
// Redefine user notification function
if ( !function_exists('wp_new_user_notification') ) {
@mohammadmursaleen
mohammadmursaleen / getCoordinatesWithinRadius.php
Created April 24, 2017 08:15
PHP function to get markers within certain radius
<?php
/**
* @author Mohammad Mursaleen
* @usange to get array of all markers within certain radius
* @param $coordinateArray
* @param $center
* @param $radius
* @return array
*/
@mohammadmursaleen
mohammadmursaleen / disable_wishlist_add_to_cart_if_no_price.php
Created March 30, 2017 11:33
YITH WooCommerce Wishlist - disable add to cart if no price for Product
<?php
add_filter( 'woocommerce_loop_add_to_cart_link' , 'mm_disable_add_to_cart_if_no_price' , 20 , 2 );
function mm_disable_add_to_cart_if_no_price( $html , $product ){
$product_price = $product->get_price();
if( !empty( $product_price ) || !is_page('wishlist') ){
@mohammadmursaleen
mohammadmursaleen / get_the_date_filter.php
Created November 3, 2016 06:48
WordPress Adding language support to all get_the_date() calls
<?php
/**
* @author Mohammad Mursalenen
* @param $date
* @return mixed
*/
function mm_get_date_lang_support($date){
if ( function_exists('icl_object_id') ) {
@mohammadmursaleen
mohammadmursaleen / mm_wpml_string_transaltion_enable_by_force.php
Created October 5, 2016 10:55
WPML auto string transaltion enable by force
<?php
add_action('wp_head','mm_wpml_string_transaltion_enable_by_force');
/**
* @author Moahammad Mursaleen
* @usage to get WPML string translation work by force
*/
function mm_wpml_string_transaltion_enable_by_force(){
$icl_sitepress_settings = get_option('icl_sitepress_settings');
@mohammadmursaleen
mohammadmursaleen / text_truncate.php
Created September 26, 2016 09:55
Simple function to get truncated text to given count with last complete word
<?php
/**
* @author Mohammad Mursaleen
* @param $text
* @param $length
* @return mixed
*/
function mm_truncate( $text , $length ) {
$length = abs( (int)$length );