Skip to content

Instantly share code, notes, and snippets.

View flowdee's full-sized avatar

flowdee flowdee

View GitHub Profile
@flowdee
flowdee / generatePassword.php
Last active December 31, 2015 03:09
PHP Funktion zur automatischen Generierung von Passwörter die Großbuchstaben, Kleinbuchstaben, Zahlen und Sonderzeichen beinhalten. Beim Aufruf der Funktion geben wir zeitgleich die Anzahl der Zeichen mit, die unser erstelltes Passwort haben soll. Diese Funktion ist Teil einer Artikel-Serie: http://bitweise.net/php/sichere-passwoerter-mit-php-er…
<?php
function generatePassword($length) {
// Festlegung der zu verwendenden Buchstaben, Zahlen und Sonderzeichen
$specialchars = array('!','@','#','$','%','*','+','=','?');
$chars = array_merge(range('a','z'), range('A','Z'), range(0,9), $specialchars);
// Einzelne Buchstaben oder Zahlen entfernen
unset($chars[array_search('A', $chars)]);
unset($chars[array_search('b', $chars)]);
@flowdee
flowdee / functions.php
Last active August 29, 2015 13:57
Removes the closing bracket at the end of WordPress' oEmbed using YouTube.
<?php
function remove_youtube_parenthesis ($html, $url ) {
if ( preg_match('#https?://(www\.)?youtu#i', $url) ) {
$html = preg_replace('/\)$/', '', $html);
}
return $html;
}
@flowdee
flowdee / functions.php
Created March 31, 2014 12:07
Remove & hide WP Admin Access / Bar
// Remove dashboard access for normal users
if (!current_user_can('manage_options')) {
add_filter('show_admin_bar', '__return_false');
}
add_action('admin_init', function () {
if (!current_user_can('manage_options') && $_SERVER['DOING_AJAX'] != '/wp-admin/admin-ajax.php') {
wp_redirect(home_url()); exit;
}
});
@flowdee
flowdee / isotope-lazyload.js
Created December 28, 2014 11:24
Isotope sorting& filtering enhancements for Unveil Lazy Load: Add this three lines to refresh lazy load items and display them after sorting / filtering.
var $iso = $('.container').isotope({
itemSelector: '.item',
layoutMode: 'masonry',
});
// Refresh lazy load
$iso.isotope('on', 'layoutComplete', function () {
$(window).trigger("scroll");
});
@flowdee
flowdee / Blueposts (Standard)
Created January 30, 2015 14:59
Blueposts for WordPress (Standard)
[bluepost]
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
[/bluepost]
@flowdee
flowdee / Blueposts (including title & link)
Created January 30, 2015 14:59
Blueposts for WordPress (including title & link)
@flowdee
flowdee / Blueposts (including title)
Created January 30, 2015 15:00
Blueposts for WordPress (including title)
[bluepost title="Lorem ipsum dolor sit"]
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
[/bluepost]
@flowdee
flowdee / wordpress-base-custom-data.php
Created May 11, 2017 20:44 — forked from paulund/wordpress-base-custom-data.php
A PHP class to handle CRUD functionality in WordPress default tables.
<?php
/**
* Abstract class which has helper functions to get data from the database
*/
abstract class Base_Custom_Data
{
/**
* The current table name
*
* @var boolean
@flowdee
flowdee / edd-sl.php
Created May 21, 2017 08:37
EDD License upgrade: Extend expiration
/**
* License upgrade: Extend expiration
*/
add_action('edd_sl_license_upgraded', function( $license_id, $args ) {
$license = edd_software_licensing()->get_license( $license_id );
$download_id =$license->download->id;
$download = new EDD_SL_Download( $download_id );
$download_exp_length = $download->get_expiration_length();
@flowdee
flowdee / ajax.php
Created March 2, 2019 08:26
Admin Ajax Example
<?php
/**
* AJAX actions
*
* @since 1.0.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;