### Start Test Environment with Docker Source: https://github.com/wovnio/wovn.php/blob/master/docker/HOWTO.md Prepare the Docker environment for running tests by stopping the current instance and starting a new one configured for testing. ```bash make stop && make start_test ``` -------------------------------- ### Start Docker Environment Source: https://github.com/wovnio/wovn.php/blob/master/docker/HOWTO.md Start the Docker containers for the WOVN.php environment. This command makes the content in `docker/public` accessible via `localhost`. ```bash make start ``` -------------------------------- ### Build Docker Image Source: https://github.com/wovnio/wovn.php/blob/master/docker/HOWTO.md Build the Docker image for WOVN.php. This command is typically needed only for the first-time setup. ```bash make build ``` -------------------------------- ### Initialize Page Start Time Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp.html Records the current time to be used as the page start time for subsequent calculations. ```javascript t.prototype.initPageStartTime = function() { this.pageStartTime = (new Date).getTime(); } ``` -------------------------------- ### Example Hreflang X-Default Tag Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md An example of a link tag with the hreflang="x-default" attribute. ```html ``` -------------------------------- ### Basic .json Configuration Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md Example of a basic wovn.json configuration file for a project with English as the default language and Japanese, French, and English as supported languages. ```json { "project_token": "TOKEN", "url_pattern_name": "query", "default_lang": "en", "supported_langs": [ "ja", "fr", "en" ], "encoding": "UTF-8" } ``` -------------------------------- ### Basic .ini Configuration Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md Example of a basic wovn.ini configuration file for a project with English as the default language and Japanese and French as supported languages. ```ini project_token = TOKEN url_pattern_name = query default_lang = en supported_langs[] = ja supported_langs[] = fr ``` -------------------------------- ### Copy .htaccess Sample for Apache Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md Alternatively, copy the provided `.htaccess` sample file from the `WOVN.php` directory to use as a starting point for your custom `.htaccess` configuration. ```bash $ cp WOVN.php/htaccess_sample .htaccess ``` -------------------------------- ### Basic Wovn.php Configuration Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/youtube_expected.html This snippet shows a basic setup for Wovn.php, including URL endpoint and web navigation settings. It's used for initializing the Wovn service for browsing web pages. ```javascript t = {"urlEndpoint":{"url":"/"},"webNavigationEndpointData":{"url":"/","webPageType":"BROWSE"}}; url = "\/"; var playerResponse = null; window['chp_ssr']( csn, endpoint, "browse", playerResponse, window["ytInitialData"], url, setFiller); })(); var meta = document.createElement('meta'); meta.name = 'referrer'; meta.content = 'origin-when-cross-origin'; document.getElementsByTagName('head')[0].appendChild(meta); if (window.ytcsi) {window.ytcsi.info("st", 1435, '');} ``` -------------------------------- ### Initialize Google Analytics Instance Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp.html Initializes a new Google Analytics instance with the provided configuration. This should be called once during application setup. ```javascript t.init = function(e) { t.setInstance(new t(e)); } ``` -------------------------------- ### Translate Content with WOVN.io Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp_expected.html This example demonstrates how to use WOVN.io to translate specific content elements within your PHP application. It wraps the content to be translated. ```php translate("Hello, world!"); echo $wovn->translate("This is a test."); ?> ``` -------------------------------- ### Yelp Performance and Analytics Tracker Setup Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp.html Initializes and configures Yelp's internal analytics and performance tracking system. This includes setting up multiple Google Analytics trackers with custom dimensions and metrics. ```javascript var main = null; !function(t){ function e(i){ if(n[i])return n[i].exports; var o=n[i]={},r=t[i].call(o.exports,o,o.exports,e); return r===undefined&&(r=o.exports),r } var n={}; e.m=t,e.c=n,e.d=function(t,n,r){ e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r}) },e.n=function(t){ var n=t&&t.__esModule?function(){return t.default}:function(){return t}; return e.d(n,"a",n),n },e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}, e.p="" }([ function(t,e,n){ "use strict"; function i(t,e){return t>=0&&t<=e} function o(t,e){return i(t.top,e.height())&&!(t.left>=e.width()||t.right<=0)} function r(t,e){return i(t.left,e.width())&&!(t.top>=e.height()||t.bottom<=0)} function s(t,e){return i(t.right,e.width())&&!(t.top>=e.height()||t.bottom<=0)} function a(t,e){return i(t.bottom,e.height())&&!(t.left>=e.width()||t.right<=0)} function c(t,e){return t.left<=0&&t.right>=e.width()||t.top<=0&&t.bottom>=e.height()} function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")} function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")} var l=function(t,e){var n=t.getBoundingClientRect();return o(n,e)||r(n,e)||s(n,e)||a(n,e)||c(n,e)}, h=function(){function t(){u(this,t),this.reset()} return t.prototype.getInstance=function(t){var e=this; Object.prototype.hasOwnProperty.call(this,"value")?setTimeout(function(){t.call(this,e.value)},0):this.callbacks.push(t) }, t.prototype.setInstance=function(t){this.value=t,this.invokecallbacks()}, t.prototype.invokecallbacks=function(){for(var t=0;t0?t(e,n,i,o-1):i()})},g=m,y=n(1),v=n(2),w=n.n(v); Object.keys||w.a.shim(),Object.entries||(Object.entries=function(t){ for(var e=Object.keys(t),n=new Array(e.length),i=0;iinit("your_project_token", array( "languages" => "en,ja,ko,zh-CN,zh-TW", "url_pattern" => "subdomain", "default_lang" => "en", "debug_mode" => true, "log_level" => "debug", )); ?> ``` -------------------------------- ### Initialize Quantcast Service Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp_expected.html Initializes the Quantcast service for the Yelp website. ```javascript yelp.init.quantcast(); ``` -------------------------------- ### Stop Docker Environment Source: https://github.com/wovnio/wovn.php/blob/master/docker/HOWTO.md Stop the running Docker containers. Ensure any old Docker instances are stopped before starting a new one. ```bash make stop ``` -------------------------------- ### Initialize Yelp Quantcast and Search Controller Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp.html Initializes Yelp's Quantcast service and the search controller with various configuration options, including ad settings, map configurations, and URIs for different functionalities. ```javascript yelp.init.quantcast(); yelp.www.init.search.Controller({"adVisibilityURI": "/ad_visibility", "isReservationSearchEnabled": true, "adAckURI": "/ad_acknowledgment", "feedbackPopupOptions": {"businessRedirectUri": "/biz_attribute", "businessSearchUri": "/contact/business_search_html"}, "searchMapMinZoom": 8, "adAckCSRF": "7abc03bb119e5a4a02bdfd5276ac8d2b0c2d99b1fce5a8af4aa574b744a9a16c", "isPlatformSearchEnabled": true, "adVisibilityCSRF": "8f321eac569534bab94c73a08274d7af94525b6e1c4549e363edd6698de6a1b9", "searchAdSense": {"canShowAdsense": true, "num_ads": 2, "query": "", "loc": "San Francisco, CA", "isAdsenseEnabledForCountry": true, "detailed_attribution": true, "googleMapsEnterpriseKey": "ABQIAAAA-4PdDZI3yUT7Q6QmlfyYQBR-H9_hULZDKDkXlc3vkn3yqIJUbRQJYjw-XzY7Nb8a-Xj4njoI-o-BLg", "pubId": "pub-1554273207255362", "tracking_adsense_channel": "8818642271", "show_site_links": true, "baseLang": "en", "channel": "7129511946"}, "parentRequestId": "5e76dc04870cdd2d", "snippetSerial": "20130418", "locInputSelector": "#dropperText_Mast", "inputSelector": "#find_desc", "ajaxSearchURI": "/search/snippet", "searchMap": {"overlay_width": null, "fit_to_geobox": false, "should_draw_checkbox": false, "max_zoomlevel": 8, "service_areas": [], "library": "google", "zoom_control_position": "top_left", "market": null, "mo_map_possible": true, "center": {"latitude": 37.76089938976322, "longitude": -122.43644714355469}, "min_zoomlevel": 18, "zoom": 11, "markers": {"1": {"ur ``` -------------------------------- ### Get Google Analytics Command Name Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp_expected.html Constructs the correct command name for Google Analytics, handling different tracker aliases. ```javascript t.prototype.getCommandName=function(e,n){if(d(t.KNOWN_TRACKER_ALIASES,n)>=0)return[n,e].join(".");throw new Error("google analytics attempted to set "+e+" to an unrecognized tracker alias: "+n)} ``` -------------------------------- ### Polymer Initialization Configuration Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/youtube_expected.html Configures Polymer, a web component framework, for YouTube. It disables certain features like upgrade checks and template notifications for performance. ```javascript window.Polymer = { "disableUpgradeEnabled":true, "suppressTemplateNotifications":true, "useNativeCSSProperties":true, "suppressBindingNotifications":true, "lazyRegister":"max" }; ``` -------------------------------- ### Enable WOVN.php Diagnostics Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md Enables the WOVN.php diagnostics tool. Requires username and password to be set. Defaults to false. ```ini enable_wovn_diagnostics = true ``` -------------------------------- ### Get Google Analytics Tracker Command Name Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp.html Constructs the correct command name for Google Analytics, including the tracker alias if specified. ```javascript t.prototype.getCommandName = function(e, n) { if (d(t.KNOWN_TRACKER_ALIASES, n) >= 0) return [n, e].join("."); throw new Error("google analytics attempted to set " + e + " to an unrecognized tracker alias: " + n); } ``` -------------------------------- ### Download WOVN.php Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md Download the WOVN.php master zip file from GitHub and extract it to your website's root directory. ```bash $ cd /website/root/directory $ wget https://github.com/WOVNio/WOVN.php/archive/master.zip -O WOVN.php.zip $ unzip WOVN.php.zip; mv WOVN.php-master WOVN.php ``` -------------------------------- ### Enable WOVN.php Diagnostics (JSON) Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md Enables the WOVN.php diagnostics tool. Requires username and password to be set. Defaults to false. ```json { "enable_wovn_diagnostics": true } ``` -------------------------------- ### Ignore Paths Using Regular Expressions (JSON) Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md Use regular expressions to specify paths that should not be localized. This example ignores search pages with two-digit identifiers. ```json { "ignore_regex": ["/\/search\/\d\d\/"] } ``` -------------------------------- ### Initialize Facebook Integration Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp_expected.html Initializes the Facebook integration with specified app ID, SDK URL, version, and permissions. ```javascript yelp.www.init.facebook("97534753161", "//connect.facebook.net/en_US/sdk.js", "v2.7", "v2", ["email", "user_birthday"], ["publish_actions"], ["publish_actions", "user_friends"]); ``` -------------------------------- ### Ignore Paths Using Regular Expressions (INI) Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md Use regular expressions to specify paths that should not be localized. This example ignores search pages with two-digit identifiers. ```ini ignore_regex[] = "/\/search\/\d\d\/" ``` -------------------------------- ### Run Unit Tests with Docker Source: https://github.com/wovnio/wovn.php/blob/master/docker/HOWTO.md Execute unit tests within the Dockerized environment. ```bash make test_unit_with_docker ``` -------------------------------- ### Configure Outbound Proxy Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md Sets up a proxy server for WOVN.php to connect to the API. Requires host and port. ```json { "outbound_proxy_host": "site.com", "outbound_proxy_port": "8080" } ``` -------------------------------- ### Log Initial Data with WOVN Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/youtube.html This snippet logs initial data using window.ytcsi.info. It's used for tracking and debugging purposes within the WOVN integration. ```javascript if (window.ytcsi) {window.ytcsi.info("st", 1435, '');} ``` -------------------------------- ### Run Integration Tests with Docker Source: https://github.com/wovnio/wovn.php/blob/master/docker/HOWTO.md Execute integration tests within the Dockerized environment. ```bash make test_integration_with_docker ``` -------------------------------- ### Google Analytics Initialization Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp_expected.html Initializes the Yelp Google Analytics library. This is a static method that should be called once to set up the global instance. ```javascript t.init=function(e){t.setInstance(new t(e))} ``` -------------------------------- ### Initialize Google Analytics Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/stack_overflow_hreflang_html_entities_expected.html Initializes Google Analytics with multiple tracking IDs and sends an initial page view. Use this for setting up basic analytics tracking. ```javascript (function(i, s, o, g, r, a, m) { i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o), m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m); })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga'); ga('create', 'UA-5620270-1'); ga('create', 'UA-5620270-60', {name: 'pageData', sampleRate: 100 }); ga('send', 'pageview'); ga('pageData.send', 'pageview'); ``` -------------------------------- ### Initialize Yelp Async Image Loader and Page Initialization Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp_expected.html Initializes the asynchronous image loader and the main Yelp page functionalities. ```javascript yelp.www.init.initAsyncImageLoader(); yelp.pages.init(); ``` -------------------------------- ### Initialize WOVN.php URL Endpoint Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/youtube.html This snippet initializes the URL endpoint for WOVN.php. Ensure this is called before other WOVN functionalities. ```javascript t = {"urlEndpoint":{"url":"/"},"webNavigationEndpointData":{"url":"/","webPageType":"BROWSE"}}; url = "\/"; var playerResponse = null; window['chp_ssr']( csn, endpoint, "browse", playerResponse, window["ytInitialData"], url, setFiller); })(); ``` -------------------------------- ### Initialize Yelp Website Utilities Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp.html Initializes various Yelp website utilities including analytics, search suggestions, account menus, header navigation tracking, and ad visibility tracking. ```javascript yelp.www.util.analytics.initJSCustomDimensions(); yelp.www.init.initSearchSuggest("#find_desc", ".find-decorator", "#dropperText_Mast", true); yelp.www.init.initAccountMenu("#topbar-account-item"); yelp.www.init.initHeaderNavTracking(); yelp.common.init.adVisibilityTracker({"servletURI": "/ad_visibility", "loggingCSRF": "8f321eac569534bab94c73a08274d7af94525b6e1c4549e363edd6698de6a1b9"}); yelp.www.init.initTimeOnPageAnalyticsBeforeUnload(); yelp.init.initDelegatedDropdowns(); ``` -------------------------------- ### Activate WOVN.php for Dynamic Websites Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md Include this require_once statement at the beginning of your PHP files to activate WOVN.php content interception for dynamic websites. ```php require_once('/website/root/directory/WOVN.php/src/wovn_interceptor.php'); ``` -------------------------------- ### Configure Logging (INI) Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md Configures WOVN.php's internal logging. Logs are written using error_log(). Requires 'path' if 'destination' is 'file'. ```ini logging[destination] = "file" logging[path] = "/var/logs/error_log.log" logging[max_line_length] = 5124 ``` -------------------------------- ### Configure Logging (JSON) Source: https://github.com/wovnio/wovn.php/blob/master/README.en.md Configures WOVN.php's internal logging. Logs are written using error_log(). Requires 'path' if 'destination' is 'file'. ```json { "logging": { "destination": "file", "path": "/var/logs/error_log.log", "max_line_length": 5124 } } ``` -------------------------------- ### Initialize Time on Page Event Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp.html Sets up an event listener for the 'beforeunload' event to track time on page and viewport dimensions. ```javascript t.prototype.initTimeOnPageEvent = function() { var t = this; Object(y.a)(window).on("beforeunload", function() { t.setViewportTrackingDimension(); var e = t.timeSincePageStart(), n = E(e); t.trackEventHighVolume("time on page", "unload", n, e); }); } ``` -------------------------------- ### Initialize Yelp Pages and Facebook Integration Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp.html Initializes the main Yelp pages and integrates with Facebook using a provided app ID, SDK version, and permissions. ```javascript yelp.www.init.initAsyncImageLoader(); yelp.pages.init(); yelp.www.init.facebook("97534753161", "//connect.facebook.net/en_US/sdk.js", "v2.7", "v2", ["email", "user_birthday"], ["publish_actions"], ["publish_actions", "user_friends"]); ``` -------------------------------- ### Initialize and Load Page Data Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/youtube_expected.html This snippet initializes the page data loading process, including setting up a callback for when the page data is ready. It also handles YouTube's internal tracking events. ```javascript adDataHook(endpoint, data); window.loadDataHook = null; state = 'ir'; } else { window.getPageData = function() { if (window.ytcsi) { window.ytcsi.tick("chls", null, ''); } if (window.ytcsi) { window.ytcsi.tick("pr", null, ''); } state = 'ir'; return {data: data, endpoint: endpoint}; }; } setFiller && setFiller(); }; })(); if (window.ytcsi) { window.ytcsi.tick("lpcf", null, ''); } if (window.ytcsi) { window.ytcsi.tick("csl", null, ''); } ``` -------------------------------- ### Initialize Quantcast with Targeting Data Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp.html Initializes Quantcast with a specified cookie name and account ID. It sets up a function to retrieve targeting data from cookies and applies it to Google Publisher Tagging if available. ```javascript (function() { var main = null; var main=(function(){function a(c,b){window._qevents=window._qevents||[];window._qevents.push({qacct:b});window.yDFP.quantcast={};window.yDFP.quantcast.cookieName=c;window.yDFP.quantcast.adTagName="qncst_segs";window.yDFP.quantcast.getTargetingData=function(){var g=new RegExp(window.yDFP.quantcast.cookieName+"=(\[^;]*) ");var f=document.cookie.match(g);if(f){var e=decodeURIComponent(f[1]);var d=e.split(",");return{key:window.yDFP.quantcast.adTagName,value:d}}else{return null}};if(Boolean(window.googletag)&&Boolean(window.googletag.cmd)){window.googletag.cmd.push(function(){var d=window.yDFP.quantcast.getTargetingData(); if(d){window.googletag.pubads().setTargeting(d.key,d.value)}})}}window.yDFP=window.yDFP||{};window.yDFP.initQuantcast=a;return a})(); if (main === null) { throw 'invalid inline script, missing main declaration.'; } main("qntcst","p-M4yfUTCPeS3vn"); })(); ``` -------------------------------- ### Apply Configuration Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp.html Applies a new configuration object to the Google Analytics instance, updating trackers, domain, and other settings. ```javascript t.prototype.applyConfig = function(t) { this.trackers = t.trackers; this.domain = t.domain; this.clientID = t.clientID; this.userID = t.user_id; this.dimensions = t.dimensions; this.metrics = t.metrics; this.jsDimensions = t.js_dimensions; this.enableHighVolumeEvents = t.enable_high_volume_events; this.siteSpeedSampleRate = t.site_speed_sample_rate; this.viewedWidgets = []; } ``` -------------------------------- ### Set Google Analytics Instance Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp.html Sets the Google Analytics instance, also handling deferred initialization. Use this to manually set the instance if needed. ```javascript t.setInstance = function(e) { t.instance = e; t.deferredInstance.setInstance(e); } ``` -------------------------------- ### Run All PHPUnit Tests Locally Source: https://github.com/wovnio/wovn.php/blob/master/docker/HOWTO.md Execute all PHPUnit tests using the PHP interpreter on your local machine. ```bash vendor/bin/phpunit ``` -------------------------------- ### Initialize Google Analytics Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/yelp.html Loads the Google Analytics tracking script asynchronously. This function sets up the global ga object for tracking pageviews and events. ```javascript (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ``` -------------------------------- ### Initialize Quantcast and Scorecard Research Source: https://github.com/wovnio/wovn.php/blob/master/test/fixtures/real_html/stack_overflow_hreflang_html_entities_expected.html Initializes Quantcast and Scorecard Research tracking scripts. This is used for audience measurement and advertising analytics. ```javascript var _qevents = _qevents || [], _comscore = _comscore || []; (function () { var ssl='https:'==document.location.protocol, s=document.getElementsByTagName('script')[0], qc=document.createElement('script'); qc.async = true; qc.src = (ssl ? 'https://secure' : 'http://edge') + '.quantserve.com/quant.js'; s.parentNode.insertBefore(qc, s); _qevents.push({ qacct: "p-c1rF4kxgLUzNc" }); var sc=document.createElement('script'); sc.async=true; sc.src=(ssl?'https://sb':'http://b') + '.scorecardresearch.com/beacon.js'; s.parentNode.insertBefore(sc, s); _comscore.push({ c1: "2", c2: "17440561" }); })(); ```