IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

WordPress PHP Discussion :

Thème Jupiter Custom-post-types


Sujet :

WordPress PHP

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2008
    Messages : 7
    Points : 5
    Points
    5
    Par défaut Thème Jupiter Custom-post-types
    Bonjour,

    Je commence la programmation sur WordPress, et pour un travail je dois modifier quelques fichiers du thème Jupiter. Le thème en lui-même propose des customs post types comme 'Employées', 'News' , 'Testimonials', etc... Ces éléments sont créé dans un fichier qui se trouve ici : 'themes\jupiter\framework\custom-post-types\config.php'. Chaque nouveau post types est ajouté avec la fonction 'Mk_Register_Custom_Post_Type' qui elle utilise la class 'Mk_Register_Custom_Post_Type'. Ensuite chaque Post type créé, procèdent différentes propriétés propre à Jupiter qui se trouve dans la class 'mkMetaboxesGenerator'.

    Je souhaite ajouter un custom post 'Event' qui puisse réutiliser les différents éléments du framework de Jupiter. Pour se faire j'ai créé un theme-child, mais quand je fais cela je n'ai plus accès au framework du thème parent et donc plus accès aux fonctions de celui-ci.
    J'ai pensé surcharger les thèmes parent, mais cela ne me semble pas l'idée la plus propre. j'ai aussi pensé ajouter mes fichiers au thème parent, mais cela ne me semble pas être une idée optimale. Je cherche une idée propre pour me permettre d'ajouter mon code en utilisant les options de jupiter.

    voici la première version de mon code 'event' :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
     
    <?php
    /*-----------------------------------------------------------------------------------*/
     
    /* Register Event Custom Post type */
     
    /*-----------------------------------------------------------------------------------*/
    $event_slug = isset($mk_options['event_slug']) ? $mk_options['event_slug'] : 'event-posts';
    Mk_Register_Custom_Post_Type('event', $supports = array(
        'title',
        'editor',
        'excerpt',
        'thumbnail',
        'page-attributes',
        'revisions'
    ) , $args = array(
        'menu_icon' => 'dashicons-calendar-alt',
        'has_archive' => true,
        'rewrite' => array(
            'slug' => _x($event_slug, 'URL slug', 'mk_framework') ,
            'with_front' => FALSE
        ) ,
    ) );
     
    /**
     * Registers Event taxonomy
     */
    Mk_Register_custom_taxonomy('event_category', 'event');
     
    function mk_edit_event_columns($columns) {
        unset($columns['date']);
        unset($columns['comments']);
        unset($columns['author']);
     
        $event_columns = array(
            "cb" => "<input type=\"checkbox\" />",
            "title" => _x('Event Name', 'column name', 'mk_framework') ,
            "event_categories" => __('Categories', 'mk_framework') ,
            "event_start_date" => __('Date de début', 'mk_framework') ,
            "event_end_date" => __('Date de fin', 'mk_framework') ,
            "thumbnail" => __('Thumbnail', 'mk_framework') ,
            "date" => 'Date',
        );
     
        return array_merge($columns, $event_columns);
    }
    add_filter('manage_event_posts_columns', 'mk_edit_event_columns');
     
    function mk_manage_event_columns($column) {
        global $post;
     
        if ($post->post_type == "event") {
            switch ($column) {
                case "description":
                    the_excerpt();
                    break;
     
                case "event_categories":
                    $terms = get_the_terms($post->ID, 'event_category');
     
                    if (!empty($terms)) {
                        foreach ($terms as $t) $output[] = "<a href='edit.php?post_type=event&event_tag=$t->slug'> " . esc_html(sanitize_term_field('name', $t->name, $t->term_id, 'event_tag', 'display')) . "</a>";
                        $output = implode(', ', $output);
                    } 
                    else {
                        $t = get_taxonomy('event_category');
                        $output = "No $t->label";
                    }
     
                    echo $output;
                    break;
     
    			case "event_start_date":
                    echo get_the_terms($post->ID, '_event_start_date');
                    break;
     
    			case "event_end_date":
                    echo get_the_terms($post->ID, '_event_end_date');
                    break;
     
                case 'thumbnail':
                    echo the_post_thumbnail('thumbnail');
                    break;
                }
        }
    }
    add_action('manage_posts_custom_column', 'mk_manage_event_columns', 10, 2);
     
    /*-----------------------------------------------------------------------------------*/
     
    /* Register metabox-event */
     
    /*-----------------------------------------------------------------------------------*/
     
    $config  = array(
      'title' => sprintf( '%s Event Post Options', THEME_NAME ),
      'id' => 'mk-metaboxes-event',
      'pages' => array(
        'event'
      ),
      'callback' => '',
      'context' => 'normal',
      'priority' => 'core'
    );
    $options = array(
    	array(
    		"name" => __("Date de début", "mk_framework") ,
    		"desc" => __("", "mk_framework") ,
    		"id" => "_event_start_date",
    		"default" => 'false',
    		"default" => "",
    		"type" => "text"
    	) 
    	,
    	array(
    		"name" => __("Date de fin", "mk_framework") ,
    		"desc" => __("", "mk_framework") ,
    		"id" => "_event_end_date",
    		"default" => 'false',
    		"default" => "",
    		"type" => "text"
    	) 
    	,
    	array(
    		"name" => __("Heure de début", "mk_framework") ,
    		"desc" => __("", "mk_framework") ,
    		"id" => "_event_start_h",
    		"default" => 'false',
    		"default" => "",
    		"type" => "text"
    	) 
    	,
    	array(
    		"name" => __("Heure de fin", "mk_framework") ,
    		"desc" => __("", "mk_framework") ,
    		"id" => "_event_end_h",
    		"default" => "",
    		"type" => "text"
    	) 
    	,
     
      array(
        "name" => __( "Post Style", "mk_framework" ),
        "desc" => __( "Please choose post style how they will look in event post loop.", "mk_framework" ),
        "id" => "_event_post_style",
        "default" => 'full-with-image',
        "preview" => false,
        "options" => array(
            "full-with-image" => __( "Full With Image", "mk_framework" ),
            "full-without-image" => __( "Full Without Image", "mk_framework" ),
            "half-with-image" => __( "Half With Image", "mk_framework" ),
            "half-without-image" => __( "Half Without Image", "mk_framework" ),
            "fourth-with-image" => __( "One Fourth With Image", "mk_framework" ),
            "fourth-without-image" => __( "One Fourth Without Image", "mk_framework" ),
        ),
        "type" => "select"
      ),
     
    );
    new mkMetaboxesGenerator( $config, $options );
    ?>
    Merci dors et déjà pour votre aide.

  2. #2
    Expert éminent sénior
    Avatar de mathieu
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    10 234
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 10 234
    Points : 15 531
    Points
    15 531
    Par défaut
    Citation Envoyé par Monnier Eric Voir le message
    voici la première version de mon code 'event' :
    c'est le contenu du fichier functions.php du thème enfant ?

    qu'est ce qui ne fonctionne pas comme vous voulez avec ce code ?

Discussions similaires

  1. limiter les doublons avec les custom post type
    Par sylvainbr dans le forum WordPress
    Réponses: 4
    Dernier message: 24/11/2015, 12h11
  2. Privatiser un custom post type
    Par jeyreem dans le forum WordPress
    Réponses: 1
    Dernier message: 22/08/2014, 17h46
  3. Custom post type avec un champ "repeater"
    Par devkaty dans le forum WordPress
    Réponses: 1
    Dernier message: 24/06/2014, 22h29
  4. Custom field type
    Par mschoum dans le forum SharePoint
    Réponses: 3
    Dernier message: 04/11/2010, 18h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo