Version Description
(June 2016) =
- Added: Add shortcut to history in Admin bar for current site and in Network Admin Bar for each site where plugin is installed. Can be disabled using filters
simple_history/add_admin_bar_menu_item
andsimple_history/add_admin_bar_network_menu_item
. - Added: Add check that mbstring is enabled and show a warning if it's not.
- Changed: Changes to "Front Page Displays" in "Reading Settings" now show the name of the old and new page (before only id was logged).
- Changed: Changes to "Default Post Category" and "Default Mail Category" in "Writing Settings" now show the name of the old and new category (before only id was logged).
- Fixed: When changing "Front Page Displays" in "Reading Settings" the option "rewrite_rules" also got logged.
- Fixed: Changes in Permalink Settings were not logged correctly.
- Fixed: Actions done with WP-CLI was not correctly attributed. Now the log should say "WP-CLI" intead of "Other" for actions done in WP CLI.
Download this release
Release Info
Developer | eskapism |
Plugin | Simple History |
Version | 2.7.1 |
Comparing to | |
See all releases |
Code changes from version 2.7 to 2.7.1
- inc/SimpleHistory.php +171 -30
- index.php +9 -3
- loggers/SimpleLogger.php +2 -1
- loggers/SimpleOptionsLogger.php +340 -148
- loggers/SimplePluginLogger.php +1 -1
- readme.txt +12 -2
inc/SimpleHistory.php
CHANGED
@@ -63,8 +63,8 @@ class SimpleHistory {
|
|
63 |
/** Slug for the settings menu */
|
64 |
const SETTINGS_MENU_SLUG = "simple_history_settings_menu_slug";
|
65 |
|
66 |
-
|
67 |
-
|
68 |
|
69 |
/** ID for the general settings section */
|
70 |
const SETTINGS_SECTION_GENERAL_ID = "simple_history_settings_section_general";
|
@@ -114,6 +114,9 @@ class SimpleHistory {
|
|
114 |
|
115 |
add_filter( 'gettext', array( $this, "filter_gettext_storeLatestTranslations" ), 10, 3 );
|
116 |
|
|
|
|
|
|
|
117 |
if ( is_admin() ) {
|
118 |
|
119 |
$this->add_admin_actions();
|
@@ -183,8 +186,144 @@ class SimpleHistory {
|
|
183 |
|
184 |
add_filter( 'plugin_action_links_simple-history/index.php', array( $this, 'plugin_action_links' ), 10, 4 );
|
185 |
|
|
|
186 |
}
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
/**
|
189 |
* Get singleton intance
|
190 |
* @return SimpleHistory instance
|
@@ -1525,22 +1664,22 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
1525 |
|
1526 |
<?php
|
1527 |
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
|
1541 |
-
|
1542 |
|
1543 |
-
|
1544 |
|
1545 |
</div>
|
1546 |
<?php
|
@@ -1667,8 +1806,8 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
1667 |
);
|
1668 |
|
1669 |
// Nonces for show where inputs
|
1670 |
-
|
1671 |
-
|
1672 |
|
1673 |
// Dropdown number if items to show
|
1674 |
add_settings_field(
|
@@ -1786,6 +1925,7 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
1786 |
|
1787 |
$setting = get_option( "simple_history_show_as_page", 1 );
|
1788 |
$setting = apply_filters( "simple_history_show_as_page", $setting );
|
|
|
1789 |
return (bool) $setting;
|
1790 |
|
1791 |
}
|
@@ -1821,6 +1961,7 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
1821 |
|
1822 |
$show_on_dashboard = $this->setting_show_on_dashboard();
|
1823 |
$show_as_page = $this->setting_show_as_page();
|
|
|
1824 |
?>
|
1825 |
|
1826 |
<input <?php echo $show_on_dashboard ? "checked='checked'" : ""?> type="checkbox" value="1" name="simple_history_show_on_dashboard" id="simple_history_show_on_dashboard" class="simple_history_show_on_dashboard" />
|
@@ -2979,7 +3120,7 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
2979 |
function get_num_events_last_n_days( $period_days = 28 ) {
|
2980 |
|
2981 |
$transient_key = "sh_" . md5( __METHOD__ . $period_days . "_2");
|
2982 |
-
|
2983 |
$count = get_transient( $transient_key );
|
2984 |
|
2985 |
|
@@ -2991,8 +3132,8 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
2991 |
|
2992 |
$sql = sprintf(
|
2993 |
'
|
2994 |
-
SELECT count(*)
|
2995 |
-
FROM %1$s
|
2996 |
WHERE UNIX_TIMESTAMP(date) >= %2$d
|
2997 |
AND logger IN %3$s
|
2998 |
',
|
@@ -3000,13 +3141,13 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
3000 |
strtotime("-$period_days days"),
|
3001 |
$sqlStringLoggersUserCanRead
|
3002 |
);
|
3003 |
-
|
3004 |
$count = $wpdb->get_var( $sql );
|
3005 |
|
3006 |
set_transient( $transient_key, $count, HOUR_IN_SECONDS );
|
3007 |
|
3008 |
}
|
3009 |
-
|
3010 |
return $count;
|
3011 |
|
3012 |
} // get_num_events_last_n_days
|
@@ -3015,7 +3156,7 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
3015 |
function get_num_events_per_day_last_n_days( $period_days = 28 ) {
|
3016 |
|
3017 |
$transient_key = "sh_" . md5( __METHOD__ . $period_days . "_2");
|
3018 |
-
|
3019 |
$dates = get_transient( $transient_key );
|
3020 |
|
3021 |
if ( false === $dates ) {
|
@@ -3026,12 +3167,12 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
3026 |
|
3027 |
$sql = sprintf(
|
3028 |
'
|
3029 |
-
SELECT
|
3030 |
date_format(date, "%%Y-%%m-%%d") AS yearDate,
|
3031 |
count(date) AS count
|
3032 |
-
FROM
|
3033 |
%1$s
|
3034 |
-
WHERE
|
3035 |
UNIX_TIMESTAMP(date) >= %2$d
|
3036 |
AND logger IN (%3$d)
|
3037 |
GROUP BY yearDate
|
@@ -3048,7 +3189,7 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
3048 |
// echo "set";exit;
|
3049 |
|
3050 |
} else {
|
3051 |
-
// echo "get";exit;
|
3052 |
}
|
3053 |
|
3054 |
return $dates;
|
@@ -3069,13 +3210,13 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
3069 |
$numEvents = get_transient( $cache_key );
|
3070 |
|
3071 |
if ( false == $numEvents ) {
|
3072 |
-
|
3073 |
$sql = $wpdb->prepare("
|
3074 |
SELECT count( DISTINCT occasionsID )
|
3075 |
FROM $table_name
|
3076 |
-
WHERE date >= DATE_ADD(CURDATE(), INTERVAL -%d DAY)
|
3077 |
", $days);
|
3078 |
-
|
3079 |
$numEvents = $wpdb->get_var($sql);
|
3080 |
|
3081 |
set_transient( $cache_key, $numEvents, HOUR_IN_SECONDS );
|
@@ -3189,7 +3330,7 @@ function simple_history_text_diff( $left_string, $right_string, $args = null ) {
|
|
3189 |
|
3190 |
if ( ! $diff )
|
3191 |
return '';
|
3192 |
-
|
3193 |
$r = "";
|
3194 |
|
3195 |
$r .= "<div class='SimpleHistory__diff__contents' tabindex='0'>";
|
63 |
/** Slug for the settings menu */
|
64 |
const SETTINGS_MENU_SLUG = "simple_history_settings_menu_slug";
|
65 |
|
66 |
+
/** Slug for the settings menu */
|
67 |
+
const SETTINGS_GENERAL_OPTION_GROUP = "simple_history_settings_group";
|
68 |
|
69 |
/** ID for the general settings section */
|
70 |
const SETTINGS_SECTION_GENERAL_ID = "simple_history_settings_section_general";
|
114 |
|
115 |
add_filter( 'gettext', array( $this, "filter_gettext_storeLatestTranslations" ), 10, 3 );
|
116 |
|
117 |
+
add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_network_menu_item' ), 40 );
|
118 |
+
add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_menu_item' ), 40 );
|
119 |
+
|
120 |
if ( is_admin() ) {
|
121 |
|
122 |
$this->add_admin_actions();
|
186 |
|
187 |
add_filter( 'plugin_action_links_simple-history/index.php', array( $this, 'plugin_action_links' ), 10, 4 );
|
188 |
|
189 |
+
|
190 |
}
|
191 |
|
192 |
+
/**
|
193 |
+
* Adds a "View history" item/shortcut to the network admin, on blogs where Simple History is installed
|
194 |
+
*
|
195 |
+
* Useful because Simple History is something at least the author of this plugin often use on a site :)
|
196 |
+
*
|
197 |
+
* @since 2.7.1
|
198 |
+
*/
|
199 |
+
function add_admin_bar_network_menu_item( $wp_admin_bar ) {
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Filter to control if admin bar shortcut should be added
|
203 |
+
*
|
204 |
+
* @since 2.7.1
|
205 |
+
*
|
206 |
+
* @param bool Add item
|
207 |
+
*/
|
208 |
+
$add_items = apply_filters( "simple_history/add_admin_bar_network_menu_item", true );
|
209 |
+
|
210 |
+
if ( ! $add_items ) {
|
211 |
+
return;
|
212 |
+
}
|
213 |
+
|
214 |
+
// Don't show for logged out users or single site mode.
|
215 |
+
if ( ! is_user_logged_in() || ! is_multisite() )
|
216 |
+
return;
|
217 |
+
|
218 |
+
// Show only when the user has at least one site, or they're a super admin.
|
219 |
+
if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() )
|
220 |
+
return;
|
221 |
+
|
222 |
+
// Setting to show as page must be true
|
223 |
+
if ( ! $this->setting_show_as_page() ) {
|
224 |
+
return;
|
225 |
+
}
|
226 |
+
|
227 |
+
// User must have capability to view the history page
|
228 |
+
if ( ! current_user_can( $this->get_view_history_capability() ) ) {
|
229 |
+
return $actions;
|
230 |
+
}
|
231 |
+
|
232 |
+
/* menu_page_url() is defined in the WordPress Plugin Administration API, which is not loaded here by default */
|
233 |
+
/* dito for is_plugin_active() */
|
234 |
+
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
235 |
+
|
236 |
+
foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
|
237 |
+
|
238 |
+
switch_to_blog( $blog->userblog_id );
|
239 |
+
|
240 |
+
if ( is_plugin_active( SIMPLE_HISTORY_BASENAME ) ) {
|
241 |
+
|
242 |
+
$menu_id = "simple-history-blog-" . $blog->userblog_id;
|
243 |
+
$parent_menu_id = 'blog-' . $blog->userblog_id;
|
244 |
+
$url = admin_url( "index.php?page=simple_history_page" );
|
245 |
+
|
246 |
+
// Each network site is added by WP core with id "blog-1", "blog-2" ... "blog-n"
|
247 |
+
// https://codex.wordpress.org/Function_Reference/add_node
|
248 |
+
$args = array(
|
249 |
+
'id' => $menu_id,
|
250 |
+
'parent' => $parent_menu_id,
|
251 |
+
'title' => _x("View History", "Admin bar network name", "simple-history"),
|
252 |
+
'href' => $url,
|
253 |
+
'meta' => array(
|
254 |
+
'class' => 'ab-item--simplehistory'
|
255 |
+
)
|
256 |
+
);
|
257 |
+
|
258 |
+
$wp_admin_bar->add_node( $args );
|
259 |
+
|
260 |
+
} // if plugin active
|
261 |
+
|
262 |
+
restore_current_blog();
|
263 |
+
|
264 |
+
} // foreach blog
|
265 |
+
|
266 |
+
} // func
|
267 |
+
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Adds a "View history" item/shortcut to the admin bar
|
271 |
+
*
|
272 |
+
* Useful because Simple History is something at least the author of this plugin often use on a site :)
|
273 |
+
*
|
274 |
+
* @since 2.7.1
|
275 |
+
*/
|
276 |
+
function add_admin_bar_menu_item( $wp_admin_bar ) {
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Filter to control if admin bar shortcut should be added
|
280 |
+
*
|
281 |
+
* @since 2.7.1
|
282 |
+
*
|
283 |
+
* @param bool Add item
|
284 |
+
*/
|
285 |
+
$add_item = apply_filters( "simple_history/add_admin_bar_menu_item", true );
|
286 |
+
|
287 |
+
if ( ! $add_item ) {
|
288 |
+
return;
|
289 |
+
}
|
290 |
+
|
291 |
+
// Don't show for logged out users
|
292 |
+
if ( ! is_user_logged_in() )
|
293 |
+
return;
|
294 |
+
|
295 |
+
// Setting to show as page must be true
|
296 |
+
if ( ! $this->setting_show_as_page() ) {
|
297 |
+
return;
|
298 |
+
}
|
299 |
+
|
300 |
+
// User must have capability to view the history page
|
301 |
+
if ( ! current_user_can( $this->get_view_history_capability() ) ) {
|
302 |
+
return $actions;
|
303 |
+
}
|
304 |
+
|
305 |
+
/* menu_page_url() is defined in the WordPress Plugin Administration API, which is not loaded here by default */
|
306 |
+
/* dito for is_plugin_active() */
|
307 |
+
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
308 |
+
|
309 |
+
$menu_id = "simple-history-view-history";
|
310 |
+
$parent_menu_id = 'site-name';
|
311 |
+
$url = admin_url( "index.php?page=simple_history_page" );
|
312 |
+
|
313 |
+
$args = array(
|
314 |
+
'id' => $menu_id,
|
315 |
+
'parent' => $parent_menu_id,
|
316 |
+
'title' => _x("Simple History", "Admin bar name", "simple-history"),
|
317 |
+
'href' => $url,
|
318 |
+
'meta' => array(
|
319 |
+
'class' => 'ab-item--simplehistory'
|
320 |
+
)
|
321 |
+
);
|
322 |
+
|
323 |
+
$wp_admin_bar->add_node( $args );
|
324 |
+
|
325 |
+
} // func
|
326 |
+
|
327 |
/**
|
328 |
* Get singleton intance
|
329 |
* @return SimpleHistory instance
|
1664 |
|
1665 |
<?php
|
1666 |
|
1667 |
+
// Output contents for selected tab
|
1668 |
+
$arr_active_tab = wp_filter_object_list( $arr_settings_tabs, array( "slug" => $active_tab ) );
|
1669 |
+
$arr_active_tab = current( $arr_active_tab );
|
1670 |
|
1671 |
+
// We must have found an active tab and it must have a callable function
|
1672 |
+
if ( ! $arr_active_tab || ! is_callable( $arr_active_tab["function"] ) ) {
|
1673 |
+
wp_die( __( "No valid callback found", "simple-history" ) );
|
1674 |
+
}
|
1675 |
|
1676 |
+
$args = array(
|
1677 |
+
"arr_active_tab" => $arr_active_tab,
|
1678 |
+
);
|
1679 |
|
1680 |
+
call_user_func_array( $arr_active_tab["function"], $args );
|
1681 |
|
1682 |
+
?>
|
1683 |
|
1684 |
</div>
|
1685 |
<?php
|
1806 |
);
|
1807 |
|
1808 |
// Nonces for show where inputs
|
1809 |
+
register_setting( SimpleHistory::SETTINGS_GENERAL_OPTION_GROUP, "simple_history_show_on_dashboard" );
|
1810 |
+
register_setting( SimpleHistory::SETTINGS_GENERAL_OPTION_GROUP, "simple_history_show_as_page" );
|
1811 |
|
1812 |
// Dropdown number if items to show
|
1813 |
add_settings_field(
|
1925 |
|
1926 |
$setting = get_option( "simple_history_show_as_page", 1 );
|
1927 |
$setting = apply_filters( "simple_history_show_as_page", $setting );
|
1928 |
+
|
1929 |
return (bool) $setting;
|
1930 |
|
1931 |
}
|
1961 |
|
1962 |
$show_on_dashboard = $this->setting_show_on_dashboard();
|
1963 |
$show_as_page = $this->setting_show_as_page();
|
1964 |
+
|
1965 |
?>
|
1966 |
|
1967 |
<input <?php echo $show_on_dashboard ? "checked='checked'" : ""?> type="checkbox" value="1" name="simple_history_show_on_dashboard" id="simple_history_show_on_dashboard" class="simple_history_show_on_dashboard" />
|
3120 |
function get_num_events_last_n_days( $period_days = 28 ) {
|
3121 |
|
3122 |
$transient_key = "sh_" . md5( __METHOD__ . $period_days . "_2");
|
3123 |
+
|
3124 |
$count = get_transient( $transient_key );
|
3125 |
|
3126 |
|
3132 |
|
3133 |
$sql = sprintf(
|
3134 |
'
|
3135 |
+
SELECT count(*)
|
3136 |
+
FROM %1$s
|
3137 |
WHERE UNIX_TIMESTAMP(date) >= %2$d
|
3138 |
AND logger IN %3$s
|
3139 |
',
|
3141 |
strtotime("-$period_days days"),
|
3142 |
$sqlStringLoggersUserCanRead
|
3143 |
);
|
3144 |
+
|
3145 |
$count = $wpdb->get_var( $sql );
|
3146 |
|
3147 |
set_transient( $transient_key, $count, HOUR_IN_SECONDS );
|
3148 |
|
3149 |
}
|
3150 |
+
|
3151 |
return $count;
|
3152 |
|
3153 |
} // get_num_events_last_n_days
|
3156 |
function get_num_events_per_day_last_n_days( $period_days = 28 ) {
|
3157 |
|
3158 |
$transient_key = "sh_" . md5( __METHOD__ . $period_days . "_2");
|
3159 |
+
|
3160 |
$dates = get_transient( $transient_key );
|
3161 |
|
3162 |
if ( false === $dates ) {
|
3167 |
|
3168 |
$sql = sprintf(
|
3169 |
'
|
3170 |
+
SELECT
|
3171 |
date_format(date, "%%Y-%%m-%%d") AS yearDate,
|
3172 |
count(date) AS count
|
3173 |
+
FROM
|
3174 |
%1$s
|
3175 |
+
WHERE
|
3176 |
UNIX_TIMESTAMP(date) >= %2$d
|
3177 |
AND logger IN (%3$d)
|
3178 |
GROUP BY yearDate
|
3189 |
// echo "set";exit;
|
3190 |
|
3191 |
} else {
|
3192 |
+
// echo "get";exit;
|
3193 |
}
|
3194 |
|
3195 |
return $dates;
|
3210 |
$numEvents = get_transient( $cache_key );
|
3211 |
|
3212 |
if ( false == $numEvents ) {
|
3213 |
+
|
3214 |
$sql = $wpdb->prepare("
|
3215 |
SELECT count( DISTINCT occasionsID )
|
3216 |
FROM $table_name
|
3217 |
+
WHERE date >= DATE_ADD(CURDATE(), INTERVAL -%d DAY)
|
3218 |
", $days);
|
3219 |
+
|
3220 |
$numEvents = $wpdb->get_var($sql);
|
3221 |
|
3222 |
set_transient( $cache_key, $numEvents, HOUR_IN_SECONDS );
|
3330 |
|
3331 |
if ( ! $diff )
|
3332 |
return '';
|
3333 |
+
|
3334 |
$r = "";
|
3335 |
|
3336 |
$r .= "<div class='SimpleHistory__diff__contents' tabindex='0'>";
|
index.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://simple-history.com
|
|
5 |
Text Domain: simple-history
|
6 |
Domain Path: /languages
|
7 |
Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
|
8 |
-
Version: 2.7
|
9 |
Author: Pär Thernström
|
10 |
Author URI: http://simple-history.com/
|
11 |
License: GPL2
|
@@ -32,7 +32,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
32 |
die;
|
33 |
}
|
34 |
|
35 |
-
if ( version_compare( phpversion(), "5.3", ">=") ) {
|
36 |
|
37 |
/**
|
38 |
* Register function that is called when plugin is installed
|
@@ -42,7 +42,7 @@ if ( version_compare( phpversion(), "5.3", ">=") ) {
|
|
42 |
// register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
|
43 |
|
44 |
if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
|
45 |
-
define( 'SIMPLE_HISTORY_VERSION', '2.7' );
|
46 |
}
|
47 |
|
48 |
if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
|
@@ -94,10 +94,16 @@ if ( version_compare( phpversion(), "5.3", ">=") ) {
|
|
94 |
?>
|
95 |
<div class="updated error">
|
96 |
<p><?php
|
|
|
97 |
printf(
|
98 |
__( 'Simple History is a great plugin, but to use it your server must have at least PHP 5.3 installed (you have version %s).', 'simple-history' ),
|
99 |
phpversion()
|
100 |
);
|
|
|
|
|
|
|
|
|
|
|
101 |
?></p>
|
102 |
</div>
|
103 |
<?php
|
5 |
Text Domain: simple-history
|
6 |
Domain Path: /languages
|
7 |
Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
|
8 |
+
Version: 2.7.1
|
9 |
Author: Pär Thernström
|
10 |
Author URI: http://simple-history.com/
|
11 |
License: GPL2
|
32 |
die;
|
33 |
}
|
34 |
|
35 |
+
if ( version_compare( phpversion(), "5.3", ">=") && function_exists( "mb_strimwidth" ) ) {
|
36 |
|
37 |
/**
|
38 |
* Register function that is called when plugin is installed
|
42 |
// register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
|
43 |
|
44 |
if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
|
45 |
+
define( 'SIMPLE_HISTORY_VERSION', '2.7.1' );
|
46 |
}
|
47 |
|
48 |
if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
|
94 |
?>
|
95 |
<div class="updated error">
|
96 |
<p><?php
|
97 |
+
|
98 |
printf(
|
99 |
__( 'Simple History is a great plugin, but to use it your server must have at least PHP 5.3 installed (you have version %s).', 'simple-history' ),
|
100 |
phpversion()
|
101 |
);
|
102 |
+
|
103 |
+
if ( ! function_exists("mb_strimwidth") ) {
|
104 |
+
__('You also need the mbstring extension to be enabled in PHP.', "simple-history");
|
105 |
+
}
|
106 |
+
|
107 |
?></p>
|
108 |
</div>
|
109 |
<?php
|
loggers/SimpleLogger.php
CHANGED
@@ -1110,7 +1110,8 @@ class SimpleLogger {
|
|
1110 |
// - it is a user that is manually doing this, on purpose, with intent, so not auto wordpress
|
1111 |
// - it is a specific user, but we don't know who
|
1112 |
// - sounds like a special case, set initiator to wp_cli
|
1113 |
-
|
|
|
1114 |
|
1115 |
$data["initiator"] = SimpleLoggerLogInitiators::WP_CLI;
|
1116 |
|
1110 |
// - it is a user that is manually doing this, on purpose, with intent, so not auto wordpress
|
1111 |
// - it is a specific user, but we don't know who
|
1112 |
// - sounds like a special case, set initiator to wp_cli
|
1113 |
+
// Can be used by plugins/themes to check if WP-CLI is running or not
|
1114 |
+
if ( defined( "WP_CLI" ) && WP_CLI ) {
|
1115 |
|
1116 |
$data["initiator"] = SimpleLoggerLogInitiators::WP_CLI;
|
1117 |
|
loggers/SimpleOptionsLogger.php
CHANGED
@@ -2,122 +2,6 @@
|
|
2 |
|
3 |
defined( 'ABSPATH' ) or die();
|
4 |
|
5 |
-
/*
|
6 |
-
|
7 |
-
<form> is posted to options.php
|
8 |
-
|
9 |
-
If $_GET['action'] == 'update' we are saving settings sent from a settings page
|
10 |
-
|
11 |
-
update_option( $option, $value );
|
12 |
-
set_transient('settings_errors', get_settings_errors(), 30);
|
13 |
-
|
14 |
-
|
15 |
-
* Fires immediately before an option value is updated.
|
16 |
-
* @param string $option Name of the option to update.
|
17 |
-
* @param mixed $old_value The old option value.
|
18 |
-
* @param mixed $value The new option value.
|
19 |
-
do_action( 'update_option', $option, $old_value, $value );
|
20 |
-
|
21 |
-
|
22 |
-
* Fires after the value of an option has been successfully updated.
|
23 |
-
*
|
24 |
-
* @since 2.9.0
|
25 |
-
*
|
26 |
-
* @param string $option Name of the updated option.
|
27 |
-
* @param mixed $old_value The old option value.
|
28 |
-
* @param mixed $value The new option value.
|
29 |
-
do_action( 'updated_option', $option, $old_value, $value );
|
30 |
-
|
31 |
-
options white list.
|
32 |
-
$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
|
33 |
-
Array
|
34 |
-
(
|
35 |
-
[general] => Array
|
36 |
-
(
|
37 |
-
[0] => blogname
|
38 |
-
[1] => blogdescription
|
39 |
-
[2] => gmt_offset
|
40 |
-
[3] => date_format
|
41 |
-
[4] => time_format
|
42 |
-
[5] => start_of_week
|
43 |
-
[6] => timezone_string
|
44 |
-
[7] => siteurl
|
45 |
-
[8] => home
|
46 |
-
[9] => admin_email
|
47 |
-
[10] => users_can_register
|
48 |
-
[11] => default_role
|
49 |
-
)
|
50 |
-
|
51 |
-
[discussion] => Array
|
52 |
-
(
|
53 |
-
[0] => default_pingback_flag
|
54 |
-
[1] => default_ping_status
|
55 |
-
[2] => default_comment_status
|
56 |
-
[3] => comments_notify
|
57 |
-
[4] => moderation_notify
|
58 |
-
[5] => comment_moderation
|
59 |
-
[6] => require_name_email
|
60 |
-
[7] => comment_whitelist
|
61 |
-
[8] => comment_max_links
|
62 |
-
[9] => moderation_keys
|
63 |
-
[10] => blacklist_keys
|
64 |
-
[11] => show_avatars
|
65 |
-
[12] => avatar_rating
|
66 |
-
[13] => avatar_default
|
67 |
-
[14] => close_comments_for_old_posts
|
68 |
-
[15] => close_comments_days_old
|
69 |
-
[16] => thread_comments
|
70 |
-
[17] => thread_comments_depth
|
71 |
-
[18] => page_comments
|
72 |
-
[19] => comments_per_page
|
73 |
-
[20] => default_comments_page
|
74 |
-
[21] => comment_order
|
75 |
-
[22] => comment_registration
|
76 |
-
)
|
77 |
-
|
78 |
-
[media] => Array
|
79 |
-
(
|
80 |
-
[0] => thumbnail_size_w
|
81 |
-
[1] => thumbnail_size_h
|
82 |
-
[2] => thumbnail_crop
|
83 |
-
[3] => medium_size_w
|
84 |
-
[4] => medium_size_h
|
85 |
-
[5] => large_size_w
|
86 |
-
[6] => large_size_h
|
87 |
-
[7] => image_default_size
|
88 |
-
[8] => image_default_align
|
89 |
-
[9] => image_default_link_type
|
90 |
-
[10] => uploads_use_yearmonth_folders
|
91 |
-
)
|
92 |
-
|
93 |
-
[reading] => Array
|
94 |
-
(
|
95 |
-
[0] => posts_per_page
|
96 |
-
[1] => posts_per_rss
|
97 |
-
[2] => rss_use_excerpt
|
98 |
-
[3] => show_on_front
|
99 |
-
[4] => page_on_front
|
100 |
-
[5] => page_for_posts
|
101 |
-
[6] => blog_public
|
102 |
-
)
|
103 |
-
|
104 |
-
[writing] => Array
|
105 |
-
(
|
106 |
-
[0] => use_smilies
|
107 |
-
[1] => default_category
|
108 |
-
[2] => default_email_category
|
109 |
-
[3] => use_balanceTags
|
110 |
-
[4] => default_link_category
|
111 |
-
[5] => default_post_format
|
112 |
-
[6] => mailserver_url
|
113 |
-
[7] => mailserver_port
|
114 |
-
[8] => mailserver_login
|
115 |
-
[9] => mailserver_pass
|
116 |
-
[10] => ping_sites
|
117 |
-
)
|
118 |
-
|
119 |
-
*/
|
120 |
-
|
121 |
/**
|
122 |
* Logs changes to wordpress options
|
123 |
*/
|
@@ -172,9 +56,9 @@ class SimpleOptionsLogger extends SimpleLogger
|
|
172 |
|
173 |
}
|
174 |
|
175 |
-
function on_updated_option($option, $old_value, $new_value) {
|
176 |
|
177 |
-
if (empty( $_SERVER["REQUEST_URI"] )) {
|
178 |
return;
|
179 |
}
|
180 |
|
@@ -200,20 +84,103 @@ class SimpleOptionsLogger extends SimpleLogger
|
|
200 |
'writing',
|
201 |
);
|
202 |
|
203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
return;
|
205 |
}
|
206 |
|
207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
'option' => $option,
|
209 |
'old_value' => $old_value,
|
210 |
'new_value' => $new_value,
|
211 |
-
'REQUEST_URI' => $_SERVER['REQUEST_URI'],
|
212 |
-
'referer' => wp_get_referer(),
|
213 |
'option_page' => $option_page,
|
214 |
-
'
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
218 |
}
|
219 |
|
@@ -225,6 +192,18 @@ class SimpleOptionsLogger extends SimpleLogger
|
|
225 |
$context = $row->context;
|
226 |
$message_key = $context["_message_key"];
|
227 |
$output = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
if ( "option_updated" == $message_key ) {
|
230 |
|
@@ -234,31 +213,42 @@ class SimpleOptionsLogger extends SimpleLogger
|
|
234 |
// Output old and new values
|
235 |
if ( $context["new_value"] || $context["old_value"] ) {
|
236 |
|
237 |
-
$
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
-
$output .= sprintf(
|
249 |
-
'
|
250 |
-
<tr>
|
251 |
-
<td>%1$s</td>
|
252 |
-
<td>%2$s</td>
|
253 |
-
</tr>
|
254 |
-
',
|
255 |
-
__("Old value", "simple-history"),
|
256 |
-
esc_html( mb_strimwidth( $context["old_value"], 0, 250, "..." ) )
|
257 |
-
);
|
258 |
-
}
|
259 |
|
260 |
// If key option_page this was saved from regular settings pages
|
261 |
-
if ( ! empty( $
|
262 |
|
263 |
$output .= sprintf(
|
264 |
'
|
@@ -269,13 +259,13 @@ class SimpleOptionsLogger extends SimpleLogger
|
|
269 |
',
|
270 |
__("Settings page", "simple-history"),
|
271 |
esc_html( $context["option_page"] ),
|
272 |
-
admin_url("options-{$
|
273 |
);
|
274 |
|
275 |
}
|
276 |
|
277 |
// If option = permalink_structure then we did it from permalink page
|
278 |
-
if ( ! empty( $
|
279 |
|
280 |
$output .= sprintf(
|
281 |
'
|
@@ -298,4 +288,206 @@ class SimpleOptionsLogger extends SimpleLogger
|
|
298 |
return $output;
|
299 |
|
300 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
}
|
2 |
|
3 |
defined( 'ABSPATH' ) or die();
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
/**
|
6 |
* Logs changes to wordpress options
|
7 |
*/
|
56 |
|
57 |
}
|
58 |
|
59 |
+
function on_updated_option( $option, $old_value, $new_value ) {
|
60 |
|
61 |
+
if ( empty( $_SERVER["REQUEST_URI"] ) ) {
|
62 |
return;
|
63 |
}
|
64 |
|
84 |
'writing',
|
85 |
);
|
86 |
|
87 |
+
$is_valid_options_page = $option_page && in_array( $option_page, $arr_valid_option_pages );
|
88 |
+
|
89 |
+
// Permalink settings page does not post any "option_page", so use http referer instead
|
90 |
+
if ( strpos( $_SERVER["REQUEST_URI"], "options-permalink.php" ) !== false ) {
|
91 |
+
$is_valid_options_page = true;
|
92 |
+
$options_page = "permalink";
|
93 |
+
}
|
94 |
+
|
95 |
+
if ( ! $is_valid_options_page ) {
|
96 |
return;
|
97 |
}
|
98 |
|
99 |
+
// Check if option name is ok
|
100 |
+
// For example if you change front page displays setting the "rewrite_rules" options gets updated too
|
101 |
+
$arr_invalid_option_names = array(
|
102 |
+
"rewrite_rules"
|
103 |
+
);
|
104 |
+
|
105 |
+
if ( in_array( $option, $arr_invalid_option_names ) ) {
|
106 |
+
return;
|
107 |
+
}
|
108 |
+
|
109 |
+
$context = array(
|
110 |
'option' => $option,
|
111 |
'old_value' => $old_value,
|
112 |
'new_value' => $new_value,
|
|
|
|
|
113 |
'option_page' => $option_page,
|
114 |
+
#'referer' => wp_get_referer(),
|
115 |
+
#'REQUEST_URI' => $_SERVER['REQUEST_URI'],
|
116 |
+
#'$_REQUEST' => print_r($_REQUEST, true),
|
117 |
+
);
|
118 |
+
|
119 |
+
// Store a bit more about some options
|
120 |
+
// Like "page_on_front" we also store post title
|
121 |
+
// Check for a method for current option in this class and calls it automagically
|
122 |
+
$methodname = "add_context_for_option_{$option}";
|
123 |
+
if ( method_exists( $this, $methodname ) ) {
|
124 |
+
$context = $this->$methodname( $context, $old_value, $new_value, $option, $option_page );
|
125 |
+
}
|
126 |
+
|
127 |
+
$this->infoMessage( 'option_updated', $context );
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Give some options better plain text output
|
133 |
+
*
|
134 |
+
* Not doing anything at the moment, because it was really difficaly to give them meaningful text values
|
135 |
+
*/
|
136 |
+
public function getLogRowPlainTextOutput( $row ) {
|
137 |
+
|
138 |
+
$message = $row->message;
|
139 |
+
$context = $row->context;
|
140 |
+
$message_key = $context["_message_key"];
|
141 |
|
142 |
+
$return_message = "";
|
143 |
+
|
144 |
+
// Only link to attachment if it is still available
|
145 |
+
if ( "option_updated" == $message_key ) {
|
146 |
+
|
147 |
+
/*
|
148 |
+
$option = isset( $context["option"] ) ? $context["option"] : null;
|
149 |
+
$option_page = isset( $context["option_page"] ) ? $context["option_page"] : null;
|
150 |
+
$new_value = isset( $context["new_value"] ) ? $context["new_value"] : null;
|
151 |
+
$old_value = isset( $context["old_value"] ) ? $context["old_value"] : null;
|
152 |
+
|
153 |
+
# $return_message = "";
|
154 |
+
$arr_options_to_translate = array(
|
155 |
+
"$option_page/blog_public" => array(
|
156 |
+
"text" => "Updated setting Search Engine Visibility"
|
157 |
+
),
|
158 |
+
"$option_page/rss_use_excerpt" => array(
|
159 |
+
"text" => "Updated setting For each article in a feed, show"
|
160 |
+
),
|
161 |
+
"$option_page/posts_per_rss" => array(
|
162 |
+
"text" => "Updated setting for Syndication feeds show the most recent"
|
163 |
+
),
|
164 |
+
"$option_page/posts_per_page" => array(
|
165 |
+
"text" => "Updated setting for Blog pages show at most"
|
166 |
+
)
|
167 |
+
);
|
168 |
+
|
169 |
+
if ( isset( $arr_options_to_translate[ "{$option_page}/{$option}" ] ) ) {
|
170 |
+
$return_message = $arr_options_to_translate[ "{$option_page}/{$option}" ]["text"];
|
171 |
+
}
|
172 |
+
*/
|
173 |
+
|
174 |
+
}
|
175 |
+
|
176 |
+
if ( empty( $return_message ) ) {
|
177 |
+
|
178 |
+
// No specific text to output, fallback to default
|
179 |
+
$return_message = parent::getLogRowPlainTextOutput( $row );
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
return $return_message;
|
184 |
|
185 |
}
|
186 |
|
192 |
$context = $row->context;
|
193 |
$message_key = $context["_message_key"];
|
194 |
$output = "";
|
195 |
+
|
196 |
+
$option = isset( $context["option"] ) ? $context["option"] : null;
|
197 |
+
$option_page = isset( $context["option_page"] ) ? $context["option_page"] : null;
|
198 |
+
$new_value = isset( $context["new_value"] ) ? $context["new_value"] : null;
|
199 |
+
$old_value = isset( $context["old_value"] ) ? $context["old_value"] : null;
|
200 |
+
|
201 |
+
$tmpl_row = '
|
202 |
+
<tr>
|
203 |
+
<td>%1$s</td>
|
204 |
+
<td>%2$s</td>
|
205 |
+
</tr>
|
206 |
+
';
|
207 |
|
208 |
if ( "option_updated" == $message_key ) {
|
209 |
|
213 |
// Output old and new values
|
214 |
if ( $context["new_value"] || $context["old_value"] ) {
|
215 |
|
216 |
+
$option_custom_output = "";
|
217 |
+
$methodname = "get_details_output_for_option_{$option}";
|
218 |
+
|
219 |
+
if ( method_exists( $this, $methodname ) ) {
|
220 |
+
$option_custom_output = $this->$methodname( $context, $old_value, $new_value, $option, $option_page, $tmpl_row );
|
221 |
+
}
|
222 |
+
|
223 |
+
if ( empty( $option_custom_output ) ) {
|
224 |
+
|
225 |
+
// all other options or fallback if custom output did not find all it's stuff
|
226 |
+
|
227 |
+
$output .= sprintf(
|
228 |
+
$tmpl_row,
|
229 |
+
__("New value", "simple-history"),
|
230 |
+
esc_html( mb_strimwidth( $new_value, 0, 250, "..." ) )
|
231 |
+
);
|
232 |
+
|
233 |
+
$output .= sprintf(
|
234 |
+
$tmpl_row,
|
235 |
+
__("Old value", "simple-history"),
|
236 |
+
esc_html( mb_strimwidth( $old_value, 0, 250, "..." ) )
|
237 |
+
);
|
238 |
+
|
239 |
+
|
240 |
+
} else {
|
241 |
+
|
242 |
+
$output .= $option_custom_output;
|
243 |
+
|
244 |
+
} // if option output
|
245 |
+
|
246 |
+
|
247 |
+
} // if new or old val
|
248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
|
250 |
// If key option_page this was saved from regular settings pages
|
251 |
+
if ( ! empty( $option_page ) ) {
|
252 |
|
253 |
$output .= sprintf(
|
254 |
'
|
259 |
',
|
260 |
__("Settings page", "simple-history"),
|
261 |
esc_html( $context["option_page"] ),
|
262 |
+
admin_url("options-{$option_page}.php")
|
263 |
);
|
264 |
|
265 |
}
|
266 |
|
267 |
// If option = permalink_structure then we did it from permalink page
|
268 |
+
if ( ! empty( $option ) && ( "permalink_structure" == $option || "tag_base" == $option || "category_base" == $option ) ) {
|
269 |
|
270 |
$output .= sprintf(
|
271 |
'
|
288 |
return $output;
|
289 |
|
290 |
}
|
291 |
+
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Page on front = "Front page displays" -> Your latest posts / A static page
|
295 |
+
* value 0 = Your latest post
|
296 |
+
* value int n = A static page
|
297 |
+
*/
|
298 |
+
function add_context_for_option_page_on_front( $context, $old_value, $new_value, $option, $option_page ) {
|
299 |
+
|
300 |
+
if ( ! empty( $old_value ) && is_numeric( $old_value ) ) {
|
301 |
+
|
302 |
+
$old_post = get_post( $old_value );
|
303 |
+
|
304 |
+
if ( $old_post ) {
|
305 |
+
$context["old_post_title"] = $old_post->post_title;
|
306 |
+
}
|
307 |
+
|
308 |
+
}
|
309 |
+
|
310 |
+
if ( ! empty( $new_value ) && is_numeric( $new_value ) ) {
|
311 |
+
|
312 |
+
$new_post = get_post( $new_value );
|
313 |
+
|
314 |
+
if ( $new_post ) {
|
315 |
+
$context["new_post_title"] = $new_post->post_title;
|
316 |
+
}
|
317 |
+
|
318 |
+
}
|
319 |
+
|
320 |
+
return $context;
|
321 |
+
|
322 |
+
}
|
323 |
+
|
324 |
+
function add_context_for_option_page_for_posts( $context, $old_value, $new_value, $option, $option_page ) {
|
325 |
+
|
326 |
+
// Get same info as for page_on_front
|
327 |
+
$context = call_user_func_array( array( $this, "add_context_for_option_page_on_front"), func_get_args() );
|
328 |
+
|
329 |
+
return $context;
|
330 |
+
|
331 |
+
}
|
332 |
+
|
333 |
+
function get_details_output_for_option_page_for_posts( $context, $old_value, $new_value, $option, $option_page ) {
|
334 |
+
|
335 |
+
$output = call_user_func_array( array( $this, "get_details_output_for_option_page_on_front"), func_get_args() );
|
336 |
+
|
337 |
+
return $output;
|
338 |
+
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Add detailed putput for page_on_front
|
343 |
+
*
|
344 |
+
* @return string output
|
345 |
+
*/
|
346 |
+
function get_details_output_for_option_page_on_front( $context, $old_value, $new_value, $option, $option_page, $tmpl_row ) {
|
347 |
+
|
348 |
+
$output = "";
|
349 |
+
|
350 |
+
if ( $new_value && ! empty( $context["new_post_title"] ) ) {
|
351 |
+
|
352 |
+
$post_title_with_link = "";
|
353 |
+
|
354 |
+
if ( get_post_status( $new_value ) ) {
|
355 |
+
$post_title_with_link = sprintf('<a href="%1$s">%2$s</a>', get_edit_post_link( $new_value ), esc_html( $context["new_post_title"] ) );
|
356 |
+
} else {
|
357 |
+
$post_title_with_link = esc_html( $context["new_post_title"] );
|
358 |
+
}
|
359 |
+
|
360 |
+
$output .= sprintf(
|
361 |
+
$tmpl_row,
|
362 |
+
__("New value", "simple-history"),
|
363 |
+
sprintf( __('Page %1$s', "simple-history" ), $post_title_with_link)
|
364 |
+
);
|
365 |
+
|
366 |
+
}
|
367 |
+
if ( intval( $new_value ) == 0 ) {
|
368 |
+
|
369 |
+
$output .= sprintf(
|
370 |
+
$tmpl_row,
|
371 |
+
__("New value", "simple-history"),
|
372 |
+
__("Your latests posts", "simple-history")
|
373 |
+
);
|
374 |
+
|
375 |
+
}
|
376 |
+
|
377 |
+
if ( $old_value && ! empty( $context["old_post_title"] ) ) {
|
378 |
+
$post_title_with_link = "";
|
379 |
+
|
380 |
+
if ( get_post_status( $old_value ) ) {
|
381 |
+
$post_title_with_link = sprintf('<a href="%1$s">%2$s</a>', get_edit_post_link( $old_value ), esc_html( $context["old_post_title"] ) );
|
382 |
+
} else {
|
383 |
+
$post_title_with_link = esc_html( $context["old_post_title"] );
|
384 |
+
}
|
385 |
+
|
386 |
+
$output .= sprintf(
|
387 |
+
$tmpl_row,
|
388 |
+
__("Old value", "simple-history"),
|
389 |
+
sprintf( __('Page %1$s', "simple-history" ), $post_title_with_link)
|
390 |
+
);
|
391 |
+
|
392 |
+
}
|
393 |
+
|
394 |
+
if ( intval( $old_value ) == 0 ) {
|
395 |
+
|
396 |
+
$output .= sprintf(
|
397 |
+
$tmpl_row,
|
398 |
+
__("Old value", "simple-history"),
|
399 |
+
__("Your latests posts", "simple-history")
|
400 |
+
);
|
401 |
+
|
402 |
+
}
|
403 |
+
|
404 |
+
return $output;
|
405 |
+
|
406 |
+
} // custom output page_on_front
|
407 |
+
|
408 |
+
|
409 |
+
/**
|
410 |
+
* "default_category" = Writing Settings » Default Post Category
|
411 |
+
*/
|
412 |
+
function add_context_for_option_default_category( $context, $old_value, $new_value, $option, $option_page ) {
|
413 |
+
|
414 |
+
if ( ! empty( $old_value ) && is_numeric( $old_value ) ) {
|
415 |
+
|
416 |
+
$old_category_name = get_the_category_by_ID( $old_value );
|
417 |
+
|
418 |
+
if ( ! is_wp_error( $old_category_name) ) {
|
419 |
+
|
420 |
+
$context["old_category_name"] = $old_category_name;
|
421 |
+
|
422 |
+
}
|
423 |
+
|
424 |
+
}
|
425 |
+
|
426 |
+
if ( ! empty( $new_value ) && is_numeric( $new_value ) ) {
|
427 |
+
|
428 |
+
$new_category_name = get_the_category_by_ID( $new_value );
|
429 |
+
|
430 |
+
if ( ! is_wp_error( $new_category_name) ) {
|
431 |
+
|
432 |
+
$context["new_category_name"] = $new_category_name;
|
433 |
+
|
434 |
+
}
|
435 |
+
|
436 |
+
}
|
437 |
+
|
438 |
+
return $context;
|
439 |
+
|
440 |
+
}
|
441 |
+
|
442 |
+
function add_context_for_option_default_email_category( $context, $old_value, $new_value, $option, $option_page ) {
|
443 |
+
|
444 |
+
$context = call_user_func_array( array( $this, "add_context_for_option_default_category"), func_get_args() );
|
445 |
+
|
446 |
+
return $context;
|
447 |
+
|
448 |
+
}
|
449 |
+
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Add detailed putput for default_category
|
453 |
+
*
|
454 |
+
* @return string output
|
455 |
+
*/
|
456 |
+
function get_details_output_for_option_default_category( $context, $old_value, $new_value, $option, $option_page, $tmpl_row ) {
|
457 |
+
|
458 |
+
$old_category_name = isset( $context["old_category_name"] ) ? $context["old_category_name"] : null;
|
459 |
+
$new_category_name = isset( $context["new_category_name"] ) ? $context["new_category_name"] : null;
|
460 |
+
|
461 |
+
if ( $old_category_name ) {
|
462 |
+
|
463 |
+
$output .= sprintf(
|
464 |
+
$tmpl_row,
|
465 |
+
__("Old value", "simple-history"),
|
466 |
+
esc_html( $old_category_name )
|
467 |
+
);
|
468 |
+
|
469 |
+
}
|
470 |
+
|
471 |
+
if ( $new_category_name ) {
|
472 |
+
|
473 |
+
$output .= sprintf(
|
474 |
+
$tmpl_row,
|
475 |
+
__("New value", "simple-history"),
|
476 |
+
esc_html( $new_category_name )
|
477 |
+
);
|
478 |
+
|
479 |
+
}
|
480 |
+
|
481 |
+
return $output;
|
482 |
+
|
483 |
+
}
|
484 |
+
|
485 |
+
function get_details_output_for_option_default_email_category( $context, $old_value, $new_value, $option, $option_page, $tmpl_row ) {
|
486 |
+
|
487 |
+
$output = call_user_func_array( array( $this, "get_details_output_for_option_default_category"), func_get_args() );
|
488 |
+
|
489 |
+
return $output;
|
490 |
+
|
491 |
+
}
|
492 |
+
|
493 |
}
|
loggers/SimplePluginLogger.php
CHANGED
@@ -296,7 +296,7 @@ class SimplePluginLogger extends SimpleLogger
|
|
296 |
* Saves info about all installed plugins to an option.
|
297 |
* When we are done logging then we remove the option.
|
298 |
*/
|
299 |
-
|
300 |
|
301 |
$plugins = get_plugins();
|
302 |
|
296 |
* Saves info about all installed plugins to an option.
|
297 |
* When we are done logging then we remove the option.
|
298 |
*/
|
299 |
+
function save_versions_before_update($bool = null, $hook_extra = null) {
|
300 |
|
301 |
$plugins = get_plugins();
|
302 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://eskapism.se/sida/donate/
|
|
4 |
Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, cms, dashboard, admin, syslog, feed, activity, stream, audit trail, brute-force
|
5 |
Requires at least: 4.5.1
|
6 |
Tested up to: 4.5.2
|
7 |
-
Stable tag: 2.7
|
8 |
|
9 |
View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
|
10 |
|
@@ -140,7 +140,7 @@ initiated by a specific user.
|
|
140 |
|
141 |
6. See even more details about a logged event (by clicking on the date and time of the event).
|
142 |
|
143 |
-
7. A chart with some quick statistics is available, so you can see the number of events that has been logged each day.
|
144 |
A simple way to see any uncommon activity, for example an increased number of logins or similar.
|
145 |
|
146 |
8. When users are created or changed you can see details on what have changed.
|
@@ -149,6 +149,16 @@ A simple way to see any uncommon activity, for example an increased number of lo
|
|
149 |
|
150 |
## Changelog
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
= 2.7 (May 2016) =
|
153 |
|
154 |
- Added: When a user is created or edited the log now shows what fields have changed and from what old value to what new value. A much requested feature!
|
4 |
Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, cms, dashboard, admin, syslog, feed, activity, stream, audit trail, brute-force
|
5 |
Requires at least: 4.5.1
|
6 |
Tested up to: 4.5.2
|
7 |
+
Stable tag: 2.7.1
|
8 |
|
9 |
View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
|
10 |
|
140 |
|
141 |
6. See even more details about a logged event (by clicking on the date and time of the event).
|
142 |
|
143 |
+
7. A chart with some quick statistics is available, so you can see the number of events that has been logged each day.
|
144 |
A simple way to see any uncommon activity, for example an increased number of logins or similar.
|
145 |
|
146 |
8. When users are created or changed you can see details on what have changed.
|
149 |
|
150 |
## Changelog
|
151 |
|
152 |
+
= 2.7.1 (June 2016) =
|
153 |
+
|
154 |
+
- Added: Add shortcut to history in Admin bar for current site and in Network Admin Bar for each site where plugin is installed. Can be disabled using filters `simple_history/add_admin_bar_menu_item` and `simple_history/add_admin_bar_network_menu_item`.
|
155 |
+
- Added: Add check that [´mbstring´](http://php.net/manual/en/book.mbstring.php) is enabled and show a warning if it's not.
|
156 |
+
- Changed: Changes to "Front Page Displays" in "Reading Settings" now show the name of the old and new page (before only id was logged).
|
157 |
+
- Changed: Changes to "Default Post Category" and "Default Mail Category" in "Writing Settings" now show the name of the old and new category (before only id was logged).
|
158 |
+
- Fixed: When changing "Front Page Displays" in "Reading Settings" the option "rewrite_rules" also got logged.
|
159 |
+
- Fixed: Changes in Permalink Settings were not logged correctly.
|
160 |
+
- Fixed: Actions done with [WP-CLI](https://wp-cli.org/) was not correctly attributed. Now the log should say "WP-CLI" intead of "Other" for actions done in WP CLI.
|
161 |
+
|
162 |
= 2.7 (May 2016) =
|
163 |
|
164 |
- Added: When a user is created or edited the log now shows what fields have changed and from what old value to what new value. A much requested feature!
|