Skip to content

Instantly share code, notes, and snippets.

View webgurus's full-sized avatar
🏠
Working from home

Gergely Márton webgurus

🏠
Working from home
View GitHub Profile
@webgurus
webgurus / custom_post_type search
Created November 17, 2012 22:45
search only custom post types in wordpress
add_filter( 'pre_get_posts', 'cpt_search' );
/**
* tgm_cpt_search function.
*
* This function modifies the main WordPress query to include an array of post types instead of the default 'post' post type.
*
* @param mixed $query The original query
* @return $query The amended query
*
*/
/*
Allows for ajax requests to be run synchronously in a queue
Usage::
var queue = new $.AjaxQueue();
queue.add({
url: 'url',
This file has been truncated, but you can view the full file.
'use strict';
var COMPILED = !0, goog = goog || {};
goog.global = this;
goog.DEBUG = !1;
goog.LOCALE = "en";
goog.provide = function (a) {
if (!COMPILED) {
if (goog.isProvided_(a))
throw Error('Namespace "' + a + '" already declared.');
delete goog.implicitNamespaces_[a];
@webgurus
webgurus / remove_admin_bar
Created May 13, 2013 12:27
Remove admin bar WordPress
add_filter('show_admin_bar', '__return_false');
/* Remove admin bar style - top padding - Front-end */
function remove_admin_bar_style_frontend() {
echo '<style type="text/css" media="screen">
html { margin-top: 0px !important; }
* html body { margin-top: 0px !important; }
</style>';
}
@webgurus
webgurus / acf_slider_bootstrap
Last active September 7, 2020 10:39
Root's bootstrap slider example with Advanced Custom Fields Gallery plugin.
<?php
/* SLIDER CUSTOM FIELD FOR HOMEPAGE */
$images = get_field('slider_photos');
$count=0;
$count1=0;
if($images) : ?>
<div id="slider">
<div id="carousel" class="carousel slide">
<!-- Indicators -->
<?php
/* place in theme's functions.php file */
/* disable json api if api key not correct */
add_action('init','json_api_apikey_check' , 1 );
function json_api_apikey_check()
{
$api_key = 'hello';
$base = get_option('json_api_base', 'api');
$this_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
@webgurus
webgurus / acf_save_custom_user_fields.php
Created July 29, 2014 17:11
Theme function to save custom profile fields created with Advanced Custom fields
// SAVE ACF FIELDS
add_action( 'personal_options_update', 'save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_profile_fields' );
function save_extra_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
update_usermeta($user_id, 'user_partner_name', ( isset($_POST['user_partner_name']) ? $_POST['user_partner_name'] : '' ) );
@webgurus
webgurus / nav_custom_post_type_highlight.php
Last active August 29, 2015 14:04
Fix Roots Nav menu walker to add active class to custom post types
/**
* Fix wp_nav_menu's active item highlighting with custom post types
*/
function roots_cpt_active_menu($menu) {
$post_type = get_post_type();
switch($post_type) {
case 'post':
$menu = str_replace('active', '', $menu);
$menu = str_replace('menu-news', 'menu-news active', $menu);
<?php
/**
* Hides the 'view' button in the post edit page
*
*/
function hv_hide_view_button() {
$current_screen = get_current_screen();
@webgurus
webgurus / woo_hide_standard_when_free_available.php
Last active August 29, 2015 14:05
WooCommerce - hide standard shipping option when free is available
<?php
/**
* Hide Standard Shipping option when free shipping is available
*
* @param array $available_methods
*/
function hide_standard_shipping_when_free_is_available( $available_methods ) {
if( isset( $available_methods['free_shipping'] ) AND isset( $available_methods['flat_rate'] ) ) {