Skip to content

Instantly share code, notes, and snippets.

Avatar
👋
AFK

Patrick Groot pgroot91

👋
AFK
View GitHub Profile
View ajax-action.php
add_action( 'wp_ajax_nopriv_ajax_pagination', 'my_ajax_pagination' );
add_action( 'wp_ajax_ajax_pagination', 'my_ajax_pagination' );
function my_ajax_pagination() {
echo get_bloginfo( 'title' );
die();
}
View image-upload-field-custom-taxonomy
<?php
/* Add Image Upload to Series Taxonomy */
// Add Upload fields to "Add New Taxonomy" form
function add_series_image_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="series_image"><?php _e( 'Series Image:', 'journey' ); ?></label>
View image-upload-field-custom-taxonomy
<?php
/* Add Image Upload to Series Taxonomy */
// Add Upload fields to "Add New Taxonomy" form
function add_series_image_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="series_image"><?php _e( 'Series Image:', 'journey' ); ?></label>
@pgroot91
pgroot91 / api.php
Created Dec 30, 2020 — forked from pixelbrackets/api.php
Simple PHP script to test and use cURL
View api.php
<?php
/**
* Simple request response script
*
* Point you cURL request to this script to see all incoming data
*/
echo '*API*'. PHP_EOL;
@pgroot91
pgroot91 / gist:1e241aa3de3053218cd2b3245ede7036
Created May 14, 2020 — forked from urre/gist:846b89237da760839b3d
Get network wide recent posts from a WordPress Multisite (1 post from every blog except main site), order by date and only show author once (unique authors). Used on http://vertikals.se/
View gist:1e241aa3de3053218cd2b3245ede7036
<?php
// Get all blog ids in network except main site (id 1)
$blogs = $wpdb->get_results("
SELECT blog_id
FROM {$wpdb->blogs}
WHERE site_id = '{$wpdb->siteid}'
AND spam = '0'
AND deleted = '0'
AND archived = '0'
@pgroot91
pgroot91 / gist:fa5439ea0790f8fec42136ffbc06b68d
Created May 14, 2020 — forked from urre/gist:846b89237da760839b3d
Get network wide recent posts from a WordPress Multisite (1 post from every blog except main site), order by date and only show author once (unique authors). Used on http://vertikals.se/
View gist:fa5439ea0790f8fec42136ffbc06b68d
<?php
// Get all blog ids in network except main site (id 1)
$blogs = $wpdb->get_results("
SELECT blog_id
FROM {$wpdb->blogs}
WHERE site_id = '{$wpdb->siteid}'
AND spam = '0'
AND deleted = '0'
AND archived = '0'
@pgroot91
pgroot91 / gist:893ecd4fd9b8ed90043a496e85d46cec
Created May 5, 2020 — forked from tripflex/gist:ccd02279117faaf365f9
Convert WordPress date format to jQuery UI DatePicker format
View gist:893ecd4fd9b8ed90043a496e85d46cec
if( ! function_exists( 'wp_date_format_php_to_js') ){
/**
* Convert a date format to a jQuery UI DatePicker format
*
* @param string $dateFormat a date format
*
* @return string
*/
function wp_date_format_php_to_js( $dateFormat ) {
@pgroot91
pgroot91 / ExampleUsage.php
Created Apr 24, 2020 — forked from jonathonbyrdziak/ExampleUsage.php
A Wordpress class that allows you to place watermarks on your images.
View ExampleUsage.php
<?php
/**
* The constants defined here are used as a fallback to whatever options you
* end up specifying specifically.
*
* @var constant string
*/
define('WATERMARK_SOURCE', ABSPATH.'/wp-content/themes/mytheme/images/fb_thumb_watermark.png');
define('WATERMARK_ORIENTATION', 'bottom right');
@pgroot91
pgroot91 / color-scheme-preview.js
Created Feb 11, 2020 — forked from digvijayad/color-scheme-preview.js
How to add Color Schemes to your WordPress theme with live preview: full working sample
View color-scheme-preview.js
(function($) {
var style = $('#yourtheme-color-scheme-css'),
api = wp.customize;
if (!style.length) {
style = $('head').append('<style type="text/css" id="yourtheme-color-scheme-css" />')
.find('#yourtheme-color-scheme-css');
}
// Color Scheme CSS.
api.bind('preview-ready', function() {
View wordpress-passwort-reset-unmultisite.php
<?php
/**
* Plugin Name: Multisite: Passwort Reset on Local Blog
* Plugin URI: https://gist.github.com/eteubert/293e07a49f56f300ddbb
* Description: By default, WordPress Multisite uses the main blog for passwort resets. This plugin enables users to stay in their blog during the whole reset process.
* Version: 1.0.0
* Author: Eric Teubert
* Author URI: http://ericteubert.de
* License: MIT
*/