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 / 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 / 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 / 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
@himanshuahuja96
himanshuahuja96 / woo-checkout.php
Created February 13, 2020 12:45 — forked from Bobz-zg/woo-checkout.php
Pre-populate Woocommerce checkout fields
<?php
/**
* Pre-populate Woocommerce checkout fields
* Note that this filter populates shipping_ and billing_ fields with a different meta field eg 'first_name'
*/
add_filter('woocommerce_checkout_get_value', function($input, $key ) {
global $current_user;
switch ($key) :
/**
* Returns a user meta value
* Usage [um_user user_id="" meta_key="" ] // leave user_id empty if you want to retrive the current user's meta value.
* meta_key is the field name that you've set in the UM form builder
* You can modify the return meta_value with filter hook 'um_user_shortcode_filter__{$meta_key}'
*/
function um_user_shortcode( $atts ) {
$atts = extract( shortcode_atts( array(
'user_id' => get_current_user_id(),
'meta_key' => '',
@himanshuahuja96
himanshuahuja96 / mepr-active-memberships.php
Created March 11, 2020 08:39 — forked from andrija-naglic/mepr-active-memberships.php
Get a list of the current user's active MemberPress Subscriptions
<?php
function memberpress__get_all_memberships( $user_id = false ){
if( class_exists('MeprUser') ){
if( ! $user_id ){
$user_id = get_current_user_id();
}
@himanshuahuja96
himanshuahuja96 / wordpress_override_password_form.php
Created March 19, 2020 13:41 — forked from dmjarvis/wordpress_override_password_form.php
How to override the default WordPress page or post protection form (pre WP 3.4)
<?php
function my_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '<form class="protected-post-form" action="' . get_option( 'siteurl' ) . '/wp-pass.php" method="post">
' . __( "To view this protected post, enter the password below:" ) . '
<label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
</form>
';
return $o;