Giter VIP home page Giter VIP logo

tl-template-checker's Introduction

Code Climate Current Child Theme Check version Number of downloads Number of active installs WordPress plugin rating Donate with PayPal

Child Theme Check

A WordPress plugin that warns you about old template files in your child theme.

Why?

Child Themes are used to avoid overwriting your customizations. But if you preserve a file in a child theme, then you maybe preserve a security risk. After an update from the parent theme you should always check the changes and maybe add them to your child theme. This plugin helps you keeping track of these changes in the parent theme.

Requirements

You have to use a child theme. If a child theme is active, you can see the status or the diff view under Child Theme Check in Tools.

For full usage of the plugin you have to define the version of the template file in the header of the PHP file with an additional @version info.

For example: * @version 1.0.0

If this is the case you will see a warning if the version of the parent theme file is higher than your child theme file. And you can see the differences between the parent theme file and the child theme file per wp_text_diff()-function like in revisions.

Thanks

Thank you very much @WooThemes and @WooCommerce for using the GPL, so that I can grab so much of their code to build this plugin.

Changelog

1.0.7

  • Tested with WordPress 6.5

1.0.6

  • Fix CSS

1.0.5

  • Fix broken layout in Wordpress 5.7 (Thanks to Torsten Bulk for the report)
  • Fix PHP warning
  • Tested up to 5.7

1.0.4

  • not released

1.0.3

  • Fix flashing of first diff view
  • More i18n improvements (Thanks @pedro-mendonca)
  • Tested up to 5.4

1.0.2

  • fixed some WordPress coding standards issues
  • added Github Updater Metadata
  • updated readme.txt
  • i18n improvements (Thanks @pedro-mendonca)
  • Tested up to 5.3

1.0.1

  • Fixed typo in German translation (Thanks @pixolin)
  • Changed text for action link on plugins page (Thanks @presskopp)
  • Tested up to 4.6.1

1.0.0

  • Initial public release

tl-template-checker's People

Contributors

drivingralle avatar glueckpress avatar hinnerk-a avatar pedro-mendonca avatar presskopp avatar rpkoller avatar staude avatar zodiac1978 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tl-template-checker's Issues

Adding child theme check for inactive child themes

After brainstorming on Contributor Day in Cologne we decided to add a button on every child theme under Appearance to check inactive child themes too.

I think this is a little more work, so this will be not done in 1.0.

Deprecated notices

Deprecated: Non-static method TPLC_Admin_Status::scan_template_files() should not be called statically, assuming $this from incompatible context in /Applications/MAMP/htdocs/wp-dev/wp-content/plugins/tl-template-checker/includes/admin/class-wc-admin-notices.php on line 112

Deprecated: Non-static method TPLC_Admin_Status::scan_template_files() should not be called statically, assuming $this from incompatible context in /Applications/MAMP/htdocs/wp-dev/wp-content/plugins/tl-template-checker/includes/admin/class-wc-admin-status.php on line 111

Deprecated: Non-static method TPLC_Admin_Status::scan_template_files() should not be called statically, assuming $this from incompatible context in /Applications/MAMP/htdocs/wp-dev/wp-content/plugins/tl-template-checker/includes/admin/class-wc-admin-status.php on line 111

Deprecated: Non-static method TPLC_Admin_Status::scan_template_files() should not be called statically, assuming $this from incompatible context in /Applications/MAMP/htdocs/wp-dev/wp-content/plugins/tl-template-checker/includes/admin/class-wc-admin-status.php on line 111

Deprecated: Non-static method TPLC_Admin_Status::scan_template_files() should not be called statically, assuming $this from incompatible context in /Applications/MAMP/htdocs/wp-dev/wp-content/plugins/tl-template-checker/includes/admin/class-wc-admin-status.php on line 111

Deprecated: Non-static method TPLC_Admin_Status::scan_template_files() should not be called statically, assuming $this from incompatible context in /Applications/MAMP/htdocs/wp-dev/wp-content/plugins/tl-template-checker/includes/admin/class-wc-admin-status.php on line 111

Deprecated: Non-static method TPLC_Admin_Status::get_file_version() should not be called statically, assuming $this from incompatible context in /Applications/MAMP/htdocs/wp-dev/wp-content/plugins/tl-template-checker/includes/admin/class-wc-admin-notices.php on line 129

Deprecated: Non-static method TPLC_Admin_Status::get_file_version() should not be called statically, assuming $this from incompatible context in /Applications/MAMP/htdocs/wp-dev/wp-content/plugins/tl-template-checker/includes/admin/class-wc-admin-notices.php on line 130

Deprecated: Non-static method TPLC_Admin_Status::get_file_version() should not be called statically, assuming $this from incompatible context in /Applications/MAMP/htdocs/wp-dev/wp-content/plugins/tl-template-checker/includes/admin/class-wc-admin-notices.php on line 129

Deprecated: Non-static method TPLC_Admin_Status::get_file_version() should not be called statically, assuming $this from incompatible context in /Applications/MAMP/htdocs/wp-dev/wp-content/plugins/tl-template-checker/includes/admin/class-wc-admin-notices.php on line 130

Warning

Warning: call_user_func_array() expects parameter 1 to be a valid callback, second array member is not a valid method in /www/htdocs/w00b1cb9/wordpress/wp-includes/class-wp-hook.php on line 288

Status

### wp-core ###

version: 5.3.2
site_language: de_DE
user_language: de_DE
timezone: Europe/Berlin
permalink: /%year%/%monthnum%/%day%/%postname%/
https_status: true
user_registration: 0
default_comment_status: open
multisite: false
user_count: 5
dotorg_communication: true


### wp-media ###

image_editor: WP_Image_Editor_Imagick
imagick_module_version: 1673
imagemagick_version: ImageMagick 6.8.9-9 Q16 x86_64 2019-11-12 http://www.imagemagick.org
imagick_limits: 
	imagick::RESOURCETYPE_AREA: 31 GB
	imagick::RESOURCETYPE_DISK: -1
	imagick::RESOURCETYPE_FILE: 48750
	imagick::RESOURCETYPE_MAP: 31 GB
	imagick::RESOURCETYPE_MEMORY: 16 GB
	imagick::RESOURCETYPE_THREAD: 8
gd_version: bundled (2.1.0 compatible)
ghostscript_version: 9.26

### wp-server ###

server_architecture: Linux 4.4.0-173-generic x86_64
httpd_software: Apache
php_version: 7.2.24-nmm1 64bit
php_sapi: fpm-fcgi
max_input_variables: 3000
time_limit: 30
memory_limit: 256M
max_input_time: 60
upload_max_size: 200M
php_post_max_size: 200M
curl_version: 7.47.0 OpenSSL/1.0.2g
suhosin: false
imagick_availability: true
htaccess_extra_rules: true

### wp-database ###

extension: mysqli
server_version: 5.7.28-nmm1-log
client_version: mysqlnd 5.0.12-dev - 20150407 - $Id: 3591daad22de08524295e1bd073aceeff11e6579 $

add API for plugins

add an API so plugins can register her templates files (like woocommerce or buddypress)

Remove version info check

As the idea of adding @version info to themes is not spreading at all and this feature needs this info to work I would recommend to remove the whole feature.

The diff view works in every case. Positive side effect: It would be much smaller and easier to maintain.

Unnecessary code in translation strings

There are a lot of code snippets in translation strings that should be avoided.

Here are some examples:

if ( $parent_version && $child_version && ( version_compare( $child_version, $parent_version, '<' ) ) ) {
$found_files[ $plugin_name ][] = sprintf(
/* translators: %1$s Markup for Icon, %2$s Filename, %3$s Version number from child theme, %4$s Version number from parent theme */
__( '%1$s <code>%2$s</code>: Child theme version <strong style="color:red">%3$s</strong> is out of date. The parent theme version is <strong>%4$s</strong>.', 'child-theme-check' ),
'<span class="dashicons dashicons-no-alt" style="color:red"></span>',
basename( $theme_file ),
$child_version ? $child_version : '-',
$parent_version
);
} elseif ( ! $child_version && $parent_version ) {
$found_files[ $plugin_name ][] = sprintf(
/* translators: %1$s Markup for Icon, %2$s Filename, %3$s Version number from parent theme */
__( '%1$s <code>%2$s</code>: Child theme is missing version keyword. The parent theme version is <strong>%3$s</strong>.', 'child-theme-check' ),
'<span class="dashicons dashicons-info" style="color:orange"></span>',
basename( $theme_file ),
$parent_version
);
} elseif ( ! $parent_version ) {
$found_files[ $plugin_name ][] = sprintf(
/* translators: %1$s Markup for Icon, %2$s Filename */
__( '%1$s <code>%2$s</code>: Parent theme is missing version keyword.', 'child-theme-check' ),
'<span class="dashicons dashicons-minus"></span>',
basename( $theme_file )
);
} else {
$found_files[ $plugin_name ][] = sprintf(
/* translators: %1$s Markup for Icon, %2$s Filename, %3$s Version number from child theme */
__( '%1$s <code>%2$s</code>: Child theme version <strong style="color:green">%3$s</strong> matches parent theme.', 'child-theme-check' ),
'<span class="dashicons dashicons-yes" style="color:green"></span>',
basename( $theme_file ),
$child_version ? $child_version : '-'
);
}

printf(
/* translators: %1$s Name of child theme, %2$s Name of parent theme */
__( 'Template overrides by <abbr title="Child theme">%1$s</abbr> for <abbr title="Parent theme">%2$s</abbr>:', 'child-theme-check' ),
esc_html( $theme ),
esc_html( $template )
);

Remove German translation

After the import on WP.org the translation is managed by WordPress and we can remove the translation files.

Status escalation for (critical) changes

Not all changes in a parent theme are critical, therefore always saying if there is a diff between the two themes, it's a red status is overkill.
I think it would be nice to have an important looking status, that shows up if a parent theme changes something very important.

I'm thinking about an extra parameter, that can be added by the author, if there is an important version change that the child-theme needs an update.

Ex.:
@Version 0.9.3
@stable 0.9.1

This way the status of all changes can be yellow and if the version number of the child theme is lower then the stable version it shows up in red.

This way it is possible to give general user/website owner this plugin to check there child theme on there own. If they always get a red error it generates often unnecessary requests for changes to the child theme.
If I remember it right, the base idea was that this plugin should help none technically people to find out if there is a need to work on there child theme.

Let's discuss.

Tidy up on deletion

We store an option in the DB, so I think we should tidy up after deletion of the plugin.

Maybe @hinnerk-a can help with that?

See: https://codex.wordpress.org/Function_Reference/register_uninstall_hook#uninstall.php

Looks like we just have to add a uninstall.php with:

//if uninstall not called from WordPress exit
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) 
    exit();

$option_name = 'tplc_admin_notices';
delete_option( $option_name );

Further reading:
https://github.com/woothemes/woocommerce/blob/5ef335b169ff4e19a4c5b393963a369446922b0c/uninstall.php

Feedback is appreciated. :)

Add email notifications

Something like:

/**
 * Send an email notification to the administrator when a post is published.
 * 
 * @param   string  $new_status
 * @param   string  $old_status
 * @param   object  $post
 */
function wpse_19040_notify_admin_on_publish( $new_status, $old_status, $post ) {
    if ( $new_status !== 'publish' || $old_status === 'publish' )
        return;
    if ( ! $post_type = get_post_type_object( $post->post_type ) )
        return;

    // Recipient, in this case the administrator email
    $emailto = get_option( 'admin_email' );

    // Email subject, "New {post_type_label}"
    $subject = 'New ' . $post_type->labels->singular_name;

    // Email body
    $message = 'View it: ' . get_permalink( $post->ID ) . "\nEdit it: " . get_edit_post_link( $post->ID );

    wp_mail( $emailto, $subject, $message );
}

add_action( 'transition_post_status', 'wpse_19040_notify_admin_on_publish', 10, 3 ); 

Is it useful to have a email notice? You get the notice if you update the parent theme, but this is a manual task, so you would get a mail even if you are on the way to do it already...

What is your opinion on that?

Implement automatic CSS minify (build process)

The files admin.min.css should be auto generated on release.

Additionally we should apply some sort of cache busting for the CSS file. For example append the plugin version, so that the new file is loaded if changed.

https://github.com/Zodiac1978/tl-template-checker/blob/master/child-theme-check.php#L103-L107

Additionally the minified version should only be used if SCRIPT_DEBUG is false, otherwise the non-minified version should be used:
https://wordpress.org/support/article/debugging-in-wordpress/#script_debug

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.