Skip to content

Commit

Permalink
WPCS changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsayan committed Aug 9, 2024
1 parent 4101109 commit a4ec8ae
Show file tree
Hide file tree
Showing 41 changed files with 5,306 additions and 17,728 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
todo
/assets/block-editor/build/
/blocks/build/
/blocks/build/
.idea
8 changes: 4 additions & 4 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
}
10 changes: 5 additions & 5 deletions inc/Api/Callbacks/AdminCallbacks.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php
/**
* Admin callbacks.
*
Expand Down Expand Up @@ -29,15 +29,15 @@ public function adminDashboard() {
public function sectionHeader( $title, $description ) { ?>
<div class="wplmi-metabox-holder">
<div class="wplmi-metabox-td">
<h3 class="wplmi-metabox-title"><?php echo esc_html( $title ); ?></h3>
<p class="wplmi-metabox-description"><?php echo wp_kses_post( $description ); ?></p>
<h3 class="wplmi-metabox-title"><?= esc_html( $title ); ?></h3>
<p class="wplmi-metabox-description"><?= wp_kses_post( $description ); ?></p>
</div>
</div>
<?php
}

public function doSettingsSection( $attr ) { ?>
<div id="<?php echo esc_attr( $attr['id'] ); ?>" class="postbox <?php echo esc_attr( $attr['class'] ); ?>">
<div id="<?= esc_attr( $attr['id'] ); ?>" class="postbox <?= esc_attr( $attr['class'] ); ?>">
<?php $this->sectionHeader( $attr['title'], $attr['description'] ); ?>
<div class="inside">
<?php do_settings_sections( $attr['name'] ); ?>
Expand All @@ -48,4 +48,4 @@ public function doSettingsSection( $attr ) { ?>
</div>
<?php
}
}
}
75 changes: 39 additions & 36 deletions inc/Api/Callbacks/ManagerCallbacks.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php
/**
* Settings callbacks.
*
Expand All @@ -18,10 +18,12 @@

class ManagerCallbacks
{
use Fields, HelperFunctions, Hooker;
use Fields;
use HelperFunctions;
use Hooker;

/* ==============================================================================================
Post Options
/* ==============================================================================================
Post Options
============================================================================================== */

public function enable_plugin( $args ) {
Expand Down Expand Up @@ -185,9 +187,9 @@ public function post_types( $args ) {
'show_if' => 'wplmi_enable_plugin',
] );
}
/* ==============================================================================================
Template Tags

/* ==============================================================================================
Template Tags
============================================================================================== */

public function template_date_type( $args ) {
Expand Down Expand Up @@ -251,8 +253,8 @@ public function template_display_info( $args ) {
] );
}

/* ==============================================================================================
Schema Options
/* ==============================================================================================
Schema Options
============================================================================================== */

public function enable_schema( $args ) {
Expand All @@ -270,7 +272,7 @@ public function enable_schema( $args ) {
],
] );
}

public function schema_post_types( $args ) {
$this->do_field( [
'type' => 'multiple',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -319,7 +321,7 @@ public function author_notification( $args ) {
'show_if' => 'wplmi_enable_notification',
] );
}

public function draft_notification( $args ) {
$this->do_field( [
'type' => 'checkbox',
Expand All @@ -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'],
Expand All @@ -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',
Expand Down Expand Up @@ -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" . '<p><strong>Post: %post_title%</strong></p><p>%post_diff%</p>';
$this->do_field( [
Expand All @@ -383,10 +385,10 @@ public function email_notification_message( $args ) {
] );
}

/* ==============================================================================================
/* ==============================================================================================
Misc Options
============================================================================================== */

public function admin_bar( $args ) {
$this->do_field( [
'type' => 'checkbox',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -421,7 +423,7 @@ public function admin_sort_order( $args ) {
],
] );
}

public function sort_order( $args ) {
$this->do_field( [
'type' => 'select',
Expand All @@ -436,7 +438,7 @@ public function sort_order( $args ) {
],
] );
}

public function replace_date( $args ) {
$this->do_field( [
'type' => 'select',
Expand All @@ -451,7 +453,7 @@ public function replace_date( $args ) {
],
] );
}

public function custom_css( $args ) {
$this->do_field( [
'type' => 'textarea',
Expand All @@ -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' ), '<code>&lt;style&gt;&lt;/style&gt;</code>' ),
] );
}

public function delete_data( $args ) {
$this->do_field( [
'type' => 'checkbox',
Expand All @@ -475,34 +477,35 @@ public function delete_data( $args ) {

/**
* Generate template tags output.
*
*
* @since 1.8.0
*/
private function generate_template_tags( $tags ) {
ob_start() ?>
<div class="dynamic-tags">
<div class="dynamic-tags-label">
<a href="https://github.com/iamsayan/wp-last-modified-info/wiki/Temaplate-Use-Cases" target="_blank" rel="noopener"><?php esc_html_e( 'Use these tags', 'wp-last-modified-info' ); ?></a>.
<a href="https://github.com/iamsayan/wp-last-modified-info/wiki/Temaplate-Use-Cases" target="_blank" rel="noopener"><?php esc_html_e( 'Use these tags', 'wp-last-modified-info' ); ?></a>.
<a href="https://github.com/iamsayan/wp-last-modified-info/wiki/Template-Tags" target="_blank" rel="noopener"><?php esc_html_e( 'Available Dynamic Tags', 'wp-last-modified-info' ); ?></a>:
</div>
<div class="dynamic-tags-content"><?php echo $this->get_available_tags( $tags ); ?></div>
<div class="dynamic-tags-content"><?= $this->get_available_tags( $tags ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
</div>
<?php
return ob_get_clean();
}

/**
* Get avaialable template tags.
*
* @since 1.8.0
* Get available template tags.
*
* @param $tags
* @return string
* @since 1.8.0
*/
private function get_available_tags( $tags ) {
private function get_available_tags( $tags ): string {
$content = [];
foreach ( $tags as $tag ) {
$content[] = '<code class="click-to-copy">%' . esc_html( $tag ) . '%</code>';
}

return join( ' ', $content );
}
}
}
Loading

0 comments on commit a4ec8ae

Please sign in to comment.