How to get $_GET var on customize.php?
-
I’m trying to do something with $_GET vars on customize.php page, but It is quite difficult than I expected.
//======== Example
WP Version: 4.0-beta4
Also tested with 3.9.2, so I think it’s not a wp beta version bug.URL:
https://localhost/wp/wp-admin/customize.php?var=google
Code:
add_action('customize_register', 'testing'); function testing($wp_customize) { // this can't get vars and throw a undefined index error, // but if I check source code of the page, I can see it's here. print_r($_GET[var]); // Notice: the stuff below inside will render properly, // in other words, I got the var once, // but it cause another fatal problem: // the setting which added inside here will not be saved. if(!empty($_GET[var]) { $wp_customize->add_setting(...); $wp_customize->add_control(...); } }
if I hook the testing() function to ‘customize_controls_init’, I’m able to get $_GET vars and no errors, but it also cause the same problem: the settings will not be saved.
seems it’s caused by iframe and refresh, but I tried a variety of ways and still can’t make it working well.
Anyone have an point? Thanks in advance.
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘How to get $_GET var on customize.php?’ is closed to new replies.