diff --git a/.gitignore b/.gitignore
index e763934..74b008e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
node_modules
todo
/assets/block-editor/build/
-/blocks/build/
\ No newline at end of file
+/blocks/build/
+.idea
diff --git a/functions.php b/functions.php
index 5056a14..627b4e1 100644
--- a/functions.php
+++ b/functions.php
@@ -11,7 +11,7 @@
/**
* Call the republish function directly
- *
+ *
* @since 1.8.0
* @param bool $escape Escape true|false
* @param bool $only_date Return only date true|false
@@ -30,13 +30,13 @@ function get_the_last_modified_info( $escape = false, $only_date = false ) {
/**
* Call the republish function directly
- *
+ *
* @since 1.8.0
* @param bool $escape Escape true|false
* @param bool $date Return only date true|false
*/
function the_last_modified_info( $escape = false, $date = false ) {
// displays/echos the last modified info.
- echo get_the_last_modified_info( $escape, $date );
+ echo get_the_last_modified_info( $escape, $date ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
-}
\ No newline at end of file
+}
diff --git a/inc/Api/Callbacks/AdminCallbacks.php b/inc/Api/Callbacks/AdminCallbacks.php
index 4603926..d5e3108 100644
--- a/inc/Api/Callbacks/AdminCallbacks.php
+++ b/inc/Api/Callbacks/AdminCallbacks.php
@@ -1,4 +1,4 @@
-
+
sectionHeader( $attr['title'], $attr['description'] ); ?>
@@ -48,4 +48,4 @@ public function doSettingsSection( $attr ) { ?>
'wplmi_enable_plugin',
] );
}
-
- /* ==============================================================================================
- Template Tags
+
+ /* ==============================================================================================
+ Template Tags
============================================================================================== */
public function template_date_type( $args ) {
@@ -251,8 +253,8 @@ public function template_display_info( $args ) {
] );
}
- /* ==============================================================================================
- Schema Options
+ /* ==============================================================================================
+ Schema Options
============================================================================================== */
public function enable_schema( $args ) {
@@ -270,7 +272,7 @@ public function enable_schema( $args ) {
],
] );
}
-
+
public function schema_post_types( $args ) {
$this->do_field( [
'type' => 'multiple',
@@ -283,7 +285,7 @@ public function schema_post_types( $args ) {
'condition' => [ 'wplmi_enable_schema', '=', 'enable' ],
] );
}
-
+
public function enhanced_schema( $args ) {
$this->do_field( [
'type' => 'checkbox',
@@ -294,11 +296,11 @@ public function enhanced_schema( $args ) {
'condition' => [ 'wplmi_enable_schema', '=', 'inline' ],
] );
}
-
- /* ==============================================================================================
- Notification Options
+
+ /* ==============================================================================================
+ Notification Options
============================================================================================== */
-
+
public function enable_notification( $args ) {
$this->do_field( [
'type' => 'checkbox',
@@ -308,7 +310,7 @@ public function enable_notification( $args ) {
'description' => __( 'Enable this if you want to receive email notification if anyone makes changes to any post of your blog.', 'wp-last-modified-info' ),
] );
}
-
+
public function author_notification( $args ) {
$this->do_field( [
'type' => 'checkbox',
@@ -319,7 +321,7 @@ public function author_notification( $args ) {
'show_if' => 'wplmi_enable_notification',
] );
}
-
+
public function draft_notification( $args ) {
$this->do_field( [
'type' => 'checkbox',
@@ -330,7 +332,7 @@ public function draft_notification( $args ) {
'show_if' => 'wplmi_enable_notification',
] );
}
-
+
public function recipients_list( $args ) {
$this->do_field( [
'id' => $args['label_for'],
@@ -342,7 +344,7 @@ public function recipients_list( $args ) {
'show_if' => 'wplmi_enable_notification',
] );
}
-
+
public function notification_post_types( $args ) {
$this->do_field( [
'type' => 'multiple',
@@ -370,7 +372,7 @@ public function email_notification_subject( $args ) {
'show_if' => 'wplmi_enable_notification',
] );
}
-
+
public function email_notification_message( $args ) {
$default = 'The following changes are made on a %post_type% of your blog by %modified_author_name%' . "\n\n" . '
Post: %post_title%
%post_diff%
';
$this->do_field( [
@@ -383,10 +385,10 @@ public function email_notification_message( $args ) {
] );
}
- /* ==============================================================================================
+ /* ==============================================================================================
Misc Options
============================================================================================== */
-
+
public function admin_bar( $args ) {
$this->do_field( [
'type' => 'checkbox',
@@ -396,7 +398,7 @@ public function admin_bar( $args ) {
'description' => __( 'Enable this if you want to show last modified info on WordPress admin bar.', 'wp-last-modified-info' ),
] );
}
-
+
public function disable_plugin_info( $args ) {
$this->do_field( [
'type' => 'checkbox',
@@ -406,7 +408,7 @@ public function disable_plugin_info( $args ) {
'description' => __( 'Enable this if you do not want to show last updated info on plugins page.', 'wp-last-modified-info' ),
] );
}
-
+
public function admin_sort_order( $args ) {
$this->do_field( [
'type' => 'select',
@@ -421,7 +423,7 @@ public function admin_sort_order( $args ) {
],
] );
}
-
+
public function sort_order( $args ) {
$this->do_field( [
'type' => 'select',
@@ -436,7 +438,7 @@ public function sort_order( $args ) {
],
] );
}
-
+
public function replace_date( $args ) {
$this->do_field( [
'type' => 'select',
@@ -451,7 +453,7 @@ public function replace_date( $args ) {
],
] );
}
-
+
public function custom_css( $args ) {
$this->do_field( [
'type' => 'textarea',
@@ -462,7 +464,7 @@ public function custom_css( $args ) {
'description' => sprintf( __( 'Do not add %s tag. This tag is not required, as it is already added.', 'wp-last-modified-info' ), '
<style></style>
' ),
] );
}
-
+
public function delete_data( $args ) {
$this->do_field( [
'type' => 'checkbox',
@@ -475,29 +477,30 @@ public function delete_data( $args ) {
/**
* Generate template tags output.
- *
+ *
* @since 1.8.0
*/
private function generate_template_tags( $tags ) {
ob_start() ?>
%' . esc_html( $tag ) . '%';
@@ -505,4 +508,4 @@ private function get_available_tags( $tags ) {
return join( ' ', $content );
}
-}
\ No newline at end of file
+}
diff --git a/inc/Base/AdminNotice.php b/inc/Base/AdminNotice.php
index d64b29b..cf69759 100644
--- a/inc/Base/AdminNotice.php
+++ b/inc/Base/AdminNotice.php
@@ -1,4 +1,4 @@
-
' . __( 'Your version of PHP is below the minimum version of PHP required by WP Last Modified Info plugin. Please contact your host and request that your version be upgraded to 5.6 or later.', 'wp-last-modified-info' ) . '
';
+ echo '
' . esc_html__( 'Your version of PHP is below the minimum version of PHP required by WP Last Modified Info plugin. Please contact your host and request that your version be upgraded to 5.6 or later.', 'wp-last-modified-info' ) . '
';
return;
}
-
+
// Check transient, if available display notice
if ( get_transient( 'wplmi-show-notice-on-activation' ) !== false ) { ?>
-
here to configure plugin settings.', 'wp-last-modified-info' ), 'WP Last Modified Info', esc_html( $this->version ), esc_url( admin_url( 'options-general.php?page=wp-last-modified-info' ) ) ); ?>
+ printf( esc_html__( 'Thanks for installing %1$s v%2$s plugin. Click
here to configure plugin settings.', 'wp-last-modified-info' ), 'WP Last Modified Info', esc_html( $this->version ), esc_url( admin_url( 'options-general.php?page=wp-last-modified-info' ) ) ); ?>
-
+
-
5-star rating on WordPress? Just to help us spread the word and boost my motivation.', 'wp-last-modified-info' ); ?>
+
= wp_kses_post( 'Hey, I noticed you\'ve been using WP Last Modified Info for more than 1 week – that’s awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress? Just to help us spread the word and boost my motivation.', 'wp-last-modified-info' ); ?>
- |
- |
-
+
|
+
|
+
-
+
-
+
= wp_kses_post( 'Hey, I noticed you\'ve been using WP Last Modified Info for more than 2 week – that’s awesome! If you like WP Last Modified Info and you are satisfied with the plugin, isn’t that worth a coffee or two? Please consider donating. Donations help me to continue support and development of this free plugin! Thank you very much!', 'wp-last-modified-info' ); ?>
- |
- |
-
+
|
+
|
+
load( 'css', 'admin', 'admin.min.css', $this->version );
$this->load( 'css', 'selectize', 'selectize.min.css', '0.15.2' );
$this->load( 'css', 'confirm', 'jquery-confirm.min.css', '3.3.4' );
-
+
$this->load( 'js', 'selectize', 'selectize.min.js', '0.15.2', [ 'jquery' ] );
$this->load( 'js', 'confirm', 'jquery-confirm.min.js', '3.3.4', [ 'jquery' ] );
$this->load( 'js', 'admin', 'admin.min.js', $this->version, [ 'jquery', 'jquery-form', 'jquery-ui-resizable', 'wplmi-confirm', 'wplmi-selectize' ] );
-
+
$args = [
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'copied' => __( 'Copied!', 'wp-last-modified-info' ),
@@ -121,4 +122,4 @@ private function load( $type, $handle, $name, $version, $dep = [], $end = true )
wp_enqueue_script( 'wplmi-' . $handle, $this->plugin_url . 'assets/js/' . $name, $dep, $version, $end );
}
}
-}
\ No newline at end of file
+}
diff --git a/inc/Base/PluginTools.php b/inc/Base/PluginTools.php
index ba12129..613885c 100644
--- a/inc/Base/PluginTools.php
+++ b/inc/Base/PluginTools.php
@@ -1,4 +1,4 @@
-ajax( 'process_import_plugin_data', 'import_data' );
$this->ajax( 'process_delete_plugin_data', 'remove_settings' );
}
-
+
/**
* Process a settings export that generates a .json file
*/
public function export_settings() {
- if ( empty( $_POST['wplmi_export_action'] ) || 'wplmi_export_settings' != $_POST['wplmi_export_action'] ) {
+ if ( empty( $_POST['wplmi_export_action'] ) || 'wplmi_export_settings' !== $_POST['wplmi_export_action'] ) {
return;
}
- if ( ! wp_verify_nonce( $_POST['wplmi_export_nonce'], 'wplmi_export_nonce' ) ) {
+ if ( ! isset( $_POST['wplmi_export_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wplmi_export_nonce'] ) ), 'wplmi_export_nonce' ) ) {
return;
}
@@ -64,7 +66,7 @@ public function export_settings() {
header( 'Content-Disposition: attachment; filename=' . str_replace( '/', '-', $output ) . '-wplmi-export-' . date( 'm-d-Y' ) . '.json' );
header( "Expires: 0" );
- echo json_encode( $settings );
+ echo wp_json_encode( $settings );
exit;
}
@@ -72,11 +74,11 @@ public function export_settings() {
* Process a settings import from a json file
*/
public function import_settings() {
- if ( empty( $_POST['wplmi_import_action'] ) || 'wplmi_import_settings' != $_POST['wplmi_import_action'] ) {
+ if ( empty( $_POST['wplmi_import_action'] ) || 'wplmi_import_settings' !== $_POST['wplmi_import_action'] ) {
return;
}
- if ( ! wp_verify_nonce( $_POST['wplmi_import_nonce'], 'wplmi_import_nonce' ) ) {
+ if ( ! isset( $_POST['wplmi_import_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wplmi_import_nonce'] ) ), 'wplmi_import_nonce' ) ) {
return;
}
@@ -84,24 +86,30 @@ public function import_settings() {
return;
}
- $extension = explode( '.', sanitize_text_field( $_FILES['import_file']['name'] ) );
+ $extension = explode( '.', sanitize_text_field( $_FILES['import_file']['name'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
$file_extension = end( $extension );
if ( 'json' !== $file_extension ) {
- wp_die( __( '
Settings import failed: Please upload a valid .json file to import settings in this website.', 'wp-last-modified-info' ) );
+ wp_die( sprintf( '
%s: %s',
+ esc_html__( 'Settings import failed', 'wp-last-modified-info' ),
+ esc_html__( 'Please upload a valid .json file to import settings in this website.', 'wp-last-modified-info' )
+ ) );
}
- $import_file = sanitize_text_field( $_FILES['import_file']['tmp_name'] );
+ $import_file = sanitize_text_field( $_FILES['import_file']['tmp_name'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
if ( empty( $import_file ) ) {
- wp_die( __( '
Settings import failed: Please upload a file to import.', 'wp-last-modified-info' ) );
+ wp_die( sprintf( '
%s: %s',
+ esc_html__( 'Settings import failed', 'wp-last-modified-info' ),
+ esc_html__( 'Please upload a file to import.', 'wp-last-modified-info' )
+ ) );
}
// Retrieve the settings from the file and convert the json object to an array.
- $settings = (array) json_decode( file_get_contents( $import_file ) );
+ $settings = (array) json_decode( file_get_contents( $import_file ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
update_option( 'lmt_plugin_global_settings', $settings, false );
// set temporary transient for admin notice
set_transient( 'wplmi_import_db_done', true );
-
+
wp_safe_redirect( add_query_arg( 'page', 'wp-last-modified-info', admin_url( 'options-general.php' ) ) );
exit;
}
@@ -113,11 +121,11 @@ public function set_meta() {
// security check
$this->verify_nonce();
- if ( ! isset( $_POST['action_type'] ) ) {
+ if ( ! isset( $_POST['action_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
$this->error();
}
- $action = sanitize_text_field( wp_unslash( $_POST['action_type'] ) );
+ $action = sanitize_text_field( wp_unslash( $_POST['action_type'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
$value = ( $action == 'check' ) ? 'yes' : 'no';
$args = [
@@ -126,14 +134,14 @@ public function set_meta() {
'post_status' => [ 'publish', 'draft', 'pending', 'future' ],
'fields' => 'ids',
];
-
+
$posts = get_posts( $args );
if ( ! empty( $posts ) ) {
foreach ( $posts as $post_id ) {
$this->update_meta( $post_id, '_lmt_disableupdate', $value );
}
}
-
+
$this->success( [
'reload' => false,
] );
@@ -147,9 +155,9 @@ public function copy_data() {
$this->verify_nonce();
$option = get_option( 'lmt_plugin_global_settings' );
-
+
$this->success( [
- 'elements' => json_encode( $option ),
+ 'elements' => wp_json_encode( $option ),
] );
}
@@ -168,12 +176,12 @@ public function import_data() {
$this->error();
}
- $data = wp_unslash( $_REQUEST['settings_data'] );
+ $data = wp_unslash( $_REQUEST['settings_data'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$settings = (array) json_decode( $data );
if ( is_array( $settings ) && ! empty( $settings ) ) {
update_option( 'lmt_plugin_global_settings', $settings, false );
-
+
// set temporary transient for admin notice
set_transient( 'wplmi_import_db_done', true );
}
@@ -187,7 +195,7 @@ public function import_data() {
public function remove_settings() {
// security check
$this->verify_nonce();
-
+
// Remove options
delete_option( 'lmt_plugin_global_settings' );
delete_option( 'wplmi_site_global_update_info' );
@@ -211,8 +219,8 @@ public function remove_settings() {
*/
public function admin_notice() {
if ( get_transient( 'wplmi_import_db_done' ) !== false ) { ?>
-
'wplmi-update',
@@ -68,10 +69,10 @@ public function admin_bar( $wp_admin_bar ) {
'target' => '_blank',
),
);
-
+
$wp_admin_bar->add_node( $args );
}
-
+
/**
* Generate title to show on admin bar
*/
@@ -80,12 +81,12 @@ private function title() {
$cur_time = current_time( 'U' );
$mod_time = $this->get_modified_date( 'U' );
$org_time = get_post_time( 'U', false, get_the_ID(), true );
-
+
if ( $mod_time > $cur_time || $org_time > $mod_time ) {
/* translators: %s: date time info */
return sprintf( __( 'Updated on %1$s at %2$s', 'wp-last-modified-info' ), $this->get_modified_date( 'M j' ), $this->get_modified_date( get_option( 'time_format' ) ) );
}
-
+
/* translators: %s: time diff */
return sprintf( __( 'Updated %s ago', 'wp-last-modified-info' ), human_time_diff( $this->get_modified_date( 'U' ), $cur_time ) );
}
@@ -99,20 +100,20 @@ private function revision() {
if ( ! $post instanceof \WP_Post ) {
return;
}
-
+
// If user can't edit post, then don't show
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
return;
}
-
+
$revision = wp_get_post_revisions( $post->ID );
$latest_revision = array_shift( $revision );
$url = '';
-
+
if ( wp_revisions_enabled( $post ) && count( $revision ) >= 1 ) {
$url = get_admin_url() . 'revision.php?revision=' . $latest_revision->ID;
}
-
+
return $url;
}
-}
\ No newline at end of file
+}
diff --git a/inc/Core/Backend/AdminColumn.php b/inc/Core/Backend/AdminColumn.php
index c44bba9..07ceb77 100644
--- a/inc/Core/Backend/AdminColumn.php
+++ b/inc/Core/Backend/AdminColumn.php
@@ -20,7 +20,8 @@
*/
class AdminColumn
{
- use Hooker, SettingsData;
+ use Hooker;
+ use SettingsData;
/**
* Register functions.
@@ -46,13 +47,13 @@ public function generate_column() {
}
}
}
-
+
/**
* Generate column data.
- *
+ *
* @param string $column Column name
* @param int $post_id Post ID
- *
+ *
* @return string $time
*/
public function column_data( $column, $post_id ) {
@@ -66,7 +67,7 @@ public function column_data( $column, $post_id ) {
$modified = date_i18n( $this->do_filter( 'admin_column_datetime_format', $get_df . ' \a\t ' . $get_tf, $post->ID ), strtotime( $m_orig ) );
$mod_format = date( 'M d, Y H:i:s', strtotime( $m_orig ) );
$disabled = ( ! empty( $p_meta ) ) ? $p_meta : 'no';
-
+
$html = $modified;
if ( get_the_modified_author() ) {
$html .= '