Skip to content

Instantly share code, notes, and snippets.

@ScreamingDev
ScreamingDev / wp-db-delta.sh
Created October 2, 2014 20:30
WordPress Database Delta
#!/bin/sh
# Almost the delta
wp db export local_before.sql --complete-insert --replace
# Make changes
wp db export local_after.sql --complete-insert --replace
@ScreamingDev
ScreamingDev / enumerate.php
Last active August 29, 2015 14:07
ngettext for and encounting
<?php
$enum = array();
// fetch last or a message for none
($last = array_pop($enum)) || ($last = __('none'));
// make a message depending on the number of elements
$message = vsprintf(
ngettext(
@ScreamingDev
ScreamingDev / regex.md
Created September 22, 2014 12:17
Find untranslated string without gettext

Regexp:

\&gt;\s*\w
@ScreamingDev
ScreamingDev / FunctionCommentSniff.php
Last active August 29, 2015 14:06
WordPress_Sniffs_Commenting_FunctionCommentSniff
<?php
/**
* Parses and verifies the doc comments for functions.
*
* PHP version 5
*
* @category PHP
* @package PHP_CodeSniffer
* @author Greg Sherwood <[email protected]>
* @author Marc McIntyre <[email protected]>
@ScreamingDev
ScreamingDev / for-your-plugin.php
Created September 20, 2014 14:32
WordPress Autoload respecting WP Coding Standards
<?php
if (!function_exists('lemike_autoload')) {
// Find classes the WordPress way
function lemike_autoload($class_name) {
$class_name = strtolower(ltrim($class_name, '\\'));
$file_name = '';
$namespace = '';
if ($last_ns_pos = strrpos($class_name, '\\')) {
$namespace = substr($class_name, 0, $last_ns_pos);
@ScreamingDev
ScreamingDev / user-meta.php
Created September 3, 2014 10:22
Add something to the users page
<?php
function init_user_meta_box( $user ) {
$dl_tax = get_the_author_meta( 'cf_user_download_cat', $user->ID );
?>
<h3><?php _e('Downloads', PLUGIN_TEXTDOMAIN); ?></h3>
<table class="form-table">
<tr>
<th>
<label for="dl-kategory">
@ScreamingDev
ScreamingDev / commit-all.sh
Last active August 29, 2015 14:05
Batch commit WordPress plugin updates
for D in $( ls -1); do
if [[ -d $D ]]; then
git add $D;
git commit -m "Plugin Live aktualisiert - $D" $D;
fi
done
@ScreamingDev
ScreamingDev / deployment.md
Created July 1, 2014 23:13
Handling Git Repo

Deploy your last changes

Via FTP

Ensure to have git-ftp configured as above. If you want to push things to the server:

git ftp push -p -D

Enter the password and see what will be changed.

<?xml version="1.0"?>
<project name="waferthin.com" description="Targets for maintaining and deploying the waferthin.com web site." default="deploy">
<!-- See book here: http://www.packtpub.com/expert-php-5-tools/book -->
<!-- initialize timestamp that will be used in naming of various files & directories -->
<tstamp/>
<target name="deploy" depends="get-env,create-skeleton,svn-export,stamp-config,disp-maint,backup-db,deploy-db,publish-site" description="Deploy the site to the web server and perform necessary build and upgrade tasks.">
</target>
<target name="get-env" description="get the environment for an action">
@ScreamingDev
ScreamingDev / AbstractPost.php
Last active August 29, 2015 14:00
Make WordPress feel like Magento - Post vs. VarienObject
<?php
namespace Oowp;
/**
* Class Oowp_AbstractPost
*
* @method getPostContent()
* @method getPostTitle()
* @method setPostContent($string)