Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Plugin Name: Test "pay button" support
*/
add_action( 'plugins_loaded', function() {
class My_Custom_Gateway extends WC_Payment_Gateway {
public function __construct() {
$this->id = 'custom_gateway';
$this->has_fields = false;
@cyberwani
cyberwani / edd.php
Created October 8, 2021 07:13 — forked from xplodedthemes/edd.php
Freemius EDD Migration Helper in case EDD License keys have a custom prefix and are over 32 chars.
<?php
/*
....
Within plugin EDD Migration Client edd.php
*/
/**
* You should use your own unique CLASS name, and be sure to replace it
* throughout this file. For example, if your product's name is "Awesome Product"
@cyberwani
cyberwani / .env
Created October 8, 2021 07:05 — forked from xplodedthemes/.env
Ticksy External Purchase Verification Freemius Integration
FS_API_SCOPE="developer"
FS_API_DEV_ID=000
FS_API_PUBLIC_KEY=""
FS_API_SECRET_KEY=""
TICKSY_SECRET_KEY=""
@cyberwani
cyberwani / WP_API_OAuth_Test_client.php
Created September 16, 2021 05:30 — forked from kosso/WP_API_OAuth_Test_client.php
Test PHP client for Wordpress REST API v2.0 / OAuth1.0a 0.3.0
<?php
//opcache_reset(); // Disable local dev MAMP cache
/*
WP_API_OAuth_Test_client.php
Tested with Wordpress 4.7.1
WordPress REST API - OAuth 1.0a Server v.0.3.0 - https://en-gb.wordpress.org/plugins/rest-api-oauth1/
@cyberwani
cyberwani / readme.md
Created August 25, 2020 09:08 — forked from rmpel/readme.md
Migrate website out of multisite

To migrate a website out of a multisite (Yes, this is WordPress!!!!)

  1. determine site ID (for example: 5)
  2. create a spot where the new website will live (for example: /www/mywebsite.nl/public)
  3. install a new WordPress
cd /www/mywebsite.nl/public ; wp core download
  1. copy theme(s) and plugins
@cyberwani
cyberwani / in-your-application.php
Created August 25, 2020 08:09 — forked from rmpel/in-your-application.php
WordPress REST-API in website, NONCE problems when authenticating or de-authenticating (login / logout)
<?php
// sent an updated nonce to the front-end on each request
add_filter( 'rest_post_dispatch', function( WP_REST_Response $response, WP_REST_Server $rest, WP_REST_Request $request) {
$response->header('X-WP-Nonce', wp_create_nonce( 'wp_rest' ));
return $response;
}, PHP_INT_MAX, 3);
// wp_create_nonce relies on user-id from global user object, and authentication cookie.
// both are INCORRECT after programmatic log-in or log-out.
// Really, WordPress? You should do this for us!
@cyberwani
cyberwani / Youtube_Regex_Grab_Video-Playlist_ID_With_Time.php
Created February 29, 2020 05:18 — forked from LinuxPanda/Youtube_Regex_Grab_Video-Playlist_ID_With_Time.php
Best regex pattern to get youtube video/playlist id with/without time from any youtube link and generate embed code. This regex works with 1) youtube & youtu.be 2) http/https 3) with/without www.
<?php
/*
* @gist Regex to get youtube video/playlist id with/without time & generate embed code
* @license UNLICENSE (http://unlicense.org)
*/
$youtube_url = array(
"https://youtu.be/yVpbFMhOAwE",
"https://www.youtube.com/embed/yVpbFMhOAwE",
@cyberwani
cyberwani / .editorconfig
Created February 17, 2020 07:37 — forked from salcode/.editorconfig
WordPress .editorconfig - modified version of the WordPress coding standards
# EditorConfig helps keep your project formatting consistent.
# See https://EditorConfig.org
#
# This is a modified version of the WordPress coding standards.
#
# Author: Sal Ferrarello (@salcode)
# https://salferrarello.com/wordpress-editorconfig/
#
# You can download this file directly
# to your project from the command-line with
@cyberwani
cyberwani / sendmail in wamp
Created February 11, 2020 09:19 — forked from abdullahbutt/sendmail in wamp
how to send email from wamp using sendmail
Install Fake Sendmail (http://glob.com.au/sendmail/). Then configure C:\wamp\sendmail\sendmail.ini:
smtp_server=smtp.gmail.com
smtp_port=465
auth_username=user@gmail.com
auth_password=your_password
The above will work against a Gmail account. And then configure php.ini:
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
Now, restart Apache, and that is basically all you need to do.
@cyberwani
cyberwani / is_localhost
Created February 10, 2020 17:57 — forked from troutacular/is_localhost
PHP - Check if localhost
// Check if we are in a local environment
function is_localhost() {
// set the array for testing the local environment
$whitelist = array( '127.0.0.1', '::1' );
// check if the server is in the array
if ( in_array( $_SERVER['REMOTE_ADDR'], $whitelist ) ) {