From dbe17eab49e38807d2364713a57cbe371557e2af Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Mon, 21 Sep 2020 11:57:15 +0200 Subject: [PATCH] Add new filters allowing one to customize experience Fixes #180 Fixes #183 --- core.traktivity.php | 11 ++++++++ cpt.traktivity.php | 63 ++++++++++++++++++++++++++++++++++++++++----- readme.txt | 10 +++++-- traktivity.php | 4 +-- 4 files changed, 77 insertions(+), 11 deletions(-) diff --git a/core.traktivity.php b/core.traktivity.php index 14db7ec..9f5a0b5 100644 --- a/core.traktivity.php +++ b/core.traktivity.php @@ -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. diff --git a/cpt.traktivity.php b/cpt.traktivity.php index a8653e4..951132e 100644 --- a/cpt.traktivity.php +++ b/cpt.traktivity.php @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/readme.txt b/readme.txt index c22b57c..61da669 100644 --- a/readme.txt +++ b/readme.txt @@ -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! @@ -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 diff --git a/traktivity.php b/traktivity.php index 4072604..b58fec9 100644 --- a/traktivity.php +++ b/traktivity.php @@ -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 @@ -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' );