Changeset 3403928
- Timestamp:
- 11/27/2025 09:50:52 AM (3 months ago)
- Location:
- repostra/trunk
- Files:
-
- 3 edited
-
README.md (modified) (3 diffs)
-
admin/settings.php (modified) (3 diffs)
-
repostra.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
repostra/trunk/README.md
r3403844 r3403928 4 4 Requires at least: 6.0 5 5 Tested up to: 6.8 6 Stable tag: 1.0. 46 Stable tag: 1.0.5 7 7 Requires PHP: 8.0 8 8 License: GPLv2 or later … … 24 24 25 25 1. Copy your API key from the plugin settings page 26 2. In Repostra, add a Website social account27 3. Select "W ebhook" as the posting method28 4. Enter your webhook URL: `https://yoursite.com/wp-json/repostra/v1/webhook`29 5. Add the API key in the Repostra webhook configuration26 2. In Repostra, add a [Website social account](https://repostra.app/admin/social-accounts) 27 3. Select "Wordpress Plugin" as the posting method 28 4. Enter your WordPress Site URL 29 5. Add the WordPress API Key from the plugin settings page 30 30 31 31 … … 33 33 == Support == 34 34 35 For support, visit https://repostra.app35 For support, visit [https://repostra.app](https://repostra.app) 36 36 37 37 == Changelog == 38 38 39 = 1.0. 1=39 = 1.0.5 = 40 40 * Initial release 41 41 * Webhook integration for blog posts -
repostra/trunk/admin/settings.php
r3403829 r3403928 7 7 // Handle form submission 8 8 if (isset($_POST['repostra_save_settings']) && check_admin_referer('repostra_settings')) { 9 // Validate and sanitize webhook URL10 $repostra_webhook_url = isset($_POST['repostra_webhook_url']) ? esc_url_raw(wp_unslash($_POST['repostra_webhook_url'])) : '';11 update_option('repostra_webhook_url', $repostra_webhook_url);12 9 13 10 // Auto publish checkbox … … 32 29 33 30 $repostra_api_key = get_option('repostra_api_key'); 34 $repostra_webhook_url = get_option('repostra_webhook_url');35 31 $repostra_auto_publish = get_option('repostra_auto_publish'); 36 32 $repostra_default_category = get_option('repostra_default_category'); 37 33 $repostra_default_author = get_option('repostra_default_author'); 38 34 39 $repostra_webhook_endpoint = rest_url('repostra/v1/webhook');35 $repostra_webhook_endpoint = get_site_url(); 40 36 ?> 41 37 … … 55 51 </tr> 56 52 <tr> 57 <th scope="row">W ebhook Endpoint</th>53 <th scope="row">Wordpress URL</th> 58 54 <td> 59 55 <code><?php echo esc_html($repostra_webhook_endpoint); ?></code> 60 <p class="description">This is your WordPress webhookURL. Copy this to your Repostra account settings.</p>56 <p class="description">This is your WordPress URL. Copy this to your Repostra account settings.</p> 61 57 </td> 62 58 </tr> -
repostra/trunk/repostra.php
r3403844 r3403928 4 4 * Plugin URI: https://repostra.app 5 5 * Description: Integrate Repostra content creation platform with your WordPress site. Automatically receive and publish blog posts from Repostra. 6 * Version: 1.0. 46 * Version: 1.0.5 7 7 * Author: AWcode Co Ltd 8 8 * License: GPL v2 or later … … 59 59 $api_key = $this->generate_api_key(); 60 60 add_option('repostra_api_key', $api_key); 61 add_option('repostra_webhook_url', '');62 61 add_option('repostra_auto_publish', false); 63 62 add_option('repostra_default_category', 0); … … 83 82 'sanitize_callback' => 'sanitize_text_field', 84 83 )); 85 register_setting('repostra_settings', 'repostra_webhook_url', array( 86 'sanitize_callback' => 'esc_url_raw', 87 )); 84 88 85 register_setting('repostra_settings', 'repostra_auto_publish', array( 89 86 'sanitize_callback' => function($value) { … … 178 175 179 176 // Set category 180 $category_id = get_option('repostra_default_category');181 if ($category_id && isset($data['category'])) {182 wp_set_post_categories($post_id, array($category_id));183 } elseif (isset($data['category']) && !empty($data['category'])) {177 $category_id = null; 178 179 // First, check if a category is provided in the payload 180 if (isset($data['category']) && !empty($data['category'])) { 184 181 // Try to find category by slug (sanitize first) 185 182 $category_slug = sanitize_title($data['category']); 186 183 $category = get_category_by_slug($category_slug); 187 184 if ($category) { 188 wp_set_post_categories($post_id, array($category->term_id));185 $category_id = $category->term_id; 189 186 } 187 } 188 189 // If no category from payload, use default category if set 190 if (!$category_id) { 191 $default_category_id = get_option('repostra_default_category'); 192 if ($default_category_id && term_exists($default_category_id, 'category')) { 193 $category_id = $default_category_id; 194 } 195 } 196 197 // Apply category if we have one 198 if ($category_id) { 199 wp_set_post_categories($post_id, array($category_id)); 190 200 } 191 201
Note: See TracChangeset
for help on using the changeset viewer.