Skip to content

Instantly share code, notes, and snippets.

@salcode
salcode / test-add-query-arg-output.php
Created December 9, 2014 03:24
mu-plugin file that replaces the content of a page with an example demonstrating add_query_arg() does not urlencode parameters.
<?php
add_action( 'the_content', 'test_add_query_arg_output' );
function test_add_query_arg_output( $content ) {
return add_query_arg(
array(
'var_key' => 'key_value',
'another_var' => 'My Value'
),
home_url()
@salcode
salcode / .gitignore
Last active April 3, 2024 18:38
Please see https://salferrarello.com/wordpress-gitignore/ for the canonical version of this WordPress .gitignore file. Note: I do not receive notifications for comments here (because GitHub does not send notifications on Gists)
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20180808
#
# 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.
How to use
[button link='http://linktosomething.com' color='orange']My Button Text![/button]
@salcode
salcode / composer.json
Created April 22, 2015 18:25
I'd prefer not to define a version (in this case 0.1.1) in the Hash-Link-Scroll-Offset WordPress plugin package, since I always want the latest version from the master branch. Is there a better way to setup this WordPress Plugin that lives on GitHub in my composer.json file?
{
"repositories":[
{
"type":"composer",
"url":"http://wpackagist.org"
},
{
"type": "package",
"package": {
"name": "WebDevStudios/Hash-Link-Scroll-Offset",
@salcode
salcode / composer.json
Created April 22, 2015 19:42
Throws the error [Composer\Repository\InvalidRepositoryException] No valid composer.json was found in any branch or tag of https://github.com/WebDevStudios/Hash-Link-Scroll-Offset, could not load a package from it.
{
"repositories":[
{
"type":"composer",
"url":"http://wpackagist.org"
},
{
"type": "vcs",
"url": "https://github.com/WebDevStudios/Hash-Link-Scroll-Offset"
}
@salcode
salcode / composer.json
Created April 23, 2015 02:07
Attempting to use branch name in place of version. Error: "Your requirements could not be resolved to an installable set of packages. Problem 1 - The requested package webdevstudios/hash-link-scroll-offset could not be found in any version, there may be a typo in the package name. Potential causes: - A typo in the package name - The package is n…
{
"repositories":[
{
"type":"composer",
"url":"http://wpackagist.org"
},
{
"type": "package",
"package": {
"name": "WebDevStudios/Hash-Link-Scroll-Offset",
@salcode
salcode / fe-disable-comments-until-4.2.1.php
Last active August 29, 2015 14:20
Disable comments on WordPress website until the WordPress version is greater than 4.2.
<?php
global $wp_version;
if ( version_compare( $wp_version, '4.2', '<=' ) ) {
add_filter( 'comments_open', '__return_false' );
}
@salcode
salcode / install-composer.sh
Created June 11, 2015 13:28
composer command line install
curl -sS https://getcomposer.org/installer | php;\
mkdir -p /usr/local/bin;\
mv composer.phar /usr/local/bin/composer
@salcode
salcode / deltadb.php
Last active August 29, 2015 14:23
#wcphilly contributors #unittests
<?php
/**
* Test dbDelta()
*
* @group upgrade
* @group dbdelta
*/
class Tests_dbDelta extends WP_UnitTestCase {
@salcode
salcode / genesis-last-updated-post-info.php
Created July 4, 2015 16:18
Update Genesis Post Info with Last Updated date in place of Publish Date. This code can be added to the end of functions.php or you can create this file genesis-last-updated-post-info.php in wp-content/mu-plugins/
// filter post_info to use 'Last updated' date
add_filter( 'genesis_post_info', 'fe_genesis_post_info_add_last_mod' );
/**
* Change Genesis Post Info date to last modified date
*
* @since 0.1.0
*
* @param string $post_info, string (with shortcodes) for post info
* @return string Genesis default post info with modified instead of publish date