File: /datos/www/www.colombia.co/public_html/wp-content/mu-plugins/colombia.php
<?php
class colombia {
const version = '2016';
function setup() {
add_action( 'init', array( __CLASS__, 'colombia_post_types' ) );
add_action( 'p2p_init', array( __CLASS__, 'my_connection_types' ) );
add_filter( 'kc_plugin_settings', array( __CLASS__, 'kc_settings_colombia') );
add_filter( 'kc_term_settings', array( __CLASS__, 'colombia_term_fields' ) );
add_filter( 'kc_post_settings', array( __CLASS__, 'colombia_custom_fields' ) );
add_filter( 'wp_kses_allowed_html', array( __CLASS__, 'esw_author_cap_filter' ),1,1 );
}
function colombia_post_types() {
register_post_type('home-slide', array(
'label' => __('Home Slides', 'colombia'),
'labels' => array (
'name' => __('Home Slides', 'colombia'),
'add_new' => __('Agregar nuevo', 'colombia'),
'add_new_item' => __('Agregar nuevo slide', 'colombia'),
'edit_item' => __('Editar slide', 'colombia'),
'new_item' => __('Nuevo slide', 'colombia'),
'view_item' => __('Ver slide', 'colombia')
),
'public' => true,
'hierarchical' => false,
'has_archive' => true,
'supports' => array('title','post-formats','editor','excerpt','revisions','thumbnail')
)
);
register_post_type('homebox', array(
'label' => __('Home boxes', 'colombia'),
'labels' => array (
'name' => __('Home box', 'colombia'),
'add_new' => __('Agregar nuevo', 'colombia'),
'add_new_item' => __('Agregar nuevo home box', 'colombia'),
'edit_item' => __('Editar home box', 'colombia'),
'new_item' => __('Nuevo home box', 'colombia'),
'view_item' => __('Ver home box', 'colombia')
),
'taxonomies' => array('category'),
'public' => true,
'hierarchical' => true,
'has_archive' => false,
'supports' => array('title','excerpt','revisions','thumbnail','custom-fields','page-attributes')
)
);
register_post_type('faq', array(
'label' => __('Preguntas frecuentes', 'colombia'),
'labels' => array (
'name' => __('Preguntas frecuentes', 'colombia'),
'add_new' => __('Agregar nuevo', 'colombia'),
'add_new_item' => __('Agregar nueva pregunta', 'colombia'),
'edit_item' => __('Editar pregunta', 'colombia'),
'new_item' => __('Nueva pregunta', 'colombia'),
'view_item' => __('Ver pregunta', 'colombia')
),
'taxonomies' => array('category'),
'public' => true,
'hierarchical' => true,
'has_archive' => false,
'supports' => array('title','editor','revisions')
)
);
register_post_type('download', array(
'label' => __('Descargas', 'colombia'),
'labels' => array (
'name' => __('Descargas', 'colombia'),
'add_new' => __('Agregar nuevo', 'colombia'),
'add_new_item' => __('Agregar nueva descarga', 'colombia'),
'edit_item' => __('Editar descarga', 'colombia'),
'new_item' => __('Nueva descarga', 'colombia'),
'view_item' => __('Ver descarga', 'colombia')
),
'taxonomies' => array('category'),
'public' => true,
'hierarchical' => true,
'has_archive' => true,
'supports' => array('title','editor', 'thumbnail','post-formats','page-attributes','revisions')
)
);
register_post_type('tp_eventos', array(
'labels' => array(
'name' => __('Eventos', 'colombia'),
'singular_name' => __('Evento', 'colombia')
),
'public' => true,
'has_archive' => false,
'exclude_from_search' => true
)
);
register_post_type('tp_lugares_unicos', array(
'labels' => array(
'name' => __('Lugares únicos', 'colombia'),
'singular_name' => __('Lugar único', 'colombia')
),
'taxonomies' => array('category'),
'public' => true,
'has_archive' => false,
'exclude_from_search' => true
)
);
register_post_type('banners', array(
'labels' => array(
'name' => __('Banners', 'colombia'),
'singular_name' => __('Banner', 'colombia')
),
'taxonomies' => array('category', 'post_tag'),
'public' => true,
'has_archive' => false,
'exclude_from_search' => true,
'supports' => array('title', 'thumbnail', 'revisions')
)
);
}
function my_connection_types() {
p2p_register_connection_type( array(
'name' => 'posts_to_posts',
'from' => 'post',
'to' => 'post',
'reciprocal' => true
) );
p2p_register_connection_type( array(
'name' => 'boxes_to_posts',
'from' => 'homebox',
'to' => 'post',
'reciprocal' => false
) );
p2p_register_connection_type( array(
'name' => 'pages_to_banners',
'from' => 'page',
'to' => 'banners',
'reciprocal' => false
) );
}
function kc_settings_colombia( $settings ) {
$my_settings = array(
/**
* Only alphanumerics, dashes and underscores are allowed here.
*/
'prefix' => 'colombia',
'menu_location' => 'themes.php',
'menu_title' => __('Configuración', 'colombia'),
'page_title' => __('Configuración', 'colombia'),
'options' => array(
array(
'id' => 'conectate_section',
'title' => __('Secciones Conéctate', 'colombia'),
'desc' => __('Imágenes, títulos y links para la sección "Conéctate con Colombia"', 'colombia'),
'fields' => array(
array(
'id' => 'conectate_1_title',
'type' => 'text',
'title' => __('Título Conéctate 1', 'colombia')
),
array(
'id' => 'conectate_1_link',
'type' => 'text',
'title' => __('Link Conéctate 1', 'colombia')
),
array(
'id' => 'conectate_1_image',
'title' => __('Imagen Conéctate 1', 'colombia'),
'type' => 'radio',
'options' => array(
'icon-visit' => 'Visit',
'icon-export' => 'Export',
'icon-invest' => 'Invest'
),
'default' => 'icon-visit'
),
array(
'id' => 'conectate_2_title',
'type' => 'text',
'title' => __('Título Conéctate 2', 'colombia')
),
array(
'id' => 'conectate_2_link',
'type' => 'text',
'title' => __('Link Conéctate 2', 'colombia')
),
array(
'id' => 'conectate_2_image',
'title' => __('Imagen Conéctate 2', 'colombia'),
'type' => 'radio',
'options' => array(
'icon-visit' => 'Visit',
'icon-export' => 'Export',
'icon-invest' => 'Invest'
),
'default' => 'icon-visit'
),
array(
'id' => 'conectate_3_title',
'type' => 'text',
'title' => __('Título Conéctate 3', 'colombia')
),
array(
'id' => 'conectate_3_link',
'type' => 'text',
'title' => __('Link Conéctate 2', 'colombia')
),
array(
'id' => 'conectate_3_image',
'title' => __('Imagen Conéctate 3', 'colombia'),
'type' => 'radio',
'options' => array(
'icon-visit' => 'Visit',
'icon-export' => 'Export',
'icon-invest' => 'Invest'
),
'default' => 'icon-visit'
)
)
),
)
);
$settings[] = $my_settings;
return $settings;
}
function colombia_custom_fields( $groups ) {
$groups[] = array(
'home-slide' => array(
array(
'id' => 'extra-data',
'title' => __('Campos opcionales', 'colombia'),
'fields' => array(
array(
'id' => 'texto',
'title' => __('Texto cabecera', 'colombia'),
'desc' => __('Texto slide', 'colombia'),
'type' => 'textarea'
),array(
'id' => 'url',
'title' => __('Link URL', 'colombia'),
'desc' => __('Link de slide (opcional)', 'colombia'),
'type' => 'text'
),array(
'id' => 'textLink',
'title' => __('Text button', 'colombia'),
'desc' => __('Text de botón (opcional)', 'colombia'),
'type' => 'text'
)
)
)
),
'homebox' => array(
array(
'id' => 'box-extra-data',
'title' => __('Campos opcionales', 'colombia'),
'fields' => array(
array(
'id' => 'url',
'title' => __('Link URL', 'colombia'),
'desc' => __('CTA (opcional)', 'colombia'),
'type' => 'text'
)
)
)
),
'banners' => array(
array(
'id' => 'banner-extra-data',
'title' => __('Campos adicionales', 'colombia'),
'fields' => array(
array(
'id' => 'url',
'title' => __('Link URL', 'colombia'),
'type' => 'text'
)
)
)
),
'event' => array(
array(
'id' => 'event-extra-data',
'title' => __('Datos del evento', 'colombia'),
'fields' => array(
array(
'id' => 'location',
'title' => __('Lugar', 'colombia'),
'desc' => __('Lugar del evento', 'colombia'),
'type' => 'text'
),
array(
'id' => 'url',
'title' => __('Link URL', 'colombia'),
'desc' => __('CTA (opcional)', 'colombia'),
'type' => 'text'
),
array(
'id' => 'start_date',
'title' => __('Fecha de inicio', 'colombia'),
'type' => 'date', // Not supported in theme customizer
'default' => date('Y-m-d'),
'desc' => 'Format: <code>'.date('Y-m-d').'</code>'
),
array(
'id' => 'end_date',
'title' => __('Fecha de finalización', 'colombia'),
'type' => 'date', // Not supported in theme customizer
'default' => date('Y-m-d'),
'desc' => 'Format: <code>'.date('Y-m-d').'</code>'
),
)
)
)
);
return $groups;
}
function colombia_term_fields( $groups ) {
$my_group = array(
'category' => array(
array(
'id' => 'category_data',
'title' => __('Datos de categoría', 'colombia'),
'role' => array('administrator', 'editor'),
'fields' => array(
array(
'id' => 'category_subtitle',
'title' => __('Subtítulo de categoría', 'colombia'),
'type' => 'text'
),
array(
'id' => 'category_color',
'title' => __('Color de categoría', 'colombia'),
'type' => 'color'
)
)
)
)
);
$groups[] = $my_group;
return $groups;
}
function esw_author_cap_filter( $allowedposttags ) {
//Here put your conditions, depending your context
if ( !current_user_can( 'publish_posts' ) )
return $allowedposttags;
// Here add tags and attributes you want to allow
$allowedposttags['iframe']=array(
'align' => true,
'width' => true,
'height' => true,
'frameborder' => true,
'name' => true,
'src' => true,
'id' => true,
'class' => true,
'style' => true,
'scrolling' => true,
'marginwidth' => true,
'marginheight' => true,
);
return $allowedposttags;
}
}
add_action( 'plugins_loaded', array('colombia', 'setup') );