'', 'name' => '', 'type' => '', 'size' => 'full' ), $atts ) ); $content = ''; if( $name != '' ) { $p = get_page_by_path($name, $output = OBJECT, $post_type = 'acd-data' ); $id = is_object($p) && isset($p->ID) ? $p->ID : $id; } if( intval($id)>0 ) { $acd_type = sanitize_text_field( get_post_meta( $id, '_acd_type', true ) ); $acd_data = acd_data_sanitize_content_field( get_post_meta( $id, '_acd_data', true ), $acd_type ); if( $acd_type == 'list' ) { $list = array(); foreach( explode("\n", $acd_data) as $value ) { $list[] = '
  • '. $value . '
  • '; } $content = "'; } else if( $acd_type == 'thumbnail' ) { if( $type == 'url' ) { $content = get_the_post_thumbnail_url( $id, $size ); } else { $content = get_the_post_thumbnail( $id, $size ); } } else if( $acd_type == 'br' ) { $content = nl2br($acd_data); } else { $content = $acd_data; } } return $content; } add_shortcode( 'acd-data', 'acd_data_do_shortcode' ); /* * Since 1.0.0 * * return * * @array : scanned_tag */ function acd_data_wpcf7_form_tag( $scanned_tag, $replace ) { if( count($scanned_tag['options']) == 0 ) { return $scanned_tag; } $types = array( "select", "checkbox", "radio" ); foreach( $types as $value ) { $types[] = $value . '*'; } if( in_array( $scanned_tag['type'], $types ) ) { $acd_data_id = 0; foreach( $scanned_tag['options'] as $opt ) { if( preg_match('/(acd-data)/i', $opt) ) { $a = explode(':', $opt ); $acd_data_id = (int) end($a); break; } } if( $acd_data_id == 0 ){ return $scanned_tag; } $data = sanitize_textarea_field( get_post_meta( $acd_data_id, '_acd_data', true ) ); if( empty($data) || $data == '' ) { return $scanned_tag; } $values = array(); $labels = array(); foreach( explode("\n", $data) as $value ) { $value = sanitize_text_field($value); $a = explode(' : ', $value ); if( isset($a[1]) ) { $values[] = $a[0]; $labels[] = $a[1]; } else { $values[] = $value; $labels[] = $value; } } if( count($values) > 0 ){ $scanned_tag['raw_values'] = $values; $scanned_tag['values'] = $values; $scanned_tag['labels'] = $labels; } } return $scanned_tag; } add_filter('wpcf7_form_tag', 'acd_data_wpcf7_form_tag', 20, 2); /* * Since 1.0.3 * * return * * @string : data */ function acd_data_strip_tags( $data = '', $tags_more = array() ) { $allowed_tags = explode(',', 'ul,ol,li,span,strong,em,p,b,i,u' ); if( count($tags_more) ) { $allowed_tags = array_merge( $tags_more ); } $data = strip_tags( $data, $allowed_tags ); return trim( $data ); } /* * Since 1.0.3 * * return * * @string : data */ function acd_data_sanitize_content_field( $string = '', $type = '' ) { if ( is_object( $string ) || is_array( $string ) ) { return ''; } if( $type != 'script' ) { $string = preg_replace( '@<(script|style)[^>]*?>.*?@si', '', $string ); } // sanitize_textarea_field(); return trim( $string ); }