| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Auto Update Post Date |
| 4 |
Description: Keep your WordPress content evergreen with Auto Update Post Date – a simple WP plugin designed to effortlessly update your posts and boost SEO. Bid farewell to outdated information as this plugin takes care of the heavy lifting for you! |
| 5 |
Version: 1.0.1 |
| 6 |
Author: Temak |
| 7 |
Author URI: https://temak.dev |
| 8 |
Plugin URI: https://github.com/git-temak/auto-update-post-date |
| 9 |
License: GPL3 or later |
| 10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| 11 |
Text Domain: auto-update-post-date |
| 12 |
Domain Path: /languages |
| 13 |
|
| 14 |
*/ |
| 15 |
|
| 16 |
// Exit if accessed directly |
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
exit; |
| 19 |
} |
| 20 |
|
| 21 |
require __DIR__ . '/inc/auto-update-post-date-runner.php'; |
| 22 |
|
| 23 |
// Add menu page |
| 24 |
if( !function_exists('tmaupd_menu_page') ){ |
| 25 |
function tmaupd_menu_page() { |
| 26 |
add_submenu_page( |
| 27 |
'tools.php', |
| 28 |
'Auto Update Post Date Settings', |
| 29 |
'Auto Update Post Date', |
| 30 |
'manage_options', |
| 31 |
'tmaupd-settings', |
| 32 |
'tmaupd_render_page' |
| 33 |
); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
add_action('admin_menu', 'tmaupd_menu_page'); |
| 38 |
|
| 39 |
// log events to file |
| 40 |
function tmaupd_log_updates($log, $date = true){ |
| 41 |
$filename = plugin_dir_path(__FILE__). 'aupd_log.txt'; |
| 42 |
if ($date){ |
| 43 |
file_put_contents($filename, $log . ' - ' . date('Y-m-d H:i:s') . "\n\n", FILE_APPEND); |
| 44 |
} else { |
| 45 |
file_put_contents($filename, $log . "\n\n", FILE_APPEND); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
// Load script and styles |
| 50 |
function tmaupd_load_scripts_styles() |
| 51 |
{ |
| 52 |
wp_enqueue_script('cs-jsDatetimePicker', plugin_dir_url(__FILE__) . 'inc/jquery.datetimepicker.full.min.js', array('jquery'), '1.0.0', true); |
| 53 |
wp_enqueue_style('cs-jsDatetimePickerStyle', plugin_dir_url(__FILE__) . 'inc/jquery.datetimepicker.min.css', array(), '1.0.0', 'all'); |
| 54 |
wp_enqueue_script('tmaupdscript', plugin_dir_url(__FILE__) . 'inc/aupd.js', array('jquery'), '1.0.1', true); |
| 55 |
wp_enqueue_style('tmaupdstyles', plugin_dir_url(__FILE__) . 'inc/aupd.css', array(), '1.0.1', 'all'); |
| 56 |
} |
| 57 |
|
| 58 |
add_action('admin_enqueue_scripts', 'tmaupd_load_scripts_styles'); |
| 59 |
|
| 60 |
// plugin uninstallation |
| 61 |
register_uninstall_hook( __FILE__, 'tmaupd_plugin_uninstall' ); |
| 62 |
function tmaupd_plugin_uninstall() { |
| 63 |
$aupd_plugin_settings = get_option('tmaupd_settings_all_options'); |
| 64 |
|
| 65 |
// delete all saved plugin options on uninstall |
| 66 |
foreach ($aupd_plugin_settings as $aupd_setting){ |
| 67 |
delete_option( $aupd_setting ); |
| 68 |
} |
| 69 |
|
| 70 |
delete_option('tmaupd_settings_all_options'); |
| 71 |
} |
| 72 |
|
| 73 |
?> |