This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 gga_set_featured_image_from_url($post_id, $url) { | |
$temp_file = download_url( $url ); | |
if (is_wp_error( $temp_file )) | |
return $temp_file; | |
$file_array['name'] = basename( $url ); | |
$file_array['tmp_name'] = $temp_file; | |
$sideloaded_id = media_handle_sideload( $file_array, $post_id ); |
This file contains hidden or 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 - AJAX Posts by Taxonomy | |
Author: Pete Nelson (@GunGeekATX) | |
Description: <a href="http://petenelson.com/wp-admin/admin-ajax.php?action=gga_posts_by_taxonomy&post_type=post&taxonomy=post_tag&term=android">Try it out</a> | |
Version: 1.0 | |
*/ | |
/* | |
http://petenelson.com/wp-admin/admin-ajax.php?action=gga_posts_by_taxonomy&post_type=post&taxonomy=post_tag&term=android |
This file contains hidden or 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 | |
// just using a file, could easily be replaced by some other storage method | |
if (isset($_REQUEST['new']) && $_REQUEST['new'] == '1') { | |
$ver = new stdClass(); | |
$ver->ver = time(); | |
file_put_contents('ver.json', json_encode($ver)); | |
} | |
else { |
This file contains hidden or 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 Import Pages | |
Description: Quick plugin to bulk import a list of pages <a href="admin-ajax.php?action=gga_import_pages">[Import Now]</a> | |
*/ | |
add_action( 'wp_ajax_gga_import_pages', 'gga_import_pages' ); | |
function gga_import_pages() { | |
global $post; |
This file contains hidden or 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
$test_data = array(); | |
$test_data[] = new stdClass(); | |
$test_data[0]->field1 = 'hello'; | |
$test_data[0]->field2 = 'world'; | |
$test_data[0]->my_object = new stdClass(); | |
$test_data[0]->my_object->field3 = 'more hello world'; | |
wp_localize_script( 'gmec-intranet', 'test_data', $test_data ); | |
// outputs the following Javascript |