Detect permalinks when passing querystring in REST API requests

In more recent browsers (everything but IE, essentially), there are some useful APIs for working with URLs that will make this easier: let url = new URL( MY_PLUGIN_WP_REST_API_CONFIG.baseUrl ); url.searchParams.append( ‘per_page’, 100 ); url.searchParams.append( ‘order’, ‘asc’ ); fetch( url.toString() ).then(); With those methods the per_page and order parameters will be added correctly regardless of whether … Read more

urlencode query string in gravity forms confirmation redirect

After digging a little deeper, I found that there is an action hook in Gravity Forms called gform_pre_submission. This allows me to modify a posted value before creating an entry or running the confirmation (see documentation). After that it was pretty basic: add_action( ‘gform_pre_submission_11’, ‘pre_submission_handler’ ); function pre_submission_handler( $form ) { $_POST[‘input_7’] = urlencode(rgpost( ‘input_7’ … Read more

Check if page is embeded

The server doesn’t know what the client is doing with the output and as such, you’re limited in what you can assume. You may or may not have params sent in the request, referer, current uri and headers. $_REQUEST[’embed_act’] $_SERVER[‘HTTP_REFERER’] $_SERVER[‘REQUEST_URI’] get_headers() On the JS side, it might be possible. if(self==top) { //… } if( … Read more

Remove query string specific key value

[EDIT] This should work the way you wanted it to: $marca = get_query_var(‘marca’); $marca_arg = isset($marca) && is_array($marca) ? $marca : []; $url_base = remove_query_arg( ‘marca’ ); $n = count( $marca_arg ); foreach ($marcas_terms as $marca_term) { $selected = in_array( $marca_term->slug, $marca_arg ); if ( $selected ) { $marca_arg2 = array_diff( $marca_arg, [ $marca_term->slug ] … Read more

Can’t add external rewrites

First off, don’t ever do this: add_action(‘init’, ‘flush_rewrite_rules’); Every time WordPress loads, you are going to flush the rewrite rules. You only need to do this once to make sure your rewrite shows up. Second, add_rewrite_tag only takes two arguments, the tag and the regex. If you want to specify a query variable directly, you’ll … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)