This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function state_list() { | |
return array( | |
'AL' => 'Alabama', | |
'AK' => 'Alaska', | |
'AZ' => 'Arizona', | |
'AR' => 'Arkansas', | |
'CA' => 'California', | |
'CO' => 'Colorado', | |
'CT' => 'Connecticut', | |
'DE' => 'Delaware', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Custom_List_Table extends WP_List_Table() { | |
// custom list table code here | |
} | |
$list_table = new Custom_List_Table(); | |
$list_table->prepare_items(); | |
// verify the nonce field generated near the bulk actions menu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// can be run inside of an admin_init hook | |
global $pagenow; | |
global $plugin_page; | |
add_action('load-' . get_plugin_page_hook($plugin_page, $pagenow), 'my_function' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_term_by_value($taxonomy, $field, $value) { | |
// probably a better way to do this, but this works for now | |
// get_field is part of Advanced Custom Fields | |
if (function_exists('get_field')) { | |
foreach (get_terms( $taxonomy ) as $term) { | |
$field = get_field($field, $term); | |
if ($value == $field) | |
return $field; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function array_insert($array, $values, $offset) { | |
// http://stackoverflow.com/questions/1783089/array-splice-for-associative-arrays/11114956#11114956 | |
return array_slice($array, 0, $offset, true) + $values + array_slice($array, $offset, NULL, true); | |
} | |
function admin_columns($columns) { | |
// this is the 'manage_edit-{post-type}_columns' filter | |
// add_filter( 'manage_edit-' . self::$post_type . '_columns', array($this, 'admin_columns'), 10, 1 ) ; | |
$columns = array_insert($columns, array('sales-channel' => 'Sales Channel'), 2); | |
return $columns; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: GGA - git branches | |
Description: Dashboard Widget | |
Author: Pete Nelson | |
Version: 1.0 | |
*/ | |
if (!defined( 'ABSPATH' )) exit('restricted access'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wp_handle_upload_prefilter', 'gga_filter_large_image_dimensions' ); | |
function gga_filter_large_image_dimensions( $file ) { | |
$maxsize = 2000; | |
if ( false !== strpos($file['type'], 'image/') ) { | |
$size = getimagesize( $file['tmp_name'] ); |