Detect if requested page is PWA on server side

You’re not passing the actual querystring to remove_query_arg(). After some quick testing, I think your $location value is probably an empty string, and the location you’re attempting to redirect to is ?isPwa. The 2nd parameter to remove_query_arg() should be the $referer value. function addIsPwaQueryArg() { $referer = wp_get_referer(); if (strpos($referer, ‘isPwa’) !== false) { $location … Read more

How to update global variables in plugin activation callback?

Thanks to @Tom J Nowell’s help, I fixed my code to persist the created page ID to Options: function install_xxx() { $post = array( ‘post_title’ => __( ‘Thank You’, ‘xxx’ ), ‘post_content’ => __( ‘Lorem ipsum dolor.’, ‘xxx’ ), ‘post_status’ => ‘publish’, ‘post_name’ => ‘thank-you’, ‘post_type’ => ‘page’ ); $post_id = wp_insert_post( $post, true ); … Read more

Can’t load a script in my plugin page

WordPress fires admin_enqueue_scripts hook earlier, than add_options_page, where you put your admin_enqueue_scripts. Solution is simple, you need to put your admin_enqueue_scripts hook outside of the add_options_page function callback. function load_wp_media(){ wp_enqueue_media(); wp_enqueue_script( ‘waterStampScript’, plugin_dir_url( __FILE__ ) . ‘js/app.js’, array(‘jquery’)); } add_action( ‘admin_enqueue_scripts’, ‘load_wp_media’ );