This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function memberpress__get_all_memberships( $user_id = false ){ | |
if( class_exists('MeprUser') ){ | |
if( ! $user_id ){ | |
$user_id = get_current_user_id(); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$token = '***********'; | |
$code = '*************'; | |
$response = wp_remote_get( | |
'https://api.envato.com/v3/market/buyer/purchase?code=' . $code, | |
[ | |
'headers' => [ | |
'Authorization' => 'Bearer ' . $token, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( | |
'rest_api_init', | |
function () { | |
if ( ! function_exists( 'use_block_editor_for_post_type' ) ) { | |
require ABSPATH . 'wp-admin/includes/post.php'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://www.facebook.com/ahmadawais | |
// Function: Shows current ip | |
alias ip="dig +short myip.opendns.com @resolver1.opendns.com" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
} |