Skip to content

Commit

Permalink
Add new filters allowing one to customize experience
Browse files Browse the repository at this point in the history
Fixes #180
Fixes #183
  • Loading branch information
jeherve committed Sep 21, 2020
1 parent a68c13f commit dbe17ea
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 11 deletions.
11 changes: 11 additions & 0 deletions core.traktivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ private function get_trakt_activity( $args = array(), $test = false ) {
$username
);

/**
* Filter the URL used to fetch activity data from Trakt.
*
* @since 2.3.0
*
* @param string $query_url Query URL.
* @param string $api_url API URL. Default to TRAKTIVITY__API_URL.
* @param string $username Trakt username.
*/
$query_url = apply_filters( 'traktivity_get_activity_url', $query_url, TRAKTIVITY__API_URL, $username );

/**
* If one specified an array of $args when calling get_trakt_activity(),
* those arguments will be added to the query.
Expand Down
63 changes: 56 additions & 7 deletions cpt.traktivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ public function register_post_type() {
'search_items' => __( 'Search Event', 'traktivity' ),
);
$rewrites = array(
'slug' => 'watched',
/**
* Filter the main CPT (traktivity_event) slug.
*
* @since 2.3.0
*
* @param string $core_cpt_slug Core CPT slug. Defaults to watched.
*/
'slug' => apply_filters( 'traktivity_core_cpt_slug', 'watched' ),
'with_front' => true,
'feeds' => true,
'pages' => true,
Expand Down Expand Up @@ -141,7 +148,14 @@ public function register_event_type_taxonomy() {
'items_list_navigation' => __( 'Event Type list navigation', 'traktivity' ),
);
$rewrites = array(
'slug' => 'type',
/**
* Filter the show taxonomy slug (trakt_type).
*
* @since 2.3.0
*
* @param string $trakt_type_tax_slug slug. Defaults to type.
*/
'slug' => apply_filters( 'traktivity_trakt_type_tax_slug', 'type' ),
'with_front' => true,
'hierarchical' => false,
'ep_mask' => EP_NONE,
Expand Down Expand Up @@ -190,7 +204,14 @@ public function register_genre_taxonomy() {
'items_list_navigation' => __( 'Genre list navigation', 'traktivity' ),
);
$rewrites = array(
'slug' => 'genre',
/**
* Filter the genre taxonomy slug (trakt_genre).
*
* @since 2.3.0
*
* @param string $trakt_genre_tax_slug slug. Defaults to genre.
*/
'slug' => apply_filters( 'traktivity_trakt_genre_tax_slug', 'genre' ),
'with_front' => true,
'hierarchical' => false,
'ep_mask' => EP_NONE,
Expand Down Expand Up @@ -238,7 +259,14 @@ public function register_event_year_taxonomy() {
'items_list_navigation' => __( 'Event Year list navigation', 'traktivity' ),
);
$rewrites = array(
'slug' => 'year',
/**
* Filter the year taxonomy slug (trakt_year).
*
* @since 2.3.0
*
* @param string $trakt_year_tax_slug slug. Defaults to year.
*/
'slug' => apply_filters( 'traktivity_trakt_year_tax_slug', 'year' ),
'with_front' => true,
'hierarchical' => false,
'ep_mask' => EP_NONE,
Expand Down Expand Up @@ -286,7 +314,14 @@ public function register_show_taxonomy() {
'items_list_navigation' => __( 'Show list navigation', 'traktivity' ),
);
$rewrites = array(
'slug' => 'show',
/**
* Filter the show taxonomy slug (trakt_show).
*
* @since 2.3.0
*
* @param string $trakt_show_tax_slug slug. Defaults to show.
*/
'slug' => apply_filters( 'traktivity_trakt_show_tax_slug', 'show' ),
'with_front' => true,
'hierarchical' => false,
'ep_mask' => EP_NONE,
Expand Down Expand Up @@ -334,7 +369,14 @@ public function register_season_taxonomy() {
'items_list_navigation' => __( 'Season list navigation', 'traktivity' ),
);
$rewrites = array(
'slug' => 'season',
/**
* Filter the season taxonomy slug (trakt_season).
*
* @since 2.3.0
*
* @param string $trakt_season_tax_slug slug. Defaults to season.
*/
'slug' => apply_filters( 'traktivity_trakt_season_tax_slug', 'season' ),
'with_front' => true,
'hierarchical' => false,
'ep_mask' => EP_NONE,
Expand Down Expand Up @@ -382,7 +424,14 @@ public function register_episode_taxonomy() {
'items_list_navigation' => __( 'Episode list navigation', 'traktivity' ),
);
$rewrites = array(
'slug' => 'episode',
/**
* Filter the episode taxonomy slug (trakt_episode).
*
* @since 2.3.0
*
* @param string $trakt_episode_tax_slug slug. Defaults to episode.
*/
'slug' => apply_filters( 'traktivity_trakt_episode_tax_slug', 'episode' ),
'with_front' => true,
'hierarchical' => false,
'ep_mask' => EP_NONE,
Expand Down
10 changes: 8 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
=== Traktivity ===
Contributors: jeherve
Tags: Trakt.tv, TV, Activity, Track, tmdb, Movies, TV Shows, Trakt, Log
Stable tag: 2.2.1
Stable tag: 2.3.0
Requires at least: 5.1
Tested up to: 5.2
Tested up to: 5.5
License: GPLv2+

Are you a TV addict, and want to keep track of all the shows you've binge-watched and movies you saw? Traktivity is for you!
Expand Down Expand Up @@ -51,6 +51,12 @@ Do you like that header image? Me too! Credit goes to [Andrew Branch](https://un

== Changelog ==

= 2.3.0 =
Release Date: September 21, 2020

* Add new filter allowing one to customize the requests to Trakt.tv.
* Add new filters allowing one to customize the slugs used by the Post Type and its taxononmies.

= 2.2.1 =
Release Date: August 26, 2017

Expand Down
4 changes: 2 additions & 2 deletions traktivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: https://wordpress.org/plugins/traktivity
* Description: Log your activity on Trakt.tv
* Author: Jeremy Herve
* Version: 2.2.1
* Version: 2.3.0
* Author URI: https://jeremy.hu
* License: GPL2+
* Text Domain: traktivity
Expand All @@ -15,7 +15,7 @@

defined( 'ABSPATH' ) || die( 'No script kiddies please!' );

define( 'TRAKTIVITY__VERSION', '2.2.1' );
define( 'TRAKTIVITY__VERSION', '2.3.0' );
define( 'TRAKTIVITY__API_URL', 'https://api.trakt.tv' );
define( 'TRAKTIVITY__API_VERSION', '2' );
define( 'TRAKTIVITY__TMDB_API_URL', 'https://api.themoviedb.org' );
Expand Down

0 comments on commit dbe17ea

Please sign in to comment.