Changeset 3136758
- Timestamp:
- 08/16/2024 05:30:07 PM (20 months ago)
- Location:
- single-user-content
- Files:
-
- 5 added
- 2 edited
-
tags/1.1 (added)
-
tags/1.1/Readme.txt (added)
-
tags/1.1/style.css (added)
-
tags/1.1/wpsuc-single-content.php (added)
-
tags/1.1/wpsuc.php (added)
-
trunk/Readme.txt (modified) (2 diffs)
-
trunk/wpsuc.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
single-user-content/trunk/Readme.txt
r3136716 r3136758 5 5 Requires at least: 5.0 6 6 Tested up to: 6.6 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later … … 25 25 26 26 == Changelog == 27 1.1 28 - Add new CPT icon 29 - Fix template bug 30 27 31 1.0 - Plugin Creted -
single-user-content/trunk/wpsuc.php
r3136716 r3136758 2 2 /* 3 3 Plugin Name: Single User Content 4 Plugin URI: https://github.com/maurodf0/wpsuc 4 5 Author: Mauro De Falco 6 Author URI: https://github.com/maurodf0 5 7 Description: 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. 08 Version: 1.1 7 9 License: GPL v2 or later 8 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 23 25 add_action('save_post', array($this, 'wpsuc_save_metabox_field')); 24 26 25 // Flush permalinks quando il plugin viene attivato27 // Flush permalinks when plugin is activated 26 28 register_activation_hook(__FILE__, array($this, 'wpsuc_flush_rewrite_rules_on_activation')); 27 29 } 28 30 29 // Registrazione del Custom Post Type31 // Add CPT 30 32 function wpsuc_add_cpt() { 31 33 register_post_type('private-user-content', … … 52 54 'public' => true, 53 55 'has_archive' => true, 54 'show_in_rest' => true, // Supporto per il blocco editor55 '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 CPT57 'menu_position' => 5, // Posizione nel menu di amministrazione58 'menu_icon' => 'dashicons- admin-post', // Icona nel menu di amministrazione56 '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', 59 61 ) 60 62 ); 61 63 } 62 64 63 // A ggiunta dello stile65 // Add Style 64 66 function wpsuc_add_style() { 65 67 //Load CSS only if is a private-user-content CPT … … 70 72 } 71 73 72 // Sovrascrittura del template singolo per il CPT74 // Override CPT single template 73 75 function wpsuc_load_single_template($single) { 74 76 global $post; 75 77 76 // Verif ica se il post è del tipoprivate-user-content78 // Verify is post type is private-user-content 77 79 if ($post->post_type == 'private-user-content') { 78 // Percorso al file single-private-user-content.php nel plugin79 $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'; 80 82 81 83 // Se il file esiste, sovrascrivi il template del tema … … 88 90 } 89 91 90 // A ggiunta della metabox per Private User Content92 // Add Metabox 91 93 function wpsuc_add_metaboxes() { 92 94 add_meta_box( 93 95 'single-user-content-metabox', // id 94 __('User for Private User Content', 'wpsuc'), // tit olo96 __('User for Private User Content', 'wpsuc'), // title 95 97 array($this, 'wpsuc_metabox_content'), // callback 96 98 'private-user-content', // post type 97 'normal', // posi zione98 'high' // priorit à99 'normal', // position 100 'high' // priority 99 101 ); 100 102 } 101 103 102 // HTML per lametabox104 // HTML for metabox 103 105 function wpsuc_metabox_content() { 104 106 global $post; … … 142 144 } 143 145 144 // Salvataggio dell'username146 // Username Autosave 145 147 if (isset($_POST['user'])) { 146 148 $user_login = sanitize_text_field($_POST['user']); … … 150 152 } 151 153 152 // F unzione per flushare i permalinks all'attivazione del plugin154 // Flush permalink 153 155 function wpsuc_flush_rewrite_rules_on_activation() { 154 156 // Registrazione del Custom Post Type
Note: See TracChangeset
for help on using the changeset viewer.