PluginProbe
FeedWordPress / 2012.1212
FeedWordPress v2012.1212
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
feedwordpress / performance-page.php

performance-page.php in FeedWordPress 2012.1212, at performance-page.php

158 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 require_once(dirname(__FILE__) . '/admin-ui.php');
3
4 class FeedWordPressPerformancePage extends FeedWordPressAdminPage {
5 function FeedWordPressPerformancePage () {
6 // Set meta-box context name
7 FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressperformancepage');
8 $this->dispatch = 'feedwordpress_performance';
9 $this->filename = __FILE__;
10 }
11
12 function has_link () { return false; }
13
14 function display () {
15 global $wpdb, $wp_db_version, $fwp_path;
16 global $fwp_post;
17
18 if (FeedWordPress::needs_upgrade()) :
19 fwp_upgrade_page();
20 return;
21 endif;
22
23 // If this is a POST, validate source and user credentials
24 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_performance', /*capability=*/ 'manage_options');
25
26 if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
27 $this->accept_POST($fwp_post);
28 do_action('feedwordpress_admin_page_performance_save', $GLOBALS['fwp_post'], $this);
29 endif;
30
31 ////////////////////////////////////////////////
32 // Prepare settings page ///////////////////////
33 ////////////////////////////////////////////////
34
35 $this->display_update_notice_if_updated('Performance');
36
37 $this->open_sheet('FeedWordPress Performance');
38 ?>
39 <div id="post-body">
40 <?php
41 $boxes_by_methods = array(
42 'performance_box' => __('Performance'),
43 );
44
45 foreach ($boxes_by_methods as $method => $title) :
46 add_meta_box(
47 /*id=*/ 'feedwordpress_'.$method,
48 /*title=*/ $title,
49 /*callback=*/ array('FeedWordPressPerformancePage', $method),
50 /*page=*/ $this->meta_box_context(),
51 /*context=*/ $this->meta_box_context()
52 );
53 endforeach;
54 do_action('feedwordpress_admin_page_performance_meta_boxes', $this);
55 ?>
56 <div class="metabox-holder">
57 <?php
58 fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
59 ?>
60 </div> <!-- class="metabox-holder" -->
61 </div> <!-- id="post-body" -->
62
63 <?php
64 $this->close_sheet();
65 } /* FeedWordPressPerformancePage::display () */
66
67 function accept_POST ($post) {
68 if (isset($post['create_index'])) :
69 FeedWordPress::create_guid_index();
70 $this->updated = __('guid column index created on database table.');
71 endif;
72 if (isset($post['remove_index'])) :
73 FeedWordPress::remove_guid_index();
74 $this->updated = __('guid column index removed from database table.');
75 endif;
76
77 if (isset($post['clear_cache'])) :
78 $N = FeedWordPress::clear_cache();
79 $feeds = (($N == 1) ? __("feed") : __("feeds"));
80 $this->updated = sprintf(__("Cleared %d cached %s from WordPress database."), $N, $feeds);
81 endif;
82
83 if (isset($post['optimize_in'])) :
84 update_option('feedwordpress_optimize_in_clauses', true);
85 $this->updated = sprintf(__("Enabled optimizing inefficient IN clauses in SQL queries."));
86 elseif (isset($post['optimize_out'])) :
87 update_option('feedwordpress_optimize_in_clauses', false);
88 $this->updated = sprintf(__("Disabled optimizing inefficient IN clauses in SQL queries."));
89 endif;
90 } /* FeedWordPressPerformancePage::accept_POST () */
91
92 /*static*/ function performance_box ($page, $box = NULL) {
93 $optimize_in = get_option('feedwordpress_optimize_in_clauses', false);
94
95 // Hey ho, let's go...
96 ?>
97 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
98 <tr style="vertical-align: top">
99 <th width="33%" scope="row">Feed cache:</th>
100 <td width="67%"><input class="button" type="submit" name="clear_cache" value="Clear all cached feeds from WordPress database" />
101 <p>This will clear all cached copies of feed data from the WordPress database
102 and force FeedWordPress to make a fresh scan for updates on syndicated feeds.</p></td></tr>
103
104 <tr style="vertical-align: top">
105 <th width="33%" scope="row">Guid index:</th>
106 <td width="67%"><?php if (!FeedWordPress::has_guid_index()) : ?>
107 <input class="button" type="submit" name="create_index" value="Create index on guid column in posts database table" />
108 <p>Creating this index may significantly improve performance on some large
109 FeedWordPress installations.</p>
110 <?php else : ?>
111
112 <p>You have already created an index on the guid column in the WordPress posts
113 table. If you'd like to remove the index for any reason, you can do so here.</p>
114
115 <input class="button" type="submit" name="remove_index" value="Remove index on guid column in posts database table" />
116
117 <?php endif; ?>
118
119 <tr style="vertical-align: top">
120 <th width="33%" scope="row">Optimize IN clauses:</th>
121 <td width="67%"><?php if (!$optimize_in) : ?>
122 <input class="button" type="submit" name="optimize_in" value="Optimize inefficient IN clauses in SQL queries" />
123
124 <p><strong>Advanced setting.</strong> As of releases up to 3.3.2, WordPress
125 still generates many SQL queries with an extremely inefficient use of the IN
126 operator (for example, <code>SELECT user_id, meta_key, meta_value FROM
127 wp_usermeta WHERE user_id IN (1)</code>). When there is only one item in the
128 set, the IN operator is unnecessary; and inefficient, because it prevents SQL
129 from making use of indexes on the table being queried. Activating this setting
130 will cause these queries to get rewritten to use a simple equality operator when
131 there is only one item in the set (for example, the example query above would be
132 rewritten as <code>SELECT user_id, meta_key, meta_value FROM wp_usermeta WHERE
133 user_id = 1</code>).</p>
134
135 <p><strong>Note.</strong> This is an advanced setting, which affects WordPress's
136 database queries at a very low level. The change should be harmless, but
137 proceed with caution, and only if you are confident in your ability to restore
138 your WordPress installation from backups if something important should stop
139 working.</p>
140
141 <?php else : ?>
142 <input class="button" type="submit" name="optimize_out" value="Disable optimizing inefficient IN clauses" />
143 <p>You can use this setting to disable any attempts by FeedWordPress to optimize
144 or rewrite WordPress's SQL queries.</p>
145 <?php endif; ?></td>
146 </tr>
147
148 </td>
149 </tr>
150 </table>
151 <?php
152 } /* FeedWordPressPerformancePage::performance_box () */
153 } /* class FeedWordPressPerformancePage */
154
155 $performancePage = new FeedWordPressPerformancePage;
156 $performancePage->display();
157
158