Plugin Directory

Changeset 3136758


Ignore:
Timestamp:
08/16/2024 05:30:07 PM (20 months ago)
Author:
maurodf
Message:

Fix template bug

Location:
single-user-content
Files:
5 added
2 edited

Legend:

Unmodified
Added
Removed
  • single-user-content/trunk/Readme.txt

    r3136716 r3136758  
    55Requires at least: 5.0
    66Tested up to: 6.6
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    2525
    2626== Changelog ==
     271.1
     28- Add new CPT icon
     29- Fix template bug
     30
    27311.0 - Plugin Creted
  • single-user-content/trunk/wpsuc.php

    r3136716 r3136758  
    22/*
    33Plugin Name: Single User Content
     4Plugin URI: https://github.com/maurodf0/wpsuc
    45Author: Mauro De Falco
     6Author URI: https://github.com/maurodf0
    57Description: Create a private page for single user registered on your site. Only the designed user can see the post, fast, secure, free.
    6 Version: 1.0
     8Version: 1.1
    79License: GPL v2 or later
    810License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2325        add_action('save_post', array($this, 'wpsuc_save_metabox_field'));
    2426       
    25         // Flush permalinks quando il plugin viene attivato
     27        // Flush permalinks when plugin is activated
    2628        register_activation_hook(__FILE__, array($this, 'wpsuc_flush_rewrite_rules_on_activation'));
    2729    }
    2830
    29     // Registrazione del Custom Post Type
     31    // Add CPT
    3032    function wpsuc_add_cpt() {
    3133        register_post_type('private-user-content',
     
    5254                'public' => true,
    5355                'has_archive' => true,
    54                 'show_in_rest' => true, // Supporto per il blocco editor
    55                 'supports' => array('title', 'editor', 'custom-fields', 'thumbnail', 'excerpt', 'comments', 'revisions'), // Aggiungi il supporto per i campi personalizzati e altre funzionalità
    56                 'rewrite' => array('slug' => 'private-user-content'), // Personalizza lo slug del CPT
    57                 'menu_position' => 5, // Posizione nel menu di amministrazione
    58                 'menu_icon' => 'dashicons-admin-post', // Icona nel menu di amministrazione
     56                'show_in_rest' => true,
     57                'supports' => array('title', 'editor', 'custom-fields', 'thumbnail', 'excerpt', 'comments', 'revisions'),
     58                'rewrite' => array('slug' => 'private-user-content'),
     59                'menu_position' => 5,
     60                'menu_icon' => 'dashicons-lock',
    5961            )
    6062        );
    6163    }
    6264
    63     // Aggiunta dello stile
     65    // Add Style
    6466    function wpsuc_add_style() {
    6567        //Load CSS only if is a private-user-content CPT
     
    7072    }
    7173
    72     // Sovrascrittura del template singolo per il CPT
     74    // Override CPT single template
    7375    function wpsuc_load_single_template($single) {
    7476        global $post;
    7577
    76         // Verifica se il post è del tipo private-user-content
     78        // Verify is post type is private-user-content
    7779        if ($post->post_type == 'private-user-content') {
    78             // Percorso al file single-private-user-content.php nel plugin
    79             $plugin_template = plugin_dir_path(__FILE__) . 'single-private-user-content.php';
     80            // Find template file
     81            $plugin_template = plugin_dir_path(__FILE__) . 'wpsuc-single-content.php';
    8082
    8183            // Se il file esiste, sovrascrivi il template del tema
     
    8890    }
    8991
    90     // Aggiunta della metabox per Private User Content
     92    // Add Metabox
    9193    function wpsuc_add_metaboxes() {
    9294        add_meta_box(
    9395            'single-user-content-metabox', // id
    94             __('User for Private User Content', 'wpsuc'), // titolo
     96            __('User for Private User Content', 'wpsuc'), // title
    9597            array($this, 'wpsuc_metabox_content'), // callback
    9698            'private-user-content', // post type
    97             'normal', // posizione
    98             'high' // priorità
     99            'normal', // position
     100            'high' // priority
    99101        );
    100102    }
    101103
    102     // HTML per la metabox
     104    // HTML for metabox
    103105    function wpsuc_metabox_content() {
    104106        global $post;
     
    142144        }
    143145
    144         // Salvataggio dell'username
     146        // Username Autosave
    145147        if (isset($_POST['user'])) {
    146148            $user_login = sanitize_text_field($_POST['user']);
     
    150152    }
    151153
    152     // Funzione per flushare i permalinks all'attivazione del plugin
     154    // Flush permalink
    153155    function wpsuc_flush_rewrite_rules_on_activation() {
    154156        // Registrazione del Custom Post Type
Note: See TracChangeset for help on using the changeset viewer.