A Pen by Muluneh Awoke on CodePen.
This file contains 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
const IS_SANDBOX = true; | |
//Require the MedaPay module and initialize with provided token | |
const MedaPay = require('medapay').init({ | |
bearerToken: 'eyJ......' | |
}, IS_SANDBOX); | |
... | |
//Create bill | |
MedaPay.create(SAMPLE_BILL) | |
.then(createBillResponse => console.log(createBillResponse.billReferenceNumber)) | |
.catch(error => console.error(error)); |
This file contains 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
/** | |
* Creates a pseudo-random value generator. The seed must be an integer. | |
* | |
* Uses an optimized version of the Park-Miller PRNG. | |
* http://www.firstpr.com.au/dsp/rand31/ | |
*/ | |
function Random(seed) { | |
this._seed = seed % 2147483647; | |
if (this._seed <= 0) this._seed += 2147483646; | |
} |
This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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 create_toc( $content ) { | |
preg_match_all( '/<h([1-6])(.*)>([^<]+)<\/h[1-6]>/i', $content, $matches, PREG_SET_ORDER ); | |
global $anchors; | |
$anchors = array(); | |
$toc = '<ol class="toc">'."\n"; | |
$i = 0; |
This file contains 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
function _generate_toc( $content , $headings, $first_heading) { | |
preg_match_all( '/<h([' . $headings . '])(.*)>([^<]+)<\/h[' . $headings . ']>/i', $content, $matches, PREG_SET_ORDER ); | |
global $anchors; | |
$anchors = array(); | |
$toc = '<ul class="nav">'."\n"; | |
$i = 0; | |
//add the fist anchor link |
This file contains 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
function _generate_toc( $content , $headings, $first_heading) { | |
preg_match_all( '/<h([' . $headings . '])(.*)>([^<]+)<\/h[' . $headings . ']>/i', $content, $matches, PREG_SET_ORDER ); | |
global $anchors; | |
$anchors = array(); | |
$toc = '<ul class="nav">'."\n"; | |
$i = 0; | |
//add the fist anchor link |
This file contains 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 | |
/** | |
* Based on: | |
* https://codex.wordpress.org/Function_Reference/get_shortcode_regex | |
*/ | |
function extract_shortcode($content, $tag) { | |
$shortcode_match = false; | |
This file contains 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
//order products alphabetically and display all of them | |
function prefix_products_archive_modify( $query ) { | |
if ( is_post_type_archive('product') && | |
! empty( $query->query['post_type']) && | |
$query->query['post_type'] == 'product') { | |
$query->set( 'orderby', 'title' ); | |
$query->set('order', 'ASC'); | |
$query->set( 'posts_per_page', -1 ); | |
} |