Changeset 3303314
- Timestamp:
- 05/30/2025 05:17:42 AM (9 months ago)
- Location:
- docid/trunk
- Files:
-
- 3 edited
-
README.txt (modified) (1 diff)
-
admin/class-docid-metaboxes.php (modified) (4 diffs)
-
docid.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
docid/trunk/README.txt
r3298699 r3303314 5 5 Requires PHP: 7.4 6 6 Tested up to: 6.8 7 Stable tag: 1.0. 67 Stable tag: 1.0.7 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html -
docid/trunk/admin/class-docid-metaboxes.php
r3298300 r3303314 32 32 // wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/example.js', array(), $this->version, false); 33 33 } 34 35 /** 36 * Save the meta box setting 37 * 38 * @param int $post_id the post id to save 39 * 40 * @since 1.0.0 41 * @access public 42 */ 43 public function docid_save_meta_boxes($post_id) 44 { 45 $options = array( 46 'docid_restricted' => 'checkbox' 47 ); 48 49 foreach ($options as $option => $type) { 50 51 $nonce = $option . '_nonce'; 52 53 if ($this->docid_user_save_permissions($post_id, $nonce, $option)) { 54 if (isset($_POST[$option])) { 55 switch($type) { 56 case 'checkbox': $sanitizedMetaValue = intval(wp_unslash($_POST[$option])); break; 57 default: $sanitizedMetaValue = sanitize_text_field(wp_unslash($_POST[$option])); 58 } 59 update_post_meta($post_id, $option, $sanitizedMetaValue); 60 } else { 61 delete_post_meta($post_id, $option); 62 } 63 } 64 65 } 66 67 } 34 68 35 69 /** … … 90 124 } 91 125 92 93 126 /** 94 127 * Meta box display restrict access … … 104 137 <div> 105 138 <label> 106 <input type="checkbox" id="docid_restricted" class="<?php echo esc_attr(get_post_meta($post->ID, 'docid_all_group', true)); ?>" name="docid_restricted" onclick="toggleCheckboxes(this)"107 <?php checked(esc_attr(get_post_meta(get_the_ID(), 'docid_restricted', true)), 'on', true); ?> />139 <input id="docid_restricted" name="docid_restricted" class="<?php echo esc_attr(get_post_meta($post->ID, 'docid_all_group', true)); ?>" type="checkbox" onclick="toggleCheckboxes(this)" 140 <?php checked(get_post_meta(get_the_ID(), 'docid_restricted', true), 1); ?> /> 108 141 <?php esc_html_e('HCP-Login Required', 'docid'); ?> 109 142 </label> 143 <?php wp_nonce_field('docid_restricted', 'docid_restricted_nonce'); ?> 110 144 </div> 111 145 112 146 <?php 113 wp_nonce_field('docid_restricted', 'docid_restricted_nonce'); 114 115 } 116 117 /** 118 * Meta box display menu items 119 * 120 * @since 1.0.0 121 * @access public 122 */ 123 public function docid_register_meta_boxes_menu_items($object) 124 { 125 global $nav_menu_selected_id; 147 148 } 149 150 /** 151 * Verifies that the user who is currently logged in has permission to save 152 * 153 * @param integer $post_id the post id to save 154 * @param string $nonce the security nonce 155 * @param string $action the source of the nonce 156 * 157 * @return boolean True if the user can save the information 158 * @since 1.0.0 159 * @access private 160 */ 161 private function docid_user_save_permissions($post_id, $nonce, $action) 162 { 163 $nonce = (isset($_POST[$nonce])) ? sanitize_text_field(wp_unslash($_POST[$nonce])) : ''; 164 165 $post_id = absint($post_id); 166 167 $action = sanitize_key($action); 168 $is_autosave = wp_is_post_autosave($post_id); 169 $is_revision = wp_is_post_revision($post_id); 170 171 return !($is_autosave || $is_revision) && wp_verify_nonce($nonce, $action); 172 } 173 174 /** 175 * Meta box display menu items 176 * 177 * @since 1.0.0 178 * @access public 179 */ 180 public function docid_register_meta_boxes_menu_items($object) 181 { 182 global $nav_menu_selected_id; 126 183 127 184 $menuItemLogout = new \stdClass; 128 185 $menuItemLogout->db_id = 0; 129 186 $menuItemLogout->object = 'custom'; 130 $menuItemLogout->object_id = self::DOCID_META_LOGOUT_LINK_PLACEHOLDER;131 $menuItemLogout->menu_item_parent = 0;132 $menuItemLogout->type = 'custom';133 $menuItemLogout->title = 'Logout';134 $menuItemLogout->url = self::DOCID_META_LOGOUT_LINK_PLACEHOLDER;135 $menuItemLogout->target = '';136 $menuItemLogout->attr_title = '';137 $menuItemLogout->classes = array('logout', 'docid-logout');138 $menuItemLogout->xfn = '';139 140 $walker = new \Walker_Nav_Menu_Checklist(array());187 $menuItemLogout->object_id = self::DOCID_META_LOGOUT_LINK_PLACEHOLDER; 188 $menuItemLogout->menu_item_parent = 0; 189 $menuItemLogout->type = 'custom'; 190 $menuItemLogout->title = esc_html__('Logout', 'docid'); 191 $menuItemLogout->url = self::DOCID_META_LOGOUT_LINK_PLACEHOLDER; 192 $menuItemLogout->target = ''; 193 $menuItemLogout->attr_title = ''; 194 $menuItemLogout->classes = array('logout', 'docid-logout'); 195 $menuItemLogout->xfn = ''; 196 197 $walker = new \Walker_Nav_Menu_Checklist(array()); 141 198 $menuItems = array( 142 $menuItemLogout199 $menuItemLogout 143 200 ); 144 201 145 ?>202 ?> 146 203 <div id="docid-links" class="docid-menu-links"> 147 204 <div id="tabs-panel-docid-links-all" class="tabs-panel tabs-panel-view-all tabs-panel-active"> 148 205 <ul id="docid-links-checklist" class="list:docid-links categorychecklist form-no-clear"> 149 <?php echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menuItems), 0, (object) array('walker' => $walker)); ?>206 <?php echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menuItems), 0, (object) array('walker' => $walker)); ?> 150 207 </ul> 151 208 </div> … … 157 214 </p> 158 215 </div> 159 <?php 160 161 } 162 163 /** 164 * Save meta box content. 165 * 166 * @param int $post_id Post ID 167 * 168 * @since 1.0.0 169 * @access public 170 */ 171 public function docid_save_meta_boxes($post_id) 172 { 173 $options = [ 174 array('name' => 'docid_restricted', 'type' => 'checkbox') 175 ]; 176 177 foreach ($options as $option) { 178 179 $nonce = $option['name'] . '_nonce'; 180 181 if ($this->docid_user_save_permissions($post_id, $nonce, $option['name'])) { 182 if (isset($_POST[$option['name']])) { 183 switch($option['type']) { 184 case 'checkbox': 185 $sanitizedMetaValue = intval(wp_unslash($_POST[$option['name']])); 186 break; 187 default: 188 $sanitizedMetaValue = sanitize_text_field(wp_unslash($_POST[$option['name']])); 189 } 190 update_post_meta($post_id, $option['name'], $sanitizedMetaValue); 191 } else { 192 delete_post_meta($post_id, $option['name']); 193 } 194 } 195 196 } 197 198 } 199 200 /** 201 * Verifies that the user who is currently logged in has permission to save the data 202 * from the meta box to the database. 203 * 204 * @param integer $post_id The current post being saved. 205 * @param string $nonce The number used once to identify the serialization value 206 * @param string $action The source of the action of the nonce being used 207 * 208 * @return boolean True if the user can save the information 209 * @since 1.0.0 210 * @access private 211 */ 212 private function docid_user_save_permissions($post_id, $nonce, $action) 213 { 214 // Sanitize nonce 215 $nonce = (isset($_POST[$nonce])) ? sanitize_text_field(wp_unslash($_POST[$nonce])) : ''; 216 217 // Sanitize and validate post ID 218 $post_id = absint($post_id); 219 220 // Sanitize and validate action 221 $action = sanitize_key($action); 222 $is_autosave = wp_is_post_autosave($post_id); 223 $is_revision = wp_is_post_revision($post_id); 224 225 return !($is_autosave || $is_revision) && wp_verify_nonce($nonce, $action); 226 } 216 <?php 217 218 } 227 219 228 220 } -
docid/trunk/docid.php
r3298699 r3303314 14 14 * Plugin Name: DocID 15 15 * Description: The DocID plugin provides all the functionalities required for a secure and legally compliant authentication of healthcare professionals on your website. 16 * Version: 1.0. 616 * Version: 1.0.7 17 17 * Author: 8awake GmbH <[email protected]> 18 18 * Author URI: https://docid.de
Note: See TracChangeset
for help on using the changeset viewer.