Announcement

Collapse
No announcement yet.

BULK export all published post links as a TXT or CSV file

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • BULK export all published post links as a TXT or CSV file

    Hey how are you?
    Does Blog2Social have a feature to export all published post links as a TXT or CSV file?
    For example, if there were an option in the calendar to select specific dates and then download all the published post links for those dates in a single TXT or CSV file with all the URLs, that would be perfect.
    If blog2social has something like that, I could then copy and paste those links manually into the indexer service. (not one by one, i know has an option to see it one by one, its not practical and can take weeks)​

    I see a lot of people compline about that from 2023... we now in 2025, have some solution?
    https://community.blog2social.com/se...words%22%3A%22 export%22%7D

    More than that, i build a mini plugin take the information from the table, i checked that on stagging site and its works. but i little afraid it can damage something.
    i be happy if you can check it:

    PHP Code:
    <?php
    /*
     * Plugin Name: ChatGPT - Blog2Social Safe Export with Date Filter
     * Description: Export Blog2Social URLs as plain TXT with optional date range.
     * Version: 1.2
     */

    if (!defined('ABSPATH')) exit;

    add_action('admin_menu', function() {
        
    add_menu_page(
            
    'B2S Safe Export',
            
    'B2S Safe Export',
            
    'manage_options',
            
    'b2s-safe-export',
            function() {
                
    ?>
                <div class="wrap">
                    <h1>Blog2Social Safe Export</h1>
                    <form method="post">
                        <label>Start Date: </label>
                        <input type="date" name="start_date">
                        <label>End Date: </label>
                        <input type="date" name="end_date">
                        <input type="submit" name="b2s_export" class="button button-primary" value="Export TXT">
                    </form>
                </div>
                <?php

                
    if (!isset($_POST['b2s_export'])) return;

                global 
    $wpdb;
                
    $table $wpdb->prefix 'b2s_posts';
                
    $url_column 'publish_link';
                
    $date_column 'publish_date';

                
    // Table check
                
    $table_exists $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s"$table));
                if (!
    $table_exists) {
                    echo 
    '<p>Table <strong>' esc_html($table) . '</strong> does not exist.</p>';
                    return;
                }

                
    // Column check
                
    $column_exists $wpdb->get_var($wpdb->prepare("SHOW COLUMNS FROM $table LIKE %s"$url_column));
                if (!
    $column_exists) {
                    echo 
    '<p>Column <strong>' esc_html($url_column) . '</strong> does not exist in table <strong>' esc_html($table) . '</strong>.</p>';
                    return;
                }

                
    // Build query
                
    $query "SELECT $url_column FROM $table";
                
    $params = [];

                if (!empty(
    $_POST['start_date']) && !empty($_POST['end_date'])) {
                    
    $query .= " WHERE $date_column BETWEEN %s AND %s";
                    
    $params[] = $_POST['start_date'] . ' 00:00:00';
                    
    $params[] = $_POST['end_date'] . ' 23:59:59';
                    
    $results $wpdb->get_results($wpdb->prepare($query$params));
                } else {
                    
    $results $wpdb->get_results($query);
                }

                if (!
    $results) {
                    echo 
    '<p>No URLs found for the selected range.</p>';
                    return;
                }

                
    // Clear buffer
                
    if (ob_get_length()) ob_end_clean();

                
    // TXT download
                
    $filename 'b2s-links-' date('Y-m-d_H-i-s') . '.txt';
                
    header('Content-Type: text/plain');
                
    header('Content-Disposition: attachment; filename="' $filename '"');
                
    header('Pragma: no-cache');
                
    header('Expires: 0');

                foreach (
    $results as $row) {
                    echo 
    $row->$url_column "\n";
                }
                exit;
            },
            
    'dashicons-download',
            
    81
        
    );
    });
    Regards,
    Levi
    Last edited by Locksmith; 11-04-2025, 11:04 PM.

  • #2
    Hello,

    We noticed that you’ve already contacted us via a support ticket, so we’ve replied to your inquiry through that channel to keep everything in one place.

    Best regards

    Your Blog2Social Team

    Comment

    Working...
    X