Skip to content

Commit

Permalink
Updated to v1.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sayan Datta committed Aug 13, 2020
1 parent 1ce2cc0 commit f12df53
Show file tree
Hide file tree
Showing 19 changed files with 322 additions and 121 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Changelog
All notable changes to this project will be documented in this file.

## 1.7.1
Release Date: August 12, 2020

* Added: Some PostView template tags.
* Added: An option to Copy and Paste plugin settings to Export and Import respectively.
* Fixed: Astra & GeneratePress Schema Output.
* Fixed: Elemetor Schema Output.
* Other minor improvements.

## 1.7.0
Release Date: August 11, 2020

Expand Down
72 changes: 71 additions & 1 deletion assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jQuery(document).ready(function ($) {
mdc.close();
var cd = $.dialog({
title: wplmi_admin_L10n.deleting,
content: wplmi_admin_L10n.process_delete,
content: wplmi_admin_L10n.processing,
useBootstrap: false,
draggable: false,
theme: 'material',
Expand Down Expand Up @@ -192,6 +192,76 @@ jQuery(document).ready(function ($) {
})
}));

$("input.wplmi-copy").on('click',(function(e) {
e.preventDefault();
var el = $(this);
var value = el.val();
var action = el.data('action');
el.addClass("disabled").val(wplmi_admin_L10n.please_wait);
$.post( wplmi_admin_L10n.ajaxurl, { action: action, security: wplmi_admin_L10n.security }, function( response, status ) {
if( response.success === true ) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val(response.data.elements).select();
document.execCommand("copy");
$temp.remove();
el.removeClass("disabled").val(value);
$(".wplmi-copied").show().delay(1000).fadeOut();
}
});
}));

$("input.wplmi-paste").on('click',(function(e) {
e.preventDefault();
var el = $(this);
var mdc = $.confirm({
title: wplmi_admin_L10n.paste_data,
content: '<textarea id="wplmi-settings-data-import" rows="4" style="width: 100%;"></textarea>',
useBootstrap: false,
theme: 'material',
animation: 'scale',
type: 'green',
boxWidth: '40%',
draggable: false,
scrollToPreviousElement: false,
buttons: {
confirm: {
text: wplmi_admin_L10n.import_btn,
action: function () {
var settings_data = this.$content.find('#wplmi-settings-data-import').val();
if ( ! settings_data ) {
alert( 'Please enter valid settings data!' );
return false;
}
console.log( settings_data );
mdc.close();
$.dialog({
title: wplmi_admin_L10n.importing,
content: wplmi_admin_L10n.processing,
useBootstrap: false,
draggable: false,
theme: 'material',
type: 'orange',
closeIcon: false,
boxWidth: '25%',
scrollToPreviousElement: false,
});
$.post( wplmi_admin_L10n.ajaxurl, { action: 'wplmi_process_import_plugin_data', settings_data: settings_data, security: wplmi_admin_L10n.security }, function( response, status ) {
if( response.success === true ) {
window.location.reload();
$.cookie('wplmi_active_tab', 'post', { expires: 30 });
}
});
}
},
close: {
text: wplmi_admin_L10n.close_btn,
action: function () {}
}
}
})
}));

$('#wplmi-form .wplmi_row_custom_css').find('.CodeMirror').on('mousedown.codemirror', function() {
var $this = $(this);
$this.addClass( 'large' );
Expand Down
2 changes: 1 addition & 1 deletion assets/js/admin.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sayan/wp-last-modified-info",
"description": "The WP Auto Republish plugin helps revive old posts by resetting the publish date to the current date. This will push old posts to your front page, the top of archive pages, and back into RSS feeds. Ideal for sites with a large repository of evergreen content.",
"description": "Adds last modified date and time automatically on pages and posts very easily. It is possible to use shortcodes to display last modified info anywhere on a WordPress site running 4.6 and beyond.",
"type": "wordpress-plugin",
"license": "GPL-3.0",
"authors": [
Expand Down
15 changes: 8 additions & 7 deletions inc/Api/Callbacks/ManagerCallbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,15 @@ public function archives( $args )
public function selectors( $args )
{
?><input id="<?php echo $args['label_for']; ?>" name="lmt_plugin_global_settings[lmt_css_selectors]" type="text" style="width:90%;" value="<?php echo wp_kses_post( $this->get_data( 'lmt_css_selectors', 'ul li.meta-date' ) ); ?>" />&nbsp;
<span class="tooltip" title="<?php _e( 'Add the CSS selector to replace the post meta. It may not work for all themes. Please check before using it. If you n eed any help, please open a support ticket with your website URL.', 'wp-last-modified-info' ); ?>"><span title="" class="dashicon dashicons dashicons-editor-help"></span></span>
<?php
<span class="tooltip" title="<?php _e( 'Add the CSS selector to replace the post meta. It may not work for all themes. Please check before using it. If you need any help, please open a support ticket with your website URL.', 'wp-last-modified-info' ); ?>"><span title="" class="dashicon dashicons dashicons-editor-help"></span></span>
<p><small style="line-height: 2;"><span style="font-style: italic;"><?php _e( 'If you are using any caching plugin, please clear/remove your cache after any changes made to this field.', 'wp-last-modified-info' ); ?></span></small>
</p><?php
}

public function display_info( $args )
{
$default = '<p id="last-modified-info">Last Updated on %post_modified% by <a href="%author_url%" target="_blank" class="last-modified-author">%author_name%</a></p>';
?><textarea id="<?php echo $args['label_for']; ?>" name="lmt_plugin_global_settings[lmt_last_modified_info_template]" rows="6" cols="100" style="width:90%;"><?php echo esc_html( $this->get_data( 'lmt_last_modified_info_template', $default ) ); ?></textarea>
$default = '<p id="post-modified-info">Last Updated on %post_modified% by <a href="%author_url%" target="_blank" class="last-modified-author">%author_name%</a></p>';
?><textarea id="<?php echo $args['label_for']; ?>" name="lmt_plugin_global_settings[lmt_last_modified_info_template]" rows="6" style="width:90%;"><?php echo esc_html( $this->get_data( 'lmt_last_modified_info_template', $default ) ); ?></textarea>
<p>
<small style="line-height: 2;"><span style="font-style: italic;"><?php _e( 'Use these tags', 'wp-last-modified-info' ); ?></span> -
<code>&#37;author_name&#37;</code> <code>&#37;author_url&#37;</code> <code>&#37;author_email&#37;</code> <code>&#37;author_archive&#37;</code> <code>&#37;post_published&#37;</code> <code>&#37;post_link&#37;</code> <code>&#37;post_modified&#37;</code>
Expand Down Expand Up @@ -282,8 +283,8 @@ public function template_author_list( $args )

public function template_display_info( $args )
{
$default = '<p id="last-modified-info">Last Updated on %post_modified% by <a href="%author_url%" target="_blank" class="last-modified-author">%author_name%</a></p>';
?><textarea id="<?php echo $args['label_for']; ?>" name="lmt_plugin_global_settings[lmt_last_modified_info_template_tt]" rows="6" cols="100" style="width:90%;"><?php echo esc_html( $this->get_data( 'lmt_last_modified_info_template_tt', $default ) ); ?></textarea>
$default = '<p id="post-modified-info">Last Updated on %post_modified% by <a href="%author_url%" target="_blank" class="last-modified-author">%author_name%</a></p>';
?><textarea id="<?php echo $args['label_for']; ?>" name="lmt_plugin_global_settings[lmt_last_modified_info_template_tt]" rows="6" style="width:90%;"><?php echo esc_html( $this->get_data( 'lmt_last_modified_info_template_tt', $default ) ); ?></textarea>
<p>
<small style="line-height: 2;"><span style="font-style: italic;"><?php _e( 'Use these tags', 'wp-last-modified-info' ); ?></span> -
<code>&#37;author_name&#37;</code> <code>&#37;author_url&#37;</code> <code>&#37;author_email&#37;</code> <code>&#37;author_archive&#37;</code> <code>&#37;post_published&#37;</code> <code>&#37;post_link&#37;</code> <code>&#37;post_modified&#37;</code>
Expand Down Expand Up @@ -467,7 +468,7 @@ public function sort_order( $args )

public function custom_css( $args )
{
?><textarea id="<?php echo $args['label_for']; ?>" name="lmt_plugin_global_settings[lmt_custom_style_box]" rows="6" cols="100" style="width:90%;"><?php echo esc_html( wp_kses_post( $this->get_data( 'lmt_custom_style_box' ) ) ); ?></textarea>
?><textarea id="<?php echo $args['label_for']; ?>" name="lmt_plugin_global_settings[lmt_custom_style_box]" rows="6" style="width:90%;"><?php echo esc_html( wp_kses_post( $this->get_data( 'lmt_custom_style_box' ) ) ); ?></textarea>
<p><small><?php printf( __( 'Do not add %s tag. This tag is not required, as it is already added.', 'wp-last-modified-info' ), '<code>&lt;style&gt; &lt;/style&gt;</code>' ); ?></small></p>
<?php
}
Expand Down
2 changes: 1 addition & 1 deletion inc/Base/AdminNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function install_notice()
if ( get_transient( 'wplmi-show-notice-on-activation' ) !== false ) {
if ( version_compare( PHP_VERSION, '5.6', '>=' ) ) { ?>
<div class="notice notice-success">
<p><strong><?php printf( __( 'Thanks for installing %1$s v%2$s plugin. Click <a href="%3$s">here</a> to configure plugin settings.', 'wp-last-modified-info' ), 'WP Last Modified Info', '1.6.0', admin_url( 'options-general.php?page=wp-last-modified-info' ) ); ?></strong></p>
<p><strong><?php printf( __( 'Thanks for installing %1$s v%2$s plugin. Click <a href="%3$s">here</a> to configure plugin settings.', 'wp-last-modified-info' ), 'WP Last Modified Info', $this->version, admin_url( 'options-general.php?page=wp-last-modified-info' ) ); ?></strong></p>
</div> <?php
}
delete_transient( 'wplmi-show-notice-on-activation' );
Expand Down
2 changes: 1 addition & 1 deletion inc/Base/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct()
$this->plugin_path = plugin_dir_path( $this->dirname_r( __FILE__, 2 ) );
$this->plugin_url = plugin_dir_url( $this->dirname_r( __FILE__, 2 ) );
$this->plugin = plugin_basename( $this->dirname_r( __FILE__, 3 ) ) . '/wp-last-modified-info.php';
$this->version = '1.7.0';
$this->version = '1.7.1';
$this->debug = false;
$this->name = 'WP Last Modified Info';
}
Expand Down
5 changes: 4 additions & 1 deletion inc/Base/Enqueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function assets( $hook )
'error' => __( 'Error!', 'wp-last-modified-info' ),
'deleting' => __( 'Deleting...', 'wp-last-modified-info' ),
'warning' => __( 'Warning!', 'wp-last-modified-info' ),
'process_delete' => __( 'Please wait while we are processing your request...', 'wp-last-modified-info' ),
'processing' => __( 'Please wait while we are processing your request...', 'wp-last-modified-info' ),
'save_button' => __( 'Save Settings', 'wp-last-modified-info' ),
'save_success' => __( 'Settings Saved Successfully!', 'wp-last-modified-info' ),
'process_failed' => __( 'Invalid Nonce! We could not process your request.', 'wp-last-modified-info' ),
Expand All @@ -78,6 +78,9 @@ public function assets( $hook )
'cancel_button' => __( 'Cancel', 'wp-last-modified-info' ),
'please_wait' => __( 'Please wait...', 'wp-last-modified-info' ),
'close_btn' => __( 'Close', 'wp-last-modified-info' ),
'paste_data' => __( 'Paste Here', 'wp-last-modified-info' ),
'import_btn' => __( 'Import', 'wp-last-modified-info' ),
'importing' => __( 'Importing...', 'wp-last-modified-info' ),
'security' => wp_create_nonce( 'wplmi_admin_nonce' ),
] );
}
Expand Down
81 changes: 66 additions & 15 deletions inc/Base/PluginTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public function register()
$this->action( 'admin_init', 'export_settings' );
$this->action( 'admin_init', 'import_settings' );
$this->action( 'admin_notices', 'admin_notice' );
$this->ajax( 'process_set_meta', 'set_meta' );
$this->ajax( 'process_set_meta', 'set_meta' );
$this->ajax( 'process_copy_data', 'copy_data' );
$this->ajax( 'process_import_plugin_data', 'import_data' );
$this->ajax( 'process_delete_plugin_data', 'remove_settings' );
}

Expand Down Expand Up @@ -92,6 +94,9 @@ public function import_settings()
exit;
}

/**
* Process post meta data update
*/
public function set_meta()
{
// security check
Expand All @@ -110,19 +115,63 @@ public function set_meta()
];

$posts = get_posts( $args );
foreach( $posts as $post ) {
if ( $action == 'check' ) {
$this->update_meta( $post->ID, '_lmt_disableupdate', 'yes' );
} else if ( $action == 'uncheck' ) {
$this->update_meta( $post->ID, '_lmt_disableupdate', 'no' );
}
}
if ( ! empty( $posts ) ) {
foreach( $posts as $post ) {
if ( $action == 'check' ) {
$this->update_meta( $post->ID, '_lmt_disableupdate', 'yes' );
} else if ( $action == 'uncheck' ) {
$this->update_meta( $post->ID, '_lmt_disableupdate', 'no' );
}
}
}

$this->success( [
'reload' => false,
] );
}

/**
* Process a settings export from ajax request
*/
public function copy_data()
{
// security check
$this->verify_nonce();

$option = get_option( 'lmt_plugin_global_settings' );

//error_log( json_encode( $option ) );

$this->success( [
'elements' => json_encode( $option ),
] );
}

/**
* Process a settings import from ajax request
*/
public function import_data()
{
// security check
$this->verify_nonce();

if ( ! isset( $_REQUEST['settings_data'] ) ) {
$this->error();
}

$data = stripslashes( $_REQUEST['settings_data'] );
$settings = (array) json_decode( $data );

if ( is_array( $settings ) && ! empty( $settings ) ) {
update_option( 'lmt_plugin_global_settings', $settings );

// set temporary transient for admin notice
set_transient( 'wplmi_import_db_done', true );
}

$this->success();
}

/**
* Process reset plugin settings
*/
Expand All @@ -142,13 +191,15 @@ public function remove_settings()
];

$posts = get_posts( $args );
foreach( $posts as $post ) {
$this->delete_meta( $post->ID, '_lmt_disable' );
$this->delete_meta( $post->ID, '_lmt_disableupdate' );
$this->delete_meta( $post->ID, '_wplmi_last_modified' );
$this->delete_meta( $post->ID, 'wp_last_modified_info' );
$this->delete_meta( $post->ID, 'wplmi_shortcode' );
}
if ( ! empty( $posts ) ) {
foreach( $posts as $post ) {
$this->delete_meta( $post->ID, '_lmt_disable' );
$this->delete_meta( $post->ID, '_lmt_disableupdate' );
$this->delete_meta( $post->ID, '_wplmi_last_modified' );
$this->delete_meta( $post->ID, 'wp_last_modified_info' );
$this->delete_meta( $post->ID, 'wplmi_shortcode' );
}
}

$this->success( [
'reload' => true,
Expand Down
2 changes: 1 addition & 1 deletion inc/Core/Elementor/Modules/ModifiedDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function render()
$value = get_the_modified_date( $date_format );

if ( 'yes' === $schema ) {
$output = '%schema_start%' . $value . '%schema_end%';
$output = '%wplmi_schema_start%' . $value . '%wplmi_schema_end%';
} else {
$output = $value;
}
Expand Down
2 changes: 1 addition & 1 deletion inc/Core/Elementor/Modules/ModifiedTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function render()
}

if ( 'yes' === $schema ) {
$output = '%schema_start%' . $value . '%wplmi_schema_end%';
$output = '%wplmi_schema_start%' . $value . '%wplmi_schema_end%';
} else {
$output = $value;
}
Expand Down
8 changes: 5 additions & 3 deletions inc/Core/Frontend/PostView.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function show_info( $content )
$modified_timestamp = get_post_modified_time( 'U' );
$gap = $this->get_data( 'lmt_gap_on_post', 0 );

if ( $modified_timestamp <= ( $published_timestamp + $gap ) ) {
if ( $modified_timestamp < ( $published_timestamp + $gap ) ) {
return $content;
}

Expand Down Expand Up @@ -153,7 +153,7 @@ public function run_replace()
$modified_timestamp = get_post_modified_time( 'U' );
$gap = $this->get_data( 'lmt_gap_on_post', 0 );

if ( $modified_timestamp <= ( $published_timestamp + $gap ) ) {
if ( $modified_timestamp < ( $published_timestamp + $gap ) ) {
return;
}

Expand Down Expand Up @@ -220,9 +220,11 @@ protected function generate( $html, $post_id, $timestamp, $author_id )
$html = str_replace( [ '%author_archive%', '%author_posts_url%' ], $author_archive, $html );
$html = str_replace( [ '%post_published%', '%published_date%' ], esc_attr( get_post_time( $date_format, false, $post->ID ) ), $html );
$html = str_replace( '%post_link%', esc_url( get_the_permalink( $post->ID ) ), $html );
$html = str_replace( '%post_categories%', get_the_category_list( $this->do_filter( 'post_categories_separator', ', ', $post->ID ), '', $post->ID ), $html );
$html = str_replace( '%comment_count%', get_comments_number( $post->ID ), $html );

$html = $this->do_filter( 'post_tags', $html, $post->ID );
$html = str_replace( [ '%post_modified%', '%modified_date%' ], esc_attr( $timestamp ), wp_kses_post( $html ) );
$html = str_replace( [ '%post_modified%', '%modified_date%' ], $timestamp, wp_kses_post( $html ) );

return preg_replace( "/\r|\n/", '', $html );
}
Expand Down
Loading

0 comments on commit f12df53

Please sign in to comment.