Skip to content

Instantly share code, notes, and snippets.

View carstingaxion's full-sized avatar

Carsten Bach carstingaxion

View GitHub Profile
@carstingaxion
carstingaxion / check_fastcgi.php
Created January 5, 2023 23:12
Check for support of fastcgi_finish_request()
<?php
$file = __DIR__ . '/text.txt';
if (is_file($file) && is_writable($file)) {
@unlink($file);
echo '<small style="color: #ccc;">' . $file . ' was deleted.</small><br>' . PHP_EOL;
}
echo '<p>Calling to <code>fastcgi_finish_request()</code>.</p>' . PHP_EOL;
@carstingaxion
carstingaxion / cbstdsys_add-icon-classes-to-post-classes-obj.php
Created May 15, 2014 11:57
Add CSS icon classes to post-class object by post_type and post-format
function cbstdsys_add_icon_classes_by_post_type_and_format( $classes ) {
global $post;
switch ( $post->post_type ) {
case 'post' :
if ( is_sticky( $post->ID ) ) {
$classes[] = 'icon-alert';
return $classes;
}
@carstingaxion
carstingaxion / cbstdsys_sw_social-stuff-for-functions.php
Created May 12, 2014 21:24
Social (Mailchimp) related defaults for functions.php
/** SOCIAL - by Mailchimp **/
// Disable default CSS and JS for the Social plugin
define('SOCIAL_COMMENTS_CSS', false);
define('SOCIAL_COMMENTS_JS', false);
// Define custom comments file for Social plugin
define('SOCIAL_COMMENTS_FILE', get_stylesheet_directory().'/social-comments.php');
@carstingaxion
carstingaxion / cbstdsys_sw_wpml-stuff-for-functions.php
Created May 12, 2014 21:22
WPML related defaults for functions.php
/** WPML - Sitepress Multilingual CMS **/
global $sitepress;
// remove language switcher, 'cause it messes with the WP backend styles
remove_action('in_admin_header', array($sitepress, 'admin_language_switcher'));
// remove meta-generator tag
remove_action('wp_head', array($sitepress, 'meta_generator_tag'));
// WPML sitepress-multilingual-cms
define( 'ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS' , true);
@carstingaxion
carstingaxion / form.php
Created October 10, 2012 15:57
form.php Improvements for "Content Widget" Plugin
// Block direct requests
defined( 'ABSPATH' ) or die( '-1' );
?>
<p>
<label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Type:'); ?></label>
<select class="contentwidget_post_type widefat" id="<?php echo $this->get_field_id('post_type'); ?>" name="<?php echo $this->get_field_name('post_type'); ?>">
<?php
$post_types = get_post_types( array( 'public' => true ), 'object' );
// Do not list any attachements
unset( $post_types['attachment'] );
@carstingaxion
carstingaxion / git-wordpress.workflow.sh
Created September 23, 2012 12:47 — forked from dongilbert/git-wordpress.txt
From WordPress SVN to GitHub and back to SVN
### Using Git with WordPress Plugin Development ###
# receive revision-number from WordPress Repository
svn log -r 1:HEAD --limit 1 http://plugins.svn.wordpress.org/your-plug-in-name
# clone to local folder
git svn clone -s -r<rev-number> --no-minimize-url https://plugins.svn.wordpress.org/<plugin-path>
# change to directory
cd <plugin-path>
@carstingaxion
carstingaxion / gist:3070690
Created July 8, 2012 12:21
Countdown Shortcode for WordPress
<?php
function countdown_shortcode ( $atts ) {
extract( shortcode_atts( array(
'date' => '',
), $atts ) );
if ( !isset($date) )
return false;
return '<span class="countdown">'.floor( ( strtotime( $date ) - time() )/60/60/24 ).'</span>';
@carstingaxion
carstingaxion / ee2wp.export.xml
Created July 8, 2012 12:05
ExpressionEngine to WordPress Export Template
<?xml version="1.0" encoding="UTF-8" ?>
<!-- To import this information into a WordPress site follow these steps: -->
<!--RUN THIS FILE IN FIREFOX OR IE-->
<!--VIEW PAGE SOURCE-->
<!--COPY-PASTE PAGE SOURCE INTO TEXT EDITOR AND SAVE AS .WXR FILE-->
<!--REMOVE "?'s" FROM XML VERSION AT TOP OF THIS PAGE-->
<!--COMMENT OUT LINE 1309, 1310, 1311 IN wp-includes/kses.php -->
<!--THEN FOLLOW THE STEPS BELOW-->