Skip to content

Commit

Permalink
issue #2 - adiciona redirect para o site antigo se preenchido metabox
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgimenez committed Feb 17, 2018
1 parent 963b66b commit 721b0d3
Show file tree
Hide file tree
Showing 2 changed files with 196 additions and 1 deletion.
28 changes: 27 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,34 @@ function my_acf_settings_dir( $dir ) {


// 3. Hide ACF field group menu item
add_filter('acf/settings/show_admin', '__return_false');
// add_filter('acf/settings/show_admin', '__return_false');


// 4. Include ACF
include_once( get_stylesheet_directory() . '/inc/advanced-custom-fields/acf.php' );

// 4. Include ACF Fields
include_once( get_stylesheet_directory() . '/inc/acf-fields.php' );

/**
* Change permalink to the old permalink on the old version of the brasa site
* @param string $permalink
* @param object $post
* @param string|null $leavename
* @return string
*/
function redirect_portfolio_to_the_old_site( $permalink, $post, $leavename = null ) {
if ( is_admin() ) {
return $permalink;
}
if ( ! is_object( $post ) || 'jetpack-portfolio' != $post->post_type ) {
return $permalink;
}
if ( $link = get_post_meta( $post->ID, 'portfolio_redirect', true ) ) {
if ( ! empty( $link ) ) {
return $link;
}
}
return $permalink;
}
add_filter( 'post_type_link', 'redirect_portfolio_to_the_old_site', 10, 3 );
169 changes: 169 additions & 0 deletions inc/acf-fields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<?php
/**
*
* Campos exportados do ACF
*
*/
if(function_exists("register_field_group"))
{
register_field_group(array (
'id' => 'acf_depoimentos',
'title' => 'Depoimentos',
'fields' => array (
array (
'key' => 'field_5a6a5c8187729',
'label' => '',
'name' => '',
'type' => 'post_object',
'post_type' => array (
0 => 'jetpack-portfolio',
),
'taxonomy' => array (
0 => 'all',
),
'allow_null' => 0,
'multiple' => 0,
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'depoimentos',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array (
'position' => 'normal',
'layout' => 'no_box',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
register_field_group(array (
'id' => 'acf_portfolio',
'title' => 'Portfolio',
'fields' => array (
array (
'key' => 'field_5a6a58aaf5a15',
'label' => 'Desafio',
'name' => 'desafio',
'type' => 'wysiwyg',
'default_value' => '',
'toolbar' => 'full',
'media_upload' => 'yes',
),
array (
'key' => 'field_5a6a58bcf5a16',
'label' => 'Solução',
'name' => 'solucao_projeto',
'type' => 'wysiwyg',
'default_value' => '',
'toolbar' => 'full',
'media_upload' => 'yes',
),
array (
'key' => 'field_5a6a58cef5a17',
'label' => 'Impacto',
'name' => 'impacto',
'type' => 'wysiwyg',
'default_value' => '',
'toolbar' => 'full',
'media_upload' => 'yes',
),
array (
'key' => 'field_5a6a58ddf5a18',
'label' => 'Thumbnail do Vídeo',
'name' => 'thumbnail_do_video',
'type' => 'image',
'save_format' => 'object',
'preview_size' => 'thumbnail',
'library' => 'all',
),
array (
'key' => 'field_5a6a5fee6d547',
'label' => 'Link do Vídeo',
'name' => 'link_do_video',
'type' => 'text',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'none',
'maxlength' => '',
),
array (
'key' => 'field_5a6a73208d2ed',
'label' => 'slider',
'name' => 'slider',
'type' => 'post_object',
'post_type' => array (
0 => 'brasa_slider_cpt',
),
'taxonomy' => array (
0 => 'all',
),
'allow_null' => 0,
'multiple' => 0,
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'jetpack-portfolio',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array (
'position' => 'normal',
'layout' => 'no_box',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
register_field_group(array (
'id' => 'acf_temporario-url-do-portfolio-no-site-antigo',
'title' => 'TEMPORARIO: URL do portfólio no site antigo',
'fields' => array (
array (
'key' => 'field_5a87864540440',
'label' => 'Preencha com o URL do portfólio no site antigo',
'name' => 'portfolio_redirect',
'type' => 'text',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'jetpack-portfolio',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array (
'position' => 'side',
'layout' => 'default',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
}

0 comments on commit 721b0d3

Please sign in to comment.