Example #1
0
 private function setupDeeplinkPublishing()
 {
     add_action('post_submitbox_misc_actions', function () {
         $this->getTemplate('deeplink-publish');
     });
     add_action('save_post', function ($post_id) {
         if (defined('DOING_AJAX') && DOING_AJAX) {
             return;
         }
         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
             return;
         }
         if (isset($_POST['mtpc_deeplink_auto'])) {
             update_post_meta($post_id, "mtpc_deeplink_auto", (int) $_POST["mtpc_deeplink_auto"]);
         }
     });
     add_filter('wp_insert_post_data', function ($filtered_data, $raw_data) {
         $deepLinkContent = isset($raw_data['mtpc_deeplink_auto']) ? (bool) $raw_data["mtpc_deeplink_auto"] : false;
         if ($deepLinkContent) {
             if (!$this->hasActiveAccount() && $this->autoRegister) {
                 $this->registerCurrentUser();
             }
             $userId = get_option("mtpc_id");
             $accessToken = is_multisite() ? null : get_option("mtpc_access_token");
             $newContent = $this->client->deepLinkBlogPost($userId, $filtered_data['post_content'], $accessToken);
             if (is_array($newContent) && isset($newContent["newHtml"]) && $newContent["isUpdated"]) {
                 $filtered_data['post_content'] = $newContent["newHtml"];
             }
         }
         return $filtered_data;
     }, 10, 2);
 }
Example #2
0
 /**
  * @param string $baseUrl
  * @param null   $clientId
  * @param null   $secretKey
  *
  * @internal param string $userToken
  */
 public function __construct($baseUrl, $clientId = null, $secretKey = null)
 {
     $this->userClientId = $clientId;
     $this->userSecretKey = $secretKey;
     parent::__construct($baseUrl);
 }