Plugin Directory

Changeset 3455487


Ignore:
Timestamp:
02/06/2026 03:07:49 PM (2 weeks ago)
Author:
pluxo
Message:

Release 1.2.2: fixes in PDF export

Location:
pluxo-blueprint/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pluxo-blueprint/trunk/includes/Admin/class-pluxo-blueprint-overview.php

    r3453209 r3455487  
    5959        echo '<div class="pluxo-blueprint-card">';
    6060        echo '<h2>' . esc_html__( 'Exports', 'pluxo-blueprint' ) . '</h2>';
    61         echo '<form method="post" action="' . esc_url( admin_url( 'admin-post.php' ) ) . '" target="_blank">';
    62         wp_nonce_field( 'pluxo_blueprint_export_overview_pdf' );
    63         echo '<input type="hidden" name="action" value="pluxo_blueprint_export_overview_pdf" />';
    64         echo '<p><button type="submit" class="button button-primary">';
     61
     62        $print_url = add_query_arg(
     63            array(
     64                'page'           => 'pluxo-blueprint',
     65                'pluxo_bp_print' => '1',
     66                '_wpnonce'       => wp_create_nonce( 'pluxo_bp_print_overview' ),
     67            ),
     68            admin_url( 'admin.php' )
     69        );
     70
     71        echo '<p><a class="button button-primary" href="' . esc_url( $print_url ) . '" target="_blank" rel="noopener">';
    6572        echo esc_html__( 'Export Overview PDF', 'pluxo-blueprint' );
    66         echo '</button></p>';
     73        echo '</a></p>';
     74
    6775        echo '<p class="pluxo-blueprint-muted">';
    6876        echo esc_html__( 'This will open a print-friendly page. Use your browser’s Print → Save as PDF.', 'pluxo-blueprint' );
     
    8088        );
    8189        echo '</p>';
    82         echo '</form>';
    8390        echo '</div>';
    8491
     
    148155        echo '</div>';
    149156    }
     157
     158    /**
     159     * Get Overview modules HTML for print/export.
     160     *
     161     * @return string
     162     */
     163    public function get_modules_html_for_print() {
     164        ob_start();
     165
     166        $this->render_export_view();
     167
     168        return (string) ob_get_clean();
     169    }
     170
    150171}
  • pluxo-blueprint/trunk/includes/class-pluxo-blueprint.php

    r3453209 r3455487  
    105105        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_menu_assets' ) );
    106106        add_action( 'admin_init', array( $this, 'handle_overview_actions' ) );
    107 
    108         add_action( 'admin_post_pluxo_blueprint_export_overview_pdf', array( $this, 'handle_export_overview_pdf' ) );
     107        add_action( 'admin_init', array( $this, 'maybe_render_overview_print_view' ), 0 );
    109108
    110109    }
     
    291290
    292291    /**
     292     * Render Overview print view (GET, opens print-friendly HTML).
     293     *
     294     * URL example:
     295     * /wp-admin/admin.php?page=pluxo-blueprint&pluxo_bp_print=1&_wpnonce=...
     296     *
     297     * @return void
     298     */
     299    public function maybe_render_overview_print_view() {
     300        if ( ! is_admin() ) {
     301            return;
     302        }
     303
     304        // Only our admin page context.
     305        $page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : '';
     306        if ( 'pluxo-blueprint' !== $page ) {
     307            return;
     308        }
     309
     310        if ( empty( $_GET['pluxo_bp_print'] ) ) {
     311            return;
     312        }
     313
     314        // Capability check.
     315        if ( ! current_user_can( 'manage_options' ) ) {
     316            wp_die( esc_html__( 'You do not have permission to access this export.', 'pluxo-blueprint' ) );
     317        }
     318
     319        // Nonce check.
     320        if ( empty( $_GET['_wpnonce'] ) ) {
     321            wp_die( esc_html__( 'Invalid export link.', 'pluxo-blueprint' ) );
     322        }
     323
     324        $nonce = (string) wp_unslash( $_GET['_wpnonce'] );
     325        if ( ! wp_verify_nonce( $nonce, 'pluxo_bp_print_overview' ) ) {
     326            wp_die( esc_html__( 'This export link has expired. Please try again.', 'pluxo-blueprint' ) );
     327        }
     328
     329        // Prevent any accidental output before headers.
     330        if ( ob_get_level() ) {
     331            while ( ob_get_level() ) {
     332                ob_end_clean();
     333            }
     334        }
     335
     336        // Force correct content-type (some stacks mess this up).
     337        nocache_headers();
     338        header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ) );
     339        header( 'X-Content-Type-Options: nosniff' );
     340
     341        require_once __DIR__ . '/Admin/class-pluxo-blueprint-overview.php';
     342
     343        $overview = new Pluxo_Blueprint_Overview( $this );
     344
     345        ob_start();
     346        $overview->render_export_view();
     347        $modules_html = (string) ob_get_clean();
     348
     349        $plugin_dir = defined( 'PLUXO_BLUEPRINT_PLUGIN_DIR' )
     350            ? PLUXO_BLUEPRINT_PLUGIN_DIR
     351            : plugin_dir_path( dirname( __DIR__ ) );
     352
     353        $generator = new Pluxo_Blueprint_PDF_Generator( $plugin_dir );
     354
     355        $generator->render_overview_print_page( $modules_html );
     356        exit;
     357    }
     358
     359    /**
    293360     * Handle Overview export (print to PDF).
    294361     *
  • pluxo-blueprint/trunk/pluxo-blueprint.php

    r3455410 r3455487  
    44 * Plugin URI:        https://pluxo.dev/#pluxo-blueprint
    55 * Description:       Generate a structured PDF snapshot of your WordPress site documentation, with a modular overview and easy Markdown copy for reuse.
    6  * Version:           1.2.1
     6 * Version:           1.2.2
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
     
    6363
    6464if ( ! defined( 'PLUXO_BLUEPRINT_VERSION' ) ) {
    65     define( 'PLUXO_BLUEPRINT_VERSION', '1.2.1' );
     65    define( 'PLUXO_BLUEPRINT_VERSION', '1.2.2');
    6666}
    6767
  • pluxo-blueprint/trunk/readme.txt

    r3455410 r3455487  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.2.1
     7Stable tag: 1.2.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5858
    5959== Changelog ==
     60= 1.2.2 =
     61* Fixes in PDF export
     62
     63== Changelog ==
    6064= 1.2.1 =
    6165* Fixes in some of the modules in the overview
Note: See TracChangeset for help on using the changeset viewer.