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
### Keybase proof | |
I hereby claim: | |
* I am brandondove on github. | |
* I am brandondove (https://keybase.io/brandondove) on keybase. | |
* I have a public key ASDkveaEeqc9F6AbCpZ3edOFnzCY3-LDYPLqCyzQOUTNAAo | |
To claim this, I am signing this object: |
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 | |
/** | |
* POST to endpoint /wp-json/my-custom-endpoint/v1/save-string | |
* | |
* Send a string and use "Application Passwords" plugin and save to option | |
*/ | |
add_action( 'rest_api_init', 'my_custom_endpoint', 10 ); | |
/** |
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 | |
/* | |
* There are many different actions you might | |
* hook into to trigger a post to your microservice | |
*/ | |
add_action( 'sample_action', 'post_to_microservice', 10 ); | |
function post_to_microservice() { |
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 | |
/** | |
* Allows you to run new code during the custom post type registration | |
* | |
* @return void | |
*/ | |
function example_ads_init() { | |
register_taxonomy( | |
'ads-formats', |
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 | |
// Hook into WordPress before the query runs | |
add_action( 'pre_get_posts', 'pj_sort_it_better' ); | |
// Modifies the WP_Query object | |
function pj_sort_it_better( $query ) { | |
if ( is_page( 'The Page Name' ) ) { | |
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 | |
// Hook into the init action | |
add_action( 'wp', 'pj_check_page' ); | |
// Checks to see if the page we want is being requested and adds a filter to any queries that run on the resulting page | |
function pj_check_page () { | |
if ( is_page( 'The Page Name' ) ) { | |
// for pagination |
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 | |
/** | |
* Allows you to modify the css classes that are applied to an ad unit so you can style each unit individually | |
*/ | |
function example_adsanity_post_class( $classes = array(), $post = false ) { | |
// Adds a dynamic class that utilizes data from the post object | |
if ( FALSE !== $post && $post instanceof WP_Post ) { | |
$classes[] = sprintf( 'custom-%d', $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 | |
/** | |
* Allows you to modify any part of the custom post type registration | |
* | |
* see: https://codex.wordpress.org/Function_Reference/register_post_type | |
*/ | |
function example_ads_setup( $args = array() ) { | |
// Change the permalink structure for the custom post type | |
$args['rewrite'] = array( |
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 | |
/** | |
* Allows you to modify the custom post type labels for the adsa custom post type | |
*/ | |
function example_pj_ads_labels( $labels = array() ) { | |
$labels['menu_name'] = __( 'Whitelabeled Ads', 'example' ); | |
return $labels; | |
} |
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 | |
/** | |
* Adds new responsive ad unit sizes to the selectable options when creating an ad | |
*/ | |
function example_adsanity_ads_posts_sortable_by_clicks( $vars = array() ) { | |
$vars = array_merge( | |
$vars, | |
array( | |
'meta_key' => sprintf( '_clicks-%s', mktime( 0,0,0, date( 'n' ), date( 'j' ), date( 'Y' ) ) ), |
NewerOlder