Skip to content

Instantly share code, notes, and snippets.

View JudeRosario's full-sized avatar

Jude Rosario JudeRosario

View GitHub Profile
<?php
$comment_user = get_user_by( 'email', get_comment_author_email() );
if ( user_can( $comment_user->ID, 'staff' ) ) {
if ( get_the_author_meta( 'staff') ) {
$x = ( the_author_meta( 'staff', $comment_user->ID ) == '' ) ? "Staff" : the_author_meta( 'staff', $comment_user->ID ) ;
echo '<div class="staff-label">';
@JudeRosario
JudeRosario / Register new CPT
Last active October 3, 2016 22:42
Register new CPT
if ( ! function_exists('customer') ) {
// Register Custom Post Type
function customer() {
$labels = array(
'name' => 'Customers',
'singular_name' => 'Customers',
'menu_name' => 'Customers',
'name_admin_bar' => 'Customers',
@JudeRosario
JudeRosario / Change Placeholder
Last active October 3, 2016 21:42
WP form change placeholder
add_filter( 'get_search_form', 'i21321_search_text_replacer', 999, 1 ) ;
function i21321_search_text_replacer ($form) {
return str_replace('Type &amp; Hit Enter to Search', 'Search in the website', $form ) ;
}
<?php
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
if ( ! class_exists( 'Snapshot_View_Table_Archives' ) ) {
class Snapshot_View_Table_Archives extends WP_List_Table {
var $item;
add_action( 'dp_duplicate_post', 'delete_sbe_meta_on_duplicate_post');
function delete_sbe_meta_on_duplicate_post( $new_post_id ) {
delete_post_meta( $new_post_id, 'sbe_sent' );
}
@JudeRosario
JudeRosario / affiliates.php
Created August 3, 2016 13:09
Affiliates + MP + Multisite
add_action( 'wp_footer', function(){
if( isset( $_COOKIE['affiliate_' . COOKIEHASH] ) ) {
$reference = isset($_GET['ref'])?$_GET['ref']:false;
@setcookie('affiliate_' . COOKIEHASH, 'aff' . md5(AUTH_SALT . $reference),
(time() + (60 * 60 * 24 * ((int) AFFILIATE_COOKIE_DAYS ))),
COOKIEPATH,
COOKIE_DOMAIN
);
@JudeRosario
JudeRosario / role.php
Created July 13, 2016 13:08
Apply CSS to users avatars by role
<?
add_filter('bp_member_avatar', 'bp_role_in_class');
function bp_role_in_class( $args ) {
global $members_template ;
$user = new WP_User( $members_template->member->id );
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
foreach ( $user->roles as $role )
$args['class'] .= " " . $role;
<div class="upfront-output-module-group upfront-module-group c10" id="module-group-1463730198987-1054" data-theme-styles="{&quot;default&quot;:false,&quot;desktop&quot;:false,&quot;tablet&quot;:false,&quot;mobile&quot;:false}"><div class="upfront-output-wrapper" id="wrapper-1463743376277-1654"><div class="upfront-output-module c10" id="module-1463728411672-1198"><div data-preset_map="{&quot;desktop&quot;:&quot;frontpagetekst&quot;}" class="upfront-output-object frontpagetekst upfront-output-plain_text c24 upfront-plain_txt" id="text-object-1463728411672-1093" data-theme-styles="{&quot;default&quot;:&quot;&quot;}"><div class="plain-text-container"><p><strong data-redactor-tag="strong" data-verified="redactor"><font><font>Are you looking to ... -&gt;</font></font></strong></p></div></div></div></div><div class="upfront-output-wrapper" id="wrapper-1463743376286-1068"><div class="upfront-output-module c10" id="module-1463730102664-1667"><div data-preset_map="{&quot;desktop&quot;:&quot;frontpagetekst&quot;,&quot;
<?php
add_action( 'dp_duplicate_post', 'delete_sbe_meta_on_duplicate_post');
function delete_sbe_meta_on_duplicate_post( $new_post_id ) {
delete_post_meta( $new_post_id, 'sbe_sent' );
}
add_action( 'wp_ajax_post_confirmation', 'app_update_status' );
add_action( 'wp_ajax_nopriv_post_confirmation', 'app_update_status' );
add_action( 'wp_ajax_nopriv_app_paypal_ipn', 'app_update_status' , 999 );
function app_update_status() {
if( $_POST['payment_status'] == 'Processed' || $_POST['payment_status'] == 'Completed' ) :
update_metadata( "app_appointment", $_POST['custom'] , "confirmed" );
endif ;