Skip to content

Instantly share code, notes, and snippets.

View rayflores's full-sized avatar

Ray Flores rayflores

View GitHub Profile
<?php
function justin_search_join( $join ) {
global $wpdb;
if( is_search() && !is_admin()) {
$join .= "LEFT JOIN $wpdb->postmeta AS m ON ($wpdb->posts.ID = m.post_id) ";
}
return $join;
}
// uncomment this to add this functionality
//add_filter('posts_join', 'justin_search_join' );
<?php
/**
* Add checkbox field to the checkout
**/
add_action('woocommerce_after_checkout_billing_form', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
add_filter ('add_to_cart_redirect', 'woo_redirect_to_checkout');
echo '<div id="my-new-field"><h3>'.__('1st Time Student?').'</h3>';
echo '<input id="my_checkbox" type="checkbox" class="input-checkbox" value="1" data-target="http://www.experiumscienceacademy.com/newsite/?add-to-cart=6319"/><label for="my_checkbox" class="checkbox ">Yes!</label>';
<?php
/**
* Redirect directly to checkout page only for ONE product
* if cart contains $product_id then go directly to checkout.
**/
add_filter ('add_to_cart_redirect', 'redirect_to_checkout');
function redirect_to_checkout() {
global $woocommerce;
//Get product ID
<?php
/**
* Auto Complete all WooCommerce orders.
* Add to theme functions.php file
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
global $woocommerce;
@rayflores
rayflores / show-page-ids-admin.php
Created July 1, 2014 20:43
Show Page ID's in admin
<?
add_filter('manage_posts_columns', 'posts_columns_id', 5);
add_action('manage_posts_custom_column', 'posts_custom_id_columns', 5, 2);
add_filter('manage_pages_columns', 'posts_columns_id', 5);
add_action('manage_pages_custom_column', 'posts_custom_id_columns', 5, 2);
function posts_columns_id($defaults){
$defaults['wps_post_id'] = __('ID');
return $defaults;
}
function posts_custom_id_columns($column_name, $id){
<?php
/**
* Plugin Name: Override Front Page Display Settings
* Plugin URI: www.floressquad.com
* Version: 1.0
* Author: Ray Flores
* Author URI: www.rayflores.com
* Description: set Reading Front Page Displays to default "your latest posts"
* Requires at least: 3.5
* Tested up to: 3.9
<?php
/*-----------------------------------------------------------------------------------*/
/* Post Meta */
/*-----------------------------------------------------------------------------------*/
if (!function_exists('woo_post_meta')) {
function woo_post_meta( ) {
?>
<p class="post-meta">
<span class="post-author"><span class="small"><?php _e('by', 'woothemes') ?></span> <?php the_author_posts_link(); ?></span>
@rayflores
rayflores / db-admin-user.php
Last active August 29, 2015 14:04
Create Admin User via database insert
<?php
INSERT INTO `wp_db_name_here`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('88', 'rayflores', MD5('cR@zYP@s5!'), 'rayflores', 'rayflores88@gmail.com', '', '2013-05-11 00:00:00', '', '0', 'Ray Flores');
// then do this one next
INSERT INTO `wp_db_name_here`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '88', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
// then do this one last
INSERT INTO `wp_db_name_here`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '88', 'wp_user_level', '10');
@rayflores
rayflores / new_excerpt_length.php
Created July 29, 2014 23:32
excerpt _new_ length
<?php
function new_excerpt_length( $length ) {
// change from default length of 55
return 200;
}
add_filter( 'excerpt_length', 'new_excerpt_length' );
<?php // start ?>
<div class="ytwrapper"> <!-- wrapper -->
<a href="javascript:void(0)" onMouseOver="play()">
<div id="player"></div><?php // where video will be housed ?>
</a>
<script> // 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];