Plugin Directory

Changeset 3444155


Ignore:
Timestamp:
01/21/2026 02:14:37 PM (2 months ago)
Author:
mrpro64
Message:

Prepare version 1.0.1

Location:
qrmemo/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • qrmemo/trunk/admin-settings.php

    r3170933 r3444155  
    11<?php
    2 if (!defined('ABSPATH')) {
    3     exit; // Exit if accessed directly
     2if ( !defined( 'ABSPATH' ) ) {
     3    exit;
     4    // Exit if accessed directly
    45}
    56
    67// Callback della pagina delle impostazioni
     8
    79function qrmemo_settings_page() {
    810    // Ottieni i tipi di post pubblici, escludendo 'attachment'
    9     $post_types = get_post_types(['public' => true], 'objects');
    10    
    11     // Rimuovi il tipo di post 'attachment' (Media)
    12     unset($post_types['attachment']);
     11    $post_types = get_post_types( ['public' => true], 'objects' );
    1312
    14     $selected_post_types = get_option('qrmemo_post_types', []);
    15 ?>
    16     <div class="wrap">
    17         <h1><?php esc_html_e('QRMemo Settings', 'qrmemo'); ?></h1>
    18         <form method="post" action="options.php">
    19             <?php
    20             settings_fields('qrmemo_settings_group');
    21             do_settings_sections('qrmemo');
    22             ?>
    23             <table class="form-table">
    24                 <tr valign="top">
    25                     <th scope="row"><?php esc_html_e('Enable QR Code for the following post types', 'qrmemo'); ?>:</th>
    26                     <td>
    27                         <ul>
    28                             <?php foreach ($post_types as $post_type) : ?>
    29                                 <li>
    30                                     <label>
    31                                         <input type="checkbox" name="qrmemo_post_types[]" value="<?php echo esc_attr($post_type->name); ?>"
    32                                             <?php echo in_array($post_type->name, $selected_post_types) ? 'checked' : ''; ?> />
    33                                         <?php echo esc_html($post_type->label); ?>
    34                                     </label>
    35                                 </li>
    36                             <?php endforeach; ?>
    37                         </ul>
    38                     </td>
    39                 </tr>
    40             </table>
    41             <p>
    42             <?php esc_html_e('To add a QR Code via shortcode, use the following syntax', 'qrmemo'); ?>:
    43             </p>
    44                 <p style="margin-left: 20px;">
    45                     [qrmemo text="<i><?php esc_html_e('text to encode', 'qrmemo'); ?></i>" size="<i><?php esc_html_e('size in pixel', 'qrmemo'); ?></i>" margin="<i><?php esc_html_e('margin in pixel', 'qrmemo'); ?></i>" align="<i><?php esc_html_e('left|center|right', 'qrmemo'); ?></i>"]
    46                 </p>
    47             <?php submit_button(); ?>
    48         </form>
     13    // Rimuovi il tipo di post 'attachment' ( Media )
     14    unset( $post_types['attachment'] );
     15
     16    $selected_post_types = get_option( 'qrmemo_post_types', [] );
     17    ?>
     18    <div class = "wrap">
     19    <h1><?php esc_html_e( 'QRMemo Settings', 'qrmemo' );
     20    ?></h1>
     21    <form method = "post" action = "options.php">
     22    <?php
     23    settings_fields( 'qrmemo_settings_group' );
     24    do_settings_sections( 'qrmemo' );
     25    ?>
     26    <table class = "form-table">
     27    <tr valign = "top">
     28    <th scope = "row"><?php esc_html_e( 'Enable QR Code for the following post types', 'qrmemo' );
     29    ?>:</th>
     30    <td>
     31    <ul>
     32    <?php foreach ( $post_types as $post_type ) : ?>
     33    <li>
     34    <label>
     35    <input type = "checkbox" name = "qrmemo_post_types[]" value = "<?php echo esc_attr($post_type->name); ?>"
     36    <?php echo in_array( $post_type->name, $selected_post_types ) ? 'checked' : '';
     37    ?> />
     38    <?php echo esc_html( $post_type->label );
     39    ?>
     40    </label>
     41    </li>
     42    <?php endforeach;
     43    ?>
     44    </ul>
     45    </td>
     46    </tr>
     47    </table>
     48    <p>
     49    <?php esc_html_e( 'To add a QR Code via shortcode, use the following syntax', 'qrmemo' );
     50    ?>:
     51    </p>
     52    <p style = "margin-left: 20px;">
     53    [qrmemo text = "<i><?php esc_html_e('text to encode', 'qrmemo'); ?></i>" size = "<i><?php esc_html_e('size in pixel', 'qrmemo'); ?></i>" margin = "<i><?php esc_html_e('margin in pixel', 'qrmemo'); ?></i>" align = "<i><?php esc_html_e('left|center|right', 'qrmemo'); ?></i>"]
     54    </p>
     55    <?php submit_button();
     56    ?>
     57    </form>
    4958    </div>
    50 <?php
     59    <?php
    5160}
    5261
    5362// Registra e definisci le impostazioni
     63
    5464function qrmemo_register_settings() {
    55     register_setting('qrmemo_settings_group', 'qrmemo_post_types');
     65    register_setting(
     66        'qrmemo_settings_group',
     67        'qrmemo_post_types',
     68        [
     69            'sanitize_callback' => function ( $value ) {
     70                if ( ! is_array( $value ) ) {
     71                    return [];
     72                }
    5673
     74                return array_values(
     75                    array_filter(
     76                        array_map( 'sanitize_key', $value )
     77                    )
     78                );
     79            }
     80            ,
     81            'default' => [],
     82        ]
     83    );
    5784    add_settings_section(
    5885        'qrmemo_settings_section',
    59         __('Main Settings', 'qrmemo'),
     86        __( 'Main Settings', 'qrmemo' ),
    6087        'qrmemo_settings_section_callback',
    6188        'qrmemo'
    6289    );
    6390}
    64 add_action('admin_init', 'qrmemo_register_settings');
     91add_action( 'admin_init', 'qrmemo_register_settings' );
    6592
    6693// Callback della sezione delle impostazioni
     94
    6795function qrmemo_settings_section_callback() {
    68     echo '<p>' . esc_html_e('Configure the settings for QRMemo', 'qrmemo') . '</p>';
     96    echo '<p>' . esc_html_e( 'Configure the settings for QRMemo', 'qrmemo' ) . '</p>';
    6997}
  • qrmemo/trunk/qrmemo.php

    r3444102 r3444155  
    44Plugin URI:
    55Description: Adds a QR code at the end of each page and post with the current page URL. Also supports generating QR codes via shortcode.
    6 Version: 1.0.0
     6Version: 1.0.1
    77Author: mrpro64
    88Author URI: https://paolobertinetti.it/web
     
    2222use Endroid\QrCode\Writer\PngWriter;
    2323use Endroid\QrCode\Encoding\Encoding;
    24 
    25 // Carica il textdomain per le traduzioni
    26 function qrmemo_load_textdomain() {
    27     load_plugin_textdomain('qrmemo', false, dirname(plugin_basename(__FILE__)) . '/languages');
    28 }
    29 add_action('plugins_loaded', 'qrmemo_load_textdomain');
    3024
    3125// Genera il QR code come immagine PNG codificata in base64
  • qrmemo/trunk/readme.txt

    r3444102 r3444155  
    55Requires at least: 5.0
    66Tested up to: 6.9
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88Requires PHP: 7.0
    99License: GPLv2 or later
     
    5252== Changelog ==
    5353
     54= 1.0.1 =
     55* Fixed Plugin Check compliance issues.
     56* Improved settings sanitization.
     57* Improved translation handling.
     58* Tested up to WordPress 6.9.
     59
    5460= 1.0 =
    5561* Initial stable release with support for adding QR codes to selected post types and shortcode generation.
Note: See TracChangeset for help on using the changeset viewer.