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
import requests | |
resp = requests.get('https://url.com/api/endpoint').json() | |
data = resp['data'] | |
while resp['next_page_url']: | |
resp = requests.get(resp['next_page_url']).json() | |
data.extend(resp['data']) |
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 | |
/** | |
* Create post loop query | |
*/ | |
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; | |
$args = array( | |
'post_type' => 'post', | |
'orderby' => 'menu_order', | |
'order' => 'ASC', | |
'showposts' => 3, |
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 | |
/** | |
* Use in loop or single, has to access post_content | |
*/ | |
$pattern = get_shortcode_regex(); | |
preg_match('/'.$pattern.'/s', $post->post_content, $matches); | |
if (is_array($matches) && $matches[2] == 'smart_track_player') { | |
$shortcode = $matches[0]; | |
echo do_shortcode($shortcode); | |
} |
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
if(! function_exists('nl2p')) { | |
function nl2p($str) { | |
$arr = explode("\n", $str); | |
$out = ''; | |
for($i = 0; $i < count($arr); $i++) { | |
if(strlen(trim($arr[$i])) > 0) | |
$out .= '<p>' .trim($arr[$i]) . '</p>'; | |
} |
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
if(! function_exists('split_name')) { | |
function split_name($name) { | |
$parts = array(); | |
while ( strlen( trim($name)) > 0 ) { | |
$name = trim($name); | |
$string = preg_replace('#.*\s([\w-]*)$#', '$1', $name); | |
$parts[] = $string; | |
$name = trim( preg_replace('#'.$string.'#', '', $name ) ); | |
} |
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 Illuminate\Pagination\LengthAwarePaginator; | |
use Illuminate\Pagination\Paginator; | |
use Illuminate\Support\Collection; | |
if(! function_exists('paginate')) | |
{ | |
function paginate($items, $perPage = 15, $page = null) | |
{ | |
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1); | |
$items = $items instanceof Collection ? $items : Collection::make($items); |
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
# remove specific file from git cache | |
git rm --cached filename | |
# remove all files from git cache | |
git rm -r --cached . | |
git add . | |
git commit -m ".gitignore is now working" |
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 | |
// woocommerce cart disable requirement of payment | |
add_filter('woocommerce_cart_needs_payment', '__return_false'); | |
?> |
NewerOlder