Skip to content

Instantly share code, notes, and snippets.

@fabianomaximiano
Last active April 15, 2018 21:52
Show Gist options
  • Save fabianomaximiano/96e0c578af1682500b2bbe3b0dbee7a6 to your computer and use it in GitHub Desktop.
Save fabianomaximiano/96e0c578af1682500b2bbe3b0dbee7a6 to your computer and use it in GitHub Desktop.
//taxonomia exemplo
function odin_evento_taxonomy() {
$evento = new Odin_Taxonomy(
'Categoria', // Nome (Singular) da nova Taxonomia.
'categoria', // Slug do Taxonomia.
'evento' // Nome do tipo de conteúdo que a taxonomia irá fazer parte.
);
$evento->set_labels(
array(
'menu_name' => __( 'Tipos de evento', 'odin' )
)
);
$evento->set_arguments(
array(
'hierarchical' => false
)
);
}
add_action( 'init', 'odin_evento_taxonomy', 1 );
//taxonomy
function evento_metabox() {
$eventos_metabox = new Odin_Metabox(
'eventos', // Slug/ID of the Metabox (Required)
'Eventos Mais Detalhes', // Metabox name (Required)
'evento', // Slug of Post Type (Optional)
'normal', // Context (options: normal, advanced, or side) (Optional)
'high' // Priority (options: high, core, default or low) (Optional)
);
$eventos_metabox->set_fields(
array(
/**
* Default input examples.
*/
// Text Field.
array(
'id' => 'titulo_evento', // Required
'label' => __( 'Titulo Evento', 'odin' ), // Required
'type' => 'text', // Required
'attributes' => array( // Optional (html input elements)
'placeholder' => __( 'Informe o titulo do evento!' )
),
// 'default' => 'Default text', // Optional
'description' => __( 'Nome do evento para destaque', 'odin' ) // Optional
),
// Textarea Field.
array(
'id' => 'descricao_evento', // Required
'label' => __( 'Descricao Evento', 'odin' ), // Required
'type' => 'textarea', // Required
'attributes' => array( // Optional (html input elements)
'placeholder' => __( 'Mais detalhes do evento!' )
),
// 'default' => 'Default text', // Optional
'description' => __( 'Mais Detalhes do Evento', 'odin' ) // Optional
),
// Checkbox field.
array(
'id' => 'cidade_evento', // Required
'label' => __( 'Cidade', 'odin' ), // Required
'type' => 'text', // Required
'attributes' => array(
'placeholder' => __( 'informe o nome da Cidade onde sera realiazdo evento!')
), // Optional (html input elements)
// 'default' => 'no', // Optional ('yes' for checked)
'description' => __( 'Cidade onde sera realizado o evento!', 'odin' ), // Optional
'add_column' => true,
),
// Editor field.
array(
'id' => 'estado_evento', // Required
'label' => __( 'Estado', 'odin' ), // Required
'type' => 'text', // Required
'attributes' => array(
'placeholder' => __( 'informe o Estado onde sera realiazdo evento!')
), // Optional (html input elements)
// 'default' => 'no', // Optional ('yes' for checked)
'description' => __( 'Estado onde sera realizado o evento!', 'odin' ), // Optional
'add_column' => true,
),
array(
'id' => 'valor_evento', // Required
'label' => __( 'Valor', 'odin' ), // Required
'type' => 'text', // Required
'attributes' => array(
'placeholder' => __( 'informe o Estado onde sera realiazdo evento!')
), // Optional (html input elements)
// 'default' => 'no', // Optional ('yes' for checked)
'description' => __( 'Estado onde sera realizado o evento!', 'odin' ), // Optional
'add_column' => true,
)
)
);
}
add_action( 'init', 'evento_metabox', 1 );
function odin_evento_cpt() {
$evento = new Odin_Post_Type(
'evento', // Nome (Singular) do Post Type.
'evento' // Slug do Post Type.
);
$evento->set_labels(
array(
'menu_name' => __( 'Meus eventos', 'odin' )
)
);
$evento->set_arguments(
array(
'supports' => array( 'title', 'thumbnail' ),
'menu_icon' => 'dashicons-tickets'
)
);
}
add_action( 'init', 'odin_evento_cpt', 1 );
@fabianomaximiano
Copy link
Author

//taxonomia exemplo
function odin_evento_taxonomy() {
$evento = new Odin_Taxonomy(
'Categoria', // Nome (Singular) da nova Taxonomia.
'categoria', // Slug do Taxonomia.
'evento' // Nome do tipo de conteúdo que a taxonomia irá fazer parte.
);

$evento->set_labels(
    array(
        'menu_name' => __( 'Tipos de evento', 'odin' )
    )
);

$evento->set_arguments(
    array(
        'hierarchical' => false
    )
);

}

add_action( 'init', 'odin_evento_taxonomy', 1 );

//taxonomy

function evento_metabox() {

$eventos_metabox = new Odin_Metabox(
    'eventos', // Slug/ID of the Metabox (Required)
    'Eventos Mais Detalhes', // Metabox name (Required)
    'evento', // Slug of Post Type (Optional)
    'normal', // Context (options: normal, advanced, or side) (Optional)
    'high' // Priority (options: high, core, default or low) (Optional)
);

$eventos_metabox->set_fields(
    array(
        /**
         * Default input examples.
         */

        // Text Field.
        array(
            'id'         => 'titulo_evento', // Required
            'label'      => __( 'Titulo Evento', 'odin' ), // Required
            'type'       => 'text', // Required
            'attributes' => array( // Optional (html input elements)
                'placeholder' => __( 'Informe o titulo do evento!' )
            ),
            // 'default'  => 'Default text', // Optional
            'description' => __( 'Nome do evento para destaque', 'odin' ) // Optional
        ),
        // Textarea Field.
        array(
            'id'          => 'descricao_evento', // Required
            'label'       => __( 'Descricao Evento', 'odin' ), // Required
            'type'        => 'textarea', // Required
            'attributes'  => array( // Optional (html input elements)
                'placeholder' => __( 'Mais detalhes do evento!' )
            ),
            // 'default'  => 'Default text', // Optional
            'description' => __( 'Mais Detalhes do Evento', 'odin' ) // Optional
        ),
        // Checkbox field.
        array(
            'id'          => 'cidade_evento', // Required
            'label'       => __( 'Cidade', 'odin' ), // Required
            'type'        => 'text', // Required
            'attributes' => array(
            	'placeholder' => __( 'informe o nome da Cidade onde sera realiazdo evento!')
            ), // Optional (html input elements)
            // 'default'    => 'no', // Optional ('yes' for checked)
            'description' => __( 'Cidade onde sera realizado o evento!', 'odin' ), // Optional
            'add_column' => true,
        ),
        // Editor field.
        array(
            'id'          => 'estado_evento', // Required
            'label'       => __( 'Estado', 'odin' ), // Required
            'type'        => 'text', // Required
            'attributes' => array(
            	'placeholder' => __( 'informe o Estado onde sera realiazdo evento!')
            ), // Optional (html input elements)
            // 'default'    => 'no', // Optional ('yes' for checked)
            'description' => __( 'Estado onde sera realizado o evento!', 'odin' ), // Optional

            'add_column' => true,
        ),
        array(
            'id'          => 'valor_evento', // Required
            'label'       => __( 'Valor', 'odin' ), // Required
            'type'        => 'text', // Required
            'attributes' => array(
            	'placeholder' => __( 'informe o Estado onde sera realiazdo evento!')
            ), // Optional (html input elements)
            // 'default'    => 'no', // Optional ('yes' for checked)
            'description' => __( 'Estado onde sera realizado o evento!', 'odin' ), // Optional

            'add_column' => true,
        )

    )
);

}

add_action( 'init', 'evento_metabox', 1 );

function odin_evento_cpt() {
$evento = new Odin_Post_Type(
'evento', // Nome (Singular) do Post Type.
'evento' // Slug do Post Type.
);

$evento->set_labels(
    array(
        'menu_name' => __( 'Meus eventos', 'odin' )
    )
);

$evento->set_arguments(
    array(
        'supports' => array( 'title', 'thumbnail' ),
        'menu_icon' => 'dashicons-tickets'
    )
);

}

add_action( 'init', 'odin_evento_cpt', 1 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment