Skip to content

Instantly share code, notes, and snippets.

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@BODA82
BODA82 / functions.php
Last active July 15, 2020 17:42
Custom WordPress Login Page
<?php
/********************************************************************************************
Example for customizing the WordPress login screen using your theme's functions.php file.
For @halo-diehard on wordpress.org forum:
https://wordpress.org/support/topic/codex-unclear-regarding-custom-login-page/
Relevant CODEX doc:
https://codex.wordpress.org/Customizing_the_Login_Form
*******************************************************************************************/
@BODA82
BODA82 / multiformat-wp-api-response.php
Created August 8, 2018 04:10 — forked from petenelson/multiformat-wp-api-response.php
WordPress: Example of returning non-JSON results from the WP-API
<?php
// reference https://github.com/WP-API/WP-API/blob/develop/lib/infrastructure/class-wp-rest-server.php
// serve_request() function
add_filter( 'rest_pre_serve_request', 'multiformat_rest_pre_serve_request', 10, 4 );
function multiformat_rest_pre_serve_request( $served, $result, $request, $server ) {
// assumes 'format' was passed into the intial API route
// example: https://baconipsum.com/wp-json/baconipsum/test-response?format=text
@BODA82
BODA82 / acf-change-file-upload-directory.php
Created October 24, 2016 23:42
Change the upload directory of Advanced Custom Fields file upload field.
<?php
// ACF upload prefilter
function gist_acf_upload_dir_prefilter($errors, $file, $field) {
// Only allow editors and admins, change capability as you see fit
if( !current_user_can('edit_pages') ) {
$errors[] = 'Only Editors and Administrators may upload attachments';
}
// This filter changes directory just for item being uploaded
@BODA82
BODA82 / wp-custom-post-type.php
Created October 24, 2016 23:30
Register WordPress Custom Post Type
<?php
if (! function_exists('gist_register_cpt')) {
/**
* Register Custom Post Type
*/
function gist_register_cpt() {
// Set CPT labels
$labels = array(
@BODA82
BODA82 / wp-custom-post-type-as-submenu-item.php
Last active May 19, 2023 06:06
Add WordPress custom post type as submenu item of existing admin menu.
<?php
if (! function_exists('gist_register_cpt')) {
/**
* Register Custom Post Type
*/
function gist_register_cpt() {
// Set CPT labels
$labels = array(
@BODA82
BODA82 / .gitignore
Created October 15, 2015 03:38 — forked from salcode/.gitignore
WordPress .gitignore - this is my preferred gitignore file when working with WordPress. It ignores almost all files by default.
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20150227
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
@BODA82
BODA82 / .gitignore
Created October 15, 2015 03:13 — forked from redoPop/.gitignore
Template .gitignore file for WordPress projects
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your