Support » Plugin: Multiple Domain Mapping on Single Site » Setting by page type

  • I modified the old version of the plugin as follows: all “post” records worked automatically (If site.ru/test == post => test.site.ru). Simply supplemented the list of manual settings with the list of posts, everything worked automatically.
    After updating the plugin all the code has changed, tell me how to do it most simply. You may decide to add this function to the plugin for other types of records at the user’s choice.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author matthias.wagner

    (@matthiaswagner)

    i do not really understand what you try to achieve or how you had it set up with the old version. could you please explain in more detail?
    just narrow down the functionality to only some post types? or page templates? or did you have some wildcard-subdomain functionality??

    matt

    All posts worked as subdomains. The list of published posts was loaded, expanding the “manual list” in the plugin settings. Attached a link to the modified version:
    Old modified version
    multidomainmapping_alter.php

    $siteurl = get_option("siteurl");//the address of the main page of WordPress site
    $url_info = parse_url($siteurl);//get all the components of the url: scheme and host
    
    //get all published posts
    $query = new WP_Query;
    $posts = $query->query
    (
        array
        (
            'post_type'=>'post',
            'post_status'=>'publish',
    		'posts_per_page' => -1
        )
    );
    
    $falke_mdm_domains_posts = array();//domains that are automatically generated from titles of posts
    
    foreach ($posts as $post)//go through all the posts, and add to the list of their respective subdomains and source URLs
    {
        $domain = $url_info['scheme'].'://'.$post->post_name.'.'.$url_info['host'];
    
        //save domains in a separate array,
        // which are automatically generated from post titles are automatically generated from titles of posts
        //this is necessary to exclude them later when saving to the database,
        //to not display them in the form of saving domains-URLs
        $falke_mdm_domains_posts[] = $domain;
    
        //also add these domains to the General list of domains,
        //which contains also the domains are taken from plugin settings
        $falke_mdm_domains[] = $domain;
        $falke_mdm_destinations[] = '/'.$post->post_name;
    }

    multidomainmapping.php

    require 'multidomainmapping_alter.php'; // 111 line
    global $falke_mdm_domains_posts; if (in_array($v,$falke_mdm_domains_posts)) continue; // 433 line
    • This reply was modified 1 month, 3 weeks ago by  WebFR.
    Plugin Author matthias.wagner

    (@matthiaswagner)

    hy,

    ah ok, i understand 🙂
    one of our goals for the new version was to help developers build their own solutions on top of the plugin. that is why we introdoced actions and filters. for your case, you should work with the filter “falke_mdmf_save_mappings” which is called before the array of mappings is stored in the database. this will save your post mappings permanently – unfortunately we did not yet set a filter when they are read out from the database…

    so in your functions.php or plugin-file you could use an action on post save (so that it is triggered each time a post is saved/edited) and call the filter there to use your logic to append the altered post to the array.

    we will introduce another filter in the next version which is called when loading the mappings, so that you would not have to save all the post-mappings if you don’t like that 😉

    see the faq for information about our actions and filters: https://wordpress.org/plugins/multiple-domain-mapping-on-single-site/#i%20am%20a%20developer%2C%20how%20can%20i%20build%20solutions%20on%20top%20of%20the%20plugin%3F

    good luck for that
    matt

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.