Changeset 2161303
- Timestamp:
- 09/23/2019 10:38:36 AM (7 years ago)
- Location:
- automatic-updates/trunk
- Files:
-
- 4 edited
-
Laksh_Automatic_Updates_Core.php (modified) (2 diffs)
-
README.txt (modified) (2 diffs)
-
automatic-updates.php (modified) (8 diffs)
-
inc/form.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
automatic-updates/trunk/Laksh_Automatic_Updates_Core.php
r2062697 r2161303 9 9 class Laksh_Automatic_Updates_Core{ 10 10 const OPTION_KEY = 'laksh_automatic_updates_core_type'; 11 const OPTION_NOTIFICATION_KEY = 'laksh_automatic_updates_notification'; 11 12 protected $updateTypes = []; 12 13 … … 40 41 } 41 42 43 public function updateNotifications($allowNotification = false) 44 { 45 update_option(self::OPTION_NOTIFICATION_KEY, $allowNotification); 46 } 47 48 public function isNotificationEnabled() 49 { 50 //return 1 for default 51 $isNotificationEnabled = get_option(self::OPTION_NOTIFICATION_KEY); 52 //return 1 if value from db is other than 0,1 or minor 53 return $isNotificationEnabled; 54 } 55 42 56 43 57 -
automatic-updates/trunk/README.txt
r2062714 r2161303 4 4 Tags: automatic-updates, update-plugins 5 5 Requires at least: 4.0.0 6 Tested up to: 5. 1.17 Stable tag: 1. 26 Tested up to: 5.2.3 7 Stable tag: 1.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 13 13 == Description == 14 14 <h3>Automatic Updates</h3> allows admin to manage the automatic updates of the core wordpress and the plugins. 15 The plugin will also allow admin to toggle email notifications with wordpress updates. 15 16 16 = Why use Automatic Updates Plugin=17 = Do I need to update any config files? = 17 18 No, you do not if you can modify the wp-config.php. 18 19 -
automatic-updates/trunk/automatic-updates.php
r2062714 r2161303 18 18 add_filter( 'allow_major_auto_core_updates', '__return_true' ); 19 19 20 add_action( 'wp_ajax_laksh_automatic_update_core', 'laksh_automatic_u dpates_core_handler' );21 add_action( 'wp_ajax_nopriv_laksh_automatic_update_core', 'laksh_automatic_udpates_core_handler' );20 add_action( 'wp_ajax_laksh_automatic_update_core', 'laksh_automatic_updates_core_handler' ); 21 //add_action( 'wp_ajax_nopriv_laksh_automatic_update_core', 'laksh_automatic_updates_core_handler' ); 22 22 23 add_action( 'wp_ajax_laksh_automatic_update_plugin', 'laksh_automatic_udpates_plugin_handler' ); 24 add_action( 'wp_ajax_nopriv_laksh_automatic_update_plugin', 'laksh_automatic_udpates_plugin_handler' ); 23 add_action( 'wp_ajax_laksh_automatic_update_plugin', 'laksh_automatic_updates_plugin_handler' ); 24 //add_action( 'wp_ajax_nopriv_laksh_automatic_update_plugin', 'laksh_automatic_updates_plugin_handler' ); 25 26 27 add_action( 'wp_ajax_laksh_automatic_update_notification', 'laksh_automatic_updates_notification_handler' ); 28 //add_action( 'wp_ajax_nopriv_laksh_automatic_update_notification', 'laksh_automatic_updates_notification_handler' ); 25 29 26 30 … … 30 34 'manage_options', //created custom capability for the artist role 31 35 'manage-updates', 32 'laksh_automatic_u dpates_manage_handler',36 'laksh_automatic_updates_manage_handler', 33 37 'dashicons-admin-tools'); 34 38 }); … … 36 40 37 41 //set updates 38 function laksh_automatic_u dpates_init(){42 function laksh_automatic_updates_init(){ 39 43 $coreUpdateType = (new Laksh_Automatic_Updates_Core())->getCoreUpdateOption(); 40 44 $pluginIgnoredList = (new Laksh_Automatic_Updates_Plugin())->getIgnoredPlugins(); 45 46 $isNotificationEnabled = (new Laksh_Automatic_Updates_Core())->isNotificationEnabled(); 47 48 if(!$isNotificationEnabled){ 49 var_dump('disable email'); 50 add_filter( 'auto_core_update_send_email', '__return_false' ); 51 } 52 //var_dump($coreUpdateType,$pluginIgnoredList,$isNotificationEnabled); 41 53 42 54 switch ($coreUpdateType){ … … 66 78 67 79 68 add_filter( 'auto_update_plugin', 'laksh_automatic_u dpates_specific_plugin_handler', 10, 2 );80 add_filter( 'auto_update_plugin', 'laksh_automatic_updates_specific_plugin_handler', 10, 2 ); 69 81 } 70 82 71 laksh_automatic_u dpates_init();83 laksh_automatic_updates_init(); 72 84 73 function laksh_automatic_u dpates_specific_plugin_handler ( $update, $item ) {85 function laksh_automatic_updates_specific_plugin_handler ( $update, $item ) { 74 86 $pluginIgnoredList = (new Laksh_Automatic_Updates_Plugin())->getIgnoredPlugins(); 75 87 if(in_array($item->slug, $pluginIgnoredList)){ … … 80 92 81 93 82 function laksh_automatic_u dpates_core_handler(){94 function laksh_automatic_updates_core_handler(){ 83 95 $updateType = (isset($_GET['updateType']) && $_GET['updateType']!='') ? $_GET['updateType'] : false; 84 96 if($updateType === false) die('unknown type'); … … 91 103 } 92 104 93 function laksh_automatic_u dpates_plugin_handler(){105 function laksh_automatic_updates_plugin_handler(){ 94 106 $pluginSlug = (isset($_GET['slug']) && $_GET['slug']!='') ? $_GET['slug'] : null; 95 107 $pluginStatus = (isset($_GET['status']) && $_GET['status']!='') ? filter_var($_GET['status'], FILTER_VALIDATE_INT) : false; … … 109 121 110 122 111 function laksh_automatic_udpates_manage_handler(){ 123 function laksh_automatic_updates_notification_handler(){ 124 if(!isset($_GET['allow'])){ 125 die(); 126 } 127 128 $isNotificationEnabled = (isset($_GET['allow']) && $_GET['allow']!='') ? $_GET['allow'] : false; 129 (new Laksh_Automatic_Updates_Core())->updateNotifications($isNotificationEnabled); 130 //echo wp_send_json($autoUpdater->getCoreUpdateOption()); 131 die(); 132 } 133 134 function laksh_automatic_updates_manage_handler(){ 112 135 //$activePlugins = get_option( 'active_plugins', [] ); 113 136 … … 121 144 $coreUpdateTypes = $coreAutoUpdater->getCoreUpdateTypes(); 122 145 146 $isNotificationEnabled = $coreAutoUpdater->isNotificationEnabled(); 147 123 148 //$ignoredPlugins = []; 124 149 -
automatic-updates/trunk/inc/form.php
r2062697 r2161303 13 13 <?php endforeach; ?> 14 14 </select> 15 </p> 16 <p><label><input type="checkbox" <?=($isNotificationEnabled==true) ? "checked" : ""?> class="update-notification" >Enable email notifications</label> 15 17 </p> 16 18 </div> … … 104 106 xhr.send(); 105 107 } 108 function laksh_automatic_updates_notification(isnotificationEnabled){ 109 coreUpdateWrapper.classList.add('show'); 110 if(isCoreUpdateBusy) return; 111 var xhr = new XMLHttpRequest(); 112 xhr.onload = function () { 113 isCoreUpdateBusy = false; 114 coreUpdateWrapper.classList.remove('show'); 115 }; 116 xhr.open('GET', ajaxUrl+"?action=laksh_automatic_update_notification&allow="+isnotificationEnabled); 117 xhr.send(); 118 } 106 119 107 120 document.querySelectorAll('.js-laksh-plugins-auto-update-input').forEach(function(input){ … … 116 129 document.getElementById('core-update-type').addEventListener('change', function(event){ 117 130 laksh_automatic_updates_core(event.currentTarget.value); 118 }) 131 }); 132 133 document.querySelector('.update-notification').addEventListener('change', function(event){ 134 var notificationVal = (event.currentTarget.checked) ? 1 : 0; 135 laksh_automatic_updates_notification(notificationVal); 136 }); 137 119 138 })(); 120 139 </script>
Note: See TracChangeset
for help on using the changeset viewer.