Skip to content

Instantly share code, notes, and snippets.

@atwellpub
Created October 24, 2018 02:11
Show Gist options
  • Save atwellpub/d80ae09aac7bcfa981a645fbda763bf5 to your computer and use it in GitHub Desktop.
Save atwellpub/d80ae09aac7bcfa981a645fbda763bf5 to your computer and use it in GitHub Desktop.
Extending SocialWarfare plugin to Easy Digital Downloads with custom permalink prefix
<?php
/**
*
*/
class Codeable_Social_Warefare {
public function __construct() {
self::load_hooks();
}
/**
* load hooks
* @return [type] [description]
*/
public static function load_hooks() {
/* adds socialwarefar support for Easy Digital Downloads */
add_filter('swp_recovery_filter', array( __CLASS__ , 'add_cpt_url_prefix' ) , 10 , 1 );
}
/**
* adds socialwarefar support for Easy Digital Downloads
* @param [type] $url [description]
*/
public static function add_cpt_url_prefix( $url ) {
if('download' === get_post_type( get_the_ID() ) ) {
$url = str_replace( '//www.oursite.com/', '//www.oursite.com/my-custom-cpt-prefix/', $url );
}
return $url;
}
}
new Codeable_Social_Warefare;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment