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 / get_ssl_info.php
Created June 30, 2016 13:41
Example PHP code to get SSL cert info
<?php
$url = "http://www.codehooligans.com";
$orignal_parse = parse_url($url, PHP_URL_HOST);
$get = stream_context_create(array("ssl" => array("capture_peer_cert" => TRUE)));
$read = stream_socket_client("ssl://".$orignal_parse.":443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $get);
$cert = stream_context_get_params($read);
$certinfo = openssl_x509_parse($cert['options']['ssl']['peer_certificate']);
echo "certinfo<pre>". print_r($certinfo, true) ."</pre>";
<?php
/*
* Template Name: Facility Map
* Description: Faicility Map Design
*/
get_header();
?>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
@codehooligans
codehooligans / WC_checkout_field_validation
Last active August 20, 2022 07:47
WooCommerce Checkout form DOB date field validation in jQuery
// We are using the WooCommerce Checkout Field Editor plugin in addition to WooCommerce. The Checkout Field Editor
// does a nice job at providing a UI for manage additional fields. But doesn't provide any method to do validations.
// So this code helps with that on a very specific implemention where we have a Gender select and a DoB date selector.
// On the Gender we want to ensure the selected value is 'Male' or 'Female' only. We don't want the
default option 'Choose Option' to be valid. On the DoB we want to enforce the user is 18 or older.
add_action( 'woocommerce_after_checkout_validation', 'woo_checkout_additional_field_validation' );
function woo_checkout_additional_field_validation() {
if (!defined('WOOCOMMERCE_CHECKOUT')) {
return;
@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;
@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 / 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 / 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-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-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-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
)