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/plugins/custom-newsletter/custom-newsletter.php
<?php
/**
 * Plugin Name: Custom Style Newsletter
 * Description: Activar o desactivar estilos 2021.
 * Version: 1.0
 * Author: Sebastián Vargas Developer / Web & Digital Ark
 * Author URI: https://www.webdigitalark.com
 * License: GPL v2 or later
*/
/** 
{Plugin Name} is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
any later version.
 
{Plugin Name} is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with {Plugin Name}. If not, see {URI to Plugin License}.
*/


// We need some CSS to position the paragraph.

    
define("NEWS_PLUGIN_URL", plugin_dir_url(__FILE__));

// Apply default settings on activation
register_activation_hook( __FILE__, 'import_styles' );


function import_styles() {
    // To enqueue style.css
    wp_enqueue_style( 'custom_newsletter.css', NEWS_PLUGIN_URL.'css/custom_newsletter.css', array(), null, false );

    wp_enqueue_script( 'script',NEWS_PLUGIN_URL.'js/custom.js' , array ( 'jquery' ), 1.1, true);
    /*wp_enqueue_style( 'icomoon_style.css', NEWS_PLUGIN_URL.'css/icomoon/icomoon_style.css', array(), time(), false );*/
}

add_action('wp_enqueue_scripts', 'import_styles');


if(function_exists("register_field_group"))
{
	register_field_group(array (
		'id' => 'acf_category-images-background',
		'title' => 'Category Images Background',
		'fields' => array (
			array (
				'key' => 'field_60241ae5a8dbd',
				'label' => 'Mobile',
				'name' => 'mobile',
				'type' => 'image',
				'instructions' => 'Seleccione una imagen para mobile',
				'save_format' => 'url',
				'preview_size' => 'thumbnail',
				'library' => 'all',
			),
		),
		'location' => array (
			array (
				array (
					'param' => 'post_type',
					'operator' => '==',
					'value' => 'banners',
					'order_no' => 0,
					'group_no' => 0,
				),
			),
		),
		'options' => array (
			'position' => 'normal',
			'layout' => 'default',
			'hide_on_screen' => array (
			),
		),
		'menu_order' => 5,
	));
}

function add_styles_to_banners_responsive() {

	global $wp_query;
	
	$cat = get_cat_ID(single_cat_title('', false));
	$cat_id = get_cat_ID(single_cat_title('', false));
	
	$category_check = get_category($cat_id);
	
	// Remaining template removed from example 
	
	// Acá definimos $subtitulo, $category_color y $category_image para usarlos donde sea necesario
	$images = get_option('taxonomy_image_plugin'); // get the taxonomy images array
	if (array_key_exists($cat_id, $images)) { // check if term has an image
		$category_image = wp_get_attachment_image_src($images[$cat_id], 'full'); // if it does, echo that image
	}
	$category_color = get_term_meta($cat_id, 'category_color', true);
	$category_color_rgb = array(hexdec($category_color[1] . $category_color[2]), hexdec($category_color[3] . $category_color[4]), hexdec($category_color[5] . $category_color[6]));
	$subtitulo = get_term_meta($cat_id, 'category_subtitle', true);
	?>
	<?php if (($category_image) || ($category_color)): ?>
		<style>
			<?php if($category_image): 
			// get the current taxonomy term
			$term = get_queried_object();
			// vars
			$background_mobile = get_field('image_mobile', $term);
			?>
			
			#category-header {
				background-image: url(<?php echo $category_image[0]; ?>) ;
				background-size: cover;
			}
			@media screen and (max-width: 767px){
				#category-header {
					background-image: url(<?php echo $background_mobile['url']; ?>) !important ;
					background-size: cover;
					bottom: 0;
					left: 0;
					width: 100%;
					background-repeat: no-repeat;
					background-position: center bottom;
					background-size: 100%;
				}
			}  
			<?php if($category_color): ?>
			#posts .post-categories li {
				background-color: <?php echo $category_color; ?>;
			}
	
			#posts .post-excerpt {
				background-color: rgba(<?php echo $category_color_rgb[0]; ?>,<?php echo $category_color_rgb[1]; ?>,<?php echo $category_color_rgb[2]; ?>, 0.9);
			}
	
			<?php endif; ?>
			<?php endif; ?>
		</style>
	<?php endif;
	}
add_action( 'wp_footer', 'add_styles_to_banners_responsive' );
	

//add extra fields to category edit form hook
// add_action ( 'category_edit_form_fields', function( $tag ){
//     $cat_title = get_term_meta( $tag->term_id, '_pagetitle', true ); 
// });
// add_action ( 'edited_category', function( $term_id ) {
//     if ( isset( $_POST['cat_title'] ) )
//         update_term_meta( $term_id , '_pagetitle', $_POST['cat_title'] );
// });
//add_filter('wp_nav_menu_items','add_narrativa_in_menu', 10, 2);

// function add_narrativa_in_menu( $items, $args ) {
//     if( $args->theme_location == 'primary')  {
         
//         $items .=  '
//             <li id="menu-item-45002" class=" acogedor-item menu-item menu-item-type-custom menu-item-object-custom menu-item-45002 depth-1">
//                <a href="#">El país más acogedor del mundo</a>
//                <ul class="sub-menu">
//                   <div class="sub-menu-title sub-menu-title-sm"><mark>El país más acogedor del mundo</mark></div>
//                   <li  class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-36948 depth-2"><a href="https://foreign-narrativa.pantheonsite.io/es/colombianos">Soy Colombiano</a></li>
//                   <li  class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-36949 depth-2"><a href="https://foreign-narrativa.pantheonsite.io/es/extranjeros">Soy extranjero</a></li>
                  
//                </ul>
//             </li>

//         ';
//     }
//     return $items;
// }


/*
register_activation_hook( __FILE__, 'import_DOM_elements' );

function import_DOM_elements() {
    // To enqueue custom-script.js
    wp_enqueue_script( 'custom-js',  NEWS_PLUGIN_URL.'/js/custom.js', array(), time(), true );
}

add_action('wp_enqueue_scripts', 'import_DOM_elements');
*/