PHP code example of googlechromelabs / wp-third-parties
1. Go to this page and download the library: Download googlechromelabs/wp-third-parties library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
googlechromelabs / wp-third-parties example snippets
$ga = new Google_Chrome_Labs\WP_Third_Parties\Third_Parties\Google_Analytics(
array(
'id' => 'G-...', // Replace this with your actual Google Analytics ID.
)
);
// Add hooks to enqueue assets.
add_action( 'wp_loaded', array( $ga, 'add_hooks' ) );
$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' ) );
$gme = new Google_Chrome_Labs\WP_Third_Parties\Third_Parties\Google_Maps_Embed(
array(
'mode' => '...', // Provide this and other parameters like 'key', 'q', 'center', etc.
)
);
// No assets need to be enqueued for a Google Maps Embed.
// To actually render the Google Maps Embed, use this.
echo $gme->get_html();
$yte = new Google_Chrome_Labs\WP_Third_Parties\Third_Parties\YouTube_Embed(
array(
'videoid' => '...', // Replace this with your actual YouTube video ID.
)
);
// 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();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.