Changeset 3276991
- Timestamp:
- 04/19/2025 01:49:09 AM (12 months ago)
- Location:
- texlab-current-year/trunk
- Files:
-
- 1 added
- 2 edited
-
languages (added)
-
readme.txt (modified) (1 diff)
-
texlab-current-year.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
texlab-current-year/trunk/readme.txt
r3113783 r3276991 1 1 === 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 2 Contributors: texlabit 3 Tags: shortcode, year, current year, date 4 Requires at least: 5.2 5 Tested up to: 6.8 6 Requires PHP: 7.2 7 Stable tag: 1.1.0 6 8 License: GPLv2 or later 7 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html 8 Texlab Current Year plugin will show the current year. 10 11 Display the current year anywhere in your WordPress site using a simple shortcode. 9 12 10 13 == Description == 11 14 12 Texlab Current Year is a small shortcode that can be added to the site's text editor to get the current year. 15 Texlab 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 28 Simply insert the shortcode `[texlab_current_year]` anywhere in your posts, pages, or widgets where you want the current year to appear. 29 30 Example 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 13 37 14 38 == Installation == 15 39 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 '<span>[texlab_current_year]</span>' (<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! 40 1. Upload the plugin files to the `/wp-content/plugins/texlab-current-year` directory, or install the plugin through the WordPress plugins screen directly. 41 2. Activate the plugin through the 'Plugins' screen in WordPress 42 3. Use the shortcode `[texlab_current_year]` in your content 21 43 22 44 == Frequently Asked Questions == 23 45 24 = Where can I get some support? =46 = How do I use this plugin? = 25 47 26 Let us know via the support forum.48 Simply insert the shortcode `[texlab_current_year]` wherever you want the current year to appear. 27 49 28 = I have some suggestions for other options I want edited=50 = Does this plugin slow down my website? = 29 51 30 Let us know via the support forum. 52 No, 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 56 Yes, 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 61 Currently, the plugin only displays the year in YYYY format. If you need different date formats, please contact us for feature requests. 31 62 32 63 == Screenshots == 33 64 34 1. See screenshot of an example usage of the plugin in a widget.65 1. Example usage in footer copyright notice 35 66 36 67 == Changelog == 37 68 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 = 82 This version includes improved code structure and security enhancements. Update recommended for all users. 83 84 == Additional Info == 85 86 For more information and support, please visit: 87 [Texlab IT](https://www.texlabit.com/contact/) -
texlab-current-year/trunk/texlab-current-year.php
r3066340 r3276991 1 1 <?php 2 2 3 /** 3 4 * Plugin Name: Texlab Current Year 4 5 * 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 6 10 * Author: Texlab IT 7 * Version: 1.08 11 * Author URI: http://www.texlabit.com/ 9 * Licen ce: GPLv2 or later12 * License: GPL v2 or later 10 13 * 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 11 18 */ 12 19 13 20 // Exit if accessed directly. 14 if ( ! defined( 'ABSPATH' )) {21 if (! defined('ABSPATH')) { 15 22 exit; 16 23 } 17 24 25 // Define plugin constants. 26 define('TEXLAB_CURRENT_YEAR_VERSION', '1.1.0'); 27 define('TEXLAB_CURRENT_YEAR_PLUGIN_DIR', plugin_dir_path(__FILE__)); 28 define('TEXLAB_CURRENT_YEAR_PLUGIN_URL', plugin_dir_url(__FILE__)); 29 18 30 /** 19 * Return current year for the shortcode.31 * Main plugin class 20 32 * 21 * @ return string Date.33 * @since 1.1.0 22 34 */ 23 function texlab_add_shortcode() { 24 return date_i18n( 'Y' ); 35 final 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 } 25 131 } 26 132 27 add_shortcode( 'texlab_current_year', 'texlab_add_shortcode' ); 133 // Initialize the plugin. 134 add_action('plugins_loaded', array('Texlab_Current_Year', 'get_instance')); 135 136 // Register activation and deactivation hooks. 137 register_activation_hook(__FILE__, array('Texlab_Current_Year', 'activate')); 138 register_deactivation_hook(__FILE__, array('Texlab_Current_Year', 'deactivate'));
Note: See TracChangeset
for help on using the changeset viewer.