Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

placeholderが含まれない時はcallbackが呼び出されないよう変更 #60

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Kunoichi/GaCommunicator/Utility/PlaceHolders.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ public function get() {
*/
public function replace( $tag ) {
foreach ( $this->place_holders as $place_holder ) {
$tag = str_replace( "%{$place_holder['name']}%", $place_holder['callback'](), $tag );
if ( false !== strpos( $tag, "%{$place_holder['name']}%" ) ) {
$tag = str_replace( "%{$place_holder['name']}%", $place_holder['callback'](), $tag );
}
// Detect placeholder with parameter.
if ( preg_match_all( "/%{$place_holder['name']}:(.*)%/", $tag, $matches ) ) {
foreach ( $matches[0] as $matched_key ) {
Expand Down
Loading