Plugin Directory

Changeset 3276991


Ignore:
Timestamp:
04/19/2025 01:49:09 AM (12 months ago)
Author:
texlab
Message:

Improved code structure and security enhancements

Location:
texlab-current-year/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • texlab-current-year/trunk/readme.txt

    r3113783 r3276991  
    11=== Texlab Current Year ===
    2 Tags: copyright,shortcode,copyright year, current year
    3 Requires at least: 3.0.1
    4 Tested up to: 6.5.5
    5 Stable tag: 1.0
     2Contributors: texlabit
     3Tags: shortcode, year, current year, date
     4Requires at least: 5.2
     5Tested up to: 6.8
     6Requires PHP: 7.2
     7Stable tag: 1.1.0
    68License: GPLv2 or later
    79License URI: https://www.gnu.org/licenses/gpl-2.0.html
    8 Texlab Current Year plugin will show the current year.
     10
     11Display the current year anywhere in your WordPress site using a simple shortcode.
    912
    1013== Description ==
    1114
    12 Texlab Current Year is a small shortcode that can be added to the site's text editor to get the current year.
     15Texlab Current Year is a lightweight WordPress plugin that allows you to display the current year anywhere on your website using a simple shortcode. This is particularly useful for copyright notices and other date-sensitive content that needs to be automatically updated each year.
     16
     17= Features =
     18
     19* Simple shortcode `[texlab_current_year]` to display the current year
     20* Supports internationalization (i18n)
     21* Lightweight and efficient
     22* No configuration needed
     23* Works with any theme
     24* Perfect for footer copyright notices
     25
     26= Usage =
     27
     28Simply insert the shortcode `[texlab_current_year]` anywhere in your posts, pages, or widgets where you want the current year to appear.
     29
     30Example usage in a copyright notice:
     31`© [texlab_current_year] Your Company Name. All rights reserved.`
     32
     33= Developers =
     34
     35* GitHub Repository: [Texlab Current Year on GitHub](https://github.com/texlabit/texlab-current-year)
     36* Feel free to contribute to the development of this plugin
    1337
    1438== Installation ==
    1539
    16 The installation and use is very easy. You need to:
    17 
    18 1. Upload the folder `texlab-current-year` to the `/wp-content/plugins/` directory
    19 2. Activate the plugin through the 'Plugins' menu in WordPress
    20 3. Add '&lt;span&gt;[texlab_current_year]&lt;/span&gt;' (<span>[texlab_current_year]</span>, surrounded by span tags) to a widget or to anywhere inside the html footer element. You can also use [texlab_current_year] as a shortcode!
     401. Upload the plugin files to the `/wp-content/plugins/texlab-current-year` directory, or install the plugin through the WordPress plugins screen directly.
     412. Activate the plugin through the 'Plugins' screen in WordPress
     423. Use the shortcode `[texlab_current_year]` in your content
    2143
    2244== Frequently Asked Questions ==
    2345
    24 = Where can I get some support? =
     46= How do I use this plugin? =
    2547
    26 Let us know via the support forum.
     48Simply insert the shortcode `[texlab_current_year]` wherever you want the current year to appear.
    2749
    28 = I have some suggestions for other options I want edited =
     50= Does this plugin slow down my website? =
    2951
    30 Let us know via the support forum.
     52No, this plugin is very lightweight and only loads the minimal code needed to display the current year.
     53
     54= Can I use this in my theme's template files? =
     55
     56Yes, you can use the shortcode in template files by using the `do_shortcode()` function:
     57`<?php echo do_shortcode('[texlab_current_year]'); ?>`
     58
     59= Does it support different date formats? =
     60
     61Currently, the plugin only displays the year in YYYY format. If you need different date formats, please contact us for feature requests.
    3162
    3263== Screenshots ==
    3364
    34 1. See screenshot of an example usage of the plugin in a widget.
     651. Example usage in footer copyright notice
    3566
    3667== Changelog ==
    3768
    38 = 1.0 =
    39 * Initial version.
     69= 1.1.0 =
     70* Added proper class-based structure
     71* Improved code organization and documentation
     72* Added internationalization support
     73* Added activation and deactivation hooks
     74* Enhanced security measures
     75
     76= 1.0.0 =
     77* Initial release
     78
     79== Upgrade Notice ==
     80
     81= 1.1.0 =
     82This version includes improved code structure and security enhancements. Update recommended for all users.
     83
     84== Additional Info ==
     85
     86For more information and support, please visit:
     87[Texlab IT](https://www.texlabit.com/contact/)
  • texlab-current-year/trunk/texlab-current-year.php

    r3066340 r3276991  
    11<?php
     2
    23/**
    34 * Plugin Name: Texlab Current Year
    45 * Plugin URI: http://www.texlabit.com/wordpress-plugin-texlab-current-year/
    5  * Description: Shows the current year.
     6 * Description: Shows the current year using a simple shortcode [texlab_current_year].
     7 * Version: 1.1.0
     8 * Requires at least: 5.2
     9 * Requires PHP: 7.2
    610 * Author: Texlab IT
    7  * Version: 1.0
    811 * Author URI: http://www.texlabit.com/
    9  * Licence: GPLv2 or later
     12 * License: GPL v2 or later
    1013 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
     14 * Text Domain: texlab-current-year
     15 * Domain Path: /languages
     16 *
     17 * @package Texlab_Current_Year
    1118 */
    1219
    1320// Exit if accessed directly.
    14 if ( ! defined( 'ABSPATH' ) ) {
     21if (! defined('ABSPATH')) {
    1522    exit;
    1623}
    1724
     25// Define plugin constants.
     26define('TEXLAB_CURRENT_YEAR_VERSION', '1.1.0');
     27define('TEXLAB_CURRENT_YEAR_PLUGIN_DIR', plugin_dir_path(__FILE__));
     28define('TEXLAB_CURRENT_YEAR_PLUGIN_URL', plugin_dir_url(__FILE__));
     29
    1830/**
    19  * Return current year for the shortcode.
     31 * Main plugin class
    2032 *
    21  * @return string Date.
     33 * @since 1.1.0
    2234 */
    23 function texlab_add_shortcode() {
    24     return date_i18n( 'Y' );
     35final class Texlab_Current_Year
     36{
     37
     38    /**
     39     * Instance of this class.
     40     *
     41     * @since 1.1.0
     42     * @var object
     43     */
     44    protected static $instance = null;
     45
     46    /**
     47     * Initialize the plugin.
     48     *
     49     * @since 1.1.0
     50     */
     51    private function __construct()
     52    {
     53        $this->init();
     54    }
     55
     56    /**
     57     * Get an instance of this class.
     58     *
     59     * @since 1.1.0
     60     * @return Texlab_Current_Year
     61     */
     62    public static function get_instance()
     63    {
     64        if (null === self::$instance) {
     65            self::$instance = new self();
     66        }
     67        return self::$instance;
     68    }
     69
     70    /**
     71     * Initialize plugin hooks and filters.
     72     *
     73     * @since 1.1.0
     74     * @return void
     75     */
     76    private function init()
     77    {
     78        add_action('init', array($this, 'load_textdomain'));
     79        add_shortcode('texlab_current_year', array($this, 'render_current_year'));
     80    }
     81
     82    /**
     83     * Load plugin textdomain.
     84     *
     85     * @since 1.1.0
     86     * @return void
     87     */
     88    public function load_textdomain()
     89    {
     90        load_plugin_textdomain(
     91            'texlab-current-year',
     92            false,
     93            dirname(plugin_basename(__FILE__)) . '/languages/'
     94        );
     95    }
     96
     97    /**
     98     * Render the current year.
     99     *
     100     * @since 1.0.0
     101     * @return string The current year.
     102     */
     103    public function render_current_year()
     104    {
     105        return esc_html(date_i18n('Y'));
     106    }
     107
     108    /**
     109     * Activate the plugin.
     110     *
     111     * @since 1.1.0
     112     * @return void
     113     */
     114    public static function activate()
     115    {
     116        // Activation tasks if needed.
     117        flush_rewrite_rules();
     118    }
     119
     120    /**
     121     * Deactivate the plugin.
     122     *
     123     * @since 1.1.0
     124     * @return void
     125     */
     126    public static function deactivate()
     127    {
     128        // Deactivation tasks if needed.
     129        flush_rewrite_rules();
     130    }
    25131}
    26132
    27 add_shortcode( 'texlab_current_year', 'texlab_add_shortcode' );
     133// Initialize the plugin.
     134add_action('plugins_loaded', array('Texlab_Current_Year', 'get_instance'));
     135
     136// Register activation and deactivation hooks.
     137register_activation_hook(__FILE__, array('Texlab_Current_Year', 'activate'));
     138register_deactivation_hook(__FILE__, array('Texlab_Current_Year', 'deactivate'));
Note: See TracChangeset for help on using the changeset viewer.