public static function deploy($remote_url, $public_key, $private_key)
 {
     $fail = false;
     self::$elapsed_time = microtime(true);
     if (!class_exists('Pods_Migrate_Packages')) {
         return new WP_Error('pods-deploy-need-packages', __('You must activate the Packages Component on both the site sending and receiving this package.', 'pods-deploy'));
     }
     //@todo add options for these params
     $params = array('pods' => true, 'templates' => true, 'page' => true, 'helpers' => true);
     $data = Pods_Migrate_Packages::export($params);
     $url = trailingslashit($remote_url) . 'pods-components?package';
     $request_token = Pods_Deploy_Auth::generate_token($public_key, $private_key);
     $url = Pods_Deploy_Auth::add_to_url($public_key, $request_token, $url);
     $data = json_encode($data);
     $response = wp_remote_post($url, array('method' => 'POST', 'body' => $data));
     if (self::check_return($response)) {
         echo self::output_message(__('Package deployed successfully. ', 'pods-deploy'), $url);
         $responses = array();
         $api = pods_api();
         $params['names'] = true;
         $pod_names = $api->load_pods($params);
         $pod_names = array_flip($pod_names);
         $data = Pods_Deploy::get_relationships();
         $pods_api_url = trailingslashit($remote_url) . 'pods-api/';
         foreach ($pod_names as $pod_name) {
             $url = $pods_api_url . "{$pod_name}/update_rel";
             $url = Pods_Deploy_Auth::add_to_url($public_key, $request_token, $url);
             $responses[] = $response = wp_remote_post($url, array('method' => 'POST', 'body' => json_encode($data)));
             if (self::check_return($response)) {
                 echo self::output_message(__(sprintf('Relationships for the %1s Pod were updated.', $pod_name), 'pods-deploy'), $url);
             } else {
                 $fail = true;
                 echo self::output_message(__(sprintf('Relationships for the %1s Pod were not updated.', $pod_name), 'pods-deploy'), $url);
                 var_dump($response);
             }
         }
         if (!$fail) {
             echo self::output_message(__('Deployment complete :)', 'pods-deploy'));
         } else {
             echo self::output_message(__('Deployment completed with mixed results :|', 'pods-deploy'));
         }
     } else {
         echo self::output_message(__('Package could not be deployed :(', 'pods-deploy'));
         var_dump($response);
     }
 }
Ejemplo n.º 2
0
 /**
  * Import a package
  *
  * @param mixed $data (optional) An associative array containing a package, or the json encoded package
  * @param bool $replace (optional) Replace existing items when found
  *
  * @return bool
  *
  * @since 1.9.0
  * @deprecated 2.0
  */
 public function import_package($data = false, $replace = false)
 {
     if (class_exists('Pods_Migrate_Packages')) {
         return Pods_Migrate_Packages::import($data, $replace);
     }
     return false;
 }
Ejemplo n.º 3
0
        wp_send_json_error($fail);
    } else {
        wp_send_json_success($fail);
    }
});
add_action('admin_init', function () {
    return;
    $content = file_get_contents(DION_THEME_DIR . '/pods.json');
    //$content =   json_decode($content);
    echo class_exists('Pods_Migrate_Packages');
    if (class_exists('Pods_Migrate_Packages')) {
        $import = Pods_Migrate_Packages::import($content, false);
    } else {
        $classpath = WP_PLUGIN_DIR . '/pods/components/Migrate-Packages/Migrate-Packages.php';
        include_once $classpath;
        $import = Pods_Migrate_Packages::import($content, false);
    }
});
function dynamic_section($sections)
{
    //$sections = array();
    $sections[] = array('title' => __('Section via hook', 'redux-framework-demo'), 'desc' => __('<p class="description">This is a section created by adding a filter to the sections array. Can be used by child themes to add/remove sections from the options.</p>', 'redux-framework-demo'), 'icon' => 'el-icon-paper-clip', 'fields' => array());
    return $sections;
}
add_action('tgmpa_register', function () {
    $plugins = array(array('name' => 'Migrate DB', 'slug' => 'wp-migrate-db', 'required' => false), array('name' => 'Pods Framework', 'slug' => 'pods', 'required' => true));
    /**
     * Array of configuration settings. Amend each line as needed.
     * If you want the default strings to be available under your own theme domain,
     * leave the strings uncommented.
     * Some of the strings are added into a sprintf, so see the comments at the
 /**
  * Deploy a package
  *
  * @since 0.3.0 ?
  *
  * @param array $params Pods_Migrate_Packages::export() params
  */
 private static function do_deploy($params)
 {
     $fail = false;
     $data = Pods_Migrate_Packages::export($params);
     $url = trailingslashit(self::$remote_url) . 'pods-components?package';
     $url = Pods_Deploy_Auth::add_to_url(self::$public_key, self::$token, $url);
     $response = wp_remote_post($url, array('method' => 'POST', 'body' => $data, 'timeout' => self::$timeout));
     $pod_name = '';
     $pod_list = array();
     foreach ($params as $param) {
         if (is_array($param)) {
             $pod_list = array_merge(array_flip($param), $pod_list);
         } else {
             array_push($pod_list, self::pod_name($param));
         }
     }
     $pod_name = pods_serial_comma($pod_list);
     if (self::check_return($response)) {
         echo self::output_message(__(sprintf('Package deployed successfully for %1s :)', $pod_name), 'pods-deploy'), $url);
         if (!$fail) {
             echo self::output_message(__('Deployment complete :)', 'pods-deploy'), $url);
         } else {
             echo self::output_message(__('Deployment completed with mixed results :|', 'pods-deploy'), $url, true, false);
         }
     } else {
         echo self::output_message(__(sprintf('Package could not be deployed for %1s:(', $pod_name), 'pods-deploy'), $url, true, false);
         var_dump($response);
     }
 }