{"id":66074,"date":"2017-04-07T15:58:15","date_gmt":"2017-04-07T15:58:15","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/browsersync-triggers\/"},"modified":"2022-06-23T15:45:12","modified_gmt":"2022-06-23T15:45:12","slug":"trigger-browsersync","status":"publish","type":"plugin","link":"https:\/\/pcd.wordpress.org\/plugins\/trigger-browsersync\/","author":13642574,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"0.8.6","stable_tag":"trunk","tested":"","requires":"3.0.1","requires_php":"","requires_plugins":"","header_name":"Trigger Browsersync","header_author":"Sami Greenbury","header_description":"Integrate Browser-Sync with WordPress - for example to trigger a reload when saving a page.","assets_banners_color":"f3db9a","last_updated":"2022-06-23 15:45:12","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/paypal.me\/patabugen\/5","header_plugin_uri":"https:\/\/www.patabugen.co.uk\/","header_author_uri":"http:\/\/www.patabugen.co.uk\/","rating":4.7,"author_block_rating":0,"active_installs":10,"downloads":1835,"num_ratings":3,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":"1","5":"2"},"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":1634350,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.png":{"filename":"icon-256x256.png","revision":1634350,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":{"banner-722x250.png":{"filename":"banner-722x250.png","revision":1634319,"resolution":"722x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[569,139227,2985,5827],"plugin_category":[],"plugin_contributors":[139228],"plugin_business_model":[],"class_list":["post-66074","plugin","type-plugin","status-publish","hentry","plugin_tags-automation","plugin_tags-browsersync","plugin_tags-dev","plugin_tags-refresh","plugin_contributors-patabugen","plugin_committers-patabugen"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/trigger-browsersync\/assets\/icon-128x128.png?rev=1634350","icon_2x":"https:\/\/ps.w.org\/trigger-browsersync\/assets\/icon-256x256.png?rev=1634350","generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Integrates WordPress with Browsersync to trigger events like reload when you edit pages.<\/p>\n\n<p>The plugin also only triggers a reload for now. If you have requests or ideas for other functionality, get in touch.<\/p>\n\n<p>Since you (should) disable this plugin on production sites, the WordPress stats won't be reliable - if you find the plugin useful I'd really appreciate it if you'd let me know with a quick email or message!<\/p>\n\n<h4>Triggers<\/h4>\n\n<p>By default the plugin will trigger a reload on these actions:<\/p>\n\n<ul>\n<li>save_post - Editing posts\/pages\/custom posts etc<\/li>\n<li>added_option - Changing settings<\/li>\n<li>attachment_updated - Editing media fields (caption etc)<\/li>\n<li>updated_postmeta - Covers many things, particularly regenerating media thumbnails. Some meta_fields are ignored (see <code>trigger_browsersync_irrelevant_meta_keys<\/code>)<\/li>\n<li>activated_plugin<\/li>\n<li>deactivated_plugin<\/li>\n<li>delete_widget<\/li>\n<\/ul>\n\n<p>you can customise this as well as other Browsersync settings using filters:<\/p>\n\n<pre><code>add_filter('trigger_browsersync_reload_actions', function($filters) {\n    \/\/ Remove a default. Bear in mind that one action you take (e.g. saving a page)\n    \/\/ may trigger more than one hook.\n    unset($filters['save_post']);\n    \/\/ Add your own. The key name lets other filters remove it (like the line above)\n    $filters['wp_logout'] = 'wp_logout';\n    return $filters;\n});\n<\/code><\/pre>\n\n<h4>Ignoring Meta Keys<\/h4>\n\n<p>Not all meta_key updates (triggered by <code>updated_postmeta<\/code>) have any impact on the front-end functioning of your site. You can customise which <code>meta_key<\/code> values are ignored with the <code>trigger_browsersync_irrelevant_meta_keys<\/code> filter:<\/p>\n\n<pre><code>add_filter('trigger_browsersync_irrelevant_meta_keys', function($filters) {\n    \/\/ Remove a default.\n    unset($filters['_edit_lock']);\n    \/\/ Add your own. The key name lets other filters remove it (like the line above)\n    $filters['_edit_lock'] = '_edit_lock';\n    return $filters;\n});\n<\/code><\/pre>\n\n<h4>Configuration with Filters<\/h4>\n\n<p>The default Browsersync settings will be used (<code>http:\/\/localhost:3000<\/code>) but you can use filters to change them. The filters are used every time the trigger is activated so you don't need to set them before instanciating the class.<\/p>\n\n<pre><code>add_filter('trigger_browsersync_protocol', function(){ return 'https'; } );\nadd_filter('trigger_browsersync_host', function(){ return 'dev.server'; } );\nadd_filter('trigger_browsersync_port', function(){ return '4321'; } );\n<\/code><\/pre>\n\n<p>Or you can specify the whole URL which will cause the others to be ignored, but don't include a trailing slash.<\/p>\n\n<pre><code>add_filter('trigger_browsersync_url', function(){ return 'http:\/\/localhost:3000'; } );\n<\/code><\/pre>\n\n<h4>Environmental Configuration<\/h4>\n\n<p>Since you probably only want Browsersync on your development or staging site, the plugin will do nothing once you activate it it in WordPress.<\/p>\n\n<p>To make it work, you'll want to create a file to activate it. See Installation for instructions.<\/p>\n\n<h4>Logging Activity<\/h4>\n\n<p>Trigger Browsersync can log events to the WordPress log - this is especially useful for development on the plugin when you want to add or exclude a new event from triggering an action.<\/p>\n\n<p>To enable logging add this filter to your <code>enable-trigger-browsersync.php<\/code> file (see Installation);<\/p>\n\n<pre><code>add_filter('trigger_browsersync_log_events', '__return_true');\n<\/code><\/pre>\n\n<!--section=installation-->\n<p>This plugin sends signals to an existing and running BrowserSync setup. You need to install Browsersync and integrate it with your workflow first - how do to that is outside the scope of the plugin but you can get more information at <a href=\"https:\/\/www.browsersync.io\/\">BrowserSync.io<\/a>.<\/p>\n\n<p>Install the plugin by uploading or via the plugin option in WordPress - the same as any other plugin.<\/p>\n\n<p>The plugin will do nothing unless you create an instance of <code>TriggerBrowsersync<\/code>  somewhere.<\/p>\n\n<p>You probably don't want the integration on your production server, which means you don't want the code to instanciate saved in your repo - I would recommend you create a file in mu-plugins with the code below, and then tell your version control to ignore the file.<\/p>\n\n<pre><code>&lt;?php\nadd_action( 'plugins_loaded', function(){ \/\/ Trigger after the TriggerBrowsersync plugin has loaded\n    if ( class_exists( 'TriggerBrowsersync' ) ) { \/\/ Check the TriggerBrowsersync plugin loaded correctly\n        \/\/ Add any configuration filters you may need here.\n\n        \/\/ Activate the integration by creating an instance.\n        new TriggerBrowsersync();\n    }\n} );\n<\/code><\/pre>\n\n<h4>Step by Step Example Installation<\/h4>\n\n<ul>\n<li>Create <code>wp-content\/mu-plugins\/enable-trigger-browsersync.php<\/code> (you may need to create the <code>mu-plugins<\/code> directory)<\/li>\n<li>Paste the code above in<\/li>\n<li>Edit .gitignore and add <code>wp-content\/mu-plugins\/enable-trigger-browsersync.php<\/code><\/li>\n<\/ul>\n\n<h4>All Hooks and Filters<\/h4>\n\n<p>Use filters to customise settings:<\/p>\n\n<ul>\n<li>trigger_browsersync_protocol - set the protocol for Gulp Watch (probably http or https). Defaults to http.<\/li>\n<li>trigger_browsersync_host - set the host port for Gulp Watch. Defaults to localhost<\/li>\n<li>trigger_browsersync_port - set the port for Gulp Watch. Defaults to 3000<\/li>\n<li>trigger_browsersync_url - Set the whole URL instead of the parts above (e.g. http:\/\/localhost:3000)<\/li>\n<li>trigger_browsersync_reload_actions - add\/change the actions on which to trigger a reload. See source for defaults.<\/li>\n<li>trigger_browsersync_log_events - Return true to enable log output (to the standard log)<\/li>\n<li>trigger_browsersync_irrelevant_meta_keys - Lets you ignore particular meta_keys or options<\/li>\n<li>trigger_browsersync_irrelevant_meta_key_regex - Lets you ignore particular meta_keys or options if they match preg_match<\/li>\n<\/ul>\n\n<p>You can also hook on to some actions if you wish:<\/p>\n\n<ul>\n<li>trigger_browsersync_before - Called just before we trigger anything<\/li>\n<li>trigger_browsersync_after - Called just before we trigger anything<\/li>\n<li>trigger_browsersync_before_reload - Called just before we trigger a reload<\/li>\n<li>trigger_browsersync_after_reload - Called just after we trigger a reload - the reload won't yet be done<\/li>\n<\/ul>\n\n<!--section=faq-->\n<dl>\n<dt id='i%27ve%20installed%20the%20plugin%2C%20but%20it%27s%20not%20doing%20anything.'><h3>I've installed the plugin, but it's not doing anything.<\/h3><\/dt>\n<dd><ul>\n<li>Have you followed the installation instructions? The plugin will do nothing without them.\n\n<ul>\n<li>If you're not using the default Browser Sync settings, you'll need to add filters to override them.<\/li>\n<\/ul><\/li>\n<\/ul><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>0.8.6<\/h4>\n\n<ul>\n<li>Tested with WordPress 6<\/li>\n<\/ul>\n\n<h4>0.8.5<\/h4>\n\n<ul>\n<li>Tested with WordPress 5.3<\/li>\n<li>Fixed typo bug.<\/li>\n<\/ul>\n\n<h4>0.8.4<\/h4>\n\n<ul>\n<li>Tested with WordPress 5.1<\/li>\n<\/ul>\n\n<h4>0.8.3<\/h4>\n\n<ul>\n<li>Don't trigger reload on cron updates.<\/li>\n<li>Handle logging non-string value types better.<\/li>\n<\/ul>\n\n<h4>0.8<\/h4>\n\n<ul>\n<li>Fixed bug where non-string option values would throw a fatal error<\/li>\n<\/ul>\n\n<h4>0.7<\/h4>\n\n<ul>\n<li>Added <code>trigger_browsersync_irrelevant_meta_key_regex<\/code> filter to let us ignore meta keys or options based on a regex match. Initial value excludes any meta_key or option mame containing 'cache'<\/li>\n<li>Fixed bug whereby options being changed were not logged properly<\/li>\n<li>Added the <code>trigger_browsersync_irrelevant_meta_keys<\/code> to options names<\/li>\n<li>Added <code>updated_option<\/code> to compliment existing <code>added_option<\/code><\/li>\n<\/ul>\n\n<h4>0.6<\/h4>\n\n<ul>\n<li>Added <code>delete_widget<\/code> hook<\/li>\n<\/ul>\n\n<h4>0.5<\/h4>\n\n<ul>\n<li>Initial release with reload functionality, custom settings and customisable hook\/trigger list.<\/li>\n<\/ul>","raw_excerpt":"Integrates WordPress with Browsersync to trigger events like Reload when you edit pages and settings.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/66074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=66074"}],"author":[{"embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/patabugen"}],"wp:attachment":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=66074"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=66074"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=66074"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=66074"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=66074"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=66074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}