Skip to content

Instantly share code, notes, and snippets.

View moabi's full-sized avatar
🎯
Focusing

David Fieffé moabi

🎯
Focusing
View GitHub Profile
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@jedp
jedp / gist:3005816
Created June 27, 2012 18:18
postMessage() security review checklist

Security-Reviewing Uses of postMessage()

The postMessage() API is an HTML5 extension that permits string message-passing between frames that don't share the same origin. It is available in all modern browsers. It is not supported in IE6 and IE7.

postMessage is generally considered very secure as long as the programmer is careful to check the origin and source of an arriving

@wpscholar
wpscholar / functions.php
Last active March 1, 2021 13:26
Enqueueing IE conditional stylesheets in WordPress the right way
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
/**
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
*
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link https://developer.wordpress.org/reference/functions/wp_style_add_data/
<?php
/**
* Create ACF setting page under Events CPT menu
*
* @since 1.0.0
*/
if ( function_exists( 'acf_add_options_sub_page' ) ){
acf_add_options_sub_page(array(
'title' => 'Event Settings',
'parent' => 'edit.php?post_type=events',
@mathpere
mathpere / config.json
Created November 18, 2014 18:35
PayZen with NodeJS
{
"payZen": {
"url": "https://secure.payzen.eu/vads-payment/",
"certificat": "XXXXXXXXX",
"vads_site_id": "YYYYYYYY",
"vads_version": "V2",
"vads_ctx_mode": "TEST"
}
}
@bentasm1
bentasm1 / functions.php
Last active September 13, 2016 14:57 — forked from digitalchild/wcv_vendors_menu
WC Vendors Free & Pro Dynamic Vendor Menus
// Place this in your themes functions.php
// This will put the menu item in your primary menu. Change the theme location if you want to change which menu this goes in.
// Use the Free code for WC Vendors Free, use the Pro code for WC Vendors Pro
/* BEGIN WC Vendors Free */
add_filter( 'wp_nav_menu_items', 'wcv_vendors_menu', 10, 2 );
function wcv_vendors_menu ( $items, $args ) {
if ($args->theme_location == 'primary') {
$vendors = get_users( array( 'role' => 'vendor' ) );
$items .= '<li><a href="#">Vendors</a>';
@bentasm1
bentasm1 / functions.php
Created January 5, 2016 03:32
WooCommerce - Collect buyers First and Last Name at Registration
/* BEGIN REGISTRATION FIELDS */
function cs_wc_extra_register_fields() {
?>
<p class="form-row form-row-first">
<label for="reg_billing_first_name"><?php _e( 'First Name', 'textdomain' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
</p>
<p class="form-row form-row-last">
<label for="reg_billing_last_name"><?php _e( 'Last Name', 'textdomain' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="billing_last_name" id="reg_billing_last_name" value="<?php if ( ! empty( $_POST['billing_last_name'] ) ) esc_attr_e( $_POST['billing_last_name'] ); ?>" />
@bentasm1
bentasm1 / product-edit.php
Created January 6, 2016 02:07 — forked from digitalchild/product-edit.php
WC Vendors Pro Form Input Type Examples
<?php
/**
* Example text input with validation
*/
WCVendors_Pro_Form_Helper::input(
array(
'post_id' => $object_id,
'id' => '_wcv_custom_product_example_text_input',
'label' => __( 'Product Meta Text Input', 'wcvendors-pro' ),
@bentasm1
bentasm1 / functions.php
Last active January 12, 2017 16:30
WC Vendors Notify Vendor when Product is Approved
/* WC Vendors Pro - Notify Vendor when Product is Approved */
add_action( 'pending_to_publish', 'wcv_notify_vendor_on_publish' );
function wcv_notify_vendor_on_publish( $post_id ) {
global $post;
if ( $post->post_author != get_current_user_id() ) {
$author = new WP_User( $post->post_author );
$email_data = array(
'to' => $author->user_email,
'subject' => sprintf( __( 'Your post on %1$s has been published!', 'email_author_on_publish' ), get_bloginfo('name') ),
'message' => sprintf( __( 'Your post "%1$s" on %2$s has been published: %3$s', 'email_author_on_publish' ), $post->post_title, get_bloginfo( 'name' ), get_permalink( $post->ID ) ),