From 7903f4e901438de8f5c83c0b2b912577d94a2d10 Mon Sep 17 00:00:00 2001 From: Philip Arthur Moore Date: Fri, 20 Jun 2014 17:24:06 +0700 Subject: [PATCH] Make sure warnings aren't triggered by no IDs. Make sure that other plugins that try to filter `the_title` without passing in two parameters don't interfere with the Subtitles plugin. When `the_title` is filtered, two parameters are needed by Subtitles: the title of the post and the post ID. If a custom widget or anything else that uses `the_title` does not provide this, then Subtitles will return a PHP warning. So, set the default ID to null if it hasn't been passed to `the_subtitle` and all should be well. --- README.md | 4 ++++ public/class-subtitles.php | 2 +- subtitles.php | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7132775..7930de8 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,10 @@ An ID isn't necessary for `get_the_subtitle`, but will work for retrieving subti All versions of _Subtitles_ can be found on the [Releases](https://github.com/philiparthurmoore/Subtitles/releases) page. +### [v1.0.4](https://github.com/philiparthurmoore/Subtitles/releases/tag/v1.0.4) (June 20th, 2014) + +- Bug Fix: Make sure that other plugins that try to mess with titles do not cause _Subtitles_ to throw PHP warnings due to the second optional `$id` parameter not being sent to the primary `the_subtitles` method used throughout sites (see [issue](https://github.com/philiparthurmoore/Subtitles/issues/16)). + ### [v1.0.3](https://github.com/philiparthurmoore/Subtitles/releases/tag/v1.0.3) (June 19th, 2014) - Bug Fix: Ensure that _Subtitles_ works in PHP 5.2.4 environments (see [issue](https://github.com/philiparthurmoore/Subtitles/issues/8)). diff --git a/public/class-subtitles.php b/public/class-subtitles.php index d5fd773..87fdd68 100644 --- a/public/class-subtitles.php +++ b/public/class-subtitles.php @@ -507,7 +507,7 @@ public function subtitle_scripts() { * * @since 1.0.0 */ - public function the_subtitle( $title, $id ) { + public function the_subtitle( $title, $id = null ) { /** * Which globals will we need? * diff --git a/subtitles.php b/subtitles.php index 192f70c..aa363bd 100644 --- a/subtitles.php +++ b/subtitles.php @@ -5,7 +5,7 @@ * Description: Easily add subtitles into your WordPress posts, pages, custom post types, and themes. * Author: Philip Arthur Moore * Author URI: https://philiparthurmoore.com/ - * Version: 1.0.3 + * Version: 1.0.4 * Text Domain: subtitles * Domain Path: /languages/ * License: GNU General Public License v2 or later