Linux 软件免费装

Trigger Browsersync

开发者 patabugen
更新时间 2019年12月27日 20:03
捐献地址: 去捐款
PHP版本: 3.0.1 及以上
WordPress版本: 5.3.2
版权: GPLv2 or later
版权网址: 版权信息

标签

dev automation refresh browsersync

下载

详情介绍:

Integrates WordPress with Browsersync to trigger events like reload when you edit pages. The plugin also only triggers a reload for now. If you have requests or ideas for other functionality, get in touch. 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! Triggers By default the plugin will trigger a reload on these actions: you can customise this as well as other Browsersync settings using filters: add_filter('trigger_browsersync_reload_actions', function($filters) { // Remove a default. Bear in mind that one action you take (e.g. saving a page) // may trigger more than one hook. unset($filters['save_post']); // Add your own. The key name lets other filters remove it (like the line above) $filters['wp_logout'] = 'wp_logout'; return $filters; }); Ignoring Meta Keys Not all meta_key updates (triggered by updated_postmeta) have any impact on the front-end functioning of your site. You can customise which meta_key values are ignored with the trigger_browsersync_irrelevant_meta_keys filter: add_filter('trigger_browsersync_irrelevant_meta_keys', function($filters) { // Remove a default. unset($filters['_edit_lock']); // Add your own. The key name lets other filters remove it (like the line above) $filters['_edit_lock'] = '_edit_lock'; return $filters; }); Configuration with Filters The default Browsersync settings will be used (http://localhost:3000) 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. add_filter('trigger_browsersync_protocol', function(){ return 'https'; } ); add_filter('trigger_browsersync_host', function(){ return 'dev.server'; } ); add_filter('trigger_browsersync_port', function(){ return '4321'; } ); Or you can specify the whole URL which will cause the others to be ignored, but don't include a trailing slash. add_filter('trigger_browsersync_url', function(){ return 'http://localhost:3000'; } ); Environmental Configuration Since you probably only want Browsersync on your development or staging site, the plugin will do nothing once you activate it it in WordPress. To make it work, you'll want to create a file to activate it. See Installation for instructions. Logging Activity 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. To enable logging add this filter to your enable-trigger-browsersync.php file (see Installation); add_filter('trigger_browsersync_log_events', '__return_true');

安装:

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 BrowserSync.io. Install the plugin by uploading or via the plugin option in WordPress - the same as any other plugin. The plugin will do nothing unless you create an instance of TriggerBrowsersync somewhere. 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. <?php add_action( 'plugins_loaded', function(){ // Trigger after the TriggerBrowsersync plugin has loaded if ( class_exists( 'TriggerBrowsersync' ) ) { // Check the TriggerBrowsersync plugin loaded correctly // Add any configuration filters you may need here. // Activate the integration by creating an instance. new TriggerBrowsersync(); } } ); Step by Step Example Installation All Hooks and Filters Use filters to customise settings: You can also hook on to some actions if you wish:

常见问题:

I've installed the plugin, but it's not doing anything.

  • Have you followed the installation instructions? The plugin will do nothing without them.
  • If you're not using the default Browser Sync settings, you'll need to add filters to override them.

更新日志:

0.8.5 0.8.4 0.8.3 0.8 0.7 0.6 0.5