. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
| Server IP : 94.23.64.18 / Your IP :
216.73.216.185 [
Web Server : Apache System : Linux webm005.cluster107.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : villadal ( 6036) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/villadal/www/wp-content/plugins/emme_gallery/includes/ |
Upload File : |
<?php
/**
* classe principale plugin
**/
namespace emme_gallery;
require_once PLUGIN_EMME_GALLERY_PATH. '/includes/class-info.php';
require_once PLUGIN_EMME_GALLERY_PATH. '/gallery-metabox/gallery.php';
require_once PLUGIN_EMME_GALLERY_PATH. '/includes/class-shortcode.php';
class emme_gallery{
private $versione;
function __construct(){
$this->versione = Info::VERSIONE;
//aggiungo il post type della gallery
add_action( 'init', array($this, 'emme_gallery_posttype') );
//aggiungo il metabox per lo shortcode
add_action( 'add_meta_boxes', array($this , 'metabox_gallery_shortcode') );
// creo la colonna shortcode nel post type gallery
add_filter( 'manage_emme_gallery_posts_columns', array($this ,'add_shortcode_gallery_posts_columns' ));
//inserisco i valori all'interno della colonna shortcode nel post type gallery
add_action( 'manage_emme_gallery_posts_custom_column', array($this ,'content_shortcode_gallery_column'));
//ordino le colonne del post type gallery
add_filter( 'manage_emme_gallery_posts_columns', array($this ,'order_gallery_columns' ));
$this->loadshortcode(); //richiamo la funzione per istanziare la classe dello shortcode (contenuto)
//aggiungo le thumb della gallery
add_action( 'init', array($this, 'emme_gallery_thumb') );
}
function emme_gallery_posttype() {
$labels = array(
'name' => _x( 'Gallery', 'Post type general name', 'emme_gallery' ),
'singular_name' => _x( 'Gallery', 'Post type singular name', 'emme_gallery' ),
'menu_name' => _x( 'Gallery', 'Admin Menu text', 'emme_gallery' ),
'name_admin_bar' => _x( 'Gallery', 'Add New on Toolbar', 'emme_gallery' ),
'add_new' => __( 'Aggiungi nuovo', 'emme_gallery' ),
'add_new_item' => __( 'Aggiungi nuova Gallery', 'emme_gallery' ),
'new_item' => __( 'Aggiungi Gallery', 'emme_gallery' ),
'edit_item' => __( 'Modifica Gallery', 'emme_gallery' ),
'view_item' => __( 'Guarda Gallery', 'emme_gallery' ),
'all_items' => __( 'Tutte le Gallery', 'emme_gallery' ),
'search_items' => __( 'Cerca Gallery', 'emme_gallery' ),
'parent_item_colon' => __( 'Parent Gallery:', 'emme_gallery' ),
'not_found' => __( 'Nessuna Gallery trovata.', 'emme_gallery' ),
'not_found_in_trash' => __( 'Nessuna Gallery trovata nel cestino.', 'emme_gallery' ),
'filter_items_list' => _x( 'Filtra lista Gallery', 'Screen reader text for the filter links heading on the post type listing screen. Default “Filter posts list”/”Filter pages list”. Added in 4.4', 'emme_gallery' ),
'items_list_navigation' => _x( 'Lista navigazione Gallery', 'Screen reader text for the pagination heading on the post type listing screen. Default “Posts list navigation”/”Pages list navigation”. Added in 4.4', 'emme_gallery' ),
'items_list' => _x( 'Lista Gallery', 'Screen reader text for the items list heading on the post type listing screen. Default “Posts list”/”Pages list”. Added in 4.4', 'emme_gallery' ),
);
$args = array(
'labels' => $labels,
'description' => 'Gallery custom post type.',
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'emme-gallery' ),
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'menu_position' => 20,
'supports' => array( 'title', 'thumbnail' ),
'show_in_rest' => false,
'menu_icon' => 'dashicons-images-alt2'
);
register_post_type( 'emme_gallery', $args );
}
//funzione per il metabox dello shortcode
public function metabox_gallery_shortcode(){
add_meta_box(
'shortcode-gallery-metabox',
'Shortcode',
array($this , 'gallery_shortcode_metabox_cb'),
'emme_gallery',
'side',
'default'
);
}
public function gallery_shortcode_metabox_cb(){
echo '[emme_gallery id="'.get_the_ID().'"]';
}
// funzione per creare la colonna shortcode nel post type gallery
public function add_shortcode_gallery_posts_columns( $columns ) {
$columns['shortcode'] = __( 'Shortcode' );
return $columns;
}
// funcione per riemire la colonna shortcode nel post type gallery
public function content_shortcode_gallery_column( ){
echo '[emme_gallery id="'.get_the_ID().'"]';
}
//funzione per ordinare le colonne del post type gallery
public function order_gallery_columns($columns ){
$columns = array(
'cb' => $columns['cb'], //checkbox per selezionare
'title' => __( 'Title' ),
'shortcode' => __( 'Shortcode', 'emme_gallery' ),
'date' => __( 'Data', 'emme_gallery' ),
);
return $columns;
}
// funzione dove viene istanziata la classe dello shortcode presente nel file class-shortcode.php
public function loadshortcode(){
$shortcode = new Shortcodes();
}
//Funzione per aggiunger le thumb della gallery
public function emme_gallery_thumb() {
add_image_size( 'emme-gallery-thumb', 450, 300, true);
add_image_size( 'emme-gallery-square', 400, 400, true );
add_image_size( 'emme-gallery-medium', 600, 400, true);
add_image_size( 'emme-gallery-big', 900, 600, true);
}
}