Skip to content

Instantly share code, notes, and snippets.

View himanshuahuja96's full-sized avatar
💭
Sitecore and WordPress Ninja

himanshuahuja96

💭
Sitecore and WordPress Ninja
View GitHub Profile
@himanshuahuja96
himanshuahuja96 / force-ssl-url-scheme.php
Created December 15, 2017 21:58 — forked from webaware/force-ssl-url-scheme.php
For WordPress, force the protocol scheme to be HTTPS when is_ssl() doesn't work, e.g. on a load-balanced server where _SERVER['HTTPS'] and _SERVER['SERVER_PORT'] don't indicate that SSL is being used. NB: may not be needed now, see SSL Insecure Content Fixer and HTTP Detection: https://ssl.webaware.net.au/https-detection/
<?php
/*
Plugin Name: Force SSL URL Scheme
Plugin URI: https://gist.github.com/webaware/4688802
Description: Force the protocol scheme to be HTTPS when is_ssl() doesn't work
Version: 1.0.0
Author: WebAware
Author URI: http://webaware.com.au/
@ref: http://wordpress.org/support/topic/ssl-insecure-needs-35-compatibility
@himanshuahuja96
himanshuahuja96 / gist:8f33fa4c9f9e72fb750a5c24cee1cbe1
Created December 16, 2017 13:52 — forked from ultimatemember/gist:f7eab149cb33df735b08
Extend Ultimate Member Account page with custom tabs/content
/* add new tab called "mytab" */
add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um', 100 );
function my_custom_tab_in_um( $tabs ) {
$tabs[800]['mytab']['icon'] = 'um-faicon-pencil';
$tabs[800]['mytab']['title'] = 'My Custom Tab';
$tabs[800]['mytab']['custom'] = true;
return $tabs;
}
@himanshuahuja96
himanshuahuja96 / computedfieldSitecoreLogic.txt
Created April 7, 2019 05:41
Sitecore computed field logix to index all the fields of current item in one go
Algorithm:
1) Get all the fields of current item
2) Store all fields in an array
3) create a empty string to store all the item data and call as itemdata (typeof string)
4) Iterate through each item and push data into itemdata
5) Remove all the html using regrex from itemdata if any
6) return itemdata
Basic code
@himanshuahuja96
himanshuahuja96 / sticky-menu-wix-type
Created May 7, 2019 12:58
Hide Menu when scroll down and show when user scrolls up (Two type of solutions)
<script>
/*
solution 1 - Not so good
var target = jQuery(".elementor-button-content-wrapper").offset().top,
timeout = null;
jQuery(window).scroll(function () {
if (!timeout) {
@himanshuahuja96
himanshuahuja96 / pmpro-limit-members-per-level.php
Created May 22, 2019 20:54 — forked from strangerstudios/pmpro-limit-members-per-level.php
Limit the number of total sign ups for a given membership level
<?php
/*
Set a maximum number of members allowed to register for a membership level.
Add this code to a plugin for PMPro Customizations.
Set the "Maximum" for a level on the Memberships > Membership Levels > Edit Level admin page.
*/
function pmproml_pmpro_save_membership_level( $level_id) {
if( $level_id <= 0 ) {
@himanshuahuja96
himanshuahuja96 / gist:dd99fade3ef16bd82077b4a4f6de597d
Created May 22, 2019 20:54 — forked from strangerstudios/gist:1389944
Paid Memberships Pro Extra Checkout/Profile Fields Example
<?php
/*
Adding First and Last Name to Checkout Form
*/
//add the fields to the form
function my_pmpro_checkout_after_password()
{
if(!empty($_REQUEST['firstname']))
$firstname = $_REQUEST['firstname'];
@himanshuahuja96
himanshuahuja96 / paid-membership-pro-integration-with-convertpro.php
Created June 6, 2019 15:27
Helps in automating members signup with the custom forms based on convertpro or even php forms
//split name into first and last
function split_name($name) {
$name = trim($name);
$last_name = (strpos($name, ' ') === false) ? '' : preg_replace('#.*\s([\w-]*)$#', '$1', $name);
$first_name = trim( preg_replace('#'.$last_name.'#', '', $name ) );
return array($first_name, $last_name);
}
@himanshuahuja96
himanshuahuja96 / gettext-filter-multiple.php
Created July 1, 2019 11:52 — forked from BFTrick/gettext-filter-multiple.php
Use the gettext WordPress filter to change any translatable string.
<?php
/**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Sale!' :
$translated_text = __( 'Clearance!', 'woocommerce' );
@himanshuahuja96
himanshuahuja96 / theme-my-login-filter-error.php
Last active August 17, 2019 11:16
Theme my login custom error message filter
function myfunctiontoaddmailme($errors){
$withoutLostPassword = '';
if( $errors === '<strong>ERROR</strong>: Invalid username. <a href="https://nicolethemathlady.com/my-account/lost-password/">Lost your password?</a>' ){
$withoutLostPassword = '<strong>ERROR</strong>: Not Sure about the Username?, Then <a href="mailto:nicole@nicolethemathlady.com?subject=Account Issue">Mail Me!</a> ';
$errors = $withoutLostPassword;
}
else if( $errors === '<strong>ERROR</strong>: Invalid email address. <a href="https://nicolethemathlady.com/my-account/lost-password/">Lost your password?</a>' ){
$withoutLostPassword = '<strong>ERROR</strong>: Not Sure about the Email?, Then <a href="mailto:nicole@nicolethemathlady.com?subject=Account Issue">Mail Me!</a> ';
$errors = $withoutLostPassword;
}
@himanshuahuja96
himanshuahuja96 / functions.php
Created September 22, 2019 17:15 — forked from tripflex/functions.php
WordPress Remove Filter (remove_filter converted to remove_class_filter) to remove Filter/Action without Class Object access. Works with WordPress 1.2+ (4.7+ support added 9-19-2016)
<?php
/**
* Make sure the function does not exist before defining it
*/
if( ! function_exists( 'remove_class_filter' ) ){
/**
* Remove Class Filter Without Access to Class Object
*
* In order to use the core WordPress remove_filter() on a filter added with the callback