HEX
Server: nginx/1.28.3
System: Linux lightweb-s1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64
User: dawonefr-98 (1071)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /home/dawonefr-98/dawonefr.lightweb.kr/public/wp-content/themes/lightweb/functions.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

// Set up theme support
function elementor_hello_theme_setup() {

	add_theme_support( 'menus' );
	add_theme_support( 'post-thumbnails' );
	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'title-tag' );
	add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
	add_theme_support( 'custom-logo', array(
		'height' => 70,
		'width' => 350,
		'flex-height' => true,
		'flex-width' => true,
	) );

	add_theme_support( 'woocommerce' );

	load_theme_textdomain( 'elementor-hello-theme', get_template_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'elementor_hello_theme_setup' );


// Register Elementor Locations
function elementor_hello_theme_register_elementor_locations( $elementor_theme_manager ) {
	$elementor_theme_manager->register_all_core_location();
};
add_action( 'elementor/theme/register_locations', 'elementor_hello_theme_register_elementor_locations' );

// Remove WP Embed
function elementor_hello_theme_deregister_scripts() {
	wp_deregister_script( 'wp-embed' );
}
add_action( 'wp_footer', 'elementor_hello_theme_deregister_scripts' );

// Remove WP Emoji
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );


//custom mime types csv허용
function custom_upload_mimes($mimes = array()) {

	// Add a key and value for the CSV file type
	$mimes['csv'] = "text/csv";

	return $mimes;
}
add_filter('upload_mimes', 'custom_upload_mimes');

//텍스트 수정
add_filter('wpmem_register_form_args', 'my_wpmem_register_form_args', 10, 2);
function my_wpmem_register_form_args($args, $tag){
	$args['submit_register'] = '회원가입하기';
	return $args;
}

//영문 월 가져오는 숏코드 (번역때문에 기존코드사용 불가능)
add_shortcode('getengmonth', 'getMonth_eng');
function getMonth_eng(){
     $month = time();
  return date('F', $month);
}

//메타필드 가져오는 숏코드
add_shortcode('field', 'shortcode_field');
function shortcode_field($atts){
     extract(shortcode_atts(array(
                  'post_id' => NULL,
               ), $atts));
  if(!isset($atts[0])) return;
       $field = esc_attr($atts[0]);
       global $post;
       $post_id = (NULL === $post_id) ? $post->ID : $post_id;
       return get_post_meta($post_id, $field, true);
}

//툴셋 필드 가져오는 숏코드 생성. -> 시간나면 위에걸로 변경할것
function get_toolset_customfield($atts, $content = null) {
	extract(shortcode_atts(array(
	'post_id' => 1,
	'field_name' => 'wpcf-lecture_schedule',
	'separator' => "\n"
	), $atts));

	$data = get_post_meta($atts['post_id'], $atts['field_name'], true);
	$data = explode("\n",$data);
	$output = array();
	foreach($data as $val){
		$output[] = json_encode(array(
			"label" => $val,
			"value" => $val
		));
	}
	return join(",",$output);
}
add_shortcode('echo-cpt-json', 'get_toolset_customfield');


//기본라이브러리 호출하기
function lightweb_web_append_theme_scripts_styles() {
	//bootstrap
	wp_enqueue_style( 'bootstrap_grid_style', get_template_directory_uri() . '/assets/bootstrap-grid.min.css',false,'1.1','all');
	//global
	wp_enqueue_style( 'lightweb_global', get_template_directory_uri() . '/assets/lightweb_global.css',false,'1.2','all');
	//fullpage
	wp_enqueue_style( 'fullpage_style', get_template_directory_uri() . '/assets/fullpagejs/fullpage.min.css',false,'1.1','all');
	wp_enqueue_script( 'fullpage_script', get_template_directory_uri() . '/assets/fullpagejs/fullpage.min.js',array ( 'jquery' ),'1.1',false);
	wp_enqueue_script( 'fullpage_easing', get_template_directory_uri() . '/assets/fullpagejs/easings.min.js',array ( 'jquery' ),'1.1',false);
	wp_enqueue_script( 'fullpage_scrolloverflow', get_template_directory_uri() . '/assets/fullpagejs/scrolloverflow.min.js',array ( 'jquery' ),'1.1',false);
}

//메뉴위치 추가
function register_my_menus() {
	register_nav_menus(
		array(
		 'main-menu' => '메인 메뉴',
		 'utility-menu' => '유틸리티 메뉴',
		 'footer-menu' => '하단 메뉴'
		 )
	);
}
add_action( 'init', 'register_my_menus' );

add_action( 'wp_enqueue_scripts', 'lightweb_web_append_theme_scripts_styles', 99);

//single post parent archive active add
function custom_active_item_classes($classes = array(), $menu_item = false){            
        global $post;
        $classes[] = ($menu_item->url == get_post_type_archive_link($post->post_type)) ? 'current-menu-item active' : '';
        return $classes;
    }
add_filter( 'nav_menu_css_class', 'custom_active_item_classes', 10, 2 );

function add_class_to_all_menu_anchors( $atts ) {
global $post;

$atts['class'] = ($atts['href'] == get_post_type_archive_link($post->post_type)) ? 'elementor-item-active' : ''; 
    return $atts;
}
add_filter( 'nav_menu_link_attributes', 'add_class_to_all_menu_anchors', 10 );

// 타임스템프 함수 추가
function cf_date_today_func($atts) {
    $timestamp = strtotime('now');
    return $timestamp;
}
add_shortcode('cf_date_today', 'cf_date_today_func');