Skip to content

Instantly share code, notes, and snippets.

View benjaminpick's full-sized avatar

Benjamin Pick benjaminpick

  • Siegen, Germany
View GitHub Profile
@benjaminpick
benjaminpick / yt_wpml_sitepress.php
Last active December 28, 2015 04:59
Wordpress WPML: Change Fallback language of posts to English. You still need to activate in the options, see http://wpml.org/2009/11/language-fallback-for-blog-posts/
<?php
/*
Plugin Name: YT WPML Sitepress Fallback
Plugin URI: http://www.yellowtree.de
Description: YT WPML Sitepress Posts from English instead of german
Author: YellowTree (Benjamin Pick)
Author URI: http://www.yellowtree.de
Version: 1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@benjaminpick
benjaminpick / yt_acf_has_capability.php
Last active November 5, 2015 11:29
ACF 5: Show a field group only if the user that is logged in can do a certain wordpress cap.
<?php
/*
Plugin Name: YT ACF Field Group Location Has Capability
Description: Show a field group only if the user that is logged in can do a certain wordpress cap.
Version: 0.1
Author: YellowTree (Benjamin Pick)
Author URI: http://yellowtree.de
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
@benjaminpick
benjaminpick / spring-news.php
Created February 26, 2015 10:44
This is a simple wordpress plugin to show the news on the home page as a shortcode.
<?php
/*
Plugin Name: Spring News Shortcode
Description: Provides a shortcode [spring_news col="4" nb="8"].
Author: Benjamin Pick
Version: 0.1
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
@benjaminpick
benjaminpick / functions.php
Last active August 29, 2015 14:24
Integrate Clear Cache for Me with Autoptimize
<?php
function yt_cache_enable($return) {
if (class_exists('autoptimizeCache'))
return true;
return $return;
}
add_filter('ccfm_supported_caching_exists', 'yt_cache_enable');
function yt_cache_clear() {
@benjaminpick
benjaminpick / functions.php
Last active August 29, 2015 14:24
Allow clearing the cache by calling an URL. This can be useful for automatic deployment.
<?php
if (!defined('CLEAR_CACHE_HOOK_KEY'))
define('CLEAR_CACHE_HOOK_KEY', 'some_secret_key_please');
function yt_cache_clear_web_hook() {
if (isset($_GET['key']) && $_GET['key'] == CLEAR_CACHE_HOOK_KEY) {
if (function_exists('ccfm_clear_cache_for_me')) {
ccfm_clear_cache_for_me( 'ajax' );
echo 'Cache was cleared.';
} else {
@benjaminpick
benjaminpick / basic.less
Created August 28, 2015 07:43
Break words if really necessary. Useful for big headlines etc.
.break-words() {
-webkit-hyphens: auto;
-moz-hyphens: auto;
-ms-hyphens: auto;
hyphens: auto;
word-wrap: break-word;
word-break: break-word;
}
@benjaminpick
benjaminpick / yt_show_acf_image.php
Last active September 3, 2015 12:04
Show an ACF image object Helper Function
<?php
function yt_show_acf_image($img, $opt = array()) {
if (!$img)
return;
$opt_default = array(
'size' => 'xl',
'echo' => true,
'attr' => array(),
@benjaminpick
benjaminpick / wpcf7_special_mail_tag.php
Last active September 8, 2015 06:44
Contact Form 7: Special Mail Tag for POST data
<?php
/**
* Verwendung: Im Email-Template können nun auch POST-Daten versendet werden, die nicht über einen WPCF7-Shortcode, sondern über HTML im Formular eingefügt wurden.
* <input type="date" name="special" />
* [post_special]
*/
add_filter('wpcf7_special_mail_tags', 'yt_wpcf7_mail_tags', 10, 3);
function yt_wpcf7_mail_tags($output, $tagname, $is_html) {
@benjaminpick
benjaminpick / page.php
Created October 5, 2015 08:22
Preferential Lite Fix for left sidebar (drop this file in your child theme)
<?php
/**
* The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @package Preferential
@benjaminpick
benjaminpick / SendMailService.php
Last active March 16, 2017 14:55
Powermail Extension: Embed images from template into the HTML email (e.g. for images in the email footer)
<?php
namespace In2code\Powermailextended\Domain\Service;
use In2code\Powermail\Domain\Model\Mail;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use In2code\Powermail\Domain\Service\SendMailService as SendMailServicePowermail;
/**
* SendMailService