Skip to content

Instantly share code, notes, and snippets.

View topdown's full-sized avatar
🎯
Focusing

Jeff Behnke topdown

🎯
Focusing
View GitHub Profile
@topdown
topdown / wpdb_docs.php
Created July 25, 2011 20:35
WPDB extend for properties for phpStorm
<?php
/* Use an autoloader on include to load this but do not instance it
* OPTION ONE (autoloaded or included)
* Name the class like this
* class wpdb_docs extends wpdb {}
*
* /** @var $tag wpdb_docs */
* $tag_urls = get_tag_link($tag->term_id);
*
* OPTION TWO and probably the best
@topdown
topdown / example.php
Created January 14, 2012 01:09
WP PHPdocs for phpStorm
<?php
/**
* @see https://gist.github.com/1105126
*/
// Also some more hints and fixes
// WP functions for adding to the admin bar
// This will provide code completion for admin_bar functions like add_menu()
/** @var $wp_admin_bar WP_Admin_Bar */
@topdown
topdown / phpBB3.php
Created January 14, 2012 01:16
Fix code completion for phpBB3 in phpStorm
<?php
// Open phpBB3 root/common.php
// Add doc blocks above
$cache = new cache();
$db = new $sql_db();
// So they look like this
/** @var $cache acm */
$cache = new cache();
@topdown
topdown / CI_phpStorm.php
Created January 29, 2012 05:21
Code Completion for CodeIgniter in phpStorm
<?php die('This file is not really here!');
/**
* ------------- DO NOT UPLOAD THIS FILE TO LIVE SERVER ---------------------
*
* Implements code completion for CodeIgniter in phpStorm
* phpStorm indexes all class constructs, so if this file is in the project it will be loaded.
* -------------------------------------------------------------------
* Drop the following file into a CI project in phpStorm
* You can put it in the project root and phpStorm will load it.
@topdown
topdown / wp-gist.php
Created July 5, 2012 04:44
Gist URL in WP Post
<?php
/**
* This allows you to simply post a gist url in a WordPress 3.0+ post and it grabs the actual gist and displays it
* For example, if your having issues or don't allow posting of embedded javascript, which should not be allowed
*
* Put this code in your theme functions file
* then post a gist url on a new line
*
* https://gist.github.com/1697338
*
@topdown
topdown / menu-fix.html
Created July 5, 2012 09:01
WordPress embedded video hides drop menu fix
<script type="text/javascript">
/*
WordPress embedded video hides drop menu fix
Put this code in your header.php after wp_head(); and before </head>
It assumes you already have jQuery loaded
*/
jQuery(document).ready(function () {
jQuery('iframe').each(function () {
var url = jQuery(this).attr("src");
jQuery(this).attr("src", url + "&wmode=transparent");
@topdown
topdown / PSR-0-final-proposal.md
Created October 11, 2012 05:17 — forked from Thinkscape/PSR-0-final-proposal.md
PSR-0 Final Proposal (PHP Standards Working Group)

PSR-0 Final Proposal (PHP Standards Working Group)

The following describes the mandatory requirements that must be adhered to for autoloader interoperability.

Mandatory:

  • A fully-qualified namespace and class must have the following structure \ <Vendor Name> \ (<Namespace>)* \ <Class Name>
  • Each namespace must have a top-level namespace ("Vendor Name").
  • Each namespace can have as many sub-namespaces as it wishes.
  • Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system.
  • Each "_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace.
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@topdown
topdown / Regex validate hex color
Created March 16, 2013 22:45
Regex validate hex color. Validates the hex color value skipping over non-valid values.
\b(?<=#)(([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}))\b
#333333 = valid
#abcde0 = valid
#333 = valid
#4 = not valid
#44 = not valid
#4444 = not valid
#44444 = not valid
#4444444 = not valid
@topdown
topdown / Regex_find_words_in_string.php
Last active December 15, 2015 01:19
Regex find words in string This regex is capable of finding specific words in string and ignoring words in HTML attributes so when replacing with HTML it does not break the code.
<?php
// Updated, the other expression misses stuff like nulla.jpg which broke images
// (?<!-)\b(ipsum|nulla|Nulla)\b(?!\/|\"|\.[a-zA-Z0-9])
//----------------------------
// Example string
//----------------------------
?>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc feugiat laoreet augue, non congue lectus mattis nec. Etiam augue risus, consequat et sodales at, scelerisque id orci. Sed posuere egestas tristique. Aenean fermentum volutpat nisi, nulla vitae convallis risus mollis vel. <a title="nulla" href="http://nulla/nulla">Nulla</a> Nulla convallis venenatis tortor, nec congue augue hendrerit quis. Fusce augue metus, venenatis posuere ornare quis, scelerisque sed quam. <img alt="ipsum" src="ipsum.png" title="ipsum">Nunc nec adipiscing justo. Morbi eget ultrices diam. Proin nisl nisl, aliquet quis aliquet non, sollicitudin ultricies lectus. Etiam malesuada mauris quis sem varius hendrerit. Etiam eu tempor magna. Donec quam metus, elementum eget sollicitudin adipiscing, porttitor di