Changeset 3207488
- Timestamp:
- 12/13/2024 09:36:17 AM (16 months ago)
- Location:
- auto-refresh-post-page
- Files:
-
- 13 added
- 12 edited
-
README.txt (modified) (3 diffs)
-
admin/css/auto-refresh-post-page-admin.css (modified) (8 diffs)
-
admin/js/auto-refresh-post-page-admin.js (modified) (1 diff)
-
admin/partials/auto_refresh_post_page-admin-dashboard.php (modified) (4 diffs)
-
assets/banner.png (added)
-
assets/css (added)
-
assets/css/bootstrap.min.css (added)
-
assets/css/bootstrap.min.css.map (added)
-
assets/css/index.php (added)
-
assets/css/style.css (added)
-
assets/img (added)
-
assets/img/none.png (added)
-
assets/index.php (added)
-
assets/js (added)
-
assets/js/index.php (added)
-
auto-refresh-post-page.php (modified) (6 diffs)
-
changelog.txt (added)
-
includes/class-auto_refresh_post_page.php (modified) (1 diff)
-
trunk/README.txt (modified) (1 diff)
-
trunk/admin/css/auto-refresh-post-page-admin.css (modified) (2 diffs)
-
trunk/admin/js/auto-refresh-post-page-admin.js (modified) (1 diff)
-
trunk/admin/partials/auto_refresh_post_page-admin-dashboard.php (modified) (3 diffs)
-
trunk/auto-refresh-post-page.php (modified) (4 diffs)
-
trunk/changelog.txt (added)
-
trunk/includes/class-auto_refresh_post_page.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
auto-refresh-post-page/README.txt
r3063386 r3207488 1 1 Auto Refresh Post & Page 2 Tested up to: 6.5 3 Requires at least: 5.4 4 Tested up to: 6.5 5 Requires PHP: 7.0 6 Stable tag: 1.0.1 2 Tested up to: 6.3 7 3 License: GPLv2 or later 8 4 Contributors: 9 Tags: Auto refresh, Post refresh, Page refresh, Scheduled refresh, C ontent refresh5 Tags: Auto refresh, Post refresh, Page refresh, Scheduled refresh, Custom refresh timing, Post type refresh, Automatic refresh, Content refresh 10 6 11 Automate post/page refreshing for up-to-date content & improved user engagement.12 7 13 8 == Description == … … 34 29 35 30 The current version of the plugin is 1.0.1 31 32 == New Update == 33 34 A select field where user can select the unit of time like Hours, Minutes, Seconds along time field 36 35 37 36 … … 79 78 Using this plugin, you can schedule the content refresh to keep the website fresh and up-to-date which improves user engagement and show them fresh content. 80 79 It also saves time as you don't need to manually refresh the pages and posts. 81 82 == Changelog ==83 84 =1.0.1=85 * improved design86 * remove bugs87 * increase reponse time88 89 =1.0.0=90 * First stable version -
auto-refresh-post-page/admin/css/auto-refresh-post-page-admin.css
r3063383 r3207488 1 1 .sucess_msg { 2 2 width: 200px; 3 background-color: #2a2b5f;3 background-color: rgb(2, 98, 2); 4 4 color: white; 5 5 border-radius: 5px; … … 9 9 display: grid; 10 10 place-items: center; 11 margin: 40px 0px ;11 margin: 40px 40px ; 12 12 border-radius: 15px; 13 13 } … … 17 17 input[type="checkbox"] { 18 18 display: inline-block; 19 } 20 input[type=number]{ 21 min-height: 36px; 19 22 } 20 23 label.cb-tab-content__label { … … 30 33 padding: 10px 25px; 31 34 font-size: 1.3em; 32 background-color: #2a2b5f;35 background-color: rgb(2, 98, 2); 33 36 color: white; 34 37 border-radius: 10px; 35 38 border: 0px; 36 39 cursor: pointer; 37 margin: 0px 0px ;40 margin: 0px 40px ; 38 41 } 39 42 #cb_global_save_post:hover { … … 52 55 table-layout: fixed; 53 56 } 54 .select_style_all {55 padding-top: 30px;56 padding-bottom: 30px;57 }58 .select_check_all {59 width: 122px;60 float: left;61 padding-top: 5px;62 padding-left: 10px;63 }64 .universal_time_input {65 width: 200px;66 float: left;67 }68 57 table.widefatsett { 69 58 background: #fff; 59 } 60 .wp-core-ui select { 61 padding: 4px 24px 2px 8px; 62 margin-bottom: 3px; 70 63 } 71 64 table.widefatsett { … … 75 68 .widefatsett { 76 69 border-spacing: 0; 77 width: 99%;70 width: 100%; 78 71 clear: both; 79 72 margin: 0; … … 116 109 .widefatsett { 117 110 border-spacing: 0; 118 width: 99%;111 width: 100%; 119 112 clear: both; 120 113 margin: 0; … … 186 179 .widefatsett { 187 180 border-spacing: 0; 188 width: 99%;181 width: 100%; 189 182 clear: both; 190 183 margin: 0; -
auto-refresh-post-page/admin/js/auto-refresh-post-page-admin.js
r2990642 r3207488 23 23 var value = jQuery(this).val(); 24 24 data[key] = value; 25 }); 25 26 // Include the selected time unit 27 var timeUnitKey = 'time_unit-' + key.split('-')[1]; 28 var timeUnitValue = jQuery(this).siblings('.js-time-unit').val(); 29 data[timeUnitKey] = timeUnitValue; 30 }); 26 31 console.log(data); 27 32 // var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; -
auto-refresh-post-page/admin/partials/auto_refresh_post_page-admin-dashboard.php
r3063383 r3207488 8 8 * @link https://cubixsol.org/ 9 9 * @since 1.0.0 10 *11 10 * 12 11 * @package Auto_refresh_post_page … … 35 34 <h1>Set Refresh Frequency</h1> 36 35 <hr class="cb-divider" /> 37 <div class="select_style_all"> 38 <div class="select_check_all"> 39 <input type="checkbox" class="js-select-all"> Select All 40 </div> 41 <div class="universal_time_input"> 42 <input type="number" placeholder="Enter Time in Seconds globallly" class="timeField" id="timeField" min=0 > 43 </div> 44 </div> 36 <tr> 37 <th style="text-align: left;"> 38 <input type="checkbox" class="js-select-all"> Select All 39 40 <input type="number" placeholder="Enter Time in Seconds globally" class="timeField" id="timeField" min="0" oninput="updateGlobalTime(this)"> 41 <select id="globalTimeUnit" class="globalTimeUnit" onchange="updateGlobalTimeUnit(this)"> 42 <option value="seconds">Seconds</option> 43 <option value="minutes">Minutes</option> 44 <option value="hours">Hours</option> 45 </select> 46 </th> 47 </tr> 45 48 46 <table class="cb-tab-content__table cb-tab-content__table--padding wp-list-table widefatsett fixedsett striped table-view-list pages"> 49 <table class="cb-tab-content__table cb-tab-content__table--padding wp-list-table widefatsett fixedsett striped table-view-list pages"><br> 47 50 48 51 <tr> … … 61 64 $post_types = get_post_types( $args, $output, $operator ); 62 65 63 foreach ( $post_types as $post_type) { ?>66 foreach ($post_types as $post_type) { ?> 64 67 <tr> 65 <?php 66 $array_from_db = get_option( 'ARPP_my_option_name');67 68 if(isset($array_from_db[$post_type]) && $array_from_db[$post_type] == 1 ) {69 $checkbox="checked";70 }else{71 $checkbox = "";72 }73 74 if(isset($array_from_db["duration-".$post_type]) && $array_from_db["duration-".$post_type] != '' ) {75 $repeat_time=$array_from_db["duration-".$post_type];76 }else{77 $repeat_time = "";78 }68 <?php 69 $array_from_db = get_option('ARPP_my_option_name'); 70 71 // Checkbox logic: Match the exact key with the `checkbox-` prefix 72 $checkbox_key = "checkbox-" . $post_type; 73 $checkbox = isset($array_from_db[$checkbox_key]) && $array_from_db[$checkbox_key] == 1 ? "checked" : ""; 74 75 // Time field logic 76 $duration_key = "duration-" . $post_type; 77 $repeat_time = isset($array_from_db[$duration_key]) ? $array_from_db[$duration_key] : ""; 78 79 // Time unit logic 80 $time_unit_key = "time_unit-" . $post_type; 81 $time_unit = isset($array_from_db[$time_unit_key]) ? $array_from_db[$time_unit_key] : "seconds"; 79 82 ?> 80 81 <td class="check_title"> 82 <input type="checkbox" name="checkbox-<?php echo esc_html($post_type); ?>" value="1" class="js-cb-customization js-select-single" id="cb-feedback-<?php echo esc_html($post_type); ?>" data-key="feedbackTitle" <?php echo esc_html($checkbox); ?>> 83 </td> 84 <td> 85 <?php echo esc_html($post_type); ?> 86 </td> 83 <td class="check_title"> 84 <input type="checkbox" name="checkbox-<?php echo esc_html($post_type); ?>" value="1" 85 class="js-cb-customization js-select-single" 86 id="cb-feedback-<?php echo esc_html($post_type); ?>" 87 <?php echo esc_html($checkbox); ?>> 88 </td> 87 89 <td> 88 <input type="number" name="duration-<?php echo esc_html($post_type); ?>" value="<?php echo esc_html($repeat_time); ?>" placeholder="Enter Time in Seconds" id="time_set_field" class="js-time-field" min=0 oninput="checkValue(this)"> 89 </td> 90 </tr> 90 <?php echo esc_html($post_type); ?> 91 </td> 92 <td> 93 <input type="number" name="duration-<?php echo esc_html($post_type); ?>" 94 value="<?php echo esc_html($repeat_time); ?>" 95 placeholder="Enter Time in Seconds" 96 class="js-time-field" 97 min="0"> 98 <select name="time_unit-<?php echo esc_html($post_type); ?>" class="js-time-unit"> 99 <option value="seconds" <?php selected($time_unit, 'seconds'); ?>>Seconds</option> 100 <option value="minutes" <?php selected($time_unit, 'minutes'); ?>>Minutes</option> 101 <option value="hours" <?php selected($time_unit, 'hours'); ?>>Hours</option> 102 </select> 103 </td> 104 </tr> 91 105 <?php } ?> 92 106 </table> … … 110 124 111 125 112 function checkValue(input) { 113 if (input.value < 0) {114 alert("Please enter a positive number.");115 input.value = 'Enter Time in Seconds';116 } 126 function updateGlobalTime(globalInput) { 127 var timeFields = document.querySelectorAll('.js-time-field'); 128 timeFields.forEach(function(timeField) { 129 timeField.value = globalInput.value; 130 }); 117 131 118 if (input.value % 1 !== 0) { 119 input.value = Math.floor(input.value); 120 alert("Please enter a value without point"); 121 } 122 132 // Automatically check all individual checkboxes if global input is used 133 document.querySelectorAll('.js-select-single').forEach(function(checkbox) { 134 checkbox.checked = true; 135 }); 136 } 137 138 // Function to update all time unit fields with the global dropdown value 139 function updateGlobalTimeUnit(globalSelect) { 140 var timeUnits = document.querySelectorAll('.js-time-unit'); 141 timeUnits.forEach(function(timeUnit) { 142 timeUnit.value = globalSelect.value; 143 }); 144 145 // Automatically check all individual checkboxes if global select is used 146 document.querySelectorAll('.js-select-single').forEach(function(checkbox) { 147 checkbox.checked = true; 148 }); 149 } 150 151 // Get the "Select All" checkbox 152 var selectAllCheckbox = document.querySelector('.js-select-all'); 153 selectAllCheckbox.addEventListener('click', function() { 154 var checkboxes = document.querySelectorAll('.js-select-single'); 123 155 var timeFields = document.querySelectorAll('.js-time-field'); 156 var timeUnits = document.querySelectorAll('.js-time-unit'); 157 var globalTime = document.querySelector('#timeField').value; 158 var globalUnit = document.querySelector('#globalTimeUnit').value; 124 159 125 // Loop through each input field 126 timeFields.forEach(function(timeField) { 127 timeField.addEventListener('input', function() { 128 var checkbox = timeField.previousElement.previousElement; 129 checkbox.checked = true; 160 // Apply the global setting to all individual fields and checkboxes 161 checkboxes.forEach(function(checkbox) { 162 checkbox.checked = selectAllCheckbox.checked; 163 }); 164 165 if (selectAllCheckbox.checked) { 166 timeFields.forEach(function(timeField) { 167 timeField.value = globalTime; 130 168 }); 131 }); 132 } 133 134 135 // Get the "Select All" checkbox 136 var selectAllCheckbox = document.querySelector('.js-select-all'); 137 selectAllCheckbox.addEventListener('click', 138 function() { 139 var checkboxes = document.querySelectorAll('.js-select-single'); 140 for (var i = 0; i < checkboxes.length; i++) { 141 // Set the checked property of the checkbox to the same value as the "Select All" checkbox 142 checkboxes[i].checked = selectAllCheckbox.checked; 143 } 144 }); 145 146 document.querySelector(".js-select-all").addEventListener("click", function() { 147 if (this.checked) { 148 document.querySelector(".timeField").addEventListener("input", function() { 149 document.querySelectorAll(".js-time-field").forEach(element => element.value = this.value); 150 }); 151 } else { 152 document.querySelector(".timeField").removeEventListener("input", function() { 153 document.querySelectorAll(".js-time-field").forEach(element => element.value = this.value); 169 timeUnits.forEach(function(timeUnit) { 170 timeUnit.value = globalUnit; 154 171 }); 155 172 } 156 });173 }); 157 174 </script> 158 175 -
auto-refresh-post-page/auto-refresh-post-page.php
r3063383 r3207488 1 1 <?php 2 2 3 /** 3 4 * The plugin bootstrap file … … 25 26 * 26 27 * 27 * 28 * 29 * 28 30 * ________ ___ ___ ________ ___ ___ ___ ________ ________ ___ 29 31 * |\ ____\ |\ \|\ \ |\ __ \ |\ \ |\ \ / /||\ ____\ |\ __ \ |\ \ … … 34 36 * \|_______| \|_______| \|_______| \|__|/__/ /\ __\ |\_________\ \|_______| \|_______| 35 37 * |__|/ \|__| \|_________| 38 * 39 * 40 * 36 41 * 37 42 */ … … 45 50 46 51 // Define plugin constants. 47 define('ARPP_AUTO_REFRESH_VERSION', '1.0. 0');52 define('ARPP_AUTO_REFRESH_VERSION', '1.0.1'); 48 53 define('ARPP_AUTO_REFRESH_PLUGIN_URL', plugin_dir_url(__FILE__)); 49 54 define('ARPP_AUTO_REFRESH_PLUGIN_PATH', plugin_dir_path(__FILE__)); … … 94 99 function ARPP_store_refresh_settings() 95 100 { 96 97 if (!isset($_POST['ARPP_nonce']) || !wp_verify_nonce(sanitize_text_field($_POST['ARPP_nonce']), 'ARPP_store_refresh_settings_nonce')) { 101 if (!isset($_POST['ARPP_nonce']) || !wp_verify_nonce(sanitize_text_field($_POST['ARPP_nonce']), 'ARPP_store_refresh_settings_nonce')) { 98 102 wp_send_json_error('Invalid nonce.'); 99 103 } 100 104 101 // Ensure the data received is an array and sanitize its elements. 102 if (!isset($_POST['data']) || !is_array($_POST['data'])) { 103 return; 104 } 105 106 $data = sanitize_text_field($_POST['data']); 107 $new_data = array(); 108 109 foreach ($data as $key => $value) { 110 // Sanitize the key and value. 111 $key = sanitize_key($key); 112 $value = sanitize_text_field($value); 113 114 // Handle special case for checkboxes if needed. 115 if (strpos($key, 'checkbox') !== false) { 116 $exploded = explode('-', $key); 117 $new_data[$exploded[1]] = $value; 118 } else { 119 $new_data[$key] = $value; 120 } 121 } 122 123 // Store the sanitized data in the database. 124 update_option('ARPP_my_option_name', $new_data); 105 if (!isset($_POST['data']) || !is_array($_POST['data'])) { 106 return; 107 } 108 109 $data = $_POST['data']; 110 $new_data = array(); 111 112 foreach ($data as $key => $value) { 113 $key = sanitize_key($key); 114 $value = sanitize_text_field($value); 115 116 // Check for time unit and duration 117 if (strpos($key, 'time_unit-') === 0 || strpos($key, 'duration-') === 0) { 118 $new_data[$key] = $value; 119 } else { 120 $new_data[$key] = $value === '1' ? 1 : 0; 121 } 122 } 123 124 // Store the sanitized data 125 update_option('ARPP_my_option_name', $new_data); 125 126 } 126 127 … … 200 201 function ARPP_setrefreshtime() 201 202 { 202 $array_from_db = get_option('ARPP_my_option_name'); 203 204 foreach ($array_from_db as $key => $value) { 205 // Sanitize the key and value. 206 $key = sanitize_key($key); 207 $value = absint($value); 208 209 if ($value === 1) { 210 $duration_key = "duration-" . $key; 211 if (array_key_exists($duration_key, $array_from_db)) { 212 $seconds = absint($array_from_db[$duration_key]); 213 $args = array( 214 'post_type' => $key, 215 'posts_per_page' => -1 216 ); 217 $pages = get_posts($args); 218 219 foreach ($pages as $page) { 220 update_post_meta($page->ID, 'ARPP_duration_options', $seconds); 221 } 222 } 223 } elseif ($value === 0) { 224 $args = array( 225 'post_type' => $key, 226 'posts_per_page' => -1 227 ); 228 $pages = get_posts($args); 229 230 foreach ($pages as $page) { 231 delete_post_meta($page->ID, 'ARPP_duration_options'); 232 } 233 } 234 } 203 $array_from_db = get_option('ARPP_my_option_name'); 204 205 foreach ($array_from_db as $key => $value) { 206 if (strpos($key, 'duration-') === 0) { 207 $post_type = str_replace('duration-', '', $key); 208 $seconds = absint($value); 209 210 $time_unit_key = "time_unit-" . $post_type; 211 if (isset($array_from_db[$time_unit_key])) { 212 switch ($array_from_db[$time_unit_key]) { 213 case 'minutes': 214 $seconds *= 60; 215 break; 216 case 'hours': 217 $seconds *= 3600; 218 break; 219 } 220 } 221 222 $args = array( 223 'post_type' => $post_type, 224 'posts_per_page' => -1 225 ); 226 $pages = get_posts($args); 227 228 foreach ($pages as $page) { 229 update_post_meta($page->ID, 'ARPP_duration_options', $seconds); 230 } 231 } 232 } 235 233 } 236 234 -
auto-refresh-post-page/includes/class-auto_refresh_post_page.php
r2990642 r3207488 89 89 $this->version = ARPP_AUTO_REFRESH_VERSION; 90 90 } else { 91 $this->version = '1.0. 0';91 $this->version = '1.0.1'; 92 92 } 93 93 $this->plugin_name = 'auto_refresh_post_page'; -
auto-refresh-post-page/trunk/README.txt
r2995733 r3207488 28 28 ==Version== 29 29 30 The current version of the plugin is 1.0.0 30 The current version of the plugin is 1.0.1 31 32 == New Update == 33 34 A select field where user can select the unit of time like Hours, Minutes, Seconds along time field 31 35 32 36 -
auto-refresh-post-page/trunk/admin/css/auto-refresh-post-page-admin.css
r2989831 r3207488 17 17 input[type="checkbox"] { 18 18 display: inline-block; 19 } 20 input[type=number]{ 21 min-height: 36px; 19 22 } 20 23 label.cb-tab-content__label { … … 54 57 table.widefatsett { 55 58 background: #fff; 59 } 60 .wp-core-ui select { 61 padding: 4px 24px 2px 8px; 62 margin-bottom: 3px; 56 63 } 57 64 table.widefatsett { -
auto-refresh-post-page/trunk/admin/js/auto-refresh-post-page-admin.js
r2989831 r3207488 23 23 var value = jQuery(this).val(); 24 24 data[key] = value; 25 }); 25 26 // Include the selected time unit 27 var timeUnitKey = 'time_unit-' + key.split('-')[1]; 28 var timeUnitValue = jQuery(this).siblings('.js-time-unit').val(); 29 data[timeUnitKey] = timeUnitValue; 30 }); 26 31 console.log(data); 27 32 // var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; -
auto-refresh-post-page/trunk/admin/partials/auto_refresh_post_page-admin-dashboard.php
r2989831 r3207488 35 35 <hr class="cb-divider" /> 36 36 <tr> 37 <th style="text-align: left;"> 38 <input type="checkbox" class="js-select-all"> Select All <input type="number" placeholder="Enter Time in Seconds globallly" class="timeField" id="timeField" min=0 > 39 </th> 37 <th style="text-align: left;"> 38 <input type="checkbox" class="js-select-all"> Select All 39 40 <input type="number" placeholder="Enter Time in Seconds globally" class="timeField" id="timeField" min="0" oninput="updateGlobalTime(this)"> 41 <select id="globalTimeUnit" class="globalTimeUnit" onchange="updateGlobalTimeUnit(this)"> 42 <option value="seconds">Seconds</option> 43 <option value="minutes">Minutes</option> 44 <option value="hours">Hours</option> 45 </select> 46 </th> 40 47 </tr> 41 48 … … 57 64 $post_types = get_post_types( $args, $output, $operator ); 58 65 59 foreach ( $post_types as $post_type) { ?>66 foreach ($post_types as $post_type) { ?> 60 67 <tr> 61 <?php 62 $array_from_db = get_option( 'ARPP_my_option_name');63 64 if(isset($array_from_db[$post_type]) && $array_from_db[$post_type] == 1 ) {65 $checkbox="checked";66 }else{67 $checkbox = "";68 }69 70 if(isset($array_from_db["duration-".$post_type]) && $array_from_db["duration-".$post_type] != '' ) {71 $repeat_time=$array_from_db["duration-".$post_type];72 }else{73 $repeat_time = "";74 }68 <?php 69 $array_from_db = get_option('ARPP_my_option_name'); 70 71 // Checkbox logic: Match the exact key with the `checkbox-` prefix 72 $checkbox_key = "checkbox-" . $post_type; 73 $checkbox = isset($array_from_db[$checkbox_key]) && $array_from_db[$checkbox_key] == 1 ? "checked" : ""; 74 75 // Time field logic 76 $duration_key = "duration-" . $post_type; 77 $repeat_time = isset($array_from_db[$duration_key]) ? $array_from_db[$duration_key] : ""; 78 79 // Time unit logic 80 $time_unit_key = "time_unit-" . $post_type; 81 $time_unit = isset($array_from_db[$time_unit_key]) ? $array_from_db[$time_unit_key] : "seconds"; 75 82 ?> 76 77 <td class="check_title"> 78 <input type="checkbox" name="checkbox-<?php echo esc_html($post_type); ?>" value="1" class="js-cb-customization js-select-single" id="cb-feedback-<?php echo esc_html($post_type); ?>" data-key="feedbackTitle" <?php echo esc_html($checkbox); ?>> 79 </td> 80 <td> 81 <?php echo esc_html($post_type); ?> 82 </td> 83 <td class="check_title"> 84 <input type="checkbox" name="checkbox-<?php echo esc_html($post_type); ?>" value="1" 85 class="js-cb-customization js-select-single" 86 id="cb-feedback-<?php echo esc_html($post_type); ?>" 87 <?php echo esc_html($checkbox); ?>> 88 </td> 83 89 <td> 84 <input type="number" name="duration-<?php echo esc_html($post_type); ?>" value="<?php echo esc_html($repeat_time); ?>" placeholder="Enter Time in Seconds" id="time_set_field" class="js-time-field" min=0 oninput="checkValue(this)"> 85 </td> 86 </tr> 90 <?php echo esc_html($post_type); ?> 91 </td> 92 <td> 93 <input type="number" name="duration-<?php echo esc_html($post_type); ?>" 94 value="<?php echo esc_html($repeat_time); ?>" 95 placeholder="Enter Time in Seconds" 96 class="js-time-field" 97 min="0"> 98 <select name="time_unit-<?php echo esc_html($post_type); ?>" class="js-time-unit"> 99 <option value="seconds" <?php selected($time_unit, 'seconds'); ?>>Seconds</option> 100 <option value="minutes" <?php selected($time_unit, 'minutes'); ?>>Minutes</option> 101 <option value="hours" <?php selected($time_unit, 'hours'); ?>>Hours</option> 102 </select> 103 </td> 104 </tr> 87 105 <?php } ?> 88 106 </table> … … 106 124 107 125 108 function checkValue(input) { 109 if (input.value < 0) {110 alert("Please enter a positive number.");111 input.value = 'Enter Time in Seconds';112 } 126 function updateGlobalTime(globalInput) { 127 var timeFields = document.querySelectorAll('.js-time-field'); 128 timeFields.forEach(function(timeField) { 129 timeField.value = globalInput.value; 130 }); 113 131 114 if (input.value % 1 !== 0) { 115 input.value = Math.floor(input.value); 116 alert("Please enter a value without point"); 117 } 118 132 // Automatically check all individual checkboxes if global input is used 133 document.querySelectorAll('.js-select-single').forEach(function(checkbox) { 134 checkbox.checked = true; 135 }); 136 } 137 138 // Function to update all time unit fields with the global dropdown value 139 function updateGlobalTimeUnit(globalSelect) { 140 var timeUnits = document.querySelectorAll('.js-time-unit'); 141 timeUnits.forEach(function(timeUnit) { 142 timeUnit.value = globalSelect.value; 143 }); 144 145 // Automatically check all individual checkboxes if global select is used 146 document.querySelectorAll('.js-select-single').forEach(function(checkbox) { 147 checkbox.checked = true; 148 }); 149 } 150 151 // Get the "Select All" checkbox 152 var selectAllCheckbox = document.querySelector('.js-select-all'); 153 selectAllCheckbox.addEventListener('click', function() { 154 var checkboxes = document.querySelectorAll('.js-select-single'); 119 155 var timeFields = document.querySelectorAll('.js-time-field'); 156 var timeUnits = document.querySelectorAll('.js-time-unit'); 157 var globalTime = document.querySelector('#timeField').value; 158 var globalUnit = document.querySelector('#globalTimeUnit').value; 120 159 121 // Loop through each input field 122 timeFields.forEach(function(timeField) { 123 timeField.addEventListener('input', function() { 124 var checkbox = timeField.previousElement.previousElement; 125 checkbox.checked = true; 160 // Apply the global setting to all individual fields and checkboxes 161 checkboxes.forEach(function(checkbox) { 162 checkbox.checked = selectAllCheckbox.checked; 163 }); 164 165 if (selectAllCheckbox.checked) { 166 timeFields.forEach(function(timeField) { 167 timeField.value = globalTime; 126 168 }); 127 }); 128 } 129 130 131 // Get the "Select All" checkbox 132 var selectAllCheckbox = document.querySelector('.js-select-all'); 133 selectAllCheckbox.addEventListener('click', 134 function() { 135 var checkboxes = document.querySelectorAll('.js-select-single'); 136 for (var i = 0; i < checkboxes.length; i++) { 137 // Set the checked property of the checkbox to the same value as the "Select All" checkbox 138 checkboxes[i].checked = selectAllCheckbox.checked; 139 } 140 }); 141 142 document.querySelector(".js-select-all").addEventListener("click", function() { 143 if (this.checked) { 144 document.querySelector(".timeField").addEventListener("input", function() { 145 document.querySelectorAll(".js-time-field").forEach(element => element.value = this.value); 146 }); 147 } else { 148 document.querySelector(".timeField").removeEventListener("input", function() { 149 document.querySelectorAll(".js-time-field").forEach(element => element.value = this.value); 169 timeUnits.forEach(function(timeUnit) { 170 timeUnit.value = globalUnit; 150 171 }); 151 172 } 152 });173 }); 153 174 </script> 154 175 -
auto-refresh-post-page/trunk/auto-refresh-post-page.php
r2990567 r3207488 17 17 * Plugin URI: https://cubixsol.com/ 18 18 * Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area. 19 * Version: 1.0. 019 * Version: 1.0.1 20 20 * Author: Cubixsol 21 21 * Author URI: https://cubixsol.com/our-products/ … … 50 50 51 51 // Define plugin constants. 52 define('ARPP_AUTO_REFRESH_VERSION', '1.0. 0');52 define('ARPP_AUTO_REFRESH_VERSION', '1.0.1'); 53 53 define('ARPP_AUTO_REFRESH_PLUGIN_URL', plugin_dir_url(__FILE__)); 54 54 define('ARPP_AUTO_REFRESH_PLUGIN_PATH', plugin_dir_path(__FILE__)); … … 99 99 function ARPP_store_refresh_settings() 100 100 { 101 102 if (!isset($_POST['ARPP_nonce']) || !wp_verify_nonce(sanitize_text_field($_POST['ARPP_nonce']), 'ARPP_store_refresh_settings_nonce')) { 101 if (!isset($_POST['ARPP_nonce']) || !wp_verify_nonce(sanitize_text_field($_POST['ARPP_nonce']), 'ARPP_store_refresh_settings_nonce')) { 103 102 wp_send_json_error('Invalid nonce.'); 104 103 } 105 104 106 // Ensure the data received is an array and sanitize its elements. 107 if (!isset($_POST['data']) || !is_array($_POST['data'])) { 108 return; 109 } 110 111 $data = sanitize_text_field($_POST['data']); 112 $new_data = array(); 113 114 foreach ($data as $key => $value) { 115 // Sanitize the key and value. 116 $key = sanitize_key($key); 117 $value = sanitize_text_field($value); 118 119 // Handle special case for checkboxes if needed. 120 if (strpos($key, 'checkbox') !== false) { 121 $exploded = explode('-', $key); 122 $new_data[$exploded[1]] = $value; 123 } else { 124 $new_data[$key] = $value; 125 } 126 } 127 128 // Store the sanitized data in the database. 129 update_option('ARPP_my_option_name', $new_data); 105 if (!isset($_POST['data']) || !is_array($_POST['data'])) { 106 return; 107 } 108 109 $data = $_POST['data']; 110 $new_data = array(); 111 112 foreach ($data as $key => $value) { 113 $key = sanitize_key($key); 114 $value = sanitize_text_field($value); 115 116 // Check for time unit and duration 117 if (strpos($key, 'time_unit-') === 0 || strpos($key, 'duration-') === 0) { 118 $new_data[$key] = $value; 119 } else { 120 $new_data[$key] = $value === '1' ? 1 : 0; 121 } 122 } 123 124 // Store the sanitized data 125 update_option('ARPP_my_option_name', $new_data); 130 126 } 131 127 … … 205 201 function ARPP_setrefreshtime() 206 202 { 207 $array_from_db = get_option('ARPP_my_option_name'); 208 209 foreach ($array_from_db as $key => $value) { 210 // Sanitize the key and value. 211 $key = sanitize_key($key); 212 $value = absint($value); 213 214 if ($value === 1) { 215 $duration_key = "duration-" . $key; 216 if (array_key_exists($duration_key, $array_from_db)) { 217 $seconds = absint($array_from_db[$duration_key]); 218 $args = array( 219 'post_type' => $key, 220 'posts_per_page' => -1 221 ); 222 $pages = get_posts($args); 223 224 foreach ($pages as $page) { 225 update_post_meta($page->ID, 'ARPP_duration_options', $seconds); 226 } 227 } 228 } elseif ($value === 0) { 229 $args = array( 230 'post_type' => $key, 231 'posts_per_page' => -1 232 ); 233 $pages = get_posts($args); 234 235 foreach ($pages as $page) { 236 delete_post_meta($page->ID, 'ARPP_duration_options'); 237 } 238 } 239 } 203 $array_from_db = get_option('ARPP_my_option_name'); 204 205 foreach ($array_from_db as $key => $value) { 206 if (strpos($key, 'duration-') === 0) { 207 $post_type = str_replace('duration-', '', $key); 208 $seconds = absint($value); 209 210 $time_unit_key = "time_unit-" . $post_type; 211 if (isset($array_from_db[$time_unit_key])) { 212 switch ($array_from_db[$time_unit_key]) { 213 case 'minutes': 214 $seconds *= 60; 215 break; 216 case 'hours': 217 $seconds *= 3600; 218 break; 219 } 220 } 221 222 $args = array( 223 'post_type' => $post_type, 224 'posts_per_page' => -1 225 ); 226 $pages = get_posts($args); 227 228 foreach ($pages as $page) { 229 update_post_meta($page->ID, 'ARPP_duration_options', $seconds); 230 } 231 } 232 } 240 233 } 241 234 -
auto-refresh-post-page/trunk/includes/class-auto_refresh_post_page.php
r2989831 r3207488 89 89 $this->version = ARPP_AUTO_REFRESH_VERSION; 90 90 } else { 91 $this->version = '1.0. 0';91 $this->version = '1.0.1'; 92 92 } 93 93 $this->plugin_name = 'auto_refresh_post_page';
Note: See TracChangeset
for help on using the changeset viewer.