Changeset 1824219
- Timestamp:
- 02/18/2018 08:47:00 PM (8 years ago)
- Location:
- stellarpress-federation
- Files:
-
- 12 added
- 4 edited
- 1 copied
-
assets/banner-1544x500.jpg (added)
-
assets/banner-772x250.jpg (added)
-
assets/icon-128x128.png (added)
-
assets/icon-256x256.png (added)
-
tags/1.1 (copied) (copied from stellarpress-federation/trunk)
-
tags/1.1/css (added)
-
tags/1.1/css/stellar.css (added)
-
tags/1.1/js (added)
-
tags/1.1/js/stellar.js (added)
-
tags/1.1/readme.txt (modified) (1 diff)
-
tags/1.1/stellarpress-federation.php (modified) (19 diffs)
-
trunk/css (added)
-
trunk/css/stellar.css (added)
-
trunk/js (added)
-
trunk/js/stellar.js (added)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/stellarpress-federation.php (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
stellarpress-federation/tags/1.1/readme.txt
r1812167 r1824219 5 5 Tags: Stellar Federation Server, Lumens, Cryptocurrency 6 6 Requires at least: 4.0 7 Tested up to: 4.9. 28 Stable tag: 1. 07 Tested up to: 4.9.4 8 Stable tag: 1.1 9 9 Requires PHP: 5.2.4 10 10 -
stellarpress-federation/tags/1.1/stellarpress-federation.php
r1812167 r1824219 4 4 * Plugin URI: https://stellarpress.org/federation/ 5 5 * Description: This plugin implements a simple Stellar Federation server within WordPress. Stellar address can be specified in the user profile. <em>This requires a blog hosted via HTTPS and in the root folder of the server!</em> 6 * Version: 1. 06 * Version: 1.1 7 7 * Author: StellarPress 8 8 * Author URI: https://stellarpress.org … … 28 28 29 29 if (!defined('STELLARPRESS_FEDERATION_VERSION')) { 30 define('STELLARPRESS_FEDERATION_VERSION', '1. 0');30 define('STELLARPRESS_FEDERATION_VERSION', '1.1'); 31 31 } 32 32 33 /** 34 * Class containing all functions for the StellarPress plugin, 35 * both admin UI and runtime functionality. 36 * 37 * @since 1.0.0 38 */ 33 39 class StellarPress_Federation { 34 40 /** 35 * constants for return HTTP status codes 41 * Constants for return HTTP status codes. 42 * 43 * @since 1.0.0 44 * @var int HTTP_OK HTTP status for everything OK. 45 * @var int HTTP_NOTFOUND HTTP status for item not found. 46 * @var int HTTP_INVALID HTTP status for invalid request. 47 * @var int HTTP_NOTIMPL HTTP status for not (yet) implemented. 36 48 */ 37 49 const HTTP_OK = 200; … … 41 53 42 54 /** 43 * constants for return messages in Federation server 55 * Constants for return messages in Federation server. 56 * 57 * @since 1.0.0 58 * @var string CODE_NOTFOUND Text message for HTTP_NOTFOUND. 59 * @var string CODE_INVALID Text message for HTTP_INVALID. 60 * @var string CODE_NOTIMPL Text message for HTTP_NOTIMPL. 44 61 */ 45 62 const CODE_NOTFOUND = "not_found"; … … 48 65 49 66 /** 50 * Static property to hold the singleton 67 * Static property to hold the singleton. 68 * 69 * @since 1.0.0 70 * @var StellarPress_Federation $instance The singleton object. 51 71 */ 52 72 static $instance = false; 53 73 54 74 /** 55 * Constructor: register all hooks needed 56 * 75 * Constructor: register all hooks needed. 76 * 77 * @since 1.0.0 57 78 * @return void 58 79 */ … … 65 86 add_action('personal_options_update', array($this, 'save_profile')); 66 87 add_action('edit_user_profile_update', array($this, 'save_profile')); 88 // Add scripts for admin user page 89 add_action('admin_enqueue_scripts', array($this, 'add_admin_scripts')); 67 90 } 68 91 … … 71 94 * create one. 72 95 * 73 * @return StellarPress_Federation 96 * @since 1.0.0 97 * @return StellarPress_Federation The singleton object. 74 98 */ 75 99 public static function getInstance() { … … 85 109 * 86 110 * It is to be called early in the WordPress process, and will 87 * look for very specific URLs ('/.well-known', '.federation'). 88 * 89 * 1. Check whether we shall return the 'stellar.toml' file 90 * More details: 91 * https://www.stellar.org/developers/guides/concepts/stellar-toml.html 92 * 2. Check whether we shall answer on Federation requests 93 * More details: 94 * https://www.stellar.org/developers/guides/concepts/federation.html 95 * 111 * look for very specific URLs (`/.well-known`, `.federation`). 112 * 113 * 1. Check whether we shall return the `stellar.toml` file 114 * 2. Check whether we shall answer on _Federation_ requests 115 * 116 * @since 1.0.0 117 * @link https://stellar.org/developers/guides/concepts/stellar-toml.html 118 * @link https://stellar.org/developers/guides/concepts/federation.html 96 119 * @return void 97 120 */ … … 115 138 /** 116 139 * This helper function delivers the stellar.toml file to the client. 140 * 141 * @since 1.0.0 117 142 * @return void 118 143 */ … … 131 156 * This helper function delivers the response from the Federation server. 132 157 * It will exit the PHP execution. 158 * 159 * @since 1.0.0 133 160 */ 134 161 function serve_federation() { … … 169 196 * WordPress site_url. 170 197 * 171 * @return Boolean true if the domain name is matching the server 198 * @since 1.0.0 199 * @return boolean `true` if the domain name is matching the server. 172 200 */ 173 201 function is_domain_ok($domain) { … … 179 207 180 208 /** 181 * This helper finds a user with a specific name & domain. 182 * 183 * @param name the name of the user 184 * @return String the stellar address, or false if not found 209 * This helper finds a user with a specific name and domain. 210 * 211 * @since 1.0.0 212 * @param string $name The name of the user. 213 * @return string|false The stellar address, or `false` if not found. 185 214 */ 186 215 function find_user($name) { … … 212 241 * object. 213 242 * 214 * @param user a user-id string for which the stellar address shall be extracted 243 * @since 1.0.0 244 * @param string $user_id User-id string for which the stellar address 245 * shall be extracted. 246 * @return string The user's Stellar account. 215 247 */ 216 248 function get_stellar_address($user_id) { … … 224 256 * This function will exit further execution and set the status code. 225 257 * 226 * @param code the HTTP status code to be used 227 * @param message text message as part of the result 258 * @since 1.0.0 259 * @param int $code The HTTP status code to be used. 260 * @param string $message Text message as part of the result. 228 261 */ 229 262 function exit_federation_error($code, $message) { … … 248 281 * It will exit further execution and set the status code. 249 282 * 250 * @ param account the Stellar account from the profile251 * @param name the name part of the Stellar address252 * @param domain the domain part of the Stellar address253 * @ return void283 * @since 1.0.0 284 * @param string $account The Stellar account from the profile. 285 * @param string $name The name part of the Stellar address. 286 * @param string $domain The domain part of the Stellar address. 254 287 */ 255 288 function exit_federation_result($account, $name, $domain) { … … 262 295 /** 263 296 * This helper will send the JSON result and exit execution. 297 * 264 298 * It will also set the required headers for the Federation. 265 299 * 266 * @param rc an associative array to be sent as JSON 267 * @param code the HTTP status code to be used 300 * @since 1.0.0 301 * @param array $rc An associative array to be sent as JSON. 302 * @param int $code The HTTP status code to be used. 268 303 */ 269 304 function exit_federation($rc, $code) { … … 278 313 * This function adds a field for the Stellar address of a user 279 314 * to the profile form. 315 * 280 316 * Based on https://wordpress.stackexchange.com/a/214723 281 * @param user a WPUser object 317 * 318 * @since 1.0.0 319 * @param WPUser user A WPUser object. 282 320 * @return void 283 321 */ … … 293 331 <td> 294 332 <input type="text" name="stellar_address" id="stellar_address" value="<?php echo esc_attr($stellar_address); ?>" class="regular-text" /><br /> 295 <span class="description"><?php _e("Please enter your Stellar address (your public key, starting with 'G')."); ?></span> 333 <p class="description"><?php _e("Please enter your Stellar address (your public key, starting with 'G')."); ?></p> 334 <p class="status" id="stellarpress-check"></p> 296 335 </td> 297 336 </tr> 298 337 </table> 338 <script> 339 stellarpressFederation.inform_into("<?php echo esc_attr($user->user_login); ?>", "<?php echo esc_attr($stellar_address); ?>", "stellarpress-check"); 340 </script> 299 341 <?php 300 342 } … … 303 345 * This function adds a field for the Stellar address of a user 304 346 * into the database after being saved by the user. 347 * 305 348 * Based on https://wordpress.stackexchange.com/a/214723 306 * @param user_id a WordPress user id 349 * 350 * @since 1.0.0 351 * @param string $user_id A WordPress user id 307 352 * @return void 308 353 */ … … 313 358 update_user_meta($user_id, 'stellar_address', $_POST['stellar_address']); 314 359 } 360 361 /** 362 * This function is used to add JS and CSS files needed for 363 * the user admin page. 364 * 365 * @since 1.1.0 366 * @param string $hook Hook name used to identify admin page 367 * @return void 368 */ 369 function add_admin_scripts($hook) { 370 if ($hook === 'profile.php' || $hook === 'user-edit.php') { 371 wp_enqueue_script('stellarsdk', 372 'https://cdnjs.cloudflare.com/ajax/libs/stellar-sdk/0.8.0/stellar-sdk.js'); 373 wp_enqueue_script('stellarfederation', 374 plugins_url('js/stellar.js', __FILE__)); 375 wp_enqueue_style('stellarcss', 376 plugins_url('css/stellar.css', __FILE__)); 377 } 378 } 315 379 } 316 380 -
stellarpress-federation/trunk/readme.txt
r1812167 r1824219 5 5 Tags: Stellar Federation Server, Lumens, Cryptocurrency 6 6 Requires at least: 4.0 7 Tested up to: 4.9. 28 Stable tag: 1. 07 Tested up to: 4.9.4 8 Stable tag: 1.1 9 9 Requires PHP: 5.2.4 10 10 -
stellarpress-federation/trunk/stellarpress-federation.php
r1812167 r1824219 4 4 * Plugin URI: https://stellarpress.org/federation/ 5 5 * Description: This plugin implements a simple Stellar Federation server within WordPress. Stellar address can be specified in the user profile. <em>This requires a blog hosted via HTTPS and in the root folder of the server!</em> 6 * Version: 1. 06 * Version: 1.1 7 7 * Author: StellarPress 8 8 * Author URI: https://stellarpress.org … … 28 28 29 29 if (!defined('STELLARPRESS_FEDERATION_VERSION')) { 30 define('STELLARPRESS_FEDERATION_VERSION', '1. 0');30 define('STELLARPRESS_FEDERATION_VERSION', '1.1'); 31 31 } 32 32 33 /** 34 * Class containing all functions for the StellarPress plugin, 35 * both admin UI and runtime functionality. 36 * 37 * @since 1.0.0 38 */ 33 39 class StellarPress_Federation { 34 40 /** 35 * constants for return HTTP status codes 41 * Constants for return HTTP status codes. 42 * 43 * @since 1.0.0 44 * @var int HTTP_OK HTTP status for everything OK. 45 * @var int HTTP_NOTFOUND HTTP status for item not found. 46 * @var int HTTP_INVALID HTTP status for invalid request. 47 * @var int HTTP_NOTIMPL HTTP status for not (yet) implemented. 36 48 */ 37 49 const HTTP_OK = 200; … … 41 53 42 54 /** 43 * constants for return messages in Federation server 55 * Constants for return messages in Federation server. 56 * 57 * @since 1.0.0 58 * @var string CODE_NOTFOUND Text message for HTTP_NOTFOUND. 59 * @var string CODE_INVALID Text message for HTTP_INVALID. 60 * @var string CODE_NOTIMPL Text message for HTTP_NOTIMPL. 44 61 */ 45 62 const CODE_NOTFOUND = "not_found"; … … 48 65 49 66 /** 50 * Static property to hold the singleton 67 * Static property to hold the singleton. 68 * 69 * @since 1.0.0 70 * @var StellarPress_Federation $instance The singleton object. 51 71 */ 52 72 static $instance = false; 53 73 54 74 /** 55 * Constructor: register all hooks needed 56 * 75 * Constructor: register all hooks needed. 76 * 77 * @since 1.0.0 57 78 * @return void 58 79 */ … … 65 86 add_action('personal_options_update', array($this, 'save_profile')); 66 87 add_action('edit_user_profile_update', array($this, 'save_profile')); 88 // Add scripts for admin user page 89 add_action('admin_enqueue_scripts', array($this, 'add_admin_scripts')); 67 90 } 68 91 … … 71 94 * create one. 72 95 * 73 * @return StellarPress_Federation 96 * @since 1.0.0 97 * @return StellarPress_Federation The singleton object. 74 98 */ 75 99 public static function getInstance() { … … 85 109 * 86 110 * It is to be called early in the WordPress process, and will 87 * look for very specific URLs ('/.well-known', '.federation'). 88 * 89 * 1. Check whether we shall return the 'stellar.toml' file 90 * More details: 91 * https://www.stellar.org/developers/guides/concepts/stellar-toml.html 92 * 2. Check whether we shall answer on Federation requests 93 * More details: 94 * https://www.stellar.org/developers/guides/concepts/federation.html 95 * 111 * look for very specific URLs (`/.well-known`, `.federation`). 112 * 113 * 1. Check whether we shall return the `stellar.toml` file 114 * 2. Check whether we shall answer on _Federation_ requests 115 * 116 * @since 1.0.0 117 * @link https://stellar.org/developers/guides/concepts/stellar-toml.html 118 * @link https://stellar.org/developers/guides/concepts/federation.html 96 119 * @return void 97 120 */ … … 115 138 /** 116 139 * This helper function delivers the stellar.toml file to the client. 140 * 141 * @since 1.0.0 117 142 * @return void 118 143 */ … … 131 156 * This helper function delivers the response from the Federation server. 132 157 * It will exit the PHP execution. 158 * 159 * @since 1.0.0 133 160 */ 134 161 function serve_federation() { … … 169 196 * WordPress site_url. 170 197 * 171 * @return Boolean true if the domain name is matching the server 198 * @since 1.0.0 199 * @return boolean `true` if the domain name is matching the server. 172 200 */ 173 201 function is_domain_ok($domain) { … … 179 207 180 208 /** 181 * This helper finds a user with a specific name & domain. 182 * 183 * @param name the name of the user 184 * @return String the stellar address, or false if not found 209 * This helper finds a user with a specific name and domain. 210 * 211 * @since 1.0.0 212 * @param string $name The name of the user. 213 * @return string|false The stellar address, or `false` if not found. 185 214 */ 186 215 function find_user($name) { … … 212 241 * object. 213 242 * 214 * @param user a user-id string for which the stellar address shall be extracted 243 * @since 1.0.0 244 * @param string $user_id User-id string for which the stellar address 245 * shall be extracted. 246 * @return string The user's Stellar account. 215 247 */ 216 248 function get_stellar_address($user_id) { … … 224 256 * This function will exit further execution and set the status code. 225 257 * 226 * @param code the HTTP status code to be used 227 * @param message text message as part of the result 258 * @since 1.0.0 259 * @param int $code The HTTP status code to be used. 260 * @param string $message Text message as part of the result. 228 261 */ 229 262 function exit_federation_error($code, $message) { … … 248 281 * It will exit further execution and set the status code. 249 282 * 250 * @ param account the Stellar account from the profile251 * @param name the name part of the Stellar address252 * @param domain the domain part of the Stellar address253 * @ return void283 * @since 1.0.0 284 * @param string $account The Stellar account from the profile. 285 * @param string $name The name part of the Stellar address. 286 * @param string $domain The domain part of the Stellar address. 254 287 */ 255 288 function exit_federation_result($account, $name, $domain) { … … 262 295 /** 263 296 * This helper will send the JSON result and exit execution. 297 * 264 298 * It will also set the required headers for the Federation. 265 299 * 266 * @param rc an associative array to be sent as JSON 267 * @param code the HTTP status code to be used 300 * @since 1.0.0 301 * @param array $rc An associative array to be sent as JSON. 302 * @param int $code The HTTP status code to be used. 268 303 */ 269 304 function exit_federation($rc, $code) { … … 278 313 * This function adds a field for the Stellar address of a user 279 314 * to the profile form. 315 * 280 316 * Based on https://wordpress.stackexchange.com/a/214723 281 * @param user a WPUser object 317 * 318 * @since 1.0.0 319 * @param WPUser user A WPUser object. 282 320 * @return void 283 321 */ … … 293 331 <td> 294 332 <input type="text" name="stellar_address" id="stellar_address" value="<?php echo esc_attr($stellar_address); ?>" class="regular-text" /><br /> 295 <span class="description"><?php _e("Please enter your Stellar address (your public key, starting with 'G')."); ?></span> 333 <p class="description"><?php _e("Please enter your Stellar address (your public key, starting with 'G')."); ?></p> 334 <p class="status" id="stellarpress-check"></p> 296 335 </td> 297 336 </tr> 298 337 </table> 338 <script> 339 stellarpressFederation.inform_into("<?php echo esc_attr($user->user_login); ?>", "<?php echo esc_attr($stellar_address); ?>", "stellarpress-check"); 340 </script> 299 341 <?php 300 342 } … … 303 345 * This function adds a field for the Stellar address of a user 304 346 * into the database after being saved by the user. 347 * 305 348 * Based on https://wordpress.stackexchange.com/a/214723 306 * @param user_id a WordPress user id 349 * 350 * @since 1.0.0 351 * @param string $user_id A WordPress user id 307 352 * @return void 308 353 */ … … 313 358 update_user_meta($user_id, 'stellar_address', $_POST['stellar_address']); 314 359 } 360 361 /** 362 * This function is used to add JS and CSS files needed for 363 * the user admin page. 364 * 365 * @since 1.1.0 366 * @param string $hook Hook name used to identify admin page 367 * @return void 368 */ 369 function add_admin_scripts($hook) { 370 if ($hook === 'profile.php' || $hook === 'user-edit.php') { 371 wp_enqueue_script('stellarsdk', 372 'https://cdnjs.cloudflare.com/ajax/libs/stellar-sdk/0.8.0/stellar-sdk.js'); 373 wp_enqueue_script('stellarfederation', 374 plugins_url('js/stellar.js', __FILE__)); 375 wp_enqueue_style('stellarcss', 376 plugins_url('css/stellar.css', __FILE__)); 377 } 378 } 315 379 } 316 380
Note: See TracChangeset
for help on using the changeset viewer.