Add_rewrite_endpoint doesn’t work with post name permalink structure

I would avoid using add_rewrite_endpoint() directly to register account page endpoints in WooCommerce. WooCommerce has a filter that you can use that make sure everything else works properly, like the endpoint title filter and calls to is_wc_endpoint_url(). So add the endpoint with the woocommerce_get_query_vars filter: add_filter( ‘woocommerce_get_query_vars’, function( $query_vars ) { $query_vars[‘conversations’] = ‘conversations’; return … Read more

How use wp media upload liberary in react components?

here is my solution import React, { useState, useEffect } from ‘react’ import _ from ‘lodash’ export default function FeaturedImage(props) { _.noConflict() let frame const runUploader = (event) => { event.preventDefault() // If the media frame already exists, reopen it. if (frame) { frame.open() return } // Create a new media frame frame = wp.media({ … Read more

serverSideRender does not render “preview” html inside Gutenberg block

Ok, after spending the whole day searching and reading I found the solution. It seems that ServerSideRender should be de-structured from wp.components and NOT from wp.serverSideRender After replacing const { serverSiderRender: ServerSideRender } = wp.serverSideRender; with const { ServerSideRender } = wp.components; And // <serverSideRender <ServerSideRender block=”gutenberg-examples/example-dynamic” attributes={ props.attributes } /> All works fine now … Read more

REST API can’t get the response manually

I was using wrong method wp_remote_post() will work. Here is the fix code: $args = array( ‘method’ => ‘POST’, ‘timeout’ => 45, ‘redirection’ => 5, ‘httpversion’ => ‘1.0’, ‘body’ => array( ‘store_name’ => $stidStore_name, ‘customer_name’ =>$stidCustomer_name, ‘payment_type’=> $stidPaymen_type, ‘amount’=> $stidAmount, ‘customer_address’=> $stidCustomer_country, ), ); $request = wp_remote_post( $stidUrl, $args); $response = wp_remote_retrieve_body( $request ); $response … Read more

How can I add IP address to my post?

I’ve modified your code and moved $ip inside the function. That way the variable is easily accessible from the function itself. function cptpost() { if (!empty($_SERVER[“HTTP_CLIENT_IP”])) { $ip = $_SERVER[“HTTP_CLIENT_IP”]; } elseif (!empty($_SERVER[“HTTP_X_FORWARDED_FOR”])) { $ip = $_SERVER[“HTTP_X_FORWARDED_FOR”]; } else { $ip = $_SERVER[“REMOTE_ADDR”]; } $dateTime = date(“Y/m/d g:i:sa”) //create post object $userid = get_current_user_id(); $my_post … Read more

Plugin Admin Menu Boiler Plate

This is a great question. I have never seen any kind of framework inside WordPress for building forms, and after a bit of searching now to verify this, I don’t think there is one, although I’m sure others will correct me if there is 😉 So, you probably need to hand code forms as you … Read more