85 lines
2.1 KiB
PHP
85 lines
2.1 KiB
PHP
<?php
|
|
namespace App;
|
|
|
|
use Timber\Timber;
|
|
|
|
//require_once(get_template_directory().'/app.php');
|
|
|
|
include(__DIR__ .'/vendor/autoload.php');
|
|
|
|
//~ use WeDevs\ORM\WP\Post as Post;
|
|
//~ composer require jgrossi/corcel
|
|
|
|
function create_team_type() {
|
|
$obj = new BaseCPT('team','Miembro del equipo');
|
|
$obj->menu_icon = 'dashicons-id-alt';
|
|
$obj->rewrite = array('slug' => 'equipo');
|
|
/*dump($obj->build_cpt());*/
|
|
register_post_type( $obj->slug, $obj->build_cpt() );
|
|
}
|
|
//add_action( 'init', 'create_team_type' );
|
|
|
|
// templatetag para rellenar con contenido dinamico la plantilla en desarollo
|
|
function frontpage_posts($numberposts=-1,$template_name='frontpage_post.twig') {
|
|
$args = [
|
|
'numberposts' => $numberposts,
|
|
'post_type' => 'post',
|
|
];
|
|
$ctx = ['posts' => Timber::get_posts( $args )];
|
|
return Timber::fetch($template_name, $ctx);
|
|
}
|
|
add_filter( 'timber/twig', function( \Twig_Environment $twig ) {
|
|
$twig->addFunction( new Timber\Twig_Function( 'frontpage_posts', 'frontpage_posts' ) );
|
|
return $twig;
|
|
} );
|
|
// fin del templatetag para rellenar con contenido dinamico la plantilla en desarollo
|
|
|
|
// Galeria
|
|
function andaira_gallery($attr) {
|
|
//~ $post = get_post();
|
|
|
|
//~ static $instance = 0;
|
|
//~ $instance++;
|
|
|
|
if ( ! empty( $attr['ids'] ) ) {
|
|
if ( empty( $attr['orderby'] ) ) {
|
|
$attr['orderby'] = 'post__in';
|
|
}
|
|
$attr['include'] = $attr['ids'];
|
|
|
|
$ids = explode(',', $attr['ids']);
|
|
}
|
|
|
|
$template_name='gallery.twig';
|
|
|
|
$medias = array();
|
|
|
|
$ids = explode(',', $attr['ids']);
|
|
for ($x=0;$x<count($ids); $x++) {
|
|
|
|
$media = new Timber\Image($ids[$x]);
|
|
array_push($medias, $media);
|
|
|
|
}
|
|
$ctx = array('medias' => $medias);
|
|
|
|
$tpl = Timber::fetch($template_name, $ctx);
|
|
return $tpl;
|
|
}
|
|
// Fin galeria
|
|
|
|
|
|
// Paginacion
|
|
//$context['pagination'] = Timber::get_pagination();
|
|
|
|
// Galeria
|
|
add_shortcode('gallery', 'andaira_gallery');
|
|
|
|
Timber::init();
|
|
|
|
$site = new AndairaSite();
|
|
//~ $site->main_menu_id = 2;
|
|
|
|
if (defined('WP_CLI') && WP_CLI) {require_once dirname(__FILE__).'/scripts/commands.php';}
|
|
|