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 / frontend.js
Created November 15, 2021 11:03
Beaver Builder: Stop Videos when they are outside of the visible viewport
// By default, videos continue to run even when not visible. This is using unnecessary CPU ressources.
jQuery.fn.isInViewport = function () {
var elementTop = jQuery(this).offset().top;
var elementBottom = elementTop + jQuery(this).outerHeight();
var viewportTop = jQuery(window).scrollTop();
var viewportBottom = viewportTop + jQuery(window).height();
return elementBottom > viewportTop && elementTop < viewportBottom;
@benjaminpick
benjaminpick / Login.php
Last active September 10, 2019 10:38
Instagram Test
<?php
namespace Instagram\Auth;
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Exception\ClientException;
use Instagram\Exception\InstagramAuthException;
use Instagram\Exception\InstagramException;
use Instagram\Transport\TransportFeed;
@benjaminpick
benjaminpick / functions.php
Created June 25, 2019 05:21
Show Bootstap Breakpoint in Admin Bar
<?php
add_action('admin_bar_menu', function ($admin_bar) {
if (!is_admin() && WP_DEBUG) $admin_bar->add_menu([
'id' => 'my-item',
'title' => 'Breakpoint: ' .
'<strong class="d-sm-none">XS</strong>' .
'<strong class="d-none d-sm-inline d-md-none">SM</strong>' .
'<strong class="d-none d-md-inline d-lg-none">MD</strong>' .
'<strong class="d-none d-lg-inline d-xl-none">LG</strong>' .
'<strong class="d-none d-xl-inline">XL</strong>'
@benjaminpick
benjaminpick / camel_case.php
Last active April 11, 2019 18:46
CamelCase
<?php
function underscoreToCamelCase($string)
{
$str = str_replace(' ', '', ucwords(str_replace('_', ' ', $string)));
$str = lcfirst($str);
return $str;
}
@benjaminpick
benjaminpick / SendMailService.php
Last active March 18, 2019 19:22
Abort sending Email
<?php
namespace In2code\Powermailextended\Domain\Service;
use In2code\Powermail\Domain\Service\Mail\SendMailService as SendMailServicePowermail;
class SendMailService {
public function manipulateMail($message, &$email, SendMailServicePowermail $sendMailService) {
if ($email['template'] == 'Mail/OptinMail' && $email['subject'] == 'subject line') {
// Never send such Optin mails ...
@benjaminpick
benjaminpick / FrontendUriBuilderUtility.php
Last active January 13, 2021 14:17
Creating Frontend URLs in Typo3 without URIBuilder
<?php
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class FrontendUriBuilder for creating a frontend link in the backend
* @package PDVSysteme\Pdvsupportbase\Util
* @see https://stackoverflow.com/questions/33751570/typo3-with-extbase-uribuilder-or-something-similar-in-backend-hook
* @license Public Domain
*/
@benjaminpick
benjaminpick / docker-compose.yml
Created March 28, 2017 17:20
PHP / MySQL combo
server:
mem_limit: 301m
image: webgriffe/docker-php-apache-base:latest
links:
- wordpress_db
ports:
- "80:80"
volumes:
- .:/var/www/html
environment:
@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
@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 / 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) {