Skip to content

Instantly share code, notes, and snippets.

View pixelbart's full-sized avatar
👋
Hi

Kevin Pliester pixelbart

👋
Hi
View GitHub Profile
@pixelbart
pixelbart / functions.php
Last active January 28, 2016 07:08
Wortzähler
<?php
/**
* Ein simpler Wortzähler für deine Website
* Ausgabe: <p><?php echo word_counter(); ?></p>
*/
function word_counter() {
return sprintf(
__( '%s Wörter', 'Textdomain' ), // Für Übersetzungen! %s wird ersetzt mit der Wortanzahl
str_word_count( strip_tags( get_post_field( 'post_content', get_the_ID() ) ) )
);
@pixelbart
pixelbart / dokumentation.php
Created February 4, 2016 08:35
Simple Doku Beispiel
<?php
/**
* Plugins controller
*
* @author Kevin pliester - info@leerzeile.com
* @version 1.0
* @date Februar 03, 2016
* @date updated Feb 04, 2016
*/
namespace Controllers;
@pixelbart
pixelbart / .htaccess
Last active April 9, 2016 00:25
HideMyMessage
RewriteEngine On
RewriteRule ^([A-Za-z0-9-]+)/?$ /index.php?key=$1 [NC,L]
@pixelbart
pixelbart / custom_query.php
Last active April 19, 2016 14:15
Custom WP-Query
<?php
// https://codex.wordpress.org/Class_Reference/WP_Query
$args = array(
'category_name' => 'KATEGORIE1, KATEGORIE2', // Hier können einzelne Kategorie gewählt werden
'post_type' => 'post', // Hier wird angegeben, was angezeigt werden soll. (Post ist Standard; Geht auch Custom Post Type)
);
$the_query = new WP_Query( $args ); ?>
@pixelbart
pixelbart / subreddits.js
Created May 18, 2016 11:00
Show an random image from a subreddit
// Place in your body:
// <div id="image"></div>
$(document).ready( function() {
var subreddit = 'VillagePorn'; // Your Subreddit without /r/
var aRandomNum = Math.floor((Math.random() * 25) + 1); // A random number - range 25
$.getJSON('http://www.reddit.com/r/'+subreddit+'.json?jsonp=?&show=all&limit=25', function(data) {
$.each(data.data.children, function(i,item){
@pixelbart
pixelbart / functions.php
Created June 10, 2016 10:48
WordPress Link Manager
<?php
/**
* Baut die alte Blogroll wieder ein.
* [links] gibt alle Links an beliebiger Stelle aus
*/
add_filter('pre_option_link_manager_enabled', '__return_true');
function _links() {
ob_start();
@pixelbart
pixelbart / lightbox.js
Last active June 16, 2016 10:01
data-featherlight Attribut allen Links hinzufügen um sie in einer Lightbox zu öffnen
/**********
* Fügt das data-featherlight attribut allen Bildlinks hinzu
* Plugin: https://github.com/noelboss/featherlight/
**/
$('a[href*=".png"], a[href*=".gif"], a[href*=".jpg"]').each(function() {
if (this.href.indexOf('?') < 0) {
$(this).attr('data-featherlight', 'image');
}
});
@pixelbart
pixelbart / custom-post-type-team.php
Created September 24, 2016 01:30
Custom Post Type: Team
<?php
/**
* Custom Post Type: Team
*
* @author Pixelbart
* @version 1.0
*/
function custom_post_type_team()
{
//* Beschriftungen im /wp-admin
@pixelbart
pixelbart / custom-post-type-team-query.php
Created September 24, 2016 01:32
Custom Post Type Query: Team
<?php
$args = array(
'post_type' => 'team', // Unser post-type sprich team
'post_status' => 'publish', // Es sollen nur Beiträge mit den Status "veröffentlicht" ausgeben werden
'posts_per_page' => -1 // Es sollen alle Beiträge auf der Seite angezeigt werden
);
$the_query = new WP_Query( $args ); // Unser WordPress Query, mit dem wir die Beiträge ausgeben werden
if ( $the_query->have_posts() ) :
@pixelbart
pixelbart / json-check.php
Created September 24, 2016 19:22
Simple JSON login function
<?php
$files = array();
$login_nick = null;
$login_pass = null;
//* loop all user files in users/ with file ending .json
foreach(glob('users/*.json') as $file) :
//* put json file contents into the users array