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
// Usage: | |
// get_id_by_slug('any-page-slug','any-post-type'); | |
function get_id_by_slug($page_slug, $slug_page_type = 'page') { | |
$find_page = get_page_by_path($page_slug, OBJECT, $slug_page_type); | |
if ($find_page) { | |
return $find_page->ID; | |
} else { | |
return null; | |
} |
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 PayPal button from checkout | |
add_filter( 'woocommerce_available_payment_gateways', '_wc_remove_braintree_pay_with_paypal' ); | |
function _wc_remove_braintree_pay_with_paypal( $gateways ) { | |
unset( $gateways['paypalbraintree_paypal'] ); | |
return $gateways; | |
} | |
// Remove PayPal button from cart | |
add_filter( 'wc_gateway_paypal_braintree_data', '_wc_remove_braintree_checkout_with_paypal' ); | |
function _wc_remove_braintree_checkout_with_paypal( $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 | |
// Version CSS file in a theme | |
wp_enqueue_style( 'theme-styles', get_stylesheet_directory_uri() . '/style.css', array(), filemtime( get_stylesheet_directory() . '/style.css' ) ); | |
// Version JS file in a theme | |
wp_enqueue_script( 'theme-scripts', get_stylesheet_directory_uri() . '/js/scripts.js', array(), filemtime( get_stylesheet_directory() . '/js/scripts.js' ) ); |
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 | |
if( class_exists( 'KC_Section_Importer' ) ) { | |
return; | |
} | |
class KC_Section_Importer { | |
/** | |
* Define the post_type & taxonomy to use | |
*/ |
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 | |
$arg = 'status'; | |
$valid_status_args = array('status', 'setting'); | |
$valid_theme_args = array('theme_data', 'theme'); | |
if (!in_array($arg, $valid_status_args)) { | |
echo 'Status Arg FAILED!!!'; echo PHP_EOL; |
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 our return TRUE function | |
function Function_TRUE($arg = '') { | |
$arg = TRUE; | |
return $arg; | |
} | |
// Create our return FALSE function |
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 | |
define('WYSIWYG_META_BOX_ID', 'my-editor'); | |
define('WYSIWYG_EDITOR_ID', 'myeditor'); //Important for CSS that this is different | |
define('WYSIWYG_META_KEY', 'extra-content'); | |
add_action('admin_init', 'wysiwyg_register_meta_box'); | |
function wysiwyg_register_meta_box(){ | |
add_meta_box(WYSIWYG_META_BOX_ID, __('WYSIWYG Meta Box', 'wysiwyg'), 'wysiwyg_render_meta_box', 'post'); | |
} |
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 | |
/* | |
Plugin Name: Disable plugins when doing local dev | |
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify | |
Version: 0.1 | |
License: GPL version 2 or any later version | |
Author: Mark Jaquith | |
Author URI: http://coveredwebservices.com/ | |
*/ |
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 | |
/* | |
Plugin Name: WP Migrate DB Pro Tweaks | |
Plugin URI: http://github.com/deliciousbrains/wp-migrate-db-pro-tweaks | |
Description: Examples of using WP Migrate DB Pro's filters | |
Author: Delicious Brains | |
Version: 0.2 | |
Author URI: http://deliciousbrains.com | |
*/ |
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 | |
// Works in every situations | |
function by_token ($src) { | |
$tokens = token_get_all($src); | |
$count = count($tokens); | |
$i = 0; | |
$namespace = ''; | |
$namespace_ok = false; | |
while ($i < $count) { |