Skip to content

Instantly share code, notes, and snippets.

View ControlledChaos's full-sized avatar

Controlled Chaos Design ControlledChaos

View GitHub Profile
/**
* Load custom post type archive on home page
*
* Reference: http://www.wpaustralia.org/wordpress-forums/topic/pre_get_posts-and-is_front_page/
* Reference: http://wordpress.stackexchange.com/questions/30851/how-to-use-a-custom-post-type-archive-as-front-page
*/
function prefix_downloads_front_page( $query ) {
// Only filter the main query on the front-end
if ( is_admin() || ! $query->is_main_query() ) {
<?php
/*
* 1. Go to Settings > Permalinks and select any page as home page
* Then use the following code
*
* You can add those codes in your functions.php in the theme, if you think your theme won’t be changed.
* Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'.
* If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that,
* give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins,
* so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.
@ControlledChaos
ControlledChaos / custom_menu_admin.php
Created December 6, 2018 18:36 — forked from carlodaniele/custom_menu_admin.php
A basic plugin showing how to add menu metaboxes to admin menu page
<?php
/**
* @package Custom_menu_admin
* @version 1.0
*/
/*
Plugin Name: Custom menu admin
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele

Embed a Vimeo Video as a Background

HTML/API Snippet

@ControlledChaos
ControlledChaos / auto-dark-mode.php
Created November 23, 2018 17:18
Lets you enable Dark Mode automatically between certain times. Requires Dark Mode plugin version 2.0 or later. https://github.com/danieltj27/Dark-Mode/wiki/Help:-Automatically-turning-Dark-Mode-on-or-off
<?php
/**
* Plugin Name: Automatic Dark Mode
* Plugin URI: https://github.com/danieltj27/Dark-Mode/
* Description: Lets your users make the WordPress admin dashboard darker.
* Author: Daniel James
* Author URI: https://www.danieltj.co.uk/
* Text Domain: auto-dark-mode
* Version: 1.0
@ControlledChaos
ControlledChaos / README.md
Last active October 30, 2018 17:28
Set Advanced Custom Fields metabox priority.

Set Advanced Custom Fields Metabox Priority

WordPress & ACF Snippet

Create Admin Account via FTP

WordPress Snippet

If you have FTP access to a client's website but they didn't give you an administrator account then this snippet in a plugin, or in file in their ~/wp-content/mu-plugins/ folder, will generate an account for you. Change the login info to yours.

Using Git to Manage a Live Web Site

Overview

As a freelancer, I build a lot of web sites. That's a lot of code changes to track. Thankfully, a Git-enabled workflow with proper branching makes short work of project tracking. I can easily see development features in branches as well as a snapshot of the sites' production code. A nice addition to that workflow is that ability to use Git to push updates to any of the various sites I work on while committing changes.

Contents

@ControlledChaos
ControlledChaos / grab_vimeo_thumbnail.php
Created October 11, 2018 18:46 — forked from bacoords/grab_vimeo_thumbnail.php
Grab a thumbnail of a private (but embeddable) Vimeo video
<?php
/**
* Grab the url of a publicly embeddable video hosted on vimeo
* @param str $video_url The "embed" url of a video
* @return str The url of the thumbnail, or false if there's an error
*/
function grab_vimeo_thumbnail($vimeo_url){
if( !$vimeo_url ) return false;
$data = json_decode( file_get_contents( 'http://vimeo.com/api/oembed.json?url=' . $vimeo_url ) );
@ControlledChaos
ControlledChaos / php-vimeo-video-thumbnail-url.php
Created October 11, 2018 18:43 — forked from anjan011/php-vimeo-video-thumbnail-url.php
php - get vimeo video thumbnail image url
<?php
/**
* Gets the thumbnail url for a vimeo video using the video id. This only works for public videos.
*
* @param string $id The video id.
* @param string $thumbType Thumbnail image size. supported sizes: small, medium (default) and large.
*
* @return string|bool