Best way for storing them is WordPress’ Options Mechanism.
ANd best way to trigger it when a post saved is using WordPress save_post action.
Example :
add_action( 'save_post', 'count' ); //Execute count() when a post saved/updated
function count()
{
your codes here ...
//save them to DB
update_option("lines-of-code", $lines);
update_option("disk-space", $diskspace);
...
}
Related Posts:
- Undefined function mysql_connect()
- MySQL “Or” Condition
- Transaction when using WP functions rather than vanilla SQL?
- Can i use php sql functions instead of $wpdb?
- How to validate WordPress generated password in DB using PHP?
- Custom query to get post names beginning with a digit
- How To Make Connection To WordPress Data Base In A Plugin?
- Jquery ajax to custom php file: returning blank data
- Add value to usermeta without removing previous values?
- How can I call a row of user specific data from a custom table added to the WP Database
- How to merge local and live databases?
- Successful or Error Message after running mysql code in functions.php
- sql query to put quotes around numbers in img tag
- Performance issues with large website [closed]
- Create a quick start wordpress installation [closed]
- theme options echoing multiple times
- PHP/MySQL issues when running WP on EC2 cloud [closed]
- WordPress 3 – how are passwords stored and how do I compare to them?
- WordPress get pagination on wpdb get_results
- How to create another version of my site based on the same database
- how to echo all tables that start with a prefix
- Strange wordpress slowness
- Looking for most performant way to execute several similar WP queries within shortcodes
- How to select WooCommerce products by post_meta and order them
- Setting All Drafts to ‘exclude-from-catalog’ in WooCommerce
- Stumped on migration
- PHP code inside shortcodes
- Show MySQL errors that occur when I excute $wpdb->insert()
- Is XAMPP faster than running LAMP in WSL on Windows 10? [closed]
- Remove one value in dismissed_wp_pointers?
- WordPress Site Running Extremely Slow on Dedicated Server
- Accessing data from a non-WP database/table within a page content
- Get updated query results on page after insert in database
- WordPress not reflecting changed of the database
- How can I fix WordPress installation errors?
- How can I save unique user data on my site? [closed]
- Ordering users by custom user meta
- How to split links generated into an xml sitemap to avoid exceeding 30 sec maximum execution time?
- Hacked WordPress website /Homepage redirect [closed]
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- Refresh table data with Ajax
- Database query works fine outside WordPress
- Large Woocommerce Site (83,000 items), What Can I Do? [closed]
- WordPress SQL injection
- multiple where condition in result query
- Grouping posts by a custom meta value
- Mixing variables into an array when inserting values
- wpdb prepare insert table doesn’t work
- Make a database query using WordPress
- Basic wpdb update question
- I can’t update my data through $wpdb
- Output: “Array”
- Using wordpress function to retrieve data
- Live search from database table
- form $_post action value gets truncated after it passes through two forms
- phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- Add row to custom database Table and delete all rows older than 1 day
- making php value numeric
- How to create Loop code for Menu using WordPress?
- How to WP_Query posts order by parent title?
- Convert a column of a table containing an Array as response in HTML
- Please help! I have a problem with getting wordpress databas
- How to run complex query using PHP
- Error establishing a database connection (Set-up locally)
- Usermeta data unserialize, extract and display in table in WordPress
- Conditional formatting on data fetched from MYSQL
- Can I split a huge wp_postmeta table across different databases or servers?
- how to get data from two different table from wordpress database
- Passing Current User ID into SQL statement
- How to insert multiple rows and columns in database using array
- WordPress mysql deos not work with php7
- How can i limit the number of posts to the most recent 6 in my query?
- Error inserting into custom table – Object of class wpdb could not be converted to string [closed]
- Windows Setup: Error establishing a database connection
- WP + MySql db / PHP
- The plugin generated 225 characters of unexpected output during activation
- WAMP SERVER Command Prompt SET PATH=%PATH%
- append data to mysql table via submit button coded in php – not working
- WordPress select query issue
- How to do a MySql query in WordPress?
- How can get all users by current user meta (array)?
- Add two or multiple functions in WordPress Post or Page
- Send data from plugin to external database
- Processing forms with php to wordpress database
- How to set max users to 17.000
- Passed variable gets undefined variable error on insert on next page
- directorypress theme error mysql_error() [closed]
- How to set up an auto delete post?
- How to connect database table to each registered wordpress user.
- Using the same shortcode to show any table from the database
- Cannot Upload Custom Header Image into WordPress Dashboard
- MySQL update text field with ‘
- Predefine Magazine Style Layouts
- I am unable to fetch json data from wp_db
- Parse error: syntax error, unexpected ‘}’ in C:\xampp\htdocs\admin\products.php on line 148 [closed]
- How to send push notification in android using php? [closed]
- How to set variable to specific field when querying
- Getting invalid user ID error when creating a new user with wp_insert_user
- Custom form that stores data in mysql database
- How to return count number from a wordpress database