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
function include_template( $template, $args = array() ) | |
{ | |
//Allow plugins to manipulate the tempalte data before sending it to the template | |
$data = apply_filters('prefix_template_data', $args, $template); | |
//Look in theme folder first, then plugin folder | |
if(locate_template($template) === '') | |
{ | |
include PREFIX_PLUGIN_PATH . 'templates/' . $template; |
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
// | |
// Improved and much cleaner version of https://gist.github.com/andyl/6360906 | |
// | |
// | |
// Bootstrap Mid-Small - col-ms-* - the missing grid set for Bootstrap3. | |
// | |
// This is a hack to fill the gap between 480 and 760 pixels - a missing range | |
// in the bootstrap responsive grid structure. Use these classes to style pages | |
// on cellphones when they transition from portrait to landscape. | |
// |
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
# This might ruin your database and I do not take any responsibility for that. Backup your database before continuing | |
! | |
# Check the results throughly | |
SELECT * FROM `wp_postmeta` | |
WHERE `meta_key` IN | |
( SELECT TRIM(LEADING '_' FROM `meta_key`) AS mk | |
FROM `wp_postmeta` | |
WHERE `meta_value` regexp '^field_[0-9a-f]+' | |
AND `meta_value` NOT IN |
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
# Only database backup | |
declare -a SITES=('site1' 'site2' 'site3' 'site4'); | |
SITES_PATH_BASE=/var/www/ | |
SITES_PATH_SUFIX=/repo/public | |
SITES_BACKUP_FOLDER=backups | |
CURRENT_DATE=`date +%Y-%m-%d`; |
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( 'woocommerce_single_product_summary', 'my_add_read_more_about_category', 25); | |
function my_add_read_more_about_category() | |
{ | |
global $product; | |
$cat_post_map = array( | |
// category id => array(<page id to link to>, <category plural label (optional)>) |
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
{ | |
"repositories": [ | |
{ | |
"type": "composer", | |
"url": "http://wpackagist.org" | |
}, | |
{ | |
"type": "package", | |
"package": { | |
"name": "advanced-custom-fields/advanced-custom-fields-pro", |
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( 'PE_Post_Type_Creator' ) ) | |
{ | |
$ptc = new PE_Post_Type_Creator(); | |
$text_domain = 'text-domain'; | |
$ptc->set_taxonomies(array( | |
'min-taxonomi' => array( | |
'singular_label' => _x('Min taxonomi', 'Post type plural', $text_domain), |
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
#!/usr/bin/php | |
<?php | |
/** | |
* USAGE: | |
* | |
* (optional) Download script: | |
* "wget https://gist.githubusercontent.com/pelmered/2ee27f1cb18b8c73a0205ded580e3195/raw/convert-to-composer.php" | |
* | |
* Basic usage: | |
* php convert-to-composer.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
/** | |
* Hide shipping rates except local delivery when free shipping is available. | |
* Updated to support WooCommerce 2.6 Shipping Zones. | |
* | |
* @param array $rates Array of rates found for the package. | |
* @return array | |
*/ | |
function my_hide_shipping_when_free_is_available( $rates ) { | |
$free = array(); | |
$local_pickup = array(); |
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 | |
$posts = get_posts([ | |
'post_status' => 'publish', | |
'posts_per_page' => -1, | |
'post_type' => 'post' | |
]); | |
$post_index = array_fill_keys( array_merge( [ '#' ], range( 'a', 'z' ), ['å', 'ä', 'ö', ] ), [] ); | |
foreach( $posts as $post ) { | |
$first_letter = strtolower( substr( $post->post_title, 0, 1 ) ); |