Skip to content

Instantly share code, notes, and snippets.

View codehooligans's full-sized avatar
🤠
I may be slow to respond.

Paul Menard codehooligans

🤠
I may be slow to respond.
View GitHub Profile
@codehooligans
codehooligans / codehooligans-edited-product-packages
Created January 13, 2015 18:27
Codehooligans.com: Edited Product Packages
<?php
add_action( 'edited_product_packages', 'save_product_packages', 10, 2);
function save_product_packages($term_id, $tt_id)
{
if (!$term_id) return;
if (isset($_POST['product_package_active']))
update_metadata($_POST['taxonomy'], $term_id, 'product_package_active',
$_POST['product_package_active']);
@codehooligans
codehooligans / codehooligans-register-taxonomy-for-product-packages-v2
Created January 13, 2015 18:31
Codehooligans.com: Register Taxonomy for Product Packages Version 2
<?php
add_action( 'init', 'product_init' );
function product_init()
{
global $wpdb;
register_taxonomy( 'product_packages', 'products',
array( 'hierarchical' => true,
'label' => __('Product Packages'),
'query_var' => false
@codehooligans
codehooligans / codehooligans-adding-taxonomy-custom-headers
Created January 13, 2015 18:41
Codehooligans.com: Adding Taxonomy Column Headers
<?php
add_action( 'init', 'product_init' );
function product_init()
{
register_taxonomy( 'product_packages', 'products',
array( 'hierarchical' => true,
'label' => __('Product Packages'),
'query_var' => false
)
);
@codehooligans
codehooligans / codehooligans-adding-taxonomy-custom-data
Created January 13, 2015 18:42
Codehooligans.com: Adding Taxonomy Column Data
<?php
add_action( 'init', 'product_init' );
function product_init()
{
// From Part I
register_taxonomy( 'product_packages', 'products',
array( 'hierarchical' => true,
'label' => __('Product Packages'),
'query_var' => false
)
@codehooligans
codehooligans / codehooligans-disable-wordpress-plugins-update-indicator.php
Created January 21, 2015 16:36
Codehooligans.com: Disable WordPress Plugins update indicator for inactive plugins
function update_active_plugins($value = '') {
/*
The $value array passed in contains the list of plugins with time
marks when the last time the groups was checked for version match
The $value->reponse node contains an array of the items that are
out of date. This response node is use by the 'Plugins' menu
for example to indicate there are updates. Also on the actual
plugins listing to provide the yellow box below a given plugin
to indicate action is needed by the user.
*/
@codehooligans
codehooligans / codehooligans-adding-simple-javascript-to-header.php
Created January 22, 2015 15:00
codehooligans.com: Adding simple JavaScript to header
<script src="http://localhost/wp-content/themes/mytheme/js/jquery/jquery.js" type="text/javascript"></script>
@codehooligans
codehooligans / codehooligans-adding-javascript-via-wordpress-init.php
Created January 22, 2015 15:01
codehooligans.com: Adding JavaScript via WordPress init
<?php
function my_functions_init() {
wp_enqueue_script('jquery');
}
add_action( 'init', 'my_functions_init' );
?>
@codehooligans
codehooligans / codehooligans-wordpress-plugin-media-tags-usage.php
Created January 22, 2015 15:03
codehooligans.com: WordPress Plugin Media-tags Usage
<?php
$media_items = $mediatags->get_media_by_tag('media_tags=sidebar&post_parent=6');
/*
This call will filter the tags for the tag 'sidebar' and the post ID of 6.
The function take three arguments.
media_tags (Required) This is the tag or tags you are filtering on.
media_types (Optional) Lets you also filter by pdf, txt, etc.
post_parent (Optional) The ID of the attachment post. If not provided then the global post ID is assumed.
*/
@codehooligans
codehooligans / gist:705e22f087c3c7d2ce5a
Last active August 29, 2015 14:16
LoginRadius Plugin bug.
// In the file LoginRadius.php in the function login_radius_update_profile_data
// The following logic starts at line 712
$contacts = $loginRadiusObject->loginradius_get_contacts( self::$loginRadiusAccessToken );
if ( is_array( $contacts ) && count( $contacts ) > 0 ) {
$wpdb->delete( $wpdb->base_prefix . 'loginradius_contacts', array( 'user_id' => $userId ) );
foreach ( $contacts as $contact ) {
// The issue is the compare of the $contacts object. In the IF above the $contacts is
// checked to see if it is an array. The problem is $contacts is actuall an object.
@codehooligans
codehooligans / gist:775abfb24794842c8142
Created March 6, 2015 18:25
To correct the post_type query
add_action( 'pre_get_posts', 'attraction_pre_get_post', 1 );
function attraction_pre_get_post( $query ) {
if ( $query->is_main_query() ) {
if ( ( $query->is_archive ) && ( $query->is_tax ) ) {
if ( ( !isset( $query->post_type ) ) || ( empty( $query->post_type ) ) ) {
$queried_object = get_queried_object();
if ( !isset($queried_object->taxonomy ) )
return;