Skip to content

Instantly share code, notes, and snippets.

View barrykooij's full-sized avatar
:shipit:
I may be slow to respond.

Barry Kooij barrykooij

:shipit:
I may be slow to respond.
View GitHub Profile
@barrykooij
barrykooij / rp4wp-disable-css.php
Created December 4, 2014 10:36
Related Posts for WordPress Premium - Disable CSS
add_filter( 'rp4wp_disable_css', '__return_true' );
<?php
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, "example.com" );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
$output = curl_exec( $ch );
curl_close( $ch );
var_dump( $output );
define('WP_DEBUG', true);
if ( WP_DEBUG ) {
/**
* Turn on error logging and show errors on-screen if in debugging mode
*/
@error_reporting( E_ALL );
@ini_set( 'log_errors', true );
@ini_set( 'log_errors_max_len', '0' );
<?php
for ( $i = 1; $i < 13; $i ++ ) {
$N = date( 'N', strtotime( '01-' . $i . '-2015' ) );
$d=1;
if ( $N > 1 ) {
$d = ( 7 - $N ) + 2;
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@barrykooij
barrykooij / CHANGELOG.md
Created November 26, 2014 13:50
CHANGELOG.md

1.2.3: November 25, 2014

  • Added related post id as second argument to 'rp4wp_post_excerpt' filter.
  • Only run upgrade script if there are posts to upgrade.
<?php
// The changelog path
$changelog_path = '/var/www/rp4wp/wp-content/plugins/related-posts-for-wp-premium/CHANGELOG.md';
// Format the changelog from .md to HTML
$changelog = file_get_contents( $changelog_path );
$changelog = preg_replace( "/###[ ]?([0-9\.]+): ([A-Z0-9 ,]+)/i", "<h3>$1</h3>" . PHP_EOL . "<i>$2</i>" . PHP_EOL . "<ul>", $changelog );
$changelog = preg_replace( "/\* ([A-Z0-9 \._,'\(\)\/\-&\"\']+)/i", "<li>$1</li>", $changelog );
$changelog = preg_replace( "/" . PHP_EOL . "<h3>/i", "</ul>" . PHP_EOL . PHP_EOL . "<h3>", $changelog );
<?php
/**
* This works
*/
add_option( 'verykey', 'wow' ); // Stored with key 'verykey'
echo get_option( 'verykey', '' ); // Outputs 'wow'
/**
<?php
if ( true == $result ) {
// Do something
}
<?php
$shout = ( 'WordPress' === $cms ) ? 'Woo!' : 'Boo!';