Plugin Directory

Changeset 3403928


Ignore:
Timestamp:
11/27/2025 09:50:52 AM (3 months ago)
Author:
awcode
Message:

fix category

Location:
repostra/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • repostra/trunk/README.md

    r3403844 r3403928  
    44Requires at least: 6.0
    55Tested up to: 6.8
    6 Stable tag: 1.0.4
     6Stable tag: 1.0.5
    77Requires PHP: 8.0
    88License: GPLv2 or later
     
    2424
    25251. Copy your API key from the plugin settings page
    26 2. In Repostra, add a Website social account
    27 3. Select "Webhook" as the posting method
    28 4. Enter your webhook URL: `https://yoursite.com/wp-json/repostra/v1/webhook`
    29 5. Add the API key in the Repostra webhook configuration
     262. In Repostra, add a [Website social account](https://repostra.app/admin/social-accounts)
     273. Select "Wordpress Plugin" as the posting method
     284. Enter your WordPress Site URL
     295. Add the WordPress API Key from the plugin settings page
    3030
    3131
     
    3333== Support ==
    3434
    35 For support, visit https://repostra.app
     35For support, visit [https://repostra.app](https://repostra.app)
    3636
    3737== Changelog ==
    3838
    39 = 1.0.1 =
     39= 1.0.5 =
    4040* Initial release
    4141* Webhook integration for blog posts
  • repostra/trunk/admin/settings.php

    r3403829 r3403928  
    77// Handle form submission
    88if (isset($_POST['repostra_save_settings']) && check_admin_referer('repostra_settings')) {
    9     // Validate and sanitize webhook URL
    10     $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);
    129   
    1310    // Auto publish checkbox
     
    3229
    3330$repostra_api_key = get_option('repostra_api_key');
    34 $repostra_webhook_url = get_option('repostra_webhook_url');
    3531$repostra_auto_publish = get_option('repostra_auto_publish');
    3632$repostra_default_category = get_option('repostra_default_category');
    3733$repostra_default_author = get_option('repostra_default_author');
    3834
    39 $repostra_webhook_endpoint = rest_url('repostra/v1/webhook');
     35$repostra_webhook_endpoint = get_site_url();
    4036?>
    4137
     
    5551            </tr>
    5652            <tr>
    57                 <th scope="row">Webhook Endpoint</th>
     53                <th scope="row">Wordpress URL</th>
    5854                <td>
    5955                    <code><?php echo esc_html($repostra_webhook_endpoint); ?></code>
    60                     <p class="description">This is your WordPress webhook URL. 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>
    6157                </td>
    6258            </tr>
  • repostra/trunk/repostra.php

    r3403844 r3403928  
    44 * Plugin URI: https://repostra.app
    55 * Description: Integrate Repostra content creation platform with your WordPress site. Automatically receive and publish blog posts from Repostra.
    6  * Version: 1.0.4
     6 * Version: 1.0.5
    77 * Author: AWcode Co Ltd
    88 * License: GPL v2 or later
     
    5959        $api_key = $this->generate_api_key();
    6060        add_option('repostra_api_key', $api_key);
    61         add_option('repostra_webhook_url', '');
    6261        add_option('repostra_auto_publish', false);
    6362        add_option('repostra_default_category', 0);
     
    8382            'sanitize_callback' => 'sanitize_text_field',
    8483        ));
    85         register_setting('repostra_settings', 'repostra_webhook_url', array(
    86             'sanitize_callback' => 'esc_url_raw',
    87         ));
     84
    8885        register_setting('repostra_settings', 'repostra_auto_publish', array(
    8986            'sanitize_callback' => function($value) {
     
    178175       
    179176        // 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'])) {
    184181            // Try to find category by slug (sanitize first)
    185182            $category_slug = sanitize_title($data['category']);
    186183            $category = get_category_by_slug($category_slug);
    187184            if ($category) {
    188                 wp_set_post_categories($post_id, array($category->term_id));
     185                $category_id = $category->term_id;
    189186            }
     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));
    190200        }
    191201       
Note: See TracChangeset for help on using the changeset viewer.