Skip to content

Commit

Permalink
Merge pull request #55 from iamsayan/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
iamsayan authored Feb 9, 2024
2 parents a4916fa + b4cac32 commit a96bfe3
Show file tree
Hide file tree
Showing 21 changed files with 9,002 additions and 4,763 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Changelog
All notable changes to this project will be documented in this file.

## 1.8.9
Release Date: February 9, 2024

* Added: Lock Modified Date Block Editor Support for Custom Post type which has `show_in_rest` set to `true`. This behavior can be changed by `wpar/post_type_args` filter.
* Updated: @wordpress/scripts to the latest version.
* Updated: Background Process PHP Library.
* Tweak: Replaced deprecated `__experimentalGetSettings()` with `getSettings()`.
* Tweak: Use of `wp_kses_allowed_html` filter to allow custom HTML tag instead of using placeholders.
* Added support for PHP v8.3.
* Minimum required PHP Version is now 7.0.
* Tested with WordPress v6.4.

## 1.8.8
Release Date: June 26, 2023

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import { __ } from "@wordpress/i18n";
import { useSelect, useDispatch } from "@wordpress/data";
import { PluginPostStatusInfo } from '@wordpress/edit-post';
import { dateI18n, __experimentalGetSettings } from "@wordpress/date";
import { dateI18n, getSettings } from "@wordpress/date";
import { DateTimePicker, Dropdown, Button } from "@wordpress/components";

const PostModifiedField = () => {
const settings = __experimentalGetSettings();
const settings = getSettings();
const dateTimeFormat = settings.formats.date + ' ' + settings.formats.time;
const is12HourFormat = ( format ) => {
return /(?:^|[^\\])[aAgh]/.test( format );
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 26 additions & 5 deletions inc/Core/Backend/BlockEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,32 @@ class BlockEditor extends BaseController
* Register functions.
*/
public function register() {
$this->filter( 'register_post_type_args', 'post_type_args', 99, 2 );
$this->action( 'init', 'register_meta' );
$this->action( 'enqueue_block_editor_assets', 'assets' );

// AIOSEO Integration
$this->action( 'init', 'filter_aioseo' );
}

$post_types = get_post_types( [ 'show_in_rest' => true ] );
foreach ( $post_types as $post_type ) {
$this->filter( "rest_pre_insert_$post_type", 'modified_params', 10, 2 );
/**
* Add support for `custom-fields` for all posts.
*
* @param array $args Post type data
* @param string $post_type Post type name
*
* @return array $args Post type data
*/
public function post_type_args( $args, $post_type ) {
if ( ! $this->do_filter( 'enable_custom_fields_support', true ) ) {
return $args;
}

// AIOSEO Integration
$this->action( 'init', 'filter_aioseo' );
if ( ! empty( $args['show_in_rest'] ) ) {
$args['supports'][] = 'custom-fields';
}

return $this->do_filter( 'post_type_args', $args, $post_type );
}

/**
Expand Down Expand Up @@ -70,6 +86,11 @@ public function register_meta() {
},
]
);

$post_types = get_post_types( [ 'show_in_rest' => true ] );
foreach ( $post_types as $post_type ) {
$this->filter( "rest_pre_insert_$post_type", 'modified_params', 99, 2 );
}
}

/**
Expand Down
39 changes: 23 additions & 16 deletions inc/Core/Elementor/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Loader
*/
public function register() {
if ( function_exists( '_is_elementor_installed' ) && defined( 'ELEMENTOR_PRO_VERSION' ) ) {
$this->filter( 'wp_kses_allowed_html', 'wp_kses_post_tags', 10, 2 );
$this->action( 'elementor/dynamic_tags/register', 'register_tags' );
$this->action( 'elementor/frontend/the_content', 'render' );
$this->action( 'elementor/widget/render_content', 'render' );
Expand All @@ -54,7 +55,7 @@ public function register_tags( $dynamic_tags_manager ) {
}

/**
* Modify elementor query obejct.
* Modify elementor query object.
*
* @param object $query Original Elementor query object
*/
Expand All @@ -64,28 +65,34 @@ public function query( $query ) {
}

/**
* Show filtered content.
* Remove old placeholders.
*
* @param string $content Original Content
*
* @return string $content Filtered Content
*/
public function render( $content ) {
$start_tag = '<time itemprop="dateModified" datetime="'. get_post_modified_time( 'Y-m-d\TH:i:sP', true ) .'">';
$end_tag = '</time>';

$content = str_replace( '%wplmi_schema_start%', $start_tag, $content );
$content = str_replace( '%wplmi_schema_end%', $end_tag, $content );

$content = str_replace( '%wplmi_span_start%', '<span class="wplmi-author">', $content );
$content = str_replace( '%wplmi_span_end%', '</span>', $content );

$author_id = get_post_meta( get_the_ID(), '_edit_last', true );
$author_name = get_the_author_meta( 'display_name', $author_id );

$content = str_replace( '%wplmi_author_avatar%', '<span class="wplmi-user-avatar">
<img class="elementor-avatar wplmi-elementor-avatar" src="' . esc_url( get_avatar_url( $author_id, [ 'size' => $this->do_filter( 'avatar_default_size', 96 ) ] ) ) . '" alt="' . $author_name . '"></span>', $content );
$content = str_replace( [ '%wplmi_schema_start%', '%wplmi_schema_end%', '%wplmi_span_start%', '%wplmi_span_end%', '%wplmi_author_avatar%' ], '', $content );

return $content;
}

/**
* Allow HTMl Tag.
*
* @param array $tags Tags array
* @param string $context Current context
*
* @return array $tags Tags array
*/
public function wp_kses_post_tags( $tags, $context ) {
if ( 'post' === $context ) {
$tags['time'] = [
'itemprop' => true,
'datetime' => true,
];
}

return $tags;
}
}
9 changes: 8 additions & 1 deletion inc/Core/Elementor/Modules/AuthorName.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Wplmi\Core\Elementor\Modules;

use Wplmi\Helpers\Hooker;
use \Elementor\Controls_Manager;
use \Elementor\Core\DynamicTags\Tag;
use \Elementor\Modules\DynamicTags\Module;
Expand All @@ -21,6 +22,8 @@
*/
Class AuthorName extends Tag {

use Hooker;

public function get_name() {
return 'wplmi-modified-author';
}
Expand Down Expand Up @@ -65,7 +68,11 @@ public function render() {
$value = get_the_author_meta( 'display_name', $author_id );

if ( 'yes' === $avatar ) {
$output = '%wplmi_author_avatar% ' . $text . '%wplmi_span_start%' . $value . '%wplmi_span_end%';
$author_id = get_post_meta( get_the_ID(), '_edit_last', true );
$author_name = get_the_author_meta( 'display_name', $author_id );
$avatar = '<span class="wplmi-user-avatar"><img class="elementor-avatar wplmi-elementor-avatar" src="' . esc_url( get_avatar_url( $author_id, [ 'size' => $this->do_filter( 'avatar_default_size', 96 ) ] ) ) . '" alt="' . $author_name . '"></span> ';

$output = '<span class="wplmi-author-tag">' . $avatar . $text . '<span class="wplmi-author">' . $value . '</span></span>';
} else {
$output = $value;
}
Expand Down
7 changes: 5 additions & 2 deletions inc/Core/Elementor/Modules/ModifiedDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ public function render() {
}

$value = get_the_modified_date( $date_format );

if ( 'yes' === $schema ) {
$output = '%wplmi_schema_start%' . $value . '%wplmi_schema_end%';
$start_tag = '<time itemprop="dateModified" datetime="'. get_post_modified_time( 'Y-m-d\TH:i:sP', true ) .'">';
$end_tag = '</time>';

$output = $start_tag . $value . $end_tag;
} else {
$output = $value;
}
Expand Down
5 changes: 4 additions & 1 deletion inc/Core/Elementor/Modules/ModifiedTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ public function render() {
}

if ( 'yes' === $schema ) {
$output = '%wplmi_schema_start%' . $value . '%wplmi_schema_end%';
$start_tag = '<time itemprop="dateModified" datetime="'. get_post_modified_time( 'Y-m-d\TH:i:sP', true ) .'">';
$end_tag = '</time>';

$output = $start_tag . $value . $end_tag;
} else {
$output = $value;
}
Expand Down
11 changes: 9 additions & 2 deletions inc/Pages/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ class Dashboard
*/
public $pages = [];

/**
* Settings sub-pages.
*
* @var array
*/
public $sub_pages = [];

/**
* Register functions.
*/
Expand All @@ -67,14 +74,14 @@ public function register() {
$this->setSections();
$this->setFields();

$this->settings->addSubPages( $this->subpages )->register();
$this->settings->addSubPages( $this->sub_pages )->register();
}

/**
* Register plugin pages.
*/
public function setSubPages() {
$this->subpages = [
$this->sub_pages = [
[
'parent_slug' => 'options-general.php',
'page_title' => __( 'WP Last Modified Info', 'wp-last-modified-info' ),
Expand Down
Loading

0 comments on commit a96bfe3

Please sign in to comment.