Skip to content

Instantly share code, notes, and snippets.

View obiPlabon's full-sized avatar
🎯
1 goal

Md Obidullah obiPlabon

🎯
1 goal
View GitHub Profile
@obiPlabon
obiPlabon / mepr-active-memberships.php
Created August 29, 2020 06:30 — 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();
}
@obiPlabon
obiPlabon / mepr-active-memberships.php
Last active August 29, 2020 06:28 — forked from cartpauj/mepr-active-memberships.php
Get a list of the current user's active MemberPress Subscriptions
<?php
if(class_exists('MeprUtils')) {
$user = MeprUtils::get_currentuserinfo();
if($user !== false && isset($user->ID)) {
//Returns an array of Membership ID's that the current user is active on
//Can also use 'products' or 'transactions' as the argument type
$active_prodcuts = $user->active_product_subscriptions('ids');
if(!empty($active_prodcuts)) {
@obiPlabon
obiPlabon / extend-subscription-intervals.php
Created August 20, 2020 06:43 — forked from thenbrent/extend-subscription-intervals.php
Add a new billing interval to WooCommerce Subscriptions. Specifically a "every 10 weeks" billing interval to selling a subscription to something and be charged every 10 weeks.
<?php
/**
* Plugin Name: Extend WooCommerce Subscription Intervals
* Description: Add a "every 10 weeks" billing interval to WooCommerce Subscriptions
* Author: Brent Shepherd
* Author URI: http://brent.io
* Version: 1.0
* License: GPL v2
*/
@obiPlabon
obiPlabon / envato-purchase-verification.php
Created January 8, 2020 18:10
Envato purchase verification using `wp_remote_get`
<?php
$token = '***********';
$code = '*************';
$response = wp_remote_get(
'https://api.envato.com/v3/market/buyer/purchase?code=' . $code,
[
'headers' => [
'Authorization' => 'Bearer ' . $token,
<?php
$request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
$request->set_query_params( [ 'per_page' => 12 ] );
$response = rest_do_request( $request );
$server = rest_get_server();
$data = $server->response_to_data( $response, false );
$json = wp_json_encode( $data );
<?php
add_action(
'rest_api_init',
function () {
if ( ! function_exists( 'use_block_editor_for_post_type' ) ) {
require ABSPATH . 'wp-admin/includes/post.php';
}
#stop directory browsing
Options All -Indexes
# SSL Https active Force non-www
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
@obiPlabon
obiPlabon / alias.sh
Created September 18, 2018 10:29
Helpful terminal alias
// Source: https://www.facebook.com/ahmadawais
// Function: Shows current ip
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
@obiPlabon
obiPlabon / wp-taxonomy-meta-box-cb.php
Last active July 3, 2018 13:16
WP taxonomy metabox callback to generate radio selection
<?php
/**
* Override the default taxonomy metabox
*
* Generate a taxonomy meta box with radio button
*/
function op_taxonomy_meta_box_cb( $post ) {
$_writers = get_the_terms( $post->ID, 'writer' );
$selected_writers = array();
if ( ! empty( $_writers ) || ! is_wp_error( $_writers ) ) {
@obiPlabon
obiPlabon / wp-remove-schema-attr.php
Created May 31, 2018 13:29
Remove schema attributes from WordPress the_custom_logo generated logo html
<?php
/**
* Remove schema attributes from custom logo html
*
* @param string $html
* @return string
*/
function op_remove_custom_logo_schema_attr( $html ) {
return str_replace( array( 'itemprop="url"', 'itemprop="logo"' ), '', $html );
}