WP Manifestindependent plugin directory
manifest / content / clone-remote

Clone Remote Content

Clone remote content using API REST WordPress

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/jmarreros/clone-remote/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Plugin to clone remote content using REST API WordPress

  • If you work locally you need to add the following line to your wp-config.php file:

    define( 'WP_ENVIRONMENT_TYPE', 'local' );
  • For remote site you have to register no private post meta

    add_action('rest_api_init', function () {
      $metas = [
          "Nivel",
          "relacionados",
          "youtube",
      ];
    
      foreach ($metas as $meta) {
          register_meta(
              'post',
              $meta,
              [
                  'type' => 'string',
                  'single' => true,
                  'show_in_rest' => true
              ]
          );
      }
    });
  • For the remote site you need to create endpoint with the following code for private custom post meta:

add_action('rest_api_init', 'dcms_register_custom_route');


function dcms_register_custom_route(): void
{
    register_rest_route('dcms-custom-meta/v1', '/add/', array(
        'methods'  => 'POST',
        'callback' => 'dcms_custom_meta_data',
    ));
}

function dcms_custom_meta_data(\WP_REST_Request $req): void
{
    $post_id = $req->get_param('post_id');
    update_post_meta($post_id, '_genesis_custom_post_class', $req->get_param('genesis_custom_post_class'));
    update_post_meta($post_id, '_dcms_eufi_img', $req->get_param('dcms_eufi_img'));
    update_post_meta($post_id, '_dcms_eufi_alt', $req->get_param('dcms_eufi_alt'));
}
  • You can change credentials and URLs in clone-remote.php file