Changeset 1704036
- Timestamp:
- 07/27/2017 08:54:34 PM (9 years ago)
- Location:
- wp-mastodon-share/trunk
- Files:
-
- 2 edited
-
tootophp/TootoPHP.php (modified) (1 diff)
-
wp-mastodon-share.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-mastodon-share/trunk/tootophp/TootoPHP.php
r1702506 r1704036 287 287 'status' => $content, 288 288 'visibility' => $visibility, 289 'media_ids ' => $medias289 'media_ids[]' => $medias 290 290 ] 291 291 ); -
wp-mastodon-share/trunk/wp-mastodon-share.php
r1702686 r1704036 5 5 * Plugin URI: https://github.com/kernox/mastoshare-wp 6 6 * Description: Share WordPress posts on a mastodon instance. 7 * Version: 0. 67 * Version: 0.7 8 8 * Author: Hellexis 9 9 * Author URI: https://github.com/kernox … … 63 63 $is_valid_nonce = wp_verify_nonce( $_POST['_wpnonce'], 'mastoshare-configuration' ); 64 64 65 if ( $is_valid_nonce ) { 65 if ( $is_valid_nonce ) { 66 $instance = get_option( 'mastoshare-instance' ); 66 67 $message = $_POST['message']; 68 $token = sanitize_key( $_POST['token'] ); 69 70 $tooto_php = new TootoPHP\TootoPHP( $instance ); 71 $app = $tooto_php->registerApp( 'Mastodon Share for WP', 'http://www.github.com/kernox' ); 72 73 if($token != get_option('mastoshare-token')){ 74 $app->registerAccessToken( trim( $token ) ); 75 76 //Force the token fetch 77 $profile = $app->getUser(); 78 } 79 67 80 update_option( 'mastoshare-message', sanitize_textarea_field( $message ) ); 68 update_option( 'mastoshare-token', sanitize_key( $_POST['token'] ));81 update_option( 'mastoshare-token', $token ); 69 82 update_option( 'mastoshare-mode', sanitize_text_field( $_POST['mode'] ) ); 70 83 update_option( 'mastoshare-toot-size', (int) $_POST['size'] ); … … 132 145 133 146 $post = get_post( $id ); 147 $thumb_url = get_the_post_thumbnail_url($id); 148 134 149 $toot_size = (int) get_option( 'mastoshare-toot-size', 500 ); 135 150 … … 146 161 $app = $tooto_php->registerApp( 'Mastodon Share for WP', 'http://www.github.com/kernox' ); 147 162 148 $token = get_option( 'mastoshare-token' );149 150 $app->registerAccessToken( trim( $token ) );151 152 163 $mode = get_option( 'mastoshare-mode', 'public' ); 153 $toot = $app->postStatus( $message, $mode ); 164 165 $medias = array(); 166 167 if ( $thumb_url ) { 168 169 $thumb_path = str_replace(get_site_url(), get_home_path(), $thumb_url); 170 171 $attachment = $app->createAttachement( $thumb_path ); 172 173 $media = $attachment['id']; 174 } 175 176 $toot = $app->postStatus( $message, $mode, $media); 154 177 155 178 update_post_meta( $post->ID, 'mastoshare-post-status', 'off' ); … … 160 183 serialize( 161 184 array( 162 'message' => ' Mastodon Share: ' . __( 'Sorry, can\'t send toot !', 'wp-mastodon-share' ) .185 'message' => '<strong>Mastodon Share</strong> : ' . __( 'Sorry, can\'t send toot !', 'wp-mastodon-share' ) . 163 186 '<p><strong>' . __( 'Instance message', 'wp-mastodon-share' ) . '</strong> : ' . $toot['error'] . '</p>', 164 187 'class' => 'error', … … 171 194 serialize( 172 195 array( 173 'message' => ' Mastodon Share: ' . __( 'Toot successfully sent !', 'wp-mastodon-share' ),196 'message' => '<strong>Mastodon Share</strong> : ' . __( 'Toot successfully sent !', 'wp-mastodon-share' ), 174 197 'class' => 'success', 175 198 ) … … 192 215 193 216 if ( is_array( $notice ) ) { 194 echo '<div class="notice notice-' . sanitize_html_class( $notice['class'] ) . ' is-dismissible"><p>' . esc_html( $notice['message'] ). '</p></div>';217 echo '<div class="notice notice-' . sanitize_html_class( $notice['class'] ) . ' is-dismissible"><p>' . $notice['message'] . '</p></div>'; 195 218 update_option( 'mastoshare-notice', null ); 196 219 }
Note: See TracChangeset
for help on using the changeset viewer.