Changeset 3401073
- Timestamp:
- 11/22/2025 08:01:05 PM (3 weeks ago)
- Location:
- yada-wiki
- Files:
-
- 32 added
- 5 edited
-
tags/3.6 (added)
-
tags/3.6/css (added)
-
tags/3.6/css/index.php (added)
-
tags/3.6/css/yadawiki.css (added)
-
tags/3.6/inc (added)
-
tags/3.6/inc/functions-admin.php (added)
-
tags/3.6/inc/functions-public.php (added)
-
tags/3.6/inc/functions-register-cpt.php (added)
-
tags/3.6/inc/functions-settings-load.php (added)
-
tags/3.6/inc/functions-settings.php (added)
-
tags/3.6/inc/functions-widgets.php (added)
-
tags/3.6/inc/index.php (added)
-
tags/3.6/inc/yadawiki-dialog-link.php (added)
-
tags/3.6/inc/yadawiki-dialog-toc.php (added)
-
tags/3.6/index.php (added)
-
tags/3.6/js (added)
-
tags/3.6/js/img (added)
-
tags/3.6/js/img/wiki-link.png (added)
-
tags/3.6/js/img/wiki-toc.png (added)
-
tags/3.6/js/index.php (added)
-
tags/3.6/js/yadawiki-button-link.js (added)
-
tags/3.6/js/yadawiki-button-toc.js (added)
-
tags/3.6/js/yadawiki-dialog.js (added)
-
tags/3.6/lang (added)
-
tags/3.6/lang/yada-wiki.pot (added)
-
tags/3.6/lang/yada_wiki_domain-en_US.mo (added)
-
tags/3.6/lang/yada_wiki_domain-en_US.po (added)
-
tags/3.6/lang/yada_wiki_domain-es_ES.mo (added)
-
tags/3.6/lang/yada_wiki_domain-es_ES.po (added)
-
tags/3.6/license.txt (added)
-
tags/3.6/readme.txt (added)
-
tags/3.6/yada-wiki.php (added)
-
trunk/inc/functions-admin.php (modified) (1 diff)
-
trunk/inc/functions-public.php (modified) (2 diffs)
-
trunk/inc/functions-widgets.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/yada-wiki.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
yada-wiki/trunk/inc/functions-admin.php
r2125863 r3401073 163 163 wp_die(); 164 164 } 165 165 166 /****************************** 167 * Sanitize shortcode input on save 168 *******************************/ 169 function yada_wiki_process_shortcodes_on_save($post_id, $post, $update) { 170 171 // Only run on standard post saves, not autosave or revision 172 if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return; 173 if ( wp_is_post_revision($post_id) ) return; 174 175 // Do we need to filter the saving of posts and pages also? 176 $options = get_option( 'yada_wiki_settings' ); 177 if ( isset($options['yada_wiki_checkbox_editor_buttons_setting']) ) { 178 $allowShortcodeOnPostsAndPages = true; 179 } 180 else { 181 $allowShortcodeOnPostsAndPages = false; 182 } 183 184 if ( $allowShortcodeOnPostsAndPages === true ) { 185 if ( $post->post_type !== 'yada_wiki' && $post->post_type !== 'post' && $post->post_type !== 'page' ) return; 186 } else { 187 if ( $post->post_type !== 'yada_wiki') return; 188 } 189 190 // Prevent infinite loop 191 remove_action('save_post', 'yada_wiki_process_shortcodes_on_save', 10); 192 193 $content = $post->post_content; 194 $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5); 195 $regex = get_shortcode_regex(); 196 $has_changes = false; 197 $allowed_html = array( 198 'em' => array(), // Allow <em> with no attributes 199 ); 200 201 if (preg_match_all('/' . $regex . '/s', $content, $matches, PREG_SET_ORDER)) { 202 foreach ($matches as $match) { 203 if (isset($match[2]) && $match[2] === 'yadawiki') { 204 if (isset($match[3])) { 205 $atts = shortcode_parse_atts($match[3]); 206 // Proceed to process $atts 207 } else { 208 $atts = array(); 209 // Proceed, but there will be no matches 210 } 211 212 // Sanitize attributes 213 $atts['link'] = isset($atts['link']) ? wp_kses($atts['link'], $allowed_html) : ''; 214 $atts['show'] = isset($atts['show']) ? wp_kses($atts['show'], $allowed_html) : ''; 215 $atts['anchor'] = isset($atts['anchor']) ? sanitize_text_field($atts['anchor']) : ''; 216 217 // Rebuild the sanitized shortcode, always with double quotes for safety 218 $sanitized = '[yadawiki'; 219 foreach ($atts as $key => $value) { 220 if ($value !== '') { 221 $sanitized .= " {$key}=\"" . esc_attr($value) . "\""; 222 } 223 } 224 $sanitized .= ']'; 225 226 // Replace the original shortcode with sanitized version 227 $content = str_replace($match[0], $sanitized, $content); 228 $has_changes = true; 229 } elseif (isset($match[2]) && $match[2] === 'yadawikitoc') { 230 if (isset($match[3])) { 231 $atts = shortcode_parse_atts($match[3]); 232 // Proceed to process $atts 233 } else { 234 $atts = array(); 235 // Proceed, but there will be no matches 236 } 237 238 // Sanitize attributes 239 $atts['show_toc'] = isset($atts['show_toc']) ? sanitize_text_field($atts['show_toc']) : ''; 240 $atts['category'] = isset($atts['category']) ? sanitize_text_field($atts['category']) : ''; 241 $atts['order'] = isset($atts['order']) ? sanitize_text_field($atts['order']) : ''; 242 243 // Rebuild the sanitized shortcode, always with double quotes for safety 244 $sanitized = '[yadawikitoc'; 245 foreach ($atts as $key => $value) { 246 if ($value !== '') { 247 $sanitized .= " {$key}=\"" . esc_attr($value) . "\""; 248 } 249 } 250 $sanitized .= ']'; 251 252 // Replace the original shortcode with sanitized version 253 $content = str_replace($match[0], $sanitized, $content); 254 $has_changes = true; 255 } elseif (isset($match[2]) && $match[2] === 'yadawiki-index') { 256 if (isset($match[3])) { 257 $atts = shortcode_parse_atts($match[3]); 258 // Proceed to process $atts 259 } else { 260 $atts = array(); 261 // Proceed, but there will be no matches 262 } 263 264 // Sanitize attributes 265 $atts['type'] = isset($atts['type']) ? sanitize_text_field($atts['type']) : ''; 266 $atts['columns'] = isset($atts['columns']) ? sanitize_text_field($atts['columns']) : ''; 267 268 // Rebuild the sanitized shortcode, always with double quotes for safety 269 $sanitized = '[yadawiki-index'; 270 foreach ($atts as $key => $value) { 271 if ($value !== '') { 272 $sanitized .= " {$key}=\"" . esc_attr($value) . "\""; 273 } 274 } 275 $sanitized .= ']'; 276 277 // Replace the original shortcode with sanitized version 278 $content = str_replace($match[0], $sanitized, $content); 279 $has_changes = true; 280 } 281 } 282 } 283 284 if ($has_changes) { 285 wp_update_post([ 286 'ID' => $post_id, 287 'post_content' => $content 288 ]); 289 } 290 291 // Re-add the hook 292 add_action('save_post', 'yada_wiki_process_shortcodes_on_save', 10, 3); 293 } 294 166 295 /******************************************************** 167 296 * Funciton from Ohad Raz - https://en.bainternet.info/ -
yada-wiki/trunk/inc/functions-public.php
r3049211 r3401073 15 15 'anchor' => '', 16 16 ), $atts ) ); 17 17 18 18 $link = sanitize_text_field($link); 19 19 $show = sanitize_text_field($show); … … 43 43 ); 44 44 if($target) { $target=$target[0]; } 45 45 // Search again in case the page title has em tags around it by removing them for the search 46 if(!$target) { 47 $target = get_posts( 48 array( 49 'post_type' => 'yada_wiki', 50 'title' => sanitize_text_field($wiki_page), 51 'post_status' => 'all', 52 'numberposts' => 1, 53 'update_post_term_cache' => false, 54 'update_post_meta_cache' => false, 55 'orderby' => 'post_date ID', 56 'order' => 'ASC', 57 ) 58 ); 59 if($target) { $target=$target[0]; } 60 } 61 46 62 if($anchor_jump) { 47 63 $firstchar = substr($anchor_jump,0,1); -
yada-wiki/trunk/inc/functions-widgets.php
r2887834 r3401073 17 17 if( $instance) { 18 18 $title = esc_attr($instance['title']); 19 $title = sanitize_text_field($instance['title']); 19 20 $category = $instance['category']; 20 21 $order = $instance['order']; … … 213 214 if( $instance) { 214 215 $title = esc_attr($instance['title']); 216 $title = sanitize_text_field($instance['title']); 215 217 $num_posts = $instance['num_posts']; 216 218 $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false; -
yada-wiki/trunk/readme.txt
r3271525 r3401073 3 3 Tags: wiki, shortcode, page links, faq, knowledge base 4 4 Requires at least: 4.1 5 Tested up to: 6. 86 Stable tag: 3. 55 Tested up to: 6.9 6 Stable tag: 3.6 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 11 11 12 12 == Description == 13 Yada Wiki provides a wiki post type, custom tags and categories, an index, and a table of contents option. The plugin allows you to link your wiki pages together using the wiki page titles. 13 Yada Wiki provides a wiki post type, custom tags and categories, an index, and a table of contents option. The plugin allows you to link your wiki pages together using the wiki page titles. 14 15 Note: As of Yada Wiki 3.6, for current users who have been manually adding HTML tags or special characters to their shortcodes, for security reasons these must be filtered on save. An exception was added for the EM tag because I saw support tickets where users said they were using this tag. If you have been manually editing the shortcodes then you may want to test before installing version 3.6. 14 16 15 17 There are two easy to use shortcode buttons available on the editor toolbar. Rather than try to remember the shortcodes and their values, it is recommended that you use these buttons to generate the shortcodes for you. … … 173 175 == Changelog == 174 176 177 = 3.6 = 178 * Sanitized shortcode inputs on save. Allowed em tags. 179 * Tested for WordPress 6.9 compatibility. 180 175 181 = 3.5 = 176 182 * Fixed shortcode index options which were not working correctly. -
yada-wiki/trunk/yada-wiki.php
r3049211 r3401073 4 4 * Plugin URI: https://www.webtng.com/yada-wiki-documentation 5 5 * Description: This plugin provides a simple wiki for your WordPress site. 6 * Version: 3. 56 * Version: 3.6 7 7 * Author: David McCan 8 8 * Author URI: https://www.webtng.com … … 21 21 * 22 22 * @package YadaWiki 23 * @version 3. 523 * @version 3.6 24 24 * @author David McCan <[email protected]> 25 25 * @copyright Copyright (c) 2015-2024, David McCan … … 208 208 add_action( 'plugins_loaded', array( $this, 'i18n' ), 2 ); 209 209 add_action( 'init', 'yadawiki_load_settings' ); 210 add_shortcode('yadawiki', 'yada_wiki_shortcode'); 211 add_shortcode('yadawikitoc', 'yada_wiki_toc_shortcode'); 212 add_shortcode('yadawiki-index', 'yada_wiki_index_shortcode'); 210 213 211 214 // public facing 212 215 if ( ! is_admin() ) { 213 216 add_action( 'wp_enqueue_scripts', 'yada_wiki_scripts' ); 214 add_shortcode('yadawiki', 'yada_wiki_shortcode');215 add_shortcode('yadawikitoc', 'yada_wiki_toc_shortcode');216 add_shortcode('yadawiki-index', 'yada_wiki_index_shortcode');217 217 } 218 218 … … 224 224 add_action( 'admin_menu', 'yada_wiki_add_admin_menu' ); 225 225 add_action( 'admin_init', 'yada_wiki_settings_init' ); 226 add_action('save_post', 'yada_wiki_process_shortcodes_on_save', 10, 3); 226 227 227 228 // Handle Gutenberg
Note: See TracChangeset
for help on using the changeset viewer.