Skip to content

Instantly share code, notes, and snippets.

@pgroot91
pgroot91 / function.php
Created August 13, 2021 10:26 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@pgroot91
pgroot91 / ajax-action.php
Created April 17, 2021 14:02 — forked from danielpataki/ajax-action.php
Twenty Fifteen AJAX
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();
}
@pgroot91
pgroot91 / image-upload-field-custom-taxonomy
Created January 2, 2021 11:17 — forked from gagimilicevic/image-upload-field-custom-taxonomy
Add Image Upload Field to 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 / image-upload-field-custom-taxonomy
Created January 2, 2021 11:15 — forked from mathetos/image-upload-field-custom-taxonomy
Add Image Upload Field to 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 December 30, 2020 11:17 — forked from pixelbrackets/api.php
Simple PHP script to test and use cURL
<?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 20:39 — 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/
<?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 20:39 — 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/
<?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 13:54 — forked from tripflex/gist:ccd02279117faaf365f9
Convert WordPress date format to jQuery UI DatePicker format
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 April 24, 2020 14:36 — forked from jonathonbyrdziak/ExampleUsage.php
A Wordpress class that allows you to place watermarks on your images.
<?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 February 11, 2020 23:07 — forked from digvijayad/color-scheme-preview.js
How to add Color Schemes to your WordPress theme with live preview: full working sample
(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() {