Skip to content

Instantly share code, notes, and snippets.

@scofennell
scofennell / get_value_from_docblock.php
Created December 22, 2016 22:48
Get the value of a docblock item.
<?php
/**
* Get the value for a docblock line.
*
* @param string $key The key for a docblock line.
* @return string The value for a docblock line.
*/
function get_value_from_docblock( $key ) {
@scofennell
scofennell / get_main_file_name.php
Created December 22, 2016 22:41
Get the name of the main plugin file
<?php
function set_main_file_name() {
// Grab the slug name for this Bitbucket repo.
$slug = $this -> slug;
// Grab the list of file names in this repo.
$file_list = $this -> file_list;
@scofennell
scofennell / get_repos.php
Created December 22, 2016 22:33
Built a list of Bitbucket Repos
<?php
/**
* Store a "shallow" list of repos.
*/
public function set_repo_list() {
...
// Let's get 100 per page, which is the maximum.
@scofennell
scofennell / class.WP_Multi_Error.php
Last active September 27, 2016 21:47
Merge Multiple WP Errors
<?php
/**
* A class for handling errors.
*
* @package WordPress
* @subpackage WP_Multi_Error
* @since WP_Multi_Error 0.1
*/
@scofennell
scofennell / oauthdemo.php
Last active June 24, 2019 06:53
Trying to hello-world oauth1 for the wp api
<?php
class myDemo {
public function __construct() {
// The url for a custom endpoint registered via register_rest_route().
$this -> url = 'http://domain.com/wp-json/namespace/v1/endpoint';
// The custom route happens to require a url param, 'meta_key'
@scofennell
scofennell / bootsrap.php
Created February 10, 2016 23:42
boostrap file for wp unit tests
<?php
$_tests_dir = getenv( 'WP_TESTS_DIR' );
if ( ! $_tests_dir ) {
$_tests_dir = '../../../../';
}
require_once $_tests_dir . '/includes/functions.php';
function _manually_load_plugin() {
@scofennell
scofennell / acp_d.php
Created December 23, 2015 19:58
alpha color picker demo
<?php
/**
* A custom control for picking a color with alpha trans.
*
* @see https://github.com/BraadMartin/components/tree/master/customizer/alpha-color-picker
* @see http://braadmartin.com/alpha-color-picker-control-for-the-wordpress-customizer/
*
* @package WordPress
* @subpackage lxb-apple-fritter
@scofennell
scofennell / db_fields.php
Created October 11, 2015 00:23
db_fields.php
<?php
array(2) {
["parent"] => string(16) "menu_item_parent"
["id"] => string(5) "db_id"
}
?>
@scofennell
scofennell / tree_type.php
Last active October 11, 2015 00:18
tree_type.php
<?php
array(3) {
[0]=> string(9) "post_type"
[1]=> string(8) "taxonomy"
[2]=> string(6) "custom"
}
?>
@scofennell
scofennell / csst_nav-get.php
Created October 9, 2015 22:19
CSST_Nav -> get()
<?php
/**
* The main template tag for this class. Get a custom menu via our walker.
*
* @return string A WordPress custom menu, passed through our walker class.
*/
public function get() {
// The CSS class for our shortcode.