Skip to content

Instantly share code, notes, and snippets.

View bryanrsebastian's full-sized avatar

Bryan Sebastian bryanrsebastian

View GitHub Profile
@mathiasbynens
mathiasbynens / jquery.email-antispam.js
Created January 26, 2010 13:10
Simple spam protection for email addresses using jQuery
/* Simple spam protection for email addresses using jQuery.
* Well, the protection isn’t jQuery-based, but you get the idea.
* This snippet allows you to slightly ‘obfuscate’ email addresses to make it harder for spambots to harvest them, while still offering a readable address to your visitors.
* E.g.
* <a href="mailto:foo(at)example(dot)com">foo at example dot com</a>
* →
* <a href="mailto:foo@example.com">foo@example.com</a>
*/
$(function() {
@landru247
landru247 / WP: PHP - Order a query by ACF date picker
Created July 26, 2013 14:11
WP: PHP - Order a query by ACF date picker
<?php
//Order a query by ACF date picker
$event = get_posts(array(
'post_type' => 'events',
'posts_per_page' => 4,
'meta_key' => 'event_date', // name of custom field
'orderby' => 'meta_value_num',
'order' => 'ASC'
));
if ($event) {
@mohammadmursaleen
mohammadmursaleen / gist:9622098e43afdab6025e
Last active October 15, 2021 18:29
Adding custom fields above WOOCOMMERCE add to cart button
<?php
// To add custom data above add to cart button in woocommerce
// step 1
add_action('wp_ajax_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
add_action('wp_ajax_nopriv_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
function wdm_add_user_custom_data_options_callback()
@Sjouw
Sjouw / custom.php
Created December 9, 2014 12:57
WordPress - Add description to featured image field
/*
* Add description to Featured image box
*/
function new_post_thumbnail_meta_box() {
global $post;
$thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); // grabing the thumbnail id of the post
echo _wp_post_thumbnail_html( $thumbnail_id ); // echoing the html markup for the thumbnail
@maxkostinevich
maxkostinevich / functions.php
Last active February 11, 2023 20:03
WordPress: Export custom data to CSV
<?php
/**
* Export Data to CSV file
* Could be used in WordPress plugin or theme
*/
// A sample link to Download CSV, could be placed somewhere in plugin settings page
?>
<a href="<?php echo admin_url( 'admin.php?page=myplugin-settings-page' ) ?>&action=download_csv&_wpnonce=<?php echo wp_create_nonce( 'download_csv' )?>" class="page-title-action"><?php _e('Export to CSV','my-plugin-slug');?></a>
@bryanrsebastian
bryanrsebastian / Auto height element
Last active September 13, 2018 01:22
Make the height of all elements with the selected class becomes automatic depends on the maximum height.
jQuery( function( $ ) {
if( $( window ).width() > 750 ) {
autoHeight( '.__your_class' );
} else {
$( '.__your_class' ).height( 'auto' );
}
$( window ).resize( function() {
if( $( window ).width() > 750 ) {
autoHeight( '.__your_class' );
@bryanrsebastian
bryanrsebastian / Wordpress Pagination with "First" and "Last"
Last active September 22, 2018 03:38
This snippets is compatible even there is a year and month in the url.
/**
* Add first and last button to the
* default pagination of wordpress
*
* Note: Don't forget to initialize your default
* query to limit your post in pre_get_post hook
*
* @var string $post_type name of your post type
* @var int $total_post number of total post to get the number of pagination
* @return void pagination
@bryanrsebastian
bryanrsebastian / Sticky header js
Created June 8, 2018 02:11
Add class to header to design it and to become sticky
$( window ).scroll( function() {
if ( $(window).scrollTop() <= 50 ) {
$( 'header' ).removeClass( 'sticky' );
} else {
$( 'header' ).addClass( 'sticky' );
}
} );
easyweb-italia
4764fbb159e067e22458285444e844c313f26d6d