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

Update to latest library version from Packagist #3

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
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
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This package is a collection of classes and utilities that can be used to efficiently load third-party libraries into your WordPress application.

It relies on the platform agnostic solution from [Third Party Capital](https://github.com/GoogleChromeLabs/third-party-capital).

## Usage

### Google Analytics
Expand All @@ -13,9 +15,27 @@ $ga = new Google_Chrome_Labs\WP_Third_Parties\Third_Parties\Google_Analytics(
)
);

// Add hooks to enqueue assets.
add_action( 'wp_loaded', array( $ga, 'add_hooks' ) );
```

See the [Google Analytics JSON schema](https://github.com/GoogleChromeLabs/third-party-capital/blob/main/data/google-analytics.json) for the full list of supported arguments.

### Google Tag Manager

```php
$gtm = new Google_Chrome_Labs\WP_Third_Parties\Third_Parties\Google_Tag_Manager(
array(
'id' => 'GTM-...', // Replace this with your actual Google Tag Manager ID.
)
);

// Add hooks to enqueue assets.
add_action( 'wp_loaded', array( $gtm, 'add_hooks' ) );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewing the entire doc I noticed they all include a hook line like add_action( 'wp_loaded', array( $yte, 'add_hooks' ) ); except "Google Maps Embed". Should it also include the hook line? If not maybe a single line explaining why these are included in the other examples but not this one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamsilverstein Great point! I clarified this in 7c43462.

The reason Google Maps Embed doesn't need to add hooks is that there are no assets (scripts or stylesheets) needed for it. You could technically still include the same hook callback, but it just wouldn't do anything. So if you know that already, you can omit it, that's why the snippet here does that.

```

See the [Google Tag Manager JSON schema](https://github.com/GoogleChromeLabs/third-party-capital/blob/main/data/google-tag-manager.json) for the full list of supported arguments.

### Google Maps Embed

```php
Expand All @@ -25,10 +45,13 @@ $gme = new Google_Chrome_Labs\WP_Third_Parties\Third_Parties\Google_Maps_Embed(
)
);

// No assets need to be enqueued for a Google Maps Embed.
// To actually render the Google Maps Embed, use this.
echo $gme->get_html();
```

See the [Google Maps Embed JSON schema](https://github.com/GoogleChromeLabs/third-party-capital/blob/main/data/google-maps-embed.json) for the full list of supported arguments.

### YouTube Embed

```php
Expand All @@ -38,12 +61,15 @@ $yte = new Google_Chrome_Labs\WP_Third_Parties\Third_Parties\YouTube_Embed(
)
);

// Add hooks to enqueue assets.
add_action( 'wp_loaded', array( $yte, 'add_hooks' ) );

// To actually render the YouTube Embed, use this.
echo $yte->get_html();
```

See the [YouTube Embed JSON schema](https://github.com/GoogleChromeLabs/third-party-capital/blob/main/data/youtube-embed.json) for the full list of supported arguments.

## Getting started

```
Expand Down
8 changes: 1 addition & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,5 @@
"Google_Chrome_Labs\\WP_Third_Parties\\Test_Data\\": "tests/phpunit/testdata",
"Google_Chrome_Labs\\WP_Third_Parties\\Test_Utils\\": "tests/phpunit/utils"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/GoogleChromeLabs/third-party-capital"
}
]
}
}
Loading