en en en en en en en en en en en es en en en en en en en en en en en en en en en en en en en en en de en de en de en de en en en fr en ja zh eu eu th th en ja en en en en en en en en en en en en en en en en en en en en en en fa en en en en en en en es en en en en pt en en en fr en pt en fr en pt en en en en en en en en id en en en
A developer plugin for WordPress that adds hooks to enable the logging of data from the site to a specified MySQL database.
Last update: 2022-09-01 22:06:17 UTC
Not using Composer? Download an archive of the code and drop it into the mu-plugins directory.
$2 Create a proxy PHP loader file inside the mu-plugins directory, or use the one included with the plugin:
The sample autoloader contains the basic code required to initialize the plugin. It will...
Add the statc_register with a sample to get started with creating a trigger to write information to your database.
Add the statc_bootstrap with a sample query to create tables in your database for the data to be stored in.
Require all files containing classes.
Create an admin settings page under Settings > Stat Collector for configuration.
Send Notifications - Wether or not to email the administrator if there is a connection error.
Tables Created - A notice that database tables have been created using the statc_bootstrap hook.
Certificate Authority - A notice that a certificate authority has been found.
Connection - A notice that a connection can be made using the credetials above.
Stat Collector uses the Amazon Web Services RDS certificate bundle for making MySQL connections over SSL.
Hook for internal actions that collect information to write to the DB.
Class StatCollector - An instance of StatCollector.
add_action('statc_register', function($statc) { add_action('my_action', function($data) use ($statc) { if (gettype($data) === 'string') { $statc->collect('my_table', [ 'my_data' => $data, ]); } }, $statc->settings->priority, 2); return true; });
Hook for plugin post-instantiation.
Class StatCollector - An instance of StatCollector.
Hook for bootstrapping the database.
Class wpdb - An instance of wpdb with a connection to your database.
add_action('statc_bootstrap', function($db) { $db->query( 'CREATE TABLE IF NOT EXISTS my_table ( id INT(11) NOT NULL AUTO_INCREMENT, my_data TEXT DEFAULT NULL, PRIMARY KEY(id) ) ENGINE=InnoDB' ); return true; });
The Mayor's Office for Economic Opportunity (NYC Opportunity) is committed to sharing open source software that we use in our products. Feel free to ask questions and share feedback. Interested in contributing? See our open positions on buildwithnyc.github.io. Follow our team on Github (if you are part of the @cityofnewyork organization) or browse our work on Github.