Пример #1
0
 static function post($post_ID, $force = false)
 {
     // global $grape_synced;
     if (!GrapePostController::check_nonce()) {
         return $post_ID;
         // nothing to do here
     }
     $post = new GrapePost($post_ID);
     if (!$post->should_be_synced()) {
         grape_debug("controller: post -> STOP (should not be synced)");
         return $post_ID;
     }
     if ($post->was_synced() && !$force) {
         grape_debug("controller: post -> edit (was synced before)");
         return GrapePostController::edit($post_ID);
     }
     do_action('grape_post_create', $post);
     foreach ($post->get_connections() as $connection) {
         $post->use_custom_title_field($connection['custom_title_field']);
         $api = new GRAPE_API($connection['api_token'], $connection['api_url']);
         $response = $api->create($post);
     }
     return $post_ID;
 }