Changeset 3476146
- Timestamp:
- 03/06/2026 07:49:42 AM (4 weeks ago)
- Location:
- pageapp
- Files:
-
- 18 added
- 3 edited
-
tags/1.5.2 (added)
-
tags/1.5.2/css (added)
-
tags/1.5.2/css/admin.css (added)
-
tags/1.5.2/images (added)
-
tags/1.5.2/images/pageapp20.png (added)
-
tags/1.5.2/inc (added)
-
tags/1.5.2/inc/cachelib.php (added)
-
tags/1.5.2/inc/httplib.php (added)
-
tags/1.5.2/inc/jsonlib.php (added)
-
tags/1.5.2/inc/pluginlib.php (added)
-
tags/1.5.2/inc/restlib.php (added)
-
tags/1.5.2/inc/settingslib.php (added)
-
tags/1.5.2/inc/utilslib.php (added)
-
tags/1.5.2/js (added)
-
tags/1.5.2/js/admin.js (added)
-
tags/1.5.2/pageapp-json.php (added)
-
tags/1.5.2/pageapp.php (added)
-
tags/1.5.2/readme.txt (added)
-
trunk/inc/restlib.php (modified) (4 diffs)
-
trunk/pageapp.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pageapp/trunk/inc/restlib.php
r3469357 r3476146 2 2 /* 3 3 * File: restlib.php 4 * Date: 20250 2254 * Date: 20250306 5 5 * Author: James D. Low 6 6 * URL: http://jameslow.com … … 14 14 public $route = 'wordpress'; 15 15 public $is_wordpress = false; 16 public $cookie = false; 16 17 17 18 /* Constructor */ 18 function __construct($apikeys = null, $cache = 60, $prefix = null, $route = 'wordpress' ) {19 function __construct($apikeys = null, $cache = 60, $prefix = null, $route = 'wordpress', $cookie = false) { 19 20 $this->apikeys = $apikeys ? (is_array($apikeys) ? $apikeys : array($apikeys)) : array(); 20 21 $this->cache = $cache !== null ? $cache : $this->cache; 21 22 $this->prefix = $prefix !== null ? $prefix : get_class($this); 22 23 $this->route = $route !== null ? $route : $this->route; 24 $this->cookie = $cookie; 23 25 $this->add_hooks(); 24 26 } … … 151 153 } 152 154 }*/ 153 return is_user_logged_in(); //This works with oauth server 155 if (is_user_logged_in()) { 156 return true; 157 } 158 return $this->check_cookie(); 154 159 } else { 155 160 return false; 156 161 } 162 } 163 164 public function check_cookie() { 165 if ($this->cookie) { 166 if (empty($_COOKIE)) { 167 return false; // No cookies sent 168 } 169 170 // Look for the standard WordPress logged-in cookie 171 $cookie = null; 172 foreach ($_COOKIE as $key => $value) { 173 if (strpos($key, 'wordpress_logged_in_') === 0) { 174 $cookie = $value; 175 break; 176 } 177 } 178 179 if (!$cookie) { 180 return false; // No login cookie found 181 } 182 183 // Parse cookie: format is user|expiration|token|hash 184 list($username, $expiration, $token, $hmac) = explode('|', $cookie); 185 186 // Get the user by login 187 $user = get_user_by('login', $username); 188 if (!$user) { 189 return false; // Invalid username 190 } 191 192 // Validate cookie using WordPress core function 193 require_once ABSPATH . 'wp-includes/pluggable.php'; 194 $check = wp_validate_auth_cookie($cookie, 'logged_in'); 195 if (!$check) { 196 return false; // Cookie invalid 197 } 198 199 // Cookie valid — set the current user and return true 200 wp_set_current_user($user->ID); 201 202 return true; 203 } 204 return false; 157 205 } 158 206 … … 268 316 269 317 public function add_hooks() { 270 $this->is_wordpress = true; 271 //add_filter('rest_url_prefix', function () { return 'api'; }); //Doing in htaccess since it lets us have plain /api/ 272 add_action('rest_api_init', array($this, 'register_rest_route')); 273 add_filter('rest_pre_dispatch', array($this, 'rest_pre_dispatch'), 10, 3); 318 if (function_exists('add_action')) { 319 $this->is_wordpress = true; 320 //add_filter('rest_url_prefix', function () { return 'api'; }); //Doing in htaccess since it lets us have plain /api/ 321 add_action('rest_api_init', array($this, 'register_rest_route')); 322 add_filter('rest_pre_dispatch', array($this, 'rest_pre_dispatch'), 10, 3); 323 } 274 324 } 275 325 } -
pageapp/trunk/pageapp.php
r3469357 r3476146 4 4 Plugin URI: https://wordpress.org/plugins/pageapp/ 5 5 Description: Extensions to Wordpress wp-json for the PageApp API and mobile framework 6 Version: 1.5. 16 Version: 1.5.2 7 7 Author: PageApp 8 8 Author URI: https://www.thirteen.com/ -
pageapp/trunk/readme.txt
r3469357 r3476146 4 4 Requires at least: 4.0 5 5 Tested up to: 6.9 6 Stable tag: 1.5. 16 Stable tag: 1.5.2 7 7 License: MIT 8 8 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=K6VKWB3HZB2T2&item_name=Donation%20to%20jameslow%2ecom¤cy_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8 … … 28 28 29 29 == Changelog == 30 31 = 1.5.2 = 32 * Latest version of restlib library 30 33 31 34 = 1.5.1 =
Note: See TracChangeset
for help on using the changeset viewer.