Changeset 2624427
- Timestamp:
- 11/04/2021 10:33:06 AM (4 years ago)
- Location:
- dynamic-widgets/trunk
- Files:
-
- 2 edited
-
dynamic-widgets.php (modified) (3 diffs)
-
dynwid_admin_save.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dynamic-widgets/trunk/dynamic-widgets.php
r2164838 r2624427 5 5 * Description: Dynamic Widgets gives you full control on which pages your widgets will appear. It lets you dynamicly show or hide widgets on WordPress pages. 6 6 * Author: Qurl 7 * Version: 1. 5.167 * Version: 1.6.0 8 8 * Author URI: http://www.qurl.nl/ 9 9 * Tags: widget, widgets, dynamic, sidebar, custom, rules, logic, admin, condition, conditional tags, hide, show, wpml, qtranslate, wpec, buddypress, pods … … 39 39 * Thanks to WordPress formm user @fjaeker for finding and debugging a problem in the Pages module since WordPress 5. 40 40 * Thanks to WordPress forum user @sovabarmak for finding and fixing a bug in Pages childs as a result of the previous Pages fix 41 * Thanks to Erwan from WPScan to find a vulnerability in processing the Custom Posts Taxonomy tree. 41 42 * 42 43 * … … 85 86 define('DW_TIME_LIMIT', 86400); // 1 day 86 87 define('DW_URL_AUTHOR', 'http://www.qurl.nl'); 87 define('DW_VERSION', '1. 5.16');88 define('DW_VERSION', '1.6.0'); 88 89 define('DW_WPML_API', '/inc/wpml-api.php'); // WPML Plugin support - API file relative to ICL_PLUGIN_PATH 89 90 define('DW_WPML_ICON', 'img/wpml_icon.png'); // WPML Plugin support - WPML icon -
dynamic-widgets/trunk/dynwid_admin_save.php
r2032225 r2624427 1 1 <?php 2 /**3 * dynwid_admin_save.php - Saving options to the database4 *5 * @version $Id$6 * @copyright 2011 Jacco Drabbe7 */2 /** 3 * dynwid_admin_save.php - Saving options to the database 4 * 5 * @version $Id$ 6 * @copyright 2011 Jacco Drabbe 7 */ 8 8 9 9 defined('ABSPATH') or die("No script kiddies please!"); 10 10 11 // Security - nonce, etc.12 $widget_id = ( isset($_POST['widget_id']) && ! empty($_POST['widget_id']) ) ? esc_attr($_POST['widget_id']) : '';13 $returnurl = ( isset($_POST['returnurl']) && ! empty($_POST['returnurl']) ) ? esc_url($_POST['returnurl']) : '';14 15 // In some cases $widget_id appears not to be global (anymore)11 // Security - nonce, etc. 12 $widget_id = ( isset($_POST['widget_id']) && ! empty($_POST['widget_id']) ) ? esc_attr($_POST['widget_id']) : ''; 13 $returnurl = ( isset($_POST['returnurl']) && ! empty($_POST['returnurl']) ) ? esc_url($_POST['returnurl']) : ''; 14 15 // In some cases $widget_id appears not to be global (anymore) 16 16 $GLOBALS['widget_id'] = $widget_id; 17 17 18 check_admin_referer('plugin-name-action_edit_' . $widget_id);19 if (!array_key_exists($widget_id, $DW->registered_widgets) ) {20 wp_die('WidgetID is not valid');21 }22 23 /* Checking basic stuff */18 check_admin_referer('plugin-name-action_edit_' . $widget_id); 19 if ( !array_key_exists($widget_id, $DW->registered_widgets) ) { 20 wp_die('WidgetID is not valid'); 21 } 22 23 /* Checking basic stuff */ 24 24 $DW->registerOverrulers(); 25 foreach ( $DW->overrule_maintype as $o ) {26 if ( $o != 'date' && $o != 'url' ) {27 $act_field = $o . '_act';28 if ( isset($_POST[$act_field]) ) {29 if ( $_POST[$o] == 'no' && count($_POST[$act_field]) == 0 ) {30 wp_redirect( $_SERVER['REQUEST_URI'] . '&work=none');31 die();32 }33 }34 }35 }36 37 // Date check38 if ( $_POST['date'] == 'no' ) {39 $date_start = trim(esc_attr($_POST['date_start']));40 $date_end = trim(esc_attr($_POST['date_end']));41 42 if (! preg_match('/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/', $date_start) && ! preg_match('/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/', $date_end) ) {43 wp_redirect( $_SERVER['REQUEST_URI'] . '&work=none');44 die();45 }46 47 if (! empty($date_start) ) {48 @list($date_start_year, $date_start_month, $date_start_day) = explode('-', $date_start);49 if (!checkdate($date_start_month, $date_start_day, $date_start_year) ) {50 unset($date_start);51 }52 }53 if (! empty($date_end) ) {54 @list($date_end_year, $date_end_month, $date_end_day) = explode('-', $date_end);55 if (!checkdate($date_end_month, $date_end_day, $date_end_year) ) {56 unset($date_end);57 }58 }59 60 if (! empty($date_start) && ! empty($date_end) ) {61 if ( mktime(0, 0, 0, $date_start_month, $date_start_day, $date_start_year) > mktime(0, 0, 0, $date_end_month, $date_end_day, $date_end_year) ) {62 wp_redirect( $_SERVER['REQUEST_URI'] . '&work=nonedate');63 die();64 }65 }66 }67 68 // URL69 if ( $_POST['url'] == 'no' && empty($_POST['url_value']) ) {70 wp_redirect( $_SERVER['REQUEST_URI'] . '&work=none');71 die();72 }25 foreach ( $DW->overrule_maintype as $o ) { 26 if ( $o != 'date' && $o != 'url' ) { 27 $act_field = $o . '_act'; 28 if ( isset($_POST[$act_field]) ) { 29 if ( $_POST[$o] == 'no' && count($_POST[$act_field]) == 0 ) { 30 wp_redirect($_SERVER['REQUEST_URI'] . '&work=none'); 31 die(); 32 } 33 } 34 } 35 } 36 37 // Date check 38 if ( $_POST['date'] == 'no' ) { 39 $date_start = trim(esc_attr($_POST['date_start'])); 40 $date_end = trim(esc_attr($_POST['date_end'])); 41 42 if ( ! preg_match('/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/', $date_start) && ! preg_match('/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/', $date_end) ) { 43 wp_redirect($_SERVER['REQUEST_URI'] . '&work=none'); 44 die(); 45 } 46 47 if ( ! empty($date_start) ) { 48 @list($date_start_year, $date_start_month, $date_start_day) = explode('-', $date_start); 49 if ( !checkdate($date_start_month, $date_start_day, $date_start_year) ) { 50 unset($date_start); 51 } 52 } 53 if ( ! empty($date_end) ) { 54 @list($date_end_year, $date_end_month, $date_end_day) = explode('-', $date_end); 55 if ( !checkdate($date_end_month, $date_end_day, $date_end_year) ) { 56 unset($date_end); 57 } 58 } 59 60 if ( ! empty($date_start) && ! empty($date_end) ) { 61 if ( mktime(0, 0, 0, $date_start_month, $date_start_day, $date_start_year) > mktime(0, 0, 0, $date_end_month, $date_end_day, $date_end_year) ) { 62 wp_redirect($_SERVER['REQUEST_URI'] . '&work=nonedate'); 63 die(); 64 } 65 } 66 } 67 68 // URL 69 if ( $_POST['url'] == 'no' && empty($_POST['url_value']) ) { 70 wp_redirect($_SERVER['REQUEST_URI'] . '&work=none'); 71 die(); 72 } 73 73 74 74 // Domain 75 75 if ( $_POST['domain'] == 'no' && empty($_POST['domain_value']) ) { 76 wp_redirect( $_SERVER['REQUEST_URI'] . '&work=none');76 wp_redirect($_SERVER['REQUEST_URI'] . '&work=none'); 77 77 die(); 78 78 } 79 79 80 // IP81 if ( $_POST['ip'] == 'no' && empty($_POST['ip_value']) ) {82 wp_redirect( $_SERVER['REQUEST_URI'] . '&work=none');83 die();84 }85 86 // Removing already set options, but keeping individual rules87 $dbtable = $GLOBALS['wpdb']->prefix . DW_DB_TABLE;88 $query = "SELECT COUNT(1) AS total FROM ". $dbtable . " WHERE widget_id = '" . $widget_id . "' AND maintype = 'individual'";89 $count = $GLOBALS['wpdb']->get_var($query);90 91 if ( $count > 0 && isset($_POST['individual']) && $_POST['individual'] == '1' ) {92 $post_types = ( is_array($_POST['post_types']) ) ? $_POST['post_types'] : array();93 $post_types = array_merge( array('single_post', 'single_tag'), $post_types);94 95 foreach ( $post_types as $t ) {96 $maintype = (!preg_match('/^single/', $t) ) ? $t . '-post' : $t;97 98 $query = "SELECT name FROM " . $dbtable . " WHERE widget_id = '" . $widget_id . "' AND maintype = '" . $maintype . "'";99 $results = $GLOBALS['wpdb']->get_results($query);100 101 foreach ( $results as $row ) {102 if ( is_numeric($row->name) ) {103 $a = $maintype . '_act';104 105 if (!is_array($_POST[$a]) ) {106 $_POST[$a] = array();107 }108 109 $_POST[$a][] = $row->name;110 }111 }112 113 }114 115 }116 117 $DW->resetOptions($widget_id);118 119 // Role80 // IP 81 if ( $_POST['ip'] == 'no' && empty($_POST['ip_value']) ) { 82 wp_redirect($_SERVER['REQUEST_URI'] . '&work=none'); 83 die(); 84 } 85 86 // Removing already set options, but keeping individual rules 87 $dbtable = $GLOBALS['wpdb']->prefix . DW_DB_TABLE; 88 $query = "SELECT COUNT(1) AS total FROM " . $dbtable . " WHERE widget_id = '" . $widget_id . "' AND maintype = 'individual'"; 89 $count = $GLOBALS['wpdb']->get_var($query); 90 91 if ( $count > 0 && isset($_POST['individual']) && $_POST['individual'] == '1' ) { 92 $post_types = ( is_array($_POST['post_types']) ) ? $_POST['post_types'] : array(); 93 $post_types = array_merge(array( 'single_post', 'single_tag' ), $post_types); 94 95 foreach ( $post_types as $t ) { 96 $maintype = ( !preg_match('/^single/', $t) ) ? $t . '-post' : $t; 97 98 $query = "SELECT name FROM " . $dbtable . " WHERE widget_id = '" . $widget_id . "' AND maintype = '" . $maintype . "'"; 99 $results = $GLOBALS['wpdb']->get_results($query); 100 101 foreach ( $results as $row ) { 102 if ( is_numeric($row->name) ) { 103 $a = $maintype . '_act'; 104 105 if ( !is_array($_POST[$a]) ) { 106 $_POST[$a] = array(); 107 } 108 109 $_POST[$a][] = $row->name; 110 } 111 } 112 113 } 114 115 } 116 117 $DW->resetOptions($widget_id); 118 119 // Role 120 120 DWModule::save('role', 'complex'); 121 121 122 // Date123 if ( $_POST['date'] == 'no' ) {124 $dates = array();125 if ( preg_match('/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/', $date_start) ) {126 $dates['date_start'] = $date_start;127 }128 if ( preg_match('/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/', $date_end) ) {129 $dates['date_end'] = $date_end;130 }131 132 if ( count($dates) > 0 ) {133 $DW->addDate($widget_id, $dates);134 }135 }136 137 // Day138 DWModule::save('day', 'complex');139 140 // Week122 // Date 123 if ( $_POST['date'] == 'no' ) { 124 $dates = array(); 125 if ( preg_match('/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/', $date_start) ) { 126 $dates['date_start'] = $date_start; 127 } 128 if ( preg_match('/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/', $date_end) ) { 129 $dates['date_end'] = $date_end; 130 } 131 132 if ( count($dates) > 0 ) { 133 $DW->addDate($widget_id, $dates); 134 } 135 } 136 137 // Day 138 DWModule::save('day', 'complex'); 139 140 // Week 141 141 DWModule::save('week', 'complex'); 142 142 143 // Browser143 // Browser 144 144 DWModule::save('browser', 'complex'); 145 145 … … 151 151 152 152 // URL 153 if ( ! empty($_POST['url_value']) ) {153 if ( ! empty($_POST['url_value']) ) { 154 154 $urls = array(); 155 155 … … 160 160 foreach ( $url_values as $url ) { 161 161 $url = trim($url); 162 if ( ! empty($url) ) {163 $urls[ ] = $url;162 if ( ! empty($url) ) { 163 $urls[] = $url; 164 164 } 165 165 } … … 171 171 172 172 // URL 173 if ( ! empty($_POST['domain_value']) ) {173 if ( ! empty($_POST['domain_value']) ) { 174 174 $domains = array(); 175 175 … … 180 180 foreach ( $domain_values as $domain ) { 181 181 $url = trim($domain); 182 if ( ! empty($domain) ) {183 $domains[ ] = $domain;182 if ( ! empty($domain) ) { 183 $domains[] = $domain; 184 184 } 185 185 } … … 190 190 } 191 191 192 193 192 // IP 194 if ( ! empty($_POST['ip_value']) ) {193 if ( ! empty($_POST['ip_value']) ) { 195 194 $ips = array(); 196 195 … … 201 200 foreach ( $ip_values as $ip ) { 202 201 $ip = trim($ip); 203 if ( ! empty($ip) ) {204 $ips[ ] = $ip;202 if ( ! empty($ip) ) { 203 $ips[] = $ip; 205 204 } 206 205 } … … 215 214 216 215 // Shortcode 217 if ( ! empty($_POST['shortcode_value']) ) {216 if ( ! empty($_POST['shortcode_value']) ) { 218 217 $value = sanitize_text_field($_POST['shortcode_value']); 219 if ( ! empty($value) && substr($value, 0, 1) !== '[' && substr($value, strlen($value)-1) !== ']' ) {218 if ( ! empty($value) && substr($value, 0, 1) !== '[' && substr($value, strlen($value) - 1) !== ']' ) { 220 219 $value = '[' . $value . ']'; 221 220 } … … 223 222 $match = sanitize_text_field($_POST['shortcode_match']); 224 223 $operator = $_POST['shortcode_operator']; 225 if ( ! in_array($operator, array('=', '!=')) ) {224 if ( !in_array($operator, array( '=', '!=' )) ) { 226 225 $operator = '='; 227 226 } 228 227 229 if ( ! empty($value) ) {228 if ( ! empty($value) ) { 230 229 $DW->addShortcode($widget_id, $_POST['shortcode'], $value, $match, $operator); 231 230 } 232 231 } 233 232 234 // Front Page235 DWModule::save('front-page', 'complex');236 237 // Single Post233 // Front Page 234 DWModule::save('front-page', 'complex'); 235 236 // Single Post 238 237 DWModule::save('single'); 239 238 240 239 // -- Post Taxonomies 241 if ( isset($_POST['single_tax_list']) && count($_POST['single_tax_list']) > 0 ) {240 if ( isset($_POST['single_tax_list']) && is_array($_POST['single_tax_list']) && count($_POST['single_tax_list']) > 0 ) { 242 241 foreach ( $_POST['single_tax_list'] as $tax ) { 242 $tax = sanitize_text_field($tax); 243 243 $act_tax_field = $tax . '_act'; 244 244 // if ( isset($_POST[$act_tax_field]) && count($_POST[$act_tax_field]) > 0 ) { 245 if ( isset($_POST[$act_tax_field]) && ! empty($_POST[$act_tax_field]) ) {245 if ( isset($_POST[$act_tax_field]) && !empty($_POST[$act_tax_field]) ) { 246 246 if ( substr($_POST[$act_tax_field], 0, 1) == ',' ) { 247 247 $_POST[$act_tax_field] = substr($_POST[$act_tax_field], 1); … … 268 268 } 269 269 270 // -- Author271 if ( isset($_POST['single_author_act']) && count($_POST['single_author_act']) > 0 ) {272 if ( $_POST['single'] == 'yes' ) {273 $DW->addSingleOption($widget_id, 'single', '1');274 }275 $DW->addMultiOption($widget_id, 'single-author', $_POST['single'], $_POST['single_author_act']);276 }277 278 // -- Category279 if ( isset($_POST['single_category_act']) && count($_POST['single_category_act']) > 0 ) {280 if ( $_POST['single'] == 'yes' && isset($_POST['single_author_act']) && count($_POST['single_author_act']) == 0 ) {281 $DW->addSingleOption($widget_id, 'single', '1');282 }283 $DW->addMultiOption($widget_id, 'single-category', $_POST['single'], $_POST['single_category_act']);284 }270 // -- Author 271 if ( isset($_POST['single_author_act']) && is_array($_POST['single_author_act']) && count($_POST['single_author_act']) > 0 ) { 272 if ( $_POST['single'] == 'yes' ) { 273 $DW->addSingleOption($widget_id, 'single', '1'); 274 } 275 $DW->addMultiOption($widget_id, 'single-author', $_POST['single'], $_POST['single_author_act']); 276 } 277 278 // -- Category 279 if ( isset($_POST['single_category_act']) && is_array($_POST['single_category_act']) && count($_POST['single_category_act']) > 0 ) { 280 if ( $_POST['single'] == 'yes' && isset($_POST['single_author_act']) && count($_POST['single_author_act']) == 0 ) { 281 $DW->addSingleOption($widget_id, 'single', '1'); 282 } 283 $DW->addMultiOption($widget_id, 'single-category', $_POST['single'], $_POST['single_category_act']); 284 } 285 285 286 286 // ---- Childs 287 if ( isset($_POST['single_category_act']) && count($_POST['single_category_act']) > 0 && isset($_POST['single_category_childs_act']) && count($_POST['single_category_childs_act']) > 0 ) {287 if ( isset($_POST['single_category_act']) && is_array($_POST['single_category_act']) && count($_POST['single_category_act']) > 0 && isset($_POST['single_category_childs_act']) && is_array($_POST['single_category_childs_act']) && count($_POST['single_category_childs_act']) > 0 ) { 288 288 $DW->addChilds($widget_id, 'single-category-childs', $_POST['single'], $_POST['single_category_act'], $_POST['single_category_childs_act']); 289 289 } 290 290 291 // -- Individual / Posts / Tag292 if ( isset($_POST['individual']) && $_POST['individual'] == '1' ) {293 $DW->addSingleOption($widget_id, 'individual', '1');294 if ( isset($_POST['single_post_act']) && count($_POST['single_post_act']) > 0 ) {295 $DW->addMultiOption($widget_id, 'single-post', $_POST['single'], $_POST['single_post_act']);296 }297 if ( isset($_POST['single_tag_act']) && count($_POST['single_tag_act']) > 0 ) {298 $DW->addMultiOption($widget_id, 'single-tag', $_POST['single'], $_POST['single_tag_act']);299 }300 }301 302 // Attachment291 // -- Individual / Posts / Tag 292 if ( isset($_POST['individual']) && $_POST['individual'] == '1' ) { 293 $DW->addSingleOption($widget_id, 'individual', '1'); 294 if ( isset($_POST['single_post_act']) && is_array($_POST['single_post_act']) && count($_POST['single_post_act']) > 0 ) { 295 $DW->addMultiOption($widget_id, 'single-post', $_POST['single'], $_POST['single_post_act']); 296 } 297 if ( isset($_POST['single_tag_act']) && is_array($_POST['single_tag_act']) && count($_POST['single_tag_act']) > 0 ) { 298 $DW->addMultiOption($widget_id, 'single-tag', $_POST['single'], $_POST['single_tag_act']); 299 } 300 } 301 302 // Attachment 303 303 DWModule::save('attachment'); 304 304 305 // Pages305 // Pages 306 306 // Go through the page_tax_list - Workaround as for some reason get_object_taxonomies() is not always filled 307 307 $page_taxonomy = FALSE; 308 308 $page_tax_list = array(); 309 if ( isset($_POST['page_tax_list']) && count($_POST['page_tax_list']) > 0 ) {309 if ( isset($_POST['page_tax_list']) && is_array($_POST['page_tax_list']) && count($_POST['page_tax_list']) > 0 ) { 310 310 foreach ( $_POST['page_tax_list'] as $tax ) { 311 $tax = sanitize_text_field($tax); 311 312 $act_tax_field = $tax . '_act'; 312 313 if ( isset($_POST[$act_tax_field]) && count($_POST[$act_tax_field]) > 0 ) { … … 317 318 } 318 319 319 if ( (isset($_POST['page_act']) && count($_POST['page_act']) > 0) || $page_taxonomy ) { 320 if (! isset($_POST['page_act']) ) { 320 if ( ( isset($_POST['page_act']) && is_array($_POST['page_act']) && count($_POST['page_act']) > 0 ) || $page_taxonomy ) { 321 // When $page_taxonomy = TRUE 322 if ( !isset($_POST['page_act']) ) { 321 323 $_POST['page_act'] = array(); 322 324 } … … 331 333 332 334 // -- Page Taxonomies 333 if ( isset($_POST['page_tax_list']) && count($_POST['page_tax_list']) > 0 ) {335 if ( isset($_POST['page_tax_list']) && is_array($_POST['page_tax_list']) && count($_POST['page_tax_list']) > 0 ) { 334 336 foreach ( $_POST['page_tax_list'] as $tax ) { 337 $tax = sanitize_text_field($tax); 338 335 339 $act_tax_field = $tax . '_act'; 336 340 if ( isset($_POST[$act_tax_field]) && ! empty($_POST[$act_tax_field]) ) { … … 347 351 // ---- Childs >> Can't use DWModule::childSave() cause of $name != $tax, but $name == 'page' 348 352 $act_tax_childs_field = $tax . '_childs_act'; 349 if ( isset($_POST[$act_tax_field]) && ! empty($_POST[$act_tax_field]) && isset($_POST[$act_tax_childs_field]) && ! empty($_POST[$act_tax_childs_field]) ) {353 if ( isset($_POST[$act_tax_field]) && ! empty($_POST[$act_tax_field]) && isset($_POST[$act_tax_childs_field]) && !empty($_POST[$act_tax_childs_field]) ) { 350 354 351 355 if ( substr($_POST[$act_tax_childs_field], 0, 1) == ',' ) { … … 360 364 } 361 365 362 // Author366 // Author 363 367 DWModule::save('author', 'complex'); 364 368 365 // Categories369 // Categories 366 370 DWModule::save('category', 'complex'); 367 DWModule::childSave('category'); // -- Childs371 DWModule::childSave('category'); // -- Childs 368 372 369 373 // Tags 370 374 DWModule::save('tag', 'complex'); 371 375 372 // Archive376 // Archive 373 377 DWModule::save('archive'); 374 378 375 // Error 404379 // Error 404 376 380 DWModule::save('e404'); 377 381 378 // Search382 // Search 379 383 DWModule::save('search'); 380 384 381 // Custom Types 382 if ( isset($_POST['post_types']) ) { 383 foreach ( $_POST['post_types'] as $type ) { 384 385 if ( isset($_POST['individual']) && $_POST['individual'] == '1' ) { 386 if ( isset($_POST[$type . '-post_act']) && count($_POST[$type . '-post_act']) > 0 ) { 387 $DW->addMultiOption($widget_id, $type . '-post', $_POST[$type], $_POST[$type . '-post_act']); 388 } 389 } 390 391 // Check taxonomies 392 $taxonomy = FALSE; 393 394 // Go through the tax_list - Workaround as for some reason get_object_taxonomies() is not always filled 395 $tax_list = array(); 396 $len = strlen($type); 397 if ( isset($_POST['tax_list']) && count($_POST['tax_list']) > 0 ) { 398 foreach ( $_POST['tax_list'] as $tl ) { 399 if ( substr($tl, 0, $len) == $type ) { 400 $tax_list[] = $tl; 401 } 402 } 403 } 404 405 foreach ( $tax_list as $tax ) { 406 $act_tax_field = $tax . '_act'; 407 if ( isset($_POST[$act_tax_field]) && count($_POST[$act_tax_field]) > 0 ) { 408 $taxonomy = TRUE; 409 break; 410 } 411 } 412 413 $act_field = $type . '_act'; 414 if ( (isset($_POST[$act_field]) && count($_POST[$act_field]) > 0) || $taxonomy ) { 415 if (! isset($_POST[$act_field]) ) { 416 $_POST[$act_field] = array(); 417 } 418 419 $DW->addMultiOption($widget_id, $type, $_POST[$type], $_POST[$act_field]); 420 } else if ( $_POST[$type] == 'no' ) { 421 $DW->addSingleOption($widget_id, $type); 422 } 423 424 // -- Childs 425 DWModule::childSave($type); 426 427 // -- Taxonomies 428 foreach ( $tax_list as $tax ) { 429 $act_tax_field = $tax . '_act'; 430 if ( isset($_POST[$act_tax_field]) && ! empty($_POST[$act_tax_field]) ) { 431 432 if ( substr($_POST[$act_tax_field], 0, 1) == ',' ) { 433 $_POST[$act_tax_field] = substr($_POST[$act_tax_field], 1); 434 } 435 $t = explode(',', $_POST[$act_tax_field]); 436 $t = array_unique($t); 385 // Custom Types 386 if ( isset($_POST['post_types']) ) { 387 foreach ( $_POST['post_types'] as $type ) { 388 $type = sanitize_text_field($type); 389 390 if ( isset($_POST['individual']) && sanitize_text_field($_POST['individual']) == '1' ) { 391 if ( isset($_POST[$type . '-post_act']) && is_array($_POST[$type . '-post_act']) && count($_POST[$type . '-post_act']) > 0 ) { 392 $DW->addMultiOption($widget_id, $type . '-post', $_POST[$type], $_POST[$type . '-post_act']); 393 } 394 } 395 396 // Check taxonomies 397 $taxonomy = FALSE; 398 399 // Go through the tax_list - Workaround as for some reason get_object_taxonomies() is not always filled 400 $tax_list = array(); 401 $len = strlen($type); 402 if ( isset($_POST['tax_list']) && is_array($_POST['tax_list']) && count($_POST['tax_list']) > 0 ) { 403 foreach ( $_POST['tax_list'] as $tl ) { 404 $tl = sanitize_text_field($tl); 405 406 if ( substr($tl, 0, $len) == $type ) { 407 $tax_list[] = $tl; 408 } 409 } 410 } 411 412 foreach ( $tax_list as $tax ) { 413 $act_tax_field = $tax . '_act'; 414 if ( isset($_POST[$act_tax_field]) && is_array($_POST[$act_tax_field]) && count($_POST[$act_tax_field]) > 0 ) { 415 $taxonomy = TRUE; 416 break; 417 } 418 } 419 420 $act_field = $type . '_act'; 421 if ( ( isset($_POST[$act_field]) && is_array($_POST[$act_tax_field]) && count($_POST[$act_field]) > 0 ) || $taxonomy ) { 422 // When taxonomy = TRUE 423 if ( !isset($_POST[$act_field]) ) { 424 $_POST[$act_field] = array(); 425 } 426 427 $DW->addMultiOption($widget_id, $type, $_POST[$type], $_POST[$act_field]); 428 } else if ( $_POST[$type] == 'no' ) { 429 $DW->addSingleOption($widget_id, $type); 430 } 431 432 // -- Childs 433 DWModule::childSave($type); 434 435 // -- Taxonomies 436 foreach ( $tax_list as $tax ) { 437 $act_tax_field = $tax . '_act'; 438 if ( isset($_POST[$act_tax_field]) && ! empty($_POST[$act_tax_field]) ) { 439 440 if ( substr($_POST[$act_tax_field], 0, 1) == ',' ) { 441 $_POST[$act_tax_field] = substr($_POST[$act_tax_field], 1); 442 } 443 $t = explode(',', $_POST[$act_tax_field]); 444 $t = array_unique($t); 437 445 438 446 $DW->addMultiOption($widget_id, $tax, $_POST[$type], $t); 439 }440 441 // ---- Childs >> Can't use DWModule::childSave() cause of $name != $tax, but $name == $type442 $act_tax_childs_field = $tax . '_childs_act';443 if ( isset($_POST[$act_tax_field]) && ! empty($_POST[$act_tax_field]) && isset($_POST[$act_tax_childs_field]) && !empty($_POST[$act_tax_childs_field]) ) {444 445 if ( substr($_POST[$act_tax_childs_field], 0, 1) == ',' ) {446 $_POST[$act_tax_childs_field] = substr($_POST[$act_tax_childs_field], 1);447 }448 $t_childs = explode(',', $_POST[$act_tax_childs_field]);449 $t_childs = array_unique($t_childs);450 451 $DW->addChilds($widget_id, $tax . '-childs', $_POST[$type], $t, $t_childs);452 }453 }454 }447 } 448 449 // ---- Childs >> Can't use DWModule::childSave() cause of $name != $tax, but $name == $type 450 $act_tax_childs_field = $tax . '_childs_act'; 451 if ( isset($_POST[$act_tax_field]) && ! empty($_POST[$act_tax_field]) && isset($_POST[$act_tax_childs_field]) && !empty($_POST[$act_tax_childs_field]) ) { 452 453 if ( substr($_POST[$act_tax_childs_field], 0, 1) == ',' ) { 454 $_POST[$act_tax_childs_field] = substr($_POST[$act_tax_childs_field], 1); 455 } 456 $t_childs = explode(',', $_POST[$act_tax_childs_field]); 457 $t_childs = array_unique($t_childs); 458 459 $DW->addChilds($widget_id, $tax . '-childs', $_POST[$type], $t, $t_childs); 460 } 461 } 462 } 455 463 456 464 DWModule::save('cp_archive', 'complex'); 457 }465 } 458 466 459 467 // Custom Taxonomies … … 463 471 $act_field = $type . '_act'; 464 472 if ( isset($_POST[$act_field]) && ! empty($_POST[$act_field]) ) { 465 /* if (! is_array($_POST[$act_field]) ) {466 $_POST[$act_field] = array();467 } */473 /* if (! is_array($_POST[$act_field]) ) { 474 $_POST[$act_field] = array(); 475 } */ 468 476 469 477 if ( substr($_POST[$act_field], 0, 1) == ',' ) { … … 482 490 } 483 491 484 // WPML PLugin support492 // WPML PLugin support 485 493 DWModule::save('wpml', 'complex'); 486 494 … … 488 496 // DWModule::save('qt', 'complex'); 489 497 490 // WPSC/WPEC Plugin support498 // WPSC/WPEC Plugin support 491 499 DWModule::save('wpsc', 'complex'); 492 500 … … 503 511 DWModule::save('pods', 'complex'); 504 512 505 // Redirect to ReturnURL506 if (! empty($returnurl) ) {507 $q = array();508 509 // Checking if there are arguments set510 $pos = strpos($returnurl, '?');511 if ( $pos !== FALSE ) {512 // evaluate the args513 $query_string = substr($returnurl, ($pos+1));514 $args = explode('&', $query_string);515 foreach ( $args as $arg ) {516 @list($name, $value) = explode('=', $arg);517 if ( $name != 'dynwid_save' && $name != 'widget_id' ) {518 $q[] = $name . '=' . $value;519 }520 }521 $script_url = substr($returnurl, 0, $pos);522 } else {523 $script_url = $returnurl;524 }525 $q[] = 'dynwid_save=yes';526 $q[] = 'widget_id=' . $widget_id;527 528 wp_redirect( $script_url . '?' . implode('&', $q));529 die();530 }513 // Redirect to ReturnURL 514 if ( ! empty($returnurl) ) { 515 $q = array(); 516 517 // Checking if there are arguments set 518 $pos = strpos($returnurl, '?'); 519 if ( $pos !== FALSE ) { 520 // evaluate the args 521 $query_string = substr($returnurl, ( $pos + 1 )); 522 $args = explode('&', $query_string); 523 foreach ( $args as $arg ) { 524 @list($name, $value) = explode('=', $arg); 525 if ( $name != 'dynwid_save' && $name != 'widget_id' ) { 526 $q[] = $name . '=' . $value; 527 } 528 } 529 $script_url = substr($returnurl, 0, $pos); 530 } else { 531 $script_url = $returnurl; 532 } 533 $q[] = 'dynwid_save=yes'; 534 $q[] = 'widget_id=' . $widget_id; 535 536 wp_redirect($script_url . '?' . implode('&', $q)); 537 die(); 538 } 531 539 ?>
Note: See TracChangeset
for help on using the changeset viewer.