WordPress.org

Make WordPress Core

Ticket #3068: testcase.php

File testcase.php, 686 bytes (added by shadytrees, 15 years ago)

An example cache plug-in that could write data to two different places

Line 
1<?php
2/*
3Plugin Name: Fleece
4*/
5
6// Caches recent comment IDs into a text file
7// so a different plug-in can use the text cache
8// instead of hitting the database server with
9// another query.
10function fleece() {
11        global $wpdb;
12       
13        // Boo. Hidden, database magic.
14        $recent_comment_IDs = $wpdb->get_results(...);
15       
16        // Serialize IDs into text and write to a file.
17        // Where the file is written changes depending on action.
18        // Result: Other plug-in and plug-in developer becomes
19        // massively confused.
20        file_put_contents('commentIdsCache.txt', implode(',', $recent_comment_IDs));
21}
22
23add_action('comment_post', 'fleece');
24add_action('delete_comment', 'fleece');
25?>