aaroneaton / better-yourls

Source code for the Better YOURLS WordPress plugin
21 stars 6 forks source link

Ability to filter keyword prior to submission to YOURLS api #12

Closed domsammut closed 8 years ago

domsammut commented 8 years ago

I thought this might be a useful addition for development and allows for checking of the keyword against any business logic that someone might have.

Example of how this filter could be used:

add_filter('better_yourls_keyword', 'testFilter', 10, 2);

function testFilter ($keyword, $post_id) {

    if (empty($keyword)) {
        if (get_post_type($post_id) == 'post') {
            $keyword = $post_id;
        }
    }
    return $keyword;

}
ChrisWiegman commented 8 years ago

This looks good. Thank you!