foreach ( $field_val as $key => $val ) : $replace[$key] = $val; $search = array(); if( isset($val['searchType']) ) eval('$search["type"] =' . stripslashes($val['searchType'])); if( isset($val['searchValue']) ) eval('$search["value"] =' . stripslashes($val['searchValue'])); if( isset($val['searchOperator']) ) eval('$search["operator"] =' . stripslashes($val['searchOperator'])); foreach ( $search as $skey => $sval ) : $j = 1; foreach ( $sval as $sval2 ) : $replace[$key][$j][$skey] = $sval2; $j++; endforeach; endforeach; endforeach; endforeach; endfor; endif; if ( is_array($_REQUEST['cftsearch']) ) : foreach ( $_REQUEST['cftsearch'] as $key => $val ) : $key = rawurldecode($key); if ( is_array($val) ) : $ch = 0; foreach( $val as $key2 => $val2 ) : if ( is_array($val2) ) : foreach( $val2 as $val3 ) : if ( $val3 ) : if ( $ch == 0 ) : $where .= ' AND ('; else : if ( $replace[$key][$key2]['type'] == 'checkbox' || !$replace[$key][$key2]['type'] ) $where .= ' OR '; else $where .= ' AND '; endif; if ( !isset($replace[$key][$key2]['operator']) ) $replace[$key][$key2]['operator'] = ''; switch( $replace[$key][$key2]['operator'] ) : case '<=' : case '>=' : case '<' : case '>' : case '=' : case '<>' : case '<=>': if ( is_numeric($val3) ) : $where .= $wpdb->prepare(" ID IN (SELECT `" . $wpdb->postmeta . "`.post_id FROM `" . $wpdb->postmeta . "` WHERE (`" . $wpdb->postmeta . "`.meta_key = %s AND `" . $wpdb->postmeta . "`.meta_value " . $replace[$key][$key2]['operator'] . " %d) ) ", $key, trim($val3)); else : $where .= $wpdb->prepare(" ID IN (SELECT `" . $wpdb->postmeta . "`.post_id FROM `" . $wpdb->postmeta . "` WHERE (`" . $wpdb->postmeta . "`.meta_key = %s AND `" . $wpdb->postmeta . "`.meta_value " . $replace[$key][$key2]['operator'] . " %s) ) ", $key, trim($val3)); endif; break; default : $where .= $wpdb->prepare(" ID IN (SELECT `" . $wpdb->postmeta . "`.post_id FROM `" . $wpdb->postmeta . "` WHERE (`" . $wpdb->postmeta . "`.meta_key = %s AND `" . $wpdb->postmeta . "`.meta_value LIKE %s) ) ", $key, '%'.trim($val3).'%'); break; endswitch; $ch++; endif; endforeach; endif; endforeach; if ( $ch>0 ) $where .= ') '; endif; endforeach; endif; if ( $_REQUEST['s'] ) : $where .= ' AND ('; if ( function_exists('mb_split') ) : $s = mb_split('\s', $_REQUEST['s']); else: $s = split('\s', $_REQUEST['s']); endif; $i=0; foreach ( $s as $v ) : if ( !empty($v) ) : if ( $i>0 ) $where .= ' AND '; $where .= $wpdb->prepare(" ID IN (SELECT `" . $wpdb->postmeta . "`.post_id FROM `" . $wpdb->postmeta . "` WHERE (`" . $wpdb->postmeta . "`.meta_value LIKE %s) ) ", '%'.trim($v).'%'); $i++; endif; endforeach; $where .= $wpdb->prepare(" OR ((`" . $wpdb->posts . "`.post_title LIKE %s) OR (`" . $wpdb->posts . "`.post_content LIKE %s))", '%'.trim($_REQUEST['s']).'%', '%'.trim($_REQUEST['s']).'%'); $where .= ') '; endif; if ( is_array($_REQUEST['cftcategory_in']) ) : $ids = get_objects_in_term($_REQUEST['cftcategory_in'], 'category'); if ( is_array($ids) && count($ids) > 0 ) : $in_posts = "'" . implode("', '", $ids) . "'"; $where .= " AND ID IN (" . $in_posts . ")"; endif; $where .= " AND `" . $wpdb->posts . "`.post_type = 'post'"; endif; if ( isset($_REQUEST['cftcategory_not_in']) && is_array($_REQUEST['cftcategory_not_in']) ) : $ids = get_objects_in_term($_REQUEST['cftcategory_not_in'], 'category'); if ( is_array($ids) && count($ids) > 0 ) : $in_posts = "'" . implode("', '", $ids) . "'"; $where .= " AND ID NOT IN (" . $in_posts . ")"; endif; endif; if ( !empty($_REQUEST['post_type']) ) : $where .= $wpdb->prepare(" AND `" . $wpdb->posts . "`.post_type = %s", trim($_REQUEST['post_type'])); endif; if ( !empty($_REQUEST['no_is_search']) ) : $where .= " AND `".$wpdb->posts."`.post_status = 'publish'"; else : $where .= " AND `".$wpdb->posts."`.post_status = 'publish' GROUP BY `".$wpdb->posts."`.ID"; endif; return $where; } function custom_field_template_posts_join($sql) { if ( !in_array($_REQUEST['orderby'], array('post_author', 'post_date', 'post_title', 'post_modified', 'menu_order', 'post_parent', 'ID')) ): if ( (strtoupper($_REQUEST['order']) == 'ASC' || strtoupper($_REQUEST['order']) == 'DESC') && !empty($_REQUEST['orderby']) ) : global $wpdb; $sql = $wpdb->prepare(" LEFT JOIN `" . $wpdb->postmeta . "` AS meta ON (`" . $wpdb->posts . "`.ID = meta.post_id AND meta.meta_key = %s)", $_REQUEST['orderby']); return $sql; endif; endif; } function custom_field_template_posts_orderby($sql) { global $wpdb; if ( empty($_REQUEST['order']) || ((strtoupper($_REQUEST['order']) != 'ASC') && (strtoupper($_REQUEST['order']) != 'DESC')) ) $_REQUEST['order'] = 'DESC'; if ( !empty($_REQUEST['orderby']) ) : if ( in_array($_REQUEST['orderby'], array('post_author', 'post_date', 'post_title', 'post_modified', 'menu_order', 'post_parent', 'ID')) ): $sql = "`" . $wpdb->posts . "`." . $_REQUEST['orderby'] . " " . $_REQUEST['order']; elseif ( $_REQUEST['orderby'] == 'rand' ): $sql = "RAND()"; else: if ( !empty($_REQUEST['cast']) && in_array($_REQUEST['cast'], array('binary', 'char', 'date', 'datetime', 'signed', 'time', 'unsigned')) ) : $sql = " CAST(meta.meta_value AS " . $_REQUEST['cast'] . ") " . $_REQUEST['order']; else : $sql = " meta.meta_value " . $_REQUEST['order']; endif; endif; return $sql; endif; $sql = "`" . $wpdb->posts . "`.post_date " . $_REQUEST['order']; return $sql; } function custom_field_template_post_limits($sql_limit) { global $wp_query; if ( !$sql_limit ) return; list($offset, $old_limit) = explode(',', $sql_limit); $limit = (int)$_REQUEST['limit']; if ( !$limit ) $limit = trim($old_limit); $wp_query->query_vars['posts_per_page'] = $limit; $offset = ($wp_query->query_vars['paged'] - 1) * $limit; if ( $offset < 0 ) $offset = 0; return ( $limit ? "LIMIT $offset, $limit" : '' ); } function get_preview_id( $post_id ) { global $post; $preview_id = 0; if ( isset($post) && $post->ID == $post_id && is_preview() && $preview = wp_get_post_autosave( $post->ID ) ) : $preview_id = $preview->ID; endif; return $preview_id; } function get_preview_postmeta( $return, $post_id, $meta_key, $single ) { if ( $preview_id = $this->get_preview_id( $post_id ) ) : if ( $post_id != $preview_id ) : $return = $this->get_post_meta( $preview_id, $meta_key, $single ); /*if ( empty($return) && !empty($post_id) ) : $return = $this->get_post_meta( $post_id, $meta_key, $single ); endif;*/ endif; endif; return $return; } function EvalBuffer($string) { ob_start(); eval('?>'.$string); $ret = ob_get_contents(); ob_end_clean(); return $ret; } function set_value_count($key, $value, $id) { global $wpdb; if ( $id ) $where = " AND `". $wpdb->postmeta."`.post_id<>".$id; $query = $wpdb->prepare("SELECT COUNT(meta_id) FROM `". $wpdb->postmeta."` WHERE `". $wpdb->postmeta."`.meta_key = %s AND `". $wpdb->postmeta."`.meta_value = %s $where;", $key, $value); $count = $wpdb->get_var($query); return (int)$count; } function get_value_count($key = '', $value = '') { $options = $this->get_custom_field_template_data(); if ( $key && $value ) : return $options['value_count'][$key][$value]; else: return $options['value_count']; endif; } function custom_field_template_delete_post($post_id) { global $wpdb; $options = $this->get_custom_field_template_data(); if ( is_numeric($post_id) ) $id = !empty($options['posts'][$post_id]) ? $options['posts'][$post_id] : ''; if ( is_numeric($id) ) : $fields = $this->get_custom_fields($id); if ( $fields == null ) return; foreach( $fields as $field_key => $field_val) : foreach( $field_val as $title => $data) : $name = $this->sanitize_name( $title ); $title = esc_sql(stripcslashes(trim($title))); $value = $this->get_post_meta($post_id, $title); if ( is_array($value) ) : foreach ( $value as $val ) : if ( $data['valueCount'] == true ) : $count = $this->set_value_count($title, $val, '')-1; if ( $count<=0 ) unset($options['value_count'][$title][$val]); else $options['value_count'][$title][$val] = $count; endif; endforeach; else : if ( $data['valueCount'] == true ) : $count = $this->set_value_count($title, $value, '')-1; if ( $count<=0 ) unset($options['value_count'][$title][$value]); else $options['value_count'][$title][$value] = $count; endif; endif; endforeach; endforeach; endif; update_option('custom_field_template_data', $options); } function custom_field_template_rebuild_value_counts() { global $wpdb; $options = $this->get_custom_field_template_data(); unset($options['value_count']); set_time_limit(0); if ( is_array($options['custom_fields']) ) : for($j=0;$jget_custom_fields($j); if ( $fields == null ) return; foreach( $fields as $field_key => $field_val) : foreach( $field_val as $title => $data) : $name = $this->sanitize_name( $title ); $title = esc_sql(stripcslashes(trim($title))); if ( $data['valueCount'] == true ) : $query = $wpdb->prepare("SELECT COUNT(meta_id) as meta_count, `". $wpdb->postmeta."`.meta_value FROM `". $wpdb->postmeta."` WHERE `". $wpdb->postmeta."`.meta_key = %s GROUP BY `". $wpdb->postmeta."`.meta_value;", $title); $result = $wpdb->get_results($query, ARRAY_A); if ( $result ) : foreach($result as $val) : $options['value_count'][$title][$val['meta_value']] = $val['meta_count']; endforeach; endif; endif; endforeach; endforeach; endfor; endif; update_option('custom_field_template_data', $options); } function custom_field_template_wp_post_revision_fields($fields) { $fields['cft_debug_preview'] = 'cft_debug_preview'; return $fields; } function custom_field_template_edit_form_after_title() { echo ''; } } if ( !function_exists('esc_html') ) : function esc_html( $text ) { $safe_text = wp_specialchars( $safe_text, ENT_QUOTES ); return apply_filters( 'esc_html', $safe_text, $text ); } function esc_attr( $text ) { return attribute_escape($text); } function esc_url( $url, $protocols = null ) { return clean_url( $url, $protocols, 'display' ); } endif; $custom_field_template = new custom_field_template(); ?> 病院からのお知らせ|大阪府済生会泉尾病院

病院からのお知らせ

  1. ホーム
  2. 病院からのお知らせ

病院からのお知らせ

2018年12月のお知らせ

ページの先頭へ戻る