<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
< script src = » < ? php bloginfo('template_directory') ; ?>/ images / jquery.imom.min.js » ></script>
. box {width : 380px ;}
. box img {vertical-align : top ; border : 0 ;}
. tb-pic a {display : table-cell ; text-align : centre ; vertical-align : centre ;}
. tb-pic a img{vertical-align : middle ;}
.tb-pic a {*display : block ;*font-family : Arial ;*line-height ; 1 ;}
. tb-thumb {margin:10px 0 0 ;overflow : hidden ;}
. tb-thumb li{background : no repeat scroll 0 0 transparent ; float : left ; height:42px ; margin : 0 6px 0 0 ; overflow : hidden ; padding:1px ;}
.tb-s310, .tb-s310 a{hauteur : 310px ; largeur : 380px ;}
.tb-s310 {max-haut : 310px ; max-width : 380px ;}
.tb-s310 img{max-height : 306px ; max-width : 376px ;}
.tb-s310 a {*font-size : 271px ;}
.tb-s40 a {*font-size : 35px ;}
.tb-s40 img {width:40px ; height:40px ;}
.tb-s40, .tb-s40 a{hauteur : 40px ; largeur : 40px ;}
.tb-booth {border:1px solid #CDCDCDCD ;position : relative ;z-index:1;}
.tb-thumb.tb-selected{background : none repeat scroll 0 0 #C30008 ; height:44px ; padding:2px ;}
.tb-thumb.tb-selected div{background-color :#FFFFFF ;border :medium none ;}
.tb-thumb li div {border:1px solid #CDCDCD ;}
div.zoomDiv {z-index : 999 ; position : absolue ; Top : 0px ; gauche : 0px ; largeur : 200px ; hauteur : 200px ; Références : #ffffff ; border:1px solid #CCCCCC ; Affichage : Aucun ; text-align : centre ; débordement : caché ;}
div.zoomMask{position : absolute ;background :url("images/mask.png") repeat scroll 0 0 transparent ;cursor : move ;z-index 1:13}
/ / Instanciation de la classe Panel Custom
/** * * * * *
$options = array() ;
$boxinfo = array('title' => 'argument fill', 'id'=> 'ashubox', 'page'=> array('post'), 'context'=> 'normal', 'priority'=> 'low', 'callback'=>") ;$options[] = array("name" => "product thumbnail upload",
« type » => « titre » ;$options[] = array(
« nom » = > « thumbnail1 »,
"desc " = >",
« id » => « ashu_upimg01 »,
« std » = > "",
« button_label » => 'Télécharger une image',
« Type » = « Médias »
);
$options [] = array (
« nom » => « thumbnail2 »,
"desc " = >",
« id » => « ashu_upimg02 »,
« std » = > "",
« button_label » => 'Télécharger une image',
« Type » = « Médias »
);
$options [] = array (
« nom » => « thumbnail 3 »,
"desc " = >",
« id » => « ashu_upimg03 »,
« std » = > "",
« button_label » => 'Télécharger une image',
« Type » = « Médias »
);
$options [] = array (
« nom » = > « thumbnail 4 »,
"desc " = >",
« id » => « ashu_upimg04 »,
« std » = > "",
« button_label » => 'Télécharger une image',
« Type » = « Médias »
);
$options [] = array (
« nom » = > « miniature 5 »,
"desc " = >",
« id » => « ashu_upimg05 »,
« std » = > "",
« button_label » => 'Télécharger une image',
« Type » = « Médias »
);
$new_box = new ashu_meta_box($options, $boxinfo) ;
?>
<div class="box">
<div class="tb-booth tb-pic tb-s310′′>
<? php if (get_post_meta($post->ID, 'ashu_upimg01', true)) { ?>
< a href = » < ? PHP echo get_post_meta($post->ID, ashu_upimg01′′, true) ; ?>>< img src = » < ? php echo get_post_meta($post->ID, ashu_upimg01′′, true) ; ?>rel = » < ? php echo get_post_meta($post->ID, ashu_upimg01′′, true) ; ?>class= "jqzoom" /></a>
<? php ? ?
</div>
<ul class=tb-thumb id=thumblist >
<? php if (get_post_meta($post->ID, 'ashu_upimg01', true)) { ?>
<li class="tb-selected"><div class="tb-pic tb-s40′′><a href="javascript :void(0) ;"><img src="< ? php echo get_post_meta($post->ID, ashu_upimg01′′, true) ; ?> mid = » ? php echo get_post_meta($post->ID, ashu_upimg01′′, true) ; ?> grand = » < ? PHP echo get_post_meta($post->ID, ashu_upimg01′′, true) ; ?>> </a></div></li>
<? php {else} { ? > <li class="tb-selected"><div class="tb-pic tb-s40′′></div></li> <? php ? ?
<? php if (get_post_meta($post->ID, 'ashu_upimg02', true)) { ? >
<li><div class="tb-pic tb-s40′′><a href="javascript : void(0) ;"><img src="< ? php echo get_post_meta($post->ID, ashu_upimg02′′, true) ; ?> mid = » ? php echo get_post_meta($post->ID, ashu_upimg02′′, true) ; ?> grand = » < ? php echo get_post_meta($post->ID, ashu_upimg02′′, true) ; ?>> </a></div></li>
<? php {else} { ? > <li><div class="tb-pic tb-s40′′></div></li> <? php ? ?
<? php if (get_post_meta($post->ID, 'ashu_upimg03', true)) { ?>
<li><div class="tb-pic tb-s40′′><a href="javascript : void(0) ;"><img src="< ? php echo get_post_meta($post->ID, ashu_upimg03′′, true) ; ?> mid = » ? php echo get_post_meta($post->ID, ashu_upimg03′′, true) ; ?> grand = » < ? php echo get_post_meta($post->ID, ashu_upimg03′′, true) ; ?>> </a></div></li>
<? php {else} { ? > <li><div class="tb-pic tb-s40′′></div></li> <? php ? ?
<? php if (get_post_meta($post->ID, 'ashu_upimg04', true)) { ?>
<li><div class="tb-pic tb-s40′′><a href="javascript : void(0) ;"><img src="< ? php echo get_post_meta($post->ID, ashu_upimg04′′, true) ; ?> mid = » ? php echo get_post_meta($post->ID, ashu_upimg04′′, true) ; ?> grand = » < ? php echo get_post_meta($post->ID, ashu_upimg04′′, true) ; ?>> </a></div></li>
<? php ? ?
<? php if (get_post_meta($post->ID, 'ashu_upimg05', true)) { ?>
<li><div class="tb-pic tb-s40′′><a href="javascript : void(0) ;"><img src="< ? php echo get_post_meta($post->ID, ashu_upimg05′′, true) ; ?> mid = » ? php echo get_post_meta($post->ID, ashu_upimg05′′, true) ; ?> grand = » < ? php echo get_post_meta($post->ID, ashu_upimg05′′, true) ; ?>> </a></div></li>
<? php ? ?
</ul>
</div>
Metaboxclass.php :
- <? php
- /*
- Article WordPress Custom Field Class Fichier
- Version : 1.0
- Auteur : Les arbres sont mes amis
- Auteur URI : www.example.com
- Licence : www.example.com
- */
- classe ashu _ meta _ box {
- var $options;
- var $boxinfo;
- Constructeur
- Fonction ashu_meta_box($options,$boxinfo){
- $ceci- > Options = $options;
- $ceci- > Boxinfo = $boxinfo;
- add_action('admin_menu', Array(&$ceci, ' init_boxes ') ;
- add_action ('save_post'), Array(&$ceci, ' save_postdata ') ;
- }
- / / initialisation
- Fonction init_boxes() {
- $ceci- > add_script_and_styles() ;
- $ceci- > create_meta_box() ;
- }
- Charger les scripts CSS et JS
- Fonction add_script_and_styles() {
- si(Basename( $_ serveur['PHP_SELF']) == « Page.php »
- || Basename( $_ serveur['PHP_SELF']) == « page-new.php »
- || Basename( $_ serveur['PHP_SELF']) == « post-new.php »
- || Basename( $_ serveur['PHP_SELF']) == « post.php »
- || Basename( $_ serveur['PHP_SELF']) == « media-upload.php »)
- {
- / / Notez l'url du script chargé
- wp_enqueue_style('metabox_fields_css', TEMJS_URI. ' metabox_fields.css ' ;
- wp_enqueue_script('metabox_fields_js', TEMJS_URI.« metabox_fields.js ») ;
- wp_enqueue_style('thickbox') ;
- wp_enqueue_script ('media-upload') ;
- wp_enqueue_script ('thickbox') ;
- si(l'isset)$get _['hijack_target ']))
- {
- add_action ('admin_head'), Array(&$ceci, 'add_hijack_var');
- }
- }
- }
- /*************************/
- Fonction add_hijack_var()
- {
- echo « <meta name='hijack_target' content=' ».$get _['hijack_target'].« / > \ n »;
- }
- Créer un panel personnalisé
- Fonction Créer _ meta _ box () {
- si (function_exists('add_meta_box') && is _ Array($ceci- > boxinfo ['page'])
- {
- foreach ($ceci- > boxinfo ['page'] As $région)
- {
- si ($ceci- > boxinfo['callback'] == ”) $ceci- > boxinfo['callback'] = 'new_meta_boxes' ;
- add _ meta _ box (
- $ceci-> boxinfo['id'],
- $ceci-> boxinfo['titre'],
- Array(&$ceci, $ceci- > boxinfo['callback']),
- $région, $ceci- > boxinfo['context'],
- $ceci-> boxinfo['priorité']
- );
- }
- }
- }
- / / Créer une fonction d'affichage pour un panneau personnalisé
- Fonction new_meta_boxes () {
- Globale $post;
- Appeler une fonction d'affichage en fonction du type
- foreach ($ceci> > Options As $option)
- {
- si (méthode _ existent)$ceci, $option[« type »]))
- {
- $meta _ box _ value = get_post_meta($post- > ID, $option['id'], vrai ;
- si($meta _ box _ value != “”) $option['std '] = $meta _ box _ value;
- echo « < div classe=« alt kriesi_meta_box_alt meta_box_'.$ Option ['type']. ' meta _ box _ '.$ this-> boxinfo ['context']. '”>’;
- $ceci->$option[« type »] ($option);
- echo ‘’;</div>
- }
- }
- / / Masquer le domaine
- echo« < type d'entrée =« caché » Nom =“‘.$ this->boxinfo['id'].'_ Noncéname " id = =“‘.$ this->boxinfo['id'].'_ Noncéname " Valeur =« wp.create_nonce ('ashumetabox'). '” />’;
- }
- Sauvegarder les données du champ
- Fonction save_postdata () {
- si(l'établissement) $_ Post['post_type'] ) && in_array($_ Post['post_type'],$ceci-> boxinfo['page'] ) && (isset($_ Post[« save »]|| par ISSET ($_ Post[« publier »]))) {
- $post_id = $_ Post['post_ID '] ;
- foreach ($ceci> > Options As $option) {
- si (! wp_verify_nonce($_ Post[$ceci-> boxinfo['id'].'_ noncename'], 'ashumetabox')) {
- retourner $post_id ;
- }
- / / Autorisations de jugement
- si (« page » = $_ Post['post_type '] {
- si ( ! current_user_can('edit_page', $post_id ))
- retourner $post_id ;
- } Autre {
- si ( ! current_user_can( 'edit_post', $post_id ))
- retourner $post_id ;
- }
- Convertir des caractères prédéfinis en entités html
- si( $option['type'] == 'tinymce') {
- $dates = Les stripslash($_ Post[$option['id ']]) ;
- }elseif( $option['type'] == 'checkbox') {
- $dates = $_ Post[$option['id ']] ;
- }Autre{
- $dates = htmlspecialchars($_ Post[$option['id'], ENT _ QUOTES,UTF - 8 »);
- }
- si(get_ post _ meta ()$post_id , $option['id']) == “”)
- add_post_meta($post_id , $option[« id »], $dates(Vrai)
- elseif($dates != get_post_meta ()$post_id , $option['id'], vrai))
- update_post_meta($post_id , $option[« id »], $dates);
- elseif($dates == “”)
- delete_post_meta($post_id , $option['id'], get_post_meta($post_id , $option['id'], vrai) ;
- }
- }
- }
- / / Afficher le titre
- Fonction Titre ($Valeurs){
- echo ‘’.<p>$Valeurs[« Nom »]. '’;</p>
- }
- Boîte de texte
- Fonction Le texte ($Valeurs){
- si(l'isset)$ceci- > Database _ Options$Valeurs['id ']])) $Valeurs['std '] = $ceci- > Database _ Options$Valeurs['id ']] ;
- echo ‘’.<p>$Valeurs[« Nom »]. '’;</p>
- echo « < type d'entrée =<p>« texte » taille =“‘.$ Les valeurs ['size']. '” Valeur =“‘.$ valeurs ['std']. '” id = =“‘.$ valeurs ['id']. '” Nom =“‘.$ valeurs ['id']. '”/>’;
- echo $Valeurs[« DESC »] '<br/></p>’;
- echo ‘<br/>’;
- }
- / / champ de texte
- Fonction Le texte ($Valeurs){
- si(l'isset)$ceci- > Database _ Options$Valeurs['id ']])) $Valeurs['std '] = $ceci- > Database _ Options$Valeurs['id ']] ;
- echo ‘’.<p>$Valeurs[« Nom »]. '’;</p>
- echo « < textarea<p> classe=« criesi_textarea » cols =“60” rows =“5” id = =“‘.$ valeurs ['id']. '” Nom =“‘.$ valeurs ['id']. '”>’.$Valeurs[« STD »]. '’;</textarea>
- echo $Valeurs[« DESC »] '<br/></p>’;
- echo ‘<br/>’;
- }
- / / Media Upload
- Fonction Médias ($Valeurs){
- si(l'isset)$ceci- > Database _ Options$Valeurs['id ']])) $Valeurs['std '] = $ceci- > Database _ Options$Valeurs['id ']] ;
- Bouton Upload d'image
- Globale $post _ ID, $temp _ ID;
- $uploading _ iframe _ id = (int) (0 ==) $post _ ID ? $temp _ ID : $post _ ID);
- $media _ upload _ iframe _ src = Media-upload.php ? post_id = $uploading_iframe_ID »;
- $image _ upload _ iframe _ src = apply_filters('image_upload_iframe_src', « $media_upload_iframe_src type=image »&);
- $Bouton = « < a href=“‘.$ image_upload_iframe_src. '& amp ; hijack_target='.$ valeurs['id']. '& amp ; TB_iframe = true » id = =“‘.$ valeurs ['id']. '” classe=« k_hijack button thickbox » cliquez sur =« retour faux » > Upload » ;</a>
- / / Déterminer le format d'image, prévisualisation d'image
- $image = ”;
- si($Valeurs['std'] ! = ”) {
- $fileextension = Sous-référence($Valeurs[« STD »], strrpos($Valeurs[« STD »], ‘.’+ 1) ;
- $Extensions = Array('png', 'gif', 'jpeg', 'jpg', 'pdf', 'tif') ;
- si(in Array ()$fileextension, $Extensions))
- {
- $image = ' < img src=“‘.$ valeurs ['std']. '” />’;
- }
- }
- echo « <div id=“‘.$ valeurs ['id'].'_ Div » classe=« kriesi_preview_pic »>’.$image . '’;</div>
- echo ‘’.<p>$Valeurs[« Nom »]. '’;</p><p>
- si($Valeurs['desc'] ! = “”) echo ‘’.<p>$Valeurs[« DESC »] '<br/>’;
- echo « < entrée classe=« kriesi_preview_pic_input » Type =« texte » taille =“‘.$ Les valeurs ['size']. '” Valeur =“‘.$ valeurs ['std']. '” Nom =“‘.$ valeurs ['id']. '”/>’.$Bouton;
- echo ‘’;</p>
- echo ‘<br/>’;
- }
- Boîte radio
- Fonction radio ( $Valeurs ){
- si(l'isset)$ceci- > Database _ Options$Valeurs['id ']]))
- $Valeurs['std '] = $ceci- > Database _ Options$Valeurs['id ']] ;
- echo ‘’.<p>$Valeurs[« Nom »]. '’;</p>
- foreach( $Valeurs[Boutons] As $key=>$valeur ) {
- $checked =“”;
- si($Valeurs['std'] $key) {
- $checked = ' vérifié = « vérifié »‘;
- }
- echo « < input ».$checked.’Type =« Radio » classe=« Check » Valeur =“‘.$ Key. '” Nom =“‘.$ valeurs ['id']. '”/>’.$valeur;
- }
- }
- / / Checkbox
- Fonction Checkbox ($Valeurs){
- echo ‘’.<p>$Valeurs[« Nom »]. '’;</p>
- foreach( $Valeurs[Boutons] As $key=>$valeur ) {
- $checked =“”;
- si( is _ Array($Valeurs['std']) && in _ array($key,$Valeurs['std '])) {
- $checked = ' vérifié = « vérifié »‘;
- }
- echo « < input ».$checked.’Type =« Checkbox » classe=« Check » Valeur =“‘.$ Key. '” Nom =“‘.$ valeurs ['id']. '[]”/>’.$valeur;
- }
- echo « < label Pour=“‘.$ valeurs ['id']. '”>’.$Valeurs[« DESC »] '</label><br/></p>’;
- }
- Boîte drop-down
- Fonction Dropdown ($Valeurs){
- echo ‘’.<p>$Valeurs[« Nom »]. '’;</p>
- / / Sélectionnez le contenu pour permettre aux pages, aux catégories, aux menus, aux barres latérales et au contenu personnalisé
- si($Valeurs['sous-type'] == 'page') {
- $sélectionner = ' Sélectionner la page ' ;
- $entrées = get_pages('title_li=&orderby=name') ;
- }Autre si($Valeurs['Subtype'] =='cat') {
- $sélectionner = « Sélectionnez la catégorie » ;
- $entrées = get_categories('title_li=&orderby=name&hide_empty=0') ;
- }Autre si($Valeurs['subtype'] == 'menu') {
- $sélectionner = 'Sélectionner le menu à gauche' ;
- $entrées = get_terms( 'nav_menu', Array('hide_empty' => false) ;
- }Autre si($Valeurs['Subtype'] == 'Sidebar') {
- Globale $wp _ registered _ sidebars;
- $sélectionner = ' Sélectionner une barre latérale spéciale ' ;
- $entrées = $wp _ registered _ sidebars;
- }Autre{
- $sélectionner = « Sélectionner ... » ;
- $entrées = $Valeurs[« sous-type »] ;
- }
- echo < Sélectionner<p> classe=« Postform » id = =“‘. $value ['id']. '” Nom =“‘. $value ['id']. '”> ‘;
- echo « < valeur de l'option =“”>’.$sélectionner . '‘;</option>
- foreach ($entrées As $key => $entré){
- si($Valeurs['sous-type'] == 'page') {
- $id = $entré- > ID ;
- $titre = $entré- > post _ title ;
- }Autre si($Valeurs['Subtype'] =='cat') {
- $id = $entré- > term_id ;
- $titre = $entré- > Nom ;
- }Autre si($Valeurs['subtype'] == 'menu') {
- $id = $entré- > term_id ;
- $titre = $entré- > Nom ;
- }Autre si($Valeurs['Subtype'] == 'Sidebar') {
- $id = $entré[« id »] ;
- $titre = $entré[« nom »] ;
- }Autre{
- $id = $entré;
- $titre = $key;
- }
- si ($Valeurs['std'] $id ){
- $sélectionné = « sélectionné » = « sélectionné »;
- }Autre{
- $sélectionné = “”;
- }
- echo« < option $value sélectionnée=' ». $id.“‘>”. $titre.“”</option>;
- }
- echo ‘’;</select>
- echo $Valeurs[« DESC »] '<br/></p>’;
- echo ‘<br/>’;
- }
- / / éditeur
- Fonction Tintin ($Valeurs){
- si(l'isset)$ceci- > Database _ Options$Valeurs['id ']]))
- $Valeurs['std '] = $ceci- > Database _ Options$Valeurs['id ']] ;
- echo ‘’.<p>$Valeurs[« Nom »]. '’;</p>
- wp_editor( $Valeurs[« STD »], $Valeurs['id'] ;
- //wp_editor($values['std'], 'content', array('dfw' => true, 'tabfocus_elements' => 'sample-permalink, post-preview', 'editor_height' => 360)) ;
- Paramètre de configuration
- /*wp_editor($meta_box['std'],$meta_box['name'].'_ value', $settings = array(quicktags=>0, // annuler le mode html
- tinymce=>1, // Mode de visualisation
- media_buttons = > 0, // Annuler le téléchargement des médias
- textarea_rows=>5, // Le nombre de lignes est réglé à 5
- editor_class=>"textareastyle") ); */
- }
- }
- ?>