From f12df531ddc7607659abfd1bffba1e483341057c Mon Sep 17 00:00:00 2001 From: Sayan Datta Date: Thu, 13 Aug 2020 08:40:44 +0530 Subject: [PATCH] Updated to v1.7.1 --- CHANGELOG.md | 9 ++ assets/js/admin.js | 72 ++++++++- assets/js/admin.min.js | 2 +- composer.json | 2 +- inc/Api/Callbacks/ManagerCallbacks.php | 15 +- inc/Base/AdminNotice.php | 2 +- inc/Base/BaseController.php | 2 +- inc/Base/Enqueue.php | 5 +- inc/Base/PluginTools.php | 81 ++++++++-- inc/Core/Elementor/Modules/ModifiedDate.php | 2 +- inc/Core/Elementor/Modules/ModifiedTime.php | 2 +- inc/Core/Frontend/PostView.php | 8 +- inc/Core/Frontend/Shortcode.php | 30 +++- inc/Core/ThemeCompat.php | 16 +- inc/Pages/Dashboard.php | 2 +- languages/wp-last-modified-info.pot | 166 ++++++++++++-------- readme.txt | 11 +- templates/admin.php | 14 +- wp-last-modified-info.php | 2 +- 19 files changed, 322 insertions(+), 121 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 300c731..e0546d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/assets/js/admin.js b/assets/js/admin.js index bb4a10f..0232bca 100644 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -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', @@ -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 = $(""); + $("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: '', + 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' ); diff --git a/assets/js/admin.min.js b/assets/js/admin.min.js index a94f1b3..d00c88c 100644 --- a/assets/js/admin.min.js +++ b/assets/js/admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(e){if("undefined"==typeof wplmi_admin_L10n)return!1;for(var t=wp.codeEditor.initialize(e("#wplmi_display_info"),wplmi_admin_L10n.html_editor),i=wp.codeEditor.initialize(e("#wplmi_custom_css"),wplmi_admin_L10n.css_editor),a=wp.codeEditor.initialize(e("#wplmi_template_display_info"),wplmi_admin_L10n.html_editor),o=e("#nav-container").find("a.nav-tab"),n=0;n()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return t.test(String(e).toLowerCase())}}),e("#wplmi_enable_schema").change(function(){"enable"==e(this).val()?(e(".wplmi_row_schema_post_types").show(),e(".wplmi_row_enhanced_schema, .schema-text").hide(),e("#wplmi_enhanced_schema").prop("checked",!1)):"inline"==e(this).val()?(e(".wplmi_row_enhanced_schema").show(),e(".wplmi_row_schema_post_types, .schema-text").hide()):"comp_mode"==e(this).val()?(e(".wplmi_row_schema_post_types, .wplmi_row_enhanced_schema").hide(),e(".schema-text").show()):"disable"==e(this).val()&&(e(".wplmi_row_schema_post_types, .wplmi_row_enhanced_schema, .schema-text").hide(),e("#wplmi_enhanced_schema").prop("checked",!1))}).change(),e("#wplmi_display_method").change(function(){"replace_original"==e(this).val()?(e(".wplmi_row_selectors, .wplmi_row_post_types").show(),e(".wplmi_row_archives").hide()):"manual"==e(this).val()?e(".wplmi_row_selectors, .wplmi_row_post_types, .wplmi_row_archives").hide():"before_content"!=e(this).val()&&"after_content"!=e(this).val()||(e(".wplmi_row_selectors").hide(),e(".wplmi_row_post_types, .wplmi_row_archives").show())}).change(),e(".coffee-amt").change(function(){var t=e(".buy-coffee-btn");t.attr("href",t.data("link")+e(this).val())}),e(window).keydown(function(t){if(t.ctrlKey||t.metaKey)switch(String.fromCharCode(t.which).toLowerCase()){case"s":t.preventDefault(),e("#form-container").submit()}})}); \ No newline at end of file +jQuery(document).ready(function(e){if("undefined"==typeof wplmi_admin_L10n)return!1;for(var t=wp.codeEditor.initialize(e("#wplmi_display_info"),wplmi_admin_L10n.html_editor),i=wp.codeEditor.initialize(e("#wplmi_custom_css"),wplmi_admin_L10n.css_editor),a=wp.codeEditor.initialize(e("#wplmi_template_display_info"),wplmi_admin_L10n.html_editor),o=e("#nav-container").find("a.nav-tab"),n=0;n");e("body").append(n),n.val(t.data.elements).select(),document.execCommand("copy"),n.remove(),i.removeClass("disabled").val(a),e(".wplmi-copied").show().delay(1e3).fadeOut()}})}),e("input.wplmi-paste").on("click",function(t){t.preventDefault();e(this);var i=e.confirm({title:wplmi_admin_L10n.paste_data,content:'',useBootstrap:!1,theme:"material",animation:"scale",type:"green",boxWidth:"40%",draggable:!1,scrollToPreviousElement:!1,buttons:{confirm:{text:wplmi_admin_L10n.import_btn,action:function(){var t=this.$content.find("#wplmi-settings-data-import").val();if(!t)return alert("Please enter valid settings data!"),!1;console.log(t),i.close(),e.dialog({title:wplmi_admin_L10n.importing,content:wplmi_admin_L10n.processing,useBootstrap:!1,draggable:!1,theme:"material",type:"orange",closeIcon:!1,boxWidth:"25%",scrollToPreviousElement:!1}),e.post(wplmi_admin_L10n.ajaxurl,{action:"wplmi_process_import_plugin_data",settings_data:t,security:wplmi_admin_L10n.security},function(t,i){!0===t.success&&(window.location.reload(),e.cookie("wplmi_active_tab","post",{expires:30}))})}},close:{text:wplmi_admin_L10n.close_btn,action:function(){}}}})}),e("#wplmi-form .wplmi_row_custom_css").find(".CodeMirror").on("mousedown.codemirror",function(){var t=e(this);t.addClass("large"),i.codemirror.refresh(),t.off("mousedown.codemirror")}),e("#wplmi_enable_plugin").on("change",function(){var i=e(this).prop("checked");t.codemirror.setOption("readOnly",!i),e("#wplmi-form .wplmi_row_display_info").find(".CodeMirror").toggleClass("disabled",!i)}).change(),e("#wplmi_date_type").change(function(){"default"==e(this).val()?e(".wplmi_row_date_format").show():"human_readable"==e(this).val()&&e(".wplmi_row_date_format").hide()}).change(),e("#wplmi_author_display").change(function(){"custom"==e(this).val()?e(".wplmi_row_author_list").show():e(".wplmi_row_author_list").hide()}).change(),e("#wplmi_template_date_type").change(function(){"default"==e(this).val()?e(".wplmi_row_template_date_format").show():"human_readable"==e(this).val()&&e(".wplmi_row_template_date_format").hide()}).change(),e("#wplmi_template_author_display").change(function(){"custom"==e(this).val()?e(".wplmi_row_template_author_list").show():e(".wplmi_row_template_author_list").hide()}).change(),e("#wplmi_astra_support, #wplmi_generatepress_support").change(function(){"replace"==e(this).val()?(e(".wplmi_row_theme_template_type").show(),e("a#post").hide(),e("#wplmi_enable_plugin").prop("checked",!1)):"none"==e(this).val()&&(e(".wplmi_row_theme_template_type").hide(),e("a#post").show())}).change(),e("#wplmi_theme_template_type").on("change",function(){var t;"default"==e(this).val()?t=!0:"custom"==e(this).val()&&(t=!1),a.codemirror.setOption("readOnly",t),e("#wplmi-form .wplmi_row_template_display_info").find(".CodeMirror").toggleClass("disabled",t)}).change(),e("#wplmi_post_types, #wplmi_schema_post_types, #wplmi_notification_post_types, #wplmi_archives").selectize({plugins:["remove_button"],delimiter:",",placeholder:e(this).data("placeholder"),persist:!1,create:!1}),e("#wplmi_recipients_list").selectize({plugins:["remove_button","restore_on_backspace"],persist:!1,create:!0,createOnBlur:!0,delimiter:",",placeholder:e(this).data("placeholder"),createFilter:function(e){var t=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return t.test(String(e).toLowerCase())}}),e("#wplmi_enable_schema").change(function(){"enable"==e(this).val()?(e(".wplmi_row_schema_post_types").show(),e(".wplmi_row_enhanced_schema, .schema-text").hide(),e("#wplmi_enhanced_schema").prop("checked",!1)):"inline"==e(this).val()?(e(".wplmi_row_enhanced_schema").show(),e(".wplmi_row_schema_post_types, .schema-text").hide()):"comp_mode"==e(this).val()?(e(".wplmi_row_schema_post_types, .wplmi_row_enhanced_schema").hide(),e(".schema-text").show()):"disable"==e(this).val()&&(e(".wplmi_row_schema_post_types, .wplmi_row_enhanced_schema, .schema-text").hide(),e("#wplmi_enhanced_schema").prop("checked",!1))}).change(),e("#wplmi_display_method").change(function(){"replace_original"==e(this).val()?(e(".wplmi_row_selectors, .wplmi_row_post_types").show(),e(".wplmi_row_archives").hide()):"manual"==e(this).val()?e(".wplmi_row_selectors, .wplmi_row_post_types, .wplmi_row_archives").hide():"before_content"!=e(this).val()&&"after_content"!=e(this).val()||(e(".wplmi_row_selectors").hide(),e(".wplmi_row_post_types, .wplmi_row_archives").show())}).change(),e(".coffee-amt").change(function(){var t=e(".buy-coffee-btn");t.attr("href",t.data("link")+e(this).val())}),e(window).keydown(function(t){if(t.ctrlKey||t.metaKey)switch(String.fromCharCode(t.which).toLowerCase()){case"s":t.preventDefault(),e("#form-container").submit()}})}); \ No newline at end of file diff --git a/composer.json b/composer.json index 8999fac..717ef15 100644 --- a/composer.json +++ b/composer.json @@ -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": [ diff --git a/inc/Api/Callbacks/ManagerCallbacks.php b/inc/Api/Callbacks/ManagerCallbacks.php index 1bc43a7..b296d1b 100644 --- a/inc/Api/Callbacks/ManagerCallbacks.php +++ b/inc/Api/Callbacks/ManagerCallbacks.php @@ -149,14 +149,15 @@ public function archives( $args ) public function selectors( $args ) { ?>  - - "> +

+

Last Updated on %post_modified% by %author_name%

'; - ?> + $default = '

Last Updated on %post_modified% by %author_name%

'; + ?>

- %author_name% %author_url% %author_email% %author_archive% %post_published% %post_link% %post_modified% @@ -282,8 +283,8 @@ public function template_author_list( $args ) public function template_display_info( $args ) { - $default = '

Last Updated on %post_modified% by %author_name%

'; - ?> + $default = '

Last Updated on %post_modified% by %author_name%

'; + ?>

- %author_name% %author_url% %author_email% %author_archive% %post_published% %post_link% %post_modified% @@ -467,7 +468,7 @@ public function sort_order( $args ) public function custom_css( $args ) { - ?> + ?>

<style> </style>' ); ?>

=' ) ) { ?>
-

here 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' ) ); ?>

+

here to configure plugin settings.', 'wp-last-modified-info' ), 'WP Last Modified Info', $this->version, admin_url( 'options-general.php?page=wp-last-modified-info' ) ); ?>

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'; } diff --git a/inc/Base/Enqueue.php b/inc/Base/Enqueue.php index 01417ca..0ca62d1 100644 --- a/inc/Base/Enqueue.php +++ b/inc/Base/Enqueue.php @@ -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' ), @@ -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' ), ] ); } diff --git a/inc/Base/PluginTools.php b/inc/Base/PluginTools.php index e621c0f..ef662b3 100644 --- a/inc/Base/PluginTools.php +++ b/inc/Base/PluginTools.php @@ -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' ); } @@ -92,6 +94,9 @@ public function import_settings() exit; } + /** + * Process post meta data update + */ public function set_meta() { // security check @@ -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 */ @@ -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, diff --git a/inc/Core/Elementor/Modules/ModifiedDate.php b/inc/Core/Elementor/Modules/ModifiedDate.php index fcf6b0a..b958b29 100644 --- a/inc/Core/Elementor/Modules/ModifiedDate.php +++ b/inc/Core/Elementor/Modules/ModifiedDate.php @@ -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; } diff --git a/inc/Core/Elementor/Modules/ModifiedTime.php b/inc/Core/Elementor/Modules/ModifiedTime.php index 65d111e..b5d02db 100644 --- a/inc/Core/Elementor/Modules/ModifiedTime.php +++ b/inc/Core/Elementor/Modules/ModifiedTime.php @@ -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; } diff --git a/inc/Core/Frontend/PostView.php b/inc/Core/Frontend/PostView.php index 7ea6e19..191506b 100644 --- a/inc/Core/Frontend/PostView.php +++ b/inc/Core/Frontend/PostView.php @@ -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; } @@ -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; } @@ -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 ); } diff --git a/inc/Core/Frontend/Shortcode.php b/inc/Core/Frontend/Shortcode.php index 786e4bb..326e7f3 100644 --- a/inc/Core/Frontend/Shortcode.php +++ b/inc/Core/Frontend/Shortcode.php @@ -26,6 +26,7 @@ public function register() { add_shortcode( 'lmt-post-modified-info', [ $this, 'render' ] ); add_shortcode( 'lmt-page-modified-info', [ $this, 'render' ] ); + add_shortcode( 'lmt-template-tags', [ $this, 'render_template_tags' ] ); add_shortcode( 'lmt-site-modified-info', [ $this, 'render_global' ] ); } @@ -44,10 +45,6 @@ public function render( $atts ) return; } - if ( ! $this->is_equal( 'show_last_modified_time_date_post', 'manual' ) ) { - return; - } - $format = $this->get_data( 'lmt_date_time_format', get_option( 'date_format' ) ); $format = ( ! empty( $format ) ) ? $format : get_option( 'date_format' ); @@ -63,8 +60,8 @@ public function render( $atts ) 'date_type' => $this->get_data( 'lmt_last_modified_format_post', 'default' ), 'schema' => $this->get_data( 'lmt_enable_jsonld_markup_cb', 'disable' ), 'author_id' => $author_id, - 'hide_archive' => [], - 'filter_ids' => [], + 'hide_archive' => '', + 'filter_ids' => '', 'gap' => $this->get_data( 'lmt_gap_on_post', 0 ), ], $atts, 'lmt-post-modified-info' ); @@ -99,7 +96,7 @@ public function render( $atts ) $published_timestamp = get_the_time( 'U' ); $modified_timestamp = get_the_modified_time( 'U' ); - if ( $modified_timestamp <= ( $published_timestamp + $atts['gap'] ) ) { + if ( $modified_timestamp < ( $published_timestamp + $atts['gap'] ) ) { return; } @@ -116,6 +113,25 @@ public function render( $atts ) return $template; } + /** + * Callback to register template tags shortcodes. + * + * @since v1.7.1 + * + * @param array $atts Shortcode attributes. + * + * @return string Shortcode output. + */ + public function render_template_tags( $atts ) + { + $atts = shortcode_atts( [ + 'escape' => false, + 'only_date' => false, + ], $atts, 'lmt-template-tags' ); + + return get_the_last_modified_info( $atts['escape'], $atts['only_date'] ); + } + /** * Callback to register shortcodes. * diff --git a/inc/Core/ThemeCompat.php b/inc/Core/ThemeCompat.php index 4199233..87526d1 100644 --- a/inc/Core/ThemeCompat.php +++ b/inc/Core/ThemeCompat.php @@ -51,10 +51,14 @@ public function astra_post_meta( $html ) $output = ''; $format = $this->do_filter( 'astra_post_date_format', '' ); - $output .= ''; - $output .= ' ' . esc_attr( get_the_modified_date( $format ) ) . ''; + $output .= '' . $this->do_filter( 'astra_post_date_prepend', '' ); + $output .= '' . esc_attr( get_the_modified_date( $format ) ) . '' . $this->do_filter( 'astra_post_date_append', '' ); $output .= ''; + if ( ! is_singular() && $this->do_filter( 'astra_filter_archive_output', true ) ) { + return $output; + } + if ( $this->is_equal( 'tt_theme_template_type', 'custom' ) ) { $output = $this->do_filter( 'astra_post_template', get_the_last_modified_info(), $html ); } @@ -81,7 +85,7 @@ public function astra_post_author_meta( $html ) $author_id = $this->get_meta( get_the_ID(), '_edit_last' ); $output = ''; - if ( $this->do_filter( 'astra_enable_author_output', true ) ) { + if ( $this->do_filter( 'astra_enable_author_output', false ) ) { $output .= ' '; + if ( ! is_singular() && $this->do_filter( 'gp_filter_archive_output', true ) ) { + return $output; + } + if ( $this->is_equal( 'tt_theme_template_type', 'custom' ) ) { $output = $this->do_filter( 'gp_post_template', get_the_last_modified_info(), $html ); } @@ -147,7 +155,7 @@ public function gp_post_author_meta( $html ) $author_id = $this->get_meta( get_the_ID(), '_edit_last' ); $output = ''; - if ( $this->is_equal( 'tt_theme_template_type', 'default' ) && $this->do_filter( 'gp_enable_author_output', true ) ) { + if ( $this->is_equal( 'tt_theme_template_type', 'default' ) && $this->do_filter( 'gp_enable_author_output', false ) ) { $output .= '' . apply_filters( 'generate_inside_post_meta_item_output', '', 'author' ); $output .= '