HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: /datos/www/www.colombia.co/public_html/wp-content/themes/colombia2016/functions.php
<?php
/**
 * Register latest jQuery, load on footer
 */

/* shortcode */

add_shortcode('linea', function($atts){
  ob_start();
  ?><div class="detailpart" style="width: 100%;">&nbsp;</div><?php
  return ob_get_clean();
});

function my_init() {
	if (!is_admin()) {
		wp_deregister_script('jquery');
		wp_register_script('jquery', '/wp-includes/js/jquery/jquery.js', false, '1.3.2', true);
	}
}
add_action('init', 'my_init');


function colapsable_jquery_script() {
	if (!is_admin()) {
		wp_register_script('colapsable', get_template_directory_uri() . '/js/colapsable.js', false, '1', true);
		wp_enqueue_script('colapsable');
	}
}
add_action('wp_enqueue_scripts', 'colapsable_jquery_script');

function minimal_jquery_script() {
	if ( ! is_admin() ) {
		wp_deregister_script('jquery');
		wp_register_script('jquery', '//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js', false, '2.2.3', true);
	}
}
add_action('wp_enqueue_scripts', 'minimal_jquery_script');


function dequeue_css_from_plugins()  {
	wp_dequeue_style('wpdm-front');
}
add_action('wp_print_styles', 'dequeue_css_from_plugins', 100);



function datalayer_script() {
	wp_enqueue_script( 'datalayer', get_template_directory_uri() . '/js/datalayer.js', array(), true);
	wp_enqueue_script('datalayer');
}
add_action('wp_enqueue_scripts', 'datalayer_script');


function responsive_data_module_script() {
	wp_enqueue_script( 'responsive_data_module', get_template_directory_uri() . '/js/responsive_data_module.js', array(), true);
	wp_enqueue_script('responsive_data_module');
}
add_action('wp_enqueue_scripts', 'responsive_data_module_script' , 9, 9);

/**
 * Theme setup
 */
function minimal_theme_setup() {
	// Adds RSS feed links to <head> for posts and comments.
	add_theme_support('automatic-feed-links');

	// Custom menu support.
	register_nav_menu('primary', 'Primary Menu');
	register_nav_menu('secondary', 'Secondary Menu');
	register_nav_menu('lang', 'Language Selector');
	register_nav_menu('social', 'Social Networks');
	register_nav_menu('footer', 'Footer Menu');

	// Most themes need featured images.
	add_theme_support('post-thumbnails' );

	add_theme_support('post-formats', array('image','audio','video'));

	// Localization support
	load_theme_textdomain('colombia', get_template_directory() . '/lang');
}
add_action('after_setup_theme', 'minimal_theme_setup');

/**
 * Remove code from the <head>
 */
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);// http://www.tech-evangelist.com/2011/09/05/disable-remove-wordpress-shortlink/
//remove_action('wp_head', 'rsd_link'); // Might be necessary if you or other people on this site use remote editors.
//remove_action('wp_head', 'feed_links', 2); // Display the links to the general feeds: Post and Comment Feed
//remove_action('wp_head', 'feed_links_extra', 3); // Display the links to the extra feeds such as category feeds
//remove_action('wp_head', 'index_rel_link'); // Displays relations link for site index
remove_action('wp_head', 'wlwmanifest_link'); // Might be necessary if you or other people on this site use Windows Live Writer.
//remove_action('wp_head', 'start_post_rel_link', 10, 0); // Start link
//remove_action('wp_head', 'parent_post_rel_link', 10, 0); // Prev link
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); // Display relational links for the posts adjacent to the current post.

// http://justintadlock.com/archives/2010/07/08/lowercase-p-dangit
remove_filter( 'the_title', 'capital_P_dangit', 11 );
remove_filter( 'the_content', 'capital_P_dangit', 11 );
remove_filter( 'comment_text', 'capital_P_dangit', 31 );

// Hide the version of WordPress you're running from source and RSS feed // Want to JUST remove it from the source? Try: remove_action('wp_head', 'wp_generator');
add_filter('the_generator', '__return_false');

//add_filter('show_admin_bar', '__return_false');

function custom_excerpt_length( $length ) {
	return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

function htpify( $link ){
	if (preg_match("#https?://#", $link) === 0) {
		$link = 'http://'.$link;
	}
	return $link;
}

function padre_class($classes){
	global $post;
	$cat=get_the_category(get_query_var('post'));
	if(is_array($cat)&&!empty($cat)){
		if($cat[0]->category_parent!=0){
			$parents=get_category_parents($cat[0]->term_id,false,'@',true);
			if(!empty($parents)){
				$parent=explode('@',$parents);
				$classes[]='category-'.$parent[0];
			}
		}
	}
	return $classes;
}
//add_filter('post_class','padre_class');

// Funcion para traer al padre de primer nivel
function get_top_parent($cat){
	$curr_cat = get_category_parents($cat, false, '/' ,true);
	$curr_cat = explode('/',$curr_cat);
	$idObj = get_category_by_slug($curr_cat[0]);
	return  $curr_cat[0];
}

// Funcion para incluir clase de categoria superior en paginas de archivo
function cat_rats_class($classes){
	global $wp_query;
	$cat=$wp_query->get_queried_object();

	if( $cat ){
		if($cat->category_parent!=0){
			$parents=get_category_parents($cat->term_id,false,'@',true);
			if(!empty($parents)){
				$parent=explode('@',$parents);
				$classes[]='category-'.$parent[0];
			}
		}
	}

	return $classes;

}
add_filter('body_class','cat_rats_class');

/**
 * retornar todos los posts del post type "lugares unicos"
 */
function get_all_sites_map() {
    // $obj_seg = new security();
    // $categories = $obj_seg->clear_all($_POST['categories']);


    $args = array(
        'post_type' => 'tp_lugares_unicos',
        'post_status' => 'publish',
        'posts_per_page' => -1
    );
    $obj_result = array();
    query_posts($args);
    if (have_posts()):
        while (have_posts()) : the_post();
            $coordinates = get_field('coordinates_pt_lugares_unicos');
            $coordinates = explode(',', $coordinates );
			$longitude = $coordinates[1];
			$latitude = $coordinates[0];

            $obj_result[] = array(
                'location' => array(
                		'lat' => $latitude,
                		'lon' => $longitude,
                		'zoom' => 10,
                		'line' => true
                	),
                'text' => array(
                		'headline' => get_the_title(),
                		'text' => get_the_content()
                	)
            );
        endwhile;
    endif;
    $storymap = array(
    				"storymap" => array(
    						"slides" => $obj_result
    					)
    				);
    die(json_encode($storymap));
}

add_filter('wp_ajax_get_all_sites_map', 'get_all_sites_map');
add_action('wp_ajax_nopriv_get_all_sites_map', 'get_all_sites_map');

function get_filtered_calendar_events(){
	global $wpdb;

	
	$desde = $_POST['desde'];
	$hasta = $_POST['hasta'];

 	$mes = substr($desde, 5, 2);

 	$year = substr($desde, 0, 4);

    switch ($mes) {
    	case '01':
    		$mes = 'Enero';
    		break;

    	case '02':
    		$mes = 'Febrero';
    		break;

    	case '03':
    		$mes = 'Marzo';
    		break;

    	case '04':
    		$mes = 'Abril';
    		break;

    	case '05':
    		$mes = 'Mayo';
    		break;

    	case '06':
    		$mes = 'Junio';
    		break;

    	case '07':
    		$mes = 'Julio';
    		break;

    	case '08':
    		$mes = 'Agosto';
    		break;

    	case '09':
    		$mes = 'Septiembre';
    		break;

    	case '10':
    		$mes = 'Octubre';
    		break;

    	case '11':
    		$mes = 'Noviembre';
    		break;

    	case '12':
    		$mes = 'Diciembre';
    		break;
    }

	$arrayFecha = [$desde, $hasta];


	// args
	$args = array(
		'numberposts'	=> -1,
		'post_type'		=> 'tp_eventos',
		'meta_query'	=> array(
			array(
				'key'		=> 'date_start_pt_eventos',
				'compare'	=> 'BETWEEN',
				'value'		=> $arrayFecha
			)
		)
	);

	// query
	$results = array();

	$posts = get_posts($args);
	global $post;

	foreach ($posts as $post) {
		setup_postdata( $post );
		$id = get_the_id();
		$title = get_the_title();
		$start_date = get_field('date_start_pt_eventos');
		$end_date = get_field('date_end_pt_eventos');
		$location = get_field('place_pt_eventos');
		$subtitle = get_field('subtitle_region');
		$content = get_the_content();
		$ext_link = get_field('link_pt_eventos');
		$link = htpify($ext_link);
		$image = get_field('image_pt_eventos');
		$descripcionCalendario = get_field('descripcion');
		$city= get_field('ciudad', $id);
		$cityImage = get_field('imagen_mapa_miniatura',  $city);
		$region = get_field( 'region', $city );
		$colorRegion = get_field( 'color', $region );
		$results[] = array(
			'ID' => $id,
			'title' => $title,
			'fecha_inicio' => $start_date,
			'fecha_fin' => $end_date,
			'location' => $location,
			'content' => $content,
			'link' => $link,
			'image' => $image['sizes']['medium'],
            'img_alt' => $image['alt'],
            'img_title' => $image['title'],
			'city' => $city,
			'cityImage' => $cityImage,
			'region' => $region,
			'colorRegion' => $colorRegion,
			'subtitle' => $subtitle,
			'descripcionCalendario' => $descripcionCalendario
		);
	}

	if( empty( $results ) ){
		$results[] = array(
				'ID' => 0,
				'title' => __('Para este mes no tenemos eventos, pero te invitamos a revisar los otros meses del año para que te agendes desde ya y vengas a vivir #LoMejorDeColombia','colombia'),
				'fecha_inicio' => '-',
				'fecha_fin' => '-',
				'location' => '-',
				'content' => '',
				'link' => '',
				'image' => 'http://placehold.it/1x1'
			);
	}

	die( json_encode( $results ) );
}

add_filter('wp_ajax_get_filtered_calendar_events', 'get_filtered_calendar_events');
add_action('wp_ajax_nopriv_get_filtered_calendar_events', 'get_filtered_calendar_events');

function searchfilter($query) {

    if ($query->is_search && !is_admin() ) {
        $query->set('post_type',array('post'));
    }

	return $query;
}

add_filter('pre_get_posts','searchfilter');

/* Redirect if there is only one product in the category */
add_action( 'template_redirect', 'correct_category_link', 10 );
function correct_category_link ($wp_query) {
	global $wp_query;
	if (is_category()) {
		$current_url = "https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
		$cat = get_cat_ID(single_cat_title('', false));
		$cat_id = get_cat_ID(single_cat_title('', false));
		$real_id = get_cat_ID($cat_id);

		$category_link = get_term_link( $cat_id, 'category' );

		if( ( $current_url != $category_link ) && !is_paged() ){
			wp_redirect( esc_url( $category_link ), 301 );
			exit();
			// echo $current_url . " vs. " . $category_link;
		}
	}
}

// change page link to display published pages only
function wcs_change_admin_page_link() {
    global $submenu;
    $submenu['edit.php?post_type=page'][5][2] = 'edit.php?post_type=page&post_status=publish';
}
add_action( 'admin_menu', 'wcs_change_admin_page_link' );

// change post link to display published posts only
function wcs_change_admin_post_link() {
    global $submenu;
    $submenu['edit.php'][5][2] = 'edit.php?post_status=publish';
}
add_action( 'admin_menu', 'wcs_change_admin_post_link' );

//Add excerpt support to pages
/*add_action( 'init', 'my_add_excerpts_to_pages' );
function my_add_excerpts_to_pages(){
    add_post_type_support( 'page', 'excerpt' );
}*/

/**
 * Removes the regular excerpt box. We're not getting rid
 * of it, we're just moving it above the wysiwyg editor
 *
 * @return null
 */
function oz_remove_normal_excerpt() {
    remove_meta_box( 'postexcerpt' , 'post' , 'normal' );
}
add_action( 'admin_menu' , 'oz_remove_normal_excerpt' );

/**
 * Add the excerpt meta box back in with a custom screen location
 *
 * @param  string $post_type
 * @return null
 */
function oz_add_excerpt_meta_box( $post_type ) {
    if ( in_array( $post_type, array( 'post', 'page' ) ) ) {
        add_meta_box(
            'oz_postexcerpt',
            __( 'Extracto', 'colombia' ),
            'post_excerpt_meta_box',
            $post_type,
            'after_title',
            'high'
        );
    }
}
add_action( 'add_meta_boxes', 'oz_add_excerpt_meta_box' );

/**
 * You can't actually add meta boxes after the title by default in WP so
 * we're being cheeky. We've registered our own meta box position
 * `after_title` onto which we've regiestered our new meta boxes and
 * are now calling them in the `edit_form_after_title` hook which is run
 * after the post tile box is displayed.
 *
 * @return null
 */
function oz_run_after_title_meta_boxes() {
    global $post, $wp_meta_boxes;
    # Output the `below_title` meta boxes:
    do_meta_boxes( get_current_screen(), 'after_title', $post );
}
add_action( 'edit_form_after_title', 'oz_run_after_title_meta_boxes' );

// allow script & iframe tag within posts
function allow_post_tags( $allowedposttags ){
    $allowedposttags['script'] = array(
        'type' => true,
        'src' => true,
        'height' => true,
        'width' => true,
    );
	/* Jhon Eslava 03/12/2018 */
    $allowedposttags['iframe'] = array(
        'src' => true,
        'width' => true,
        'height' => true,
        'class' => true,
        'frameborder' => true,
        'webkitAllowFullScreen' => true,
        'mozallowfullscreen' => true,
        'allowFullScreen' => true,
		'seamless' => true,
		'style' => true,
		'scrolling' => true,
		'allowtransparency' => true,
		'allowfullscreen' => true
    );
    return $allowedposttags;
}
add_filter('wp_kses_allowed_html','allow_post_tags', 1);


//fijar el tamaño de las imagenes de los post en 768 X 397
set_post_thumbnail_size( 768, 397, true );

function limit_posts_per_archive_page() {

	   $locale = get_locale();
        if($locale == "es_CO"){
            $category_ID =3455;
        }else if($locale == "en_US"){
            //$category_ID = 1941;
             $category_ID = 2075;
        }
        else if($locale == "fr_FR"){
                        $category_ID = 235;
        }
	$cat_id = get_cat_ID(single_cat_title('', false));
	$category = get_category($category_ID);


//$a = get_category_parents_ID($cat_id);



if (!empty($category)  && (($cat_id == $category_ID) ||  ($category->category_parent == $category_ID))) {
   $limit = 9;
}

else {
    $limit = get_option('posts_per_page');
}


set_query_var('posts_per_archive_page', $limit);
}
add_filter('pre_get_posts', 'limit_posts_per_archive_page');


/*function exclude_category($query) {
    if ( is_category('marca-colombia') && isset($query) ) {
       // $query->set('cat', '-3167,-3163');
        $query->set('cat', '-3455,-13');

    }
    return $query;
}
add_filter('pre_get_posts', 'exclude_category');*/




function more_post_ajax(){
     $offset = $_POST["offset"];
     $ppp = $_POST["ppp"];
      $pid = $_POST["pid"];
     header("Content-Type: text/html");

     $args = array(
             'cat' => 3155,
             'posts_per_page' => $ppp,
             'offset' => $offset,
             'orderby' => 'meta_value',
             'order' => 'ASC',
                       'meta_query' => array(
                           array(
                               'key' => 'event_end_date',
                               'value' => $today,
                               'compare' => '>=',
                               'type' => 'DATE'
                           ),
                           array(
                               'key' => 'select_artist',
                               'value' => $pid,
                               'compare' => '=',
                           )
                       )
     );
     $loop = new WP_Query($args);

            while ($loop->have_posts() ) {
                $loop->the_post();

	echo "<article class='eventos-item post'>";
	echo "<figure class='post-img'>";


echo "<a href=".get_permalink()."><img src=".get_field('event_thumb_image')." class='attachment-post-thumbnail size-post-thumbnail wp-post-image'>";

echo "<div class='post-category'>";
echo "<h2 class='hidden-xs'>".get_the_title()."</a></h2>";
 echo"<a href='<?php echo get_permalink(); ?>' class='orange-with-arrow'>";
echo "<span>".the_field('event_start_date')."<i></i></span></a>";
echo "</figure> <div class='post-excerpt'>  <span class='read-more'><i class='icon-read-more'></i>lEER</span> </div></div> </article>";






wp_reset_query();

            }
            exit;
}
add_action('wp_ajax_nopriv_more_post_ajax', 'more_post_ajax');
add_action('wp_ajax_more_post_ajax', 'more_post_ajax');


add_action( 'wp_footer', 'mycustom_wp_footer' );

function addSlick(){
	?>
	<script src="https://old.colombia.co/wp-content/themes/colombia2016/js/jquery-2.2.0.min.js" type="text/javascript"></script>	 
	<script type="text/javascript" src="//cdn.jsdelivr.net/npm/[email protected]/slick/slick.min.js"></script>

	<link rel="stylesheet" type="text/css" href="https://kenwheeler.github.io/slick/slick/slick.css"/>
	<link rel="stylesheet" type="text/css" href="https://kenwheeler.github.io/slick/slick/slick-theme.css"/>
	<script type="text/javascript">
    $(document).on('ready', function() {
      $(".vertical-center-4").slick({
        dots: true,
        vertical: true,
        centerMode: true,
        slidesToShow: 4,
        slidesToScroll: 2
      });
      $(".vertical-center-3").slick({
        dots: true,
        vertical: true,
        centerMode: true,
        slidesToShow: 3,
        slidesToScroll: 3
      });
      $(".vertical-center-2").slick({
        dots: true,
        vertical: true,
        centerMode: true,
        slidesToShow: 2,
        slidesToScroll: 2
      });
      $(".vertical-center").slick({
        dots: true,
        vertical: true,
        centerMode: true,
      });
      $(".vertical").slick({
        dots: true,
        vertical: true,
        slidesToShow: 3,
        slidesToScroll: 3
      });
      $(".regular").slick({
        dots: true,
        infinite: true,
        slidesToShow: 4,
        slidesToScroll: 4
      });
	  $(".mobile-post").slick({
        dots: true,
        infinite: true,
        slidesToShow: 1,
        slidesToScroll: 1
      });
      $(".center").slick({
        dots: true,
        infinite: true,
        centerMode: true,
        slidesToShow: 5,
        slidesToScroll: 3
      });
      $(".variable").slick({
        dots: true,
        infinite: true,
        variableWidth: true
      });
      $(".lazy").slick({
        lazyLoad: 'ondemand', // ondemand progressive anticipated
        infinite: true
      });
    });
</script>
	<?php
}

add_action ('wp_head', 'addSlick');
// Deshabilitar la notificación de actualización de plugins
add_filter( 'site_transient_update_plugins', 'dcms_disable_plugin_update' );
function dcms_disable_plugin_update( $value ) {
	if ( isset($value) && is_object($value) ) {
		// Desactivamos las notificaciones del plugin1
		if ( isset( $value->response['ai-related-posts/index.php'] ) ) {
			unset( $value->response['ai-related-posts/index.php'] );
		}
	}
	return $value;
}

function create_city_taxonomy() {
    register_taxonomy(
        'city',
        'post',
        array(
            'label' => __( 'Ciudades' ),
            'rewrite' => array( 'slug' => 'city' ),
            'hierarchical' => true,
        )
    );
}
add_action( 'init', 'create_city_taxonomy' );

function create_region_taxonomy() {
    register_taxonomy(
        'region',
        'post',
        array(
            'label' => __( 'Regiones' ),
            'rewrite' => array( 'slug' => 'region' ),
            'hierarchical' => true,
        )
    );
}
add_action( 'init', 'create_region_taxonomy' );

function megamenu_add_settings_page() {
  add_options_page( 'Config Megamenu Url', 'Megamenu Url', 'manage_options', 'megamenu_slug', 'megamenu_render_plugin_settings_page' );
}

function megamenu_render_plugin_settings_page() {
  ?>
  <h2>Megamenu Settings</h2>
  <form action="options.php" method="post">
    <?php
    settings_fields( 'megamenu_plugin_options' );
    do_settings_sections( 'megamenu_plugin' ); ?>
    <input name="submit" class="button button-primary" type="submit" value="<?php esc_attr_e( 'Save' ); ?>" />
  </form>
  <?php
}

add_action( 'admin_menu', 'megamenu_add_settings_page' );

function dbi_register_settings() {
  register_setting( 'megamenu_plugin_options', 'megamenu_plugin_options' );
  add_settings_section( 'api_settings', 'Megamenu Settings', 'megamenu_plugin_section_text', 'megamenu_plugin' );
  add_settings_field( 'megamenu_plugin_setting_url_es', 'Url es', 'megamenu_plugin_setting_url_es', 'megamenu_plugin', 'api_settings' );
  add_settings_field( 'megamenu_plugin_setting_url_en', 'Url en', 'megamenu_plugin_setting_url_en', 'megamenu_plugin', 'api_settings' );
}
add_action( 'admin_init', 'dbi_register_settings' );

function megamenu_plugin_options_validate( $input ) {
  $newinput['url'] = trim( $input['url'] );
  if ( ! preg_match( '/^[a-z0-9]{32}$/i', $newinput['api_key'] ) ) {
    $newinput['url'] = '';
  }

  return $newinput;
}

function megamenu_plugin_section_text() {
  echo '<p>Here you can set all the options for using Iframe</p>';
}

function megamenu_plugin_setting_url_es() {
  $options = get_option( 'megamenu_plugin_options' );
  echo "<input id='megamenu_plugin_setting_url_es' name='megamenu_plugin_options[url_es]' type='text' value='" . esc_attr( $options['url_es'] ) . "' />";
}

function megamenu_plugin_setting_url_en() {
  $options = get_option( 'megamenu_plugin_options' );
  echo "<input id='megamenu_plugin_setting_url_en' name='megamenu_plugin_options[url_en]' type='text' value='" . esc_attr( $options['url_en'] ) . "' />";
}

/* Site dependencies loading. */

/* Controllers. */
require get_stylesheet_directory() . '/inc/controllers/aliados.php';

new Colombia\Controllers\AliadosController();