Skip to content

Instantly share code, notes, and snippets.

View glueckpress's full-sized avatar

Caspar Hübinger glueckpress

View GitHub Profile
@israelcurtis
israelcurtis / gist:3798347
Created September 28, 2012 06:57
Use the get_post_field() function to get any of the wp_posts column fields #wordpress #php
<?php
echo get_post_field('post_content', $post_id); // retrieve content
echo get_post_field('post_name', $post_id); // retrieve the slug
?>
@johnpbloch
johnpbloch / README.md
Created August 23, 2012 13:55
A bash script to make .pot files for WordPress plugins

Installation

To install, you need to have the WordPress i18n library on your computer. Check it out using SVN:

sudo svn co http://i18n.svn.wordpress.org/tools/trunk/ /usr/lib/wpi18n

You don't have to put the library in /usr/lib/wpi18n, but if you don't put it there, make sure to set the $WP_I18N_LIB environment variable in your .bashrc file (with no trailing slash):

export WP_I18N_LIB="/path/to/i18n/lib"

@2ndkauboy
2ndkauboy / grep_infections.sh
Created May 21, 2014 12:28
This is a simple bash script, that scans text files for typical infections and sends an email to the user. Just setup a cron and run it every couple of hour. And don't worry, even scanning thousand of text files will only take some seconds.
#!/bin/bash
grep '#[0-9a-fA-F]\{6\}#' -r -H -lc /var/www/ --include=*.{html,js,css,php,tpl,sh,py,java,class} | # Only get found issues
/usr/bin/mail -E -s 'INFECTED FILES FOUND on example.com' mail@example.com # Send EMail
grep '/\*[0-9a-fA-F]\{6\}\*/' -r -H -lc /var/www/ --include=*.{html,js,css,php,tpl,sh,py,java,class} | # Only get found issues
/usr/bin/mail -E -s 'INFECTED FILES FOUND on example.com' mail@example.com # Send EMail
grep 'e=w\["eval"\]' -r -H -lc /var/www/ --include=*.{html,js,css,php,tpl,sh,py,java,class} | # Only get found issues
/usr/bin/mail -E -s 'INFECTED FILES FOUND on example.com' mail@example.com # Send EMail
grep '<!--/[0-9a-fA-F]\{6\}-->' -r -H -lc /var/www/ --include=*.{html,js,css,php,tpl,sh,py,java,class} | # Only get found issues
/usr/bin/mail -E -s 'INFECTED FILES FOUND on example.com' mail@example.com # Send EMail
grep 'r=eval' -r -H -lc /var/www/ --include=*.{html,js,css,php,tpl,sh,py,java,class} | # Only get found issues
@bueltge
bueltge / widget-tut.php
Last active December 8, 2017 03:19 — forked from chrisguitarguy/widget-tut.php
An example of how to build your own WordPress widget
<?php
/*
Plugin Name: FB Widget Tutorial
Plugin URI:
Description: How to create WordPress Widgets.
Version: 13/03/2013
Author: Frank Bültge
Author URI: http://bueltge.de/
License: GPLv3
*/
@thefuxia
thefuxia / remove-admin-bar-wp-menu.php
Last active August 5, 2017 08:15
Remove WP Menu From Tool Bar
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Remove WP Menu From Tool Bar
*/
add_action( 'add_admin_bar_menus', function(){
remove_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu' );
});
@pippinsplugins
pippinsplugins / gist:146c6f90bc8194c7dba1
Last active May 9, 2017 23:13
This is a simple example that shows how we can maintain backwards compatibility in a plugin for data that used to be stored in post meta but is now stored in a taxonomy term. When this change was made, a new `edd_get_commission_status()` function was introduced, but before this function existed, the status was retrieved by calling `get_post_meta…
<?php
/**
* Filters get_post_meta() to ensure old commission status checks don't fail
*
* The status for commission records used to be stored in postmeta, now it's stored in a taxonomy
*
* @access private
* @since 2.8
* @return mixed
@krafit
krafit / wpseo-iconfix.php
Created December 2, 2015 12:38
Nachdem der Schmerz, den wpSEO-Menüpunkt ansehen zu müssen zu groß wurde, habe ich das Icon im Admin-Menü ersetzt.
if (function_exists(wpseo_autoload)) {
function krafit_repair_wpseo() {
?>
<style>
#adminmenu #toplevel_page_wpseo div.wp-menu-image img {
display: none;
}
#adminmenu #toplevel_page_wpseo div.wp-menu-image::before {
content: "\f511";
@joehoyle
joehoyle / private-wp-api.php
Created October 14, 2015 18:37
Only allow access to the API for authenticated requests
<?php
add_filter( 'rest_pre_dispatch', function() {
if ( ! is_user_logged_in() ) {
return new WP_Error( 'not-logged-in', 'API Requests are only supported for authenticated requests', array( 'status' => 401 ) );
}
} );
@sergejmueller
sergejmueller / goodbye-wordpress.md
Last active July 13, 2016 11:19
Goodbye, WordPress!

Goodbye, WordPress!

Fast 9 Jahre und nahezu 3 Millionen Downloads später ist Schluss.
Schluss mit WordPress.

Für mich geht ein Lebensabschnitt zu Ende. Ein Lebensabschnitt, der unendlich viel Erfahrung, Learnings und Spaß mit sich brachte. Ein Lebensabschnitt, der aber unendlich viel Zeit, Nerven und Motivation mit sich nahm. Doch der Wille zählt und ich hoffe stark, dass meine Software und mein Engagement die WordPress-Community ein Stückchen besser, qualitativer gemacht haben.

// Bitteschön

@sergejmueller
sergejmueller / .htaccess
Last active June 16, 2016 08:34
Stop search engines from indexing .txt, .log, .xml, .css and .js files in Apache
<FilesMatch "\.(txt|log|xml|css|js)$">
Header set X-Robots-Tag "noindex"
</FilesMatch>