wp query – How best to retrieve and publish a single post from the network in WordPress Multisite and create a permalink for it, e.g. B. "blog /% site_id% /% postname%"

My idea is to collect and open posts from subsites to the main page in Network WP MS. I found a nice class https://github.com/miguelpeixe/WP_Query_Multisite for multisite querying. Now I want to open posts on a page with structure: mysite.com/blog/%site_id%/%postname%. I tried to create a query variable. add_rewrite_tag and supported actions. I also tried to include this tag in WP Admin Option => Peamalink as a structural element for a custom structure. But after asking mysite.com?site_id=2&p=5 I had results like: mysite.com/blog/2/post-name?site_id=2. The query variable remained in the URL line. If I delete ?site_id=2 Link Countinue to work. I think I'm doing wrong logic because few links are rewritten and hope to get ideas and advice from more experienced people. There my class without "work code garbage":

class WP_Rewrite_Multisite_Link {

    function __construct() {

        add_filter('query_vars', array($this, 'query_vars'));
        add_action('pre_get_posts', array($this, 'pre_get_posts'), 100);
        add_filter( 'available_permalink_structure_tags', array($this, 'available_permalink_structure_tags')); 
        add_action('init', array($this, 'register_rewrite_rules'), 10);
        add_filter( 'post_link', array($this, 'post_link'), 10, 3);
    }


    function query_vars($vars) {

        $vars() = 'site_id';

        return $vars;
    }

    function pre_get_posts($query) {
        //Setup table for getting posts
        if( ($query->get('site_id')) && ( ($query->get('p')) || ($query->get('name')) ) ) {

            global $wpdb;

            $exist_sites = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");

            if ( in_array($query->get('site_id'), $exist_sites)) {
                $wpdb->posts = $wpdb->get_blog_prefix($query->get('site_id')) . 'posts';
                $this->posts_site_id = (int) $query->get('site_id');
            }
        }

    }

    function register_rewrite_rules() { 

        global $wp_rewrite;

        $wp_rewrite->add_rewrite_tag( '%site_id%', '((0-9)+)', 'site_id=' );

        //There i tryed to use different rewrite_rules, not understainding how do it

        $wp_rewrite->add_permastruct('site_id', '%site_id%');


        $wp_rewrite->flush_rules();

    }

    function available_permalink_structure_tags ( $tags ) {
        global $blog_id;

        $tags('site_id') = $blog_id;

        return $tags;
    }

    function post_link($permalink, $post, $leavename) {
        //Replace tag in permalink. It isn't best way, i think
        global $blog_id;

        if ( strpos( $permalink, '%site_id%') ) {
            if( isset($this->posts_site_id) ){
                $permalink = str_replace('%site_id%', $this->posts_site_id, $permalink);
            }
            else {
                $permalink = str_replace('%site_id%', $blog_id, $permalink);
            }       
        }
        return $permalink;


    }   
    }
}
new WP_Rewrite_Multisite_Link();

nginx – The "Access-Control-Allow-Origin" header is not considered as a response when using a POST request

I have the following in my Nginx configuration:

location / {
    # CORS
    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Methods' 'GET, POST' always;

    proxy_pass http://localhost:8080/guacamole/;  # systemd: tomcat9
    proxy_buffering off;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_cookie_path /guacamole/ /;
    access_log off;
}

If I send one POST Request to the server that Access-Control-Allow-Origin There is no header in the response. However, it is when I send one GET Inquiry. Any ideas why?

How can I analyze the DIVI WordPress Builder shortcode outside of the post content?

Divi WordPress Builder question.

I have the following divi content shortcode. I will love to analyze it so that the actual content is shown. I tried to create a do_shortcode ($ content) but it didn't work. Any idea how to get this going?

(et_pb_section fb_built="1" admin_label="section" _builder_version="3.22")
(et_pb_row _builder_version="4.4.2")
(et_pb_column type="4_4" _builder_version="4.4.2")
(et_pb_text _builder_version="4.4.2")Testing - Please ignore!(/et_pb_text)
(/et_pb_column)
(/et_pb_row)
(et_pb_row column_structure="1_2,1_2" admin_label="row" _builder_version="3.25" background_size="initial" background_position="top_left" background_repeat="repeat")(et_pb_column type="1_2" _builder_version="3.25" custom_padding="|||" custom_padding__hover="|||")
(et_pb_image src="https://example.com/wp-content/uploads/2020/04/April20MMH-feature.jpg" _builder_version="4.4.2")(/et_pb_image)
(/et_pb_column)
(et_pb_column type="1_2" _builder_version="3.25" custom_padding="|||" custom_padding__hover="|||")
(et_pb_signup mailchimp_list="Janette Kausen|bf98bad426" admin_label="Email Optin" _builder_version="4.4.2")(/et_pb_signup)
(/et_pb_column)
(/et_pb_row)
(/et_pb_section)

Custom Post Types – ACF pre_save_posts that are sent when the page loads

I have a form with all ACF fields. I want to send the form to a custom post type and set the title. However, if I only load the page, the form is submitted. I use the same example from the ACF website.
Here is my code:

  function instructor_time_title( $post_id ) {
      if( $post_id != 'new' ) {
        return $post_id;
      }

      // Create a new post
      $post = array(
        'post_status'  => 'publish' ,
        'post_title'  => 'A title, maybe a $_POST variable' ,
        'post_type'  => 'post' ,
      );  

      // insert the post
      $post_id = wp_insert_post( $post ); 

      // return the new ID
      return $post_id;
    }
    add_filter( 'acf/pre_save_post' , 'instructor_time_title', 10, 1 );

Any help is appreciated!

Customization – Include last used post in category

I use a free WordPress theme called DefautMag. It has a 3 column homepage. In the settings of the start page I could select any category that should be displayed in one of these columns. However, I want to display the most recent posts in one of these columns. However, the last post is a widget and not a category. Is there a way to add current categories to the categories to select them?
A minor problem with this is that I'm not a PHP programmer and I don't want to damage my website just in case I need to edit the topic to replace one of the columns with current posts.
I have searched extensively for days. Any help is greatly appreciated.

woocommerce – send email to custom field in custom post type when order is complete

So I have this function, which is supposed to send the finished order email via a CC to a user-defined email address. If the function contains only the if statement (see below), it works properly. However, if I add other custom code, the email won't fire.

I have a custom post type that stores the required email address.

The CC email is retrieved from an ACF post object field in the product meta. From this ACF Post object field, I grab the custom field (partner_email).

I know $ partnerEmail is valid because I see that it is logged in the error logs. However, if I put this variable in the headers, it doesn't work. Any help would be appreciated. Thank you in advance.

add_filter( 'woocommerce_email_headers', 'enyc_order_completed_email_add_cc_bcc', 9999, 3 );

function enyc_order_completed_email_add_cc_bcc( $headers, $email_id, $order ) {

$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;  

$order = new WC_Order( $order_id );

$items = $order->get_items();

foreach ( $items as $item ) {

    //Get Product ID
    $product_id = $item('product_id');

    //Get Product Data
    $product = wc_get_product( $product_id );

    //Get Partner Data from Product
    $partner = get_field( 'venue', $product_id);

    //Get Partner ID
    $partnerID = $partner->ID;



    //Get Partner Email
    $partnerEmail = get_field( 'partner_email', $partnerID);

    //error_log( $partnerEmail);



}

 if ( 'customer_completed_order' == $email_id ) {
        $headers .= "Cc: Name <'.$partnerEmail.'>" . "rn"; // del if not needed
        $headers .= "Bcc: Name " . "rn"; // del if not needed
    }   


    return $headers;
}

GDAX Post API does not work VB.net

I have problems with a (400) incorrect request for POST requests. I can do all get and delete requests using the same signature process, but the text is obviously string.empty. We tested all sorts of JSON formatting to get this working, but it doesn't work. We couldn't find an example of a pre-hash signature to compare with. Unless the POST server time differs from the GET and DELETE server times, we have the correct time stamp because we are within 1 second of the GET / time API call for the server time. GDAX enables authentication of 30 seconds of buffer.

Public Shared Function placeOrder()
    Try
        Dim Body As String = "{""type"":""limit"",""side"":""sell"",""product_id"":""BTC-USD"",""price"":""20000"",""size"":""0.02235229""}"
        Dim ts As String = GetNonce()
        Dim method As String = "/orders"
        Dim str_GDAX_Main As String = "https://api.gdax.com"
        Dim sig As String = GetSignature(ts, "POST", method, Body)
        Dim fr As System.Net.HttpWebRequest
        Dim targetURI As New Uri(str_GDAX_Main & method)
        'Dim response As String

        Dim jsonDataBytes As Byte() = Encoding.UTF8.GetBytes(Body)


        fr = DirectCast(HttpWebRequest.Create(targetURI), System.Net.HttpWebRequest)
        fr.Headers.Add("CB-ACCESS-KEY", config_API_Key)
        fr.Headers.Add("CB-ACCESS-SIGN", sig)
        fr.Headers.Add("CB-ACCESS-TIMESTAMP", ts)
        fr.Headers.Add("CB-ACCESS-PASSPHRASE", config_API_Passphrase)
        fr.UserAgent = UserAgent
        fr.Accept = "application/json"
        fr.Method = "POST"
        fr.ContentLength = jsonDataBytes.Length

        Dim stream = fr.GetRequestStream()
        stream.Write(jsonDataBytes, 0, jsonDataBytes.Length)
        stream.Close()

        Dim response = fr.GetResponse().GetResponseStream()

        Dim reader As New StreamReader(response)
        Dim res = reader.ReadToEnd()
        reader.Close()
        response.Close()
        Return res

        'If (fr.GetResponse().ContentLength > 0) Then
        '    Dim str As New System.IO.StreamReader(fr.GetResponse().GetResponseStream())
        '    response = (str.ReadToEnd())
        '    str.Close()
        'End If

        'Form1.RichTextBox1.Text = (response)
    Catch ex As System.Net.WebException
        MessageBox.Show(ex.Message)
        'Error in accessing the resource, handle it
    End Try
End Function

Public Shared Function GetNonce() As String
    Return (DateTime.UtcNow - New DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds.ToString()
End Function

Public Shared Function GetSignature(nonce As String, method As String, url As String, body As String) As String
    Dim message As String = String.Concat(nonce, method.ToUpper(), url, body)
    Dim encoding = New ASCIIEncoding()
    Dim keyByte As Byte() = Convert.FromBase64String(config_API_Secret)
    Dim messageBytes As Byte() = encoding.GetBytes(message)
    Using hmacsha256 = New HMACSHA256(keyByte)
        Dim hashmessage As Byte() = hmacsha256.ComputeHash(messageBytes)
        Return Convert.ToBase64String(hashmessage)
    End Using
End Function

We have no idea if our body is wrong or if the URI is wrong or where the problem is. If someone can take a look and find out where our body syntax error is. Or if we should look elsewhere.

How can I limit a specific user ID to 5 comments per post?

Can someone please give me a function to restrict a Specific User ID for 5 comments per post? I found several questions about how to set a limit of one comment per post for all users. However, I only have to set the limit for a single user ID. When I tried to change the code to specify a single user ID, the limit was instead applied to all users based on that one ID.

I found a plugin limit for comments and the number of words that includes an option to set a limit for a specific user ID. For some reason, however, the plugin on my website is not working. If I set the limit, no comments will go through for this user ID. After clicking the comment button, only a blank screen is displayed.

However, if someone can give me a simple function to limit the number of comments per post from a Specific User ID I would very much appreciate it. Thank you so much!