您好,我正在尝试一些wordpress的东西,但是一旦我激活了以下代码的插件,整个服务器就会变慢。但是,当我使用未激活此插件的相同API时,一切都很快。
你们能帮助我,告诉我哪里出了问题,也许告诉我如何做得更好。
我尝试1.添加自定义帖子类型和2.现在可以使用简码接收有关配置文件的外部数据库信息。
<?php
/*
Plugin Name: Virtueel Assistent CP
Description: Custom Post plug-in voor virtuele assistenten
Author: Rico Otto - 2lemon
*/
// Our custom post type function
function create_virtueelassistent() {
register_post_type( 'virtueelassistent',
// CPT Options
array(
'labels' => array(
'name' => __( 'Virtueel Assistent' ),
'singular_name' => __( 'VirtueelAssistent' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'virtueelassistent'),
)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_virtueelassistent' );
/*
* Creating a function to create our CPT
*/
function virtueel_assistent_cp() {
// Set UI labels for Custom Post Type
$labels = array(
'name' => _x( 'Virtueel Assistent', 'Post Type General Name' ),
'singular_name' => _x( 'Virtueel Assistent', 'Post Type Singular Name' ),
'menu_name' => __( 'Virtueel Assistenten' ),
'parent_item_colon' => __( 'Parent VA' ),
'all_items' => __( 'Alle VAs' ),
'view_item' => __( 'Bekijk VA' ),
'add_new_item' => __( 'Voeg Nieuwe VA toe' ),
'add_new' => __( 'Nieuwe VA' ),
'edit_item' => __( 'Wijzig VA' ),
'update_item' => __( 'Update VA' ),
'search_items' => __( 'Zoek VA' ),
'not_found' => __( 'Niet Gevonden' ),
'not_found_in_trash' => __( 'Niet Gevonden in Prullenbak' ),
);
// Set other options for Custom Post Type
$args = array(
'label' => __( 'virtueelassistent' ),
'description' => __( 'Virtueel assistent profiel' ),
'labels' => $labels,
// Features this CPT supports in Post Editor
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
// You can associate this CPT with a taxonomy or custom taxonomy.
'taxonomies' => array( 'skills' ),
/* A hierarchical CPT is like Pages and can have
* Parent and child items. A non-hierarchical CPT
* is like Posts.
*/
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
// Registering your Custom Post Type
register_post_type( 'virtueelassistent', $args );
}
/* Hook into the 'init' action so that the function
* Containing our post type registration is not
* unnecessarily executed.
*/
add_action( 'init', 'virtueel_assistent_cp', 0 );
function do_getVa(){
global $wpdb;
$post = get_post();
$VaID = $post->ID;
$custom_url = '31.186.173.38:3032/profile/' . $VaID;
$curl = curl_init($custom_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$answer = curl_exec($curl);
curl_close($curl);
$res1 = json_decode($answer);
$profile_image = 'http://vabusinessacademy.2citroenen.nl/wp-content/uploads/2017/05/Liesbeth-de-Korte.jpeg';
$content = '';
$content = $content . '<div class="entry-content" vocab="http://schema.org/" typeof="Product">
<div class="et_pb_section et_pb_section_0 et_section_regular">
<div class="et_pb_row et_pb_row_0">
<div class="et_pb_column et_pb_column_4_4 et_pb_column_0 et_pb_css_mix_blend_mode_passthrough et-last-child">
<div class="et_pb_module et_pb_team_member et_pb_team_member_0 et_pb_bg_layout_light clearfix">
<div class="et_pb_team_member_image et-waypoint et_pb_animation_off">
<img property="image" src="' . $res1->profile_image . '" alt="Virtueel assistent '. $res1->name .'">
</div>
<div class="et_pb_team_member_description">
<span property="brand" style="display:none">VA Business Academy</span>
<h3 class="et_pb_module_header" property="name">' . $res1->name . '</h3>
<p property="description">' . $res1->bio . '</p>' .
'<span property="mpn" style="display: none;">' . $VaID . '</span>' .
'<div property="aggregateRating" typeof="AggregateRating" class="average-rating">
<span property="ratingValue">'. $res1->average_rating .'</span> score, gebaseerd op <span property="reviewCount">'.$res1->rating_count.'</span> reviews
<span property="bestRating" style="display:none;">' .$res1->rating_best.'</span>
<span property="worstRating" style="display:none;">' .$res1->rating_worst.'</span><div>' ;
$content = $content . '</div> <!-- .et_pb_team_member_description -->
<div class="average-rating">' . $res1->average_rating . '</div>';
if(property_exists ($res1, 'facebook_link')){$facebook_link = $res1->facebook_link;}
if(property_exists ($res1, 'twitter_link')){$twitter_link = $res1->twitter_link;}
if(property_exists ($res1, 'google_link')){$google_link = $res1->google_link;}
if(property_exists ($res1, 'linkedin_link')){$linkedin_link = $res1->linkedin_link;}
$content = $content . ' <ul class="et_pb_member_social_links">';
if(property_exists ($res1, 'facebook_link')){
$content = $content . '<li><a href="' . $facebook_link . '" class="et_pb_font_icon et_pb_facebook_icon"><span>Facebook</span></a></li>';
}
if(property_exists ($res1, 'twitter_link')){
$content = $content . '<li><a href="' . $twitter_link . '" class="et_pb_font_icon et_pb_twitter_icon"><span>Twitter</span></a></li>';
}
if(property_exists ($res1, 'google_link')){
$content = $content . '<li><a href="' . $google_link . '" class="et_pb_font_icon et_pb_google_icon"><span>Google+</span></a></li>';
}
if(property_exists ($res1, 'linkedin_link')){
$content = $content . '<li><a href="' . $linkedin_link . '" class="et_pb_font_icon et_pb_linkedin_icon"><span>LinkedIn</span></a></li>';
}
$content = $content . '</ul>
</div> <!-- .et_pb_team_member -->
<div class="skill-set">';
if($res1->business_mngmnt_spprt) {$content = $content . '<h4>Business Management Support</h4>';}
$content = $content . '<ul>' ;
foreach($res1->business_mngmnt_spprt as $skill)
{
$content = $content . '<li>' . $skill . '</li>';
}
$content = $content . '</ul>';
if($res1->social_media) {$content = $content . '<h4>Social Media</h4>';}
foreach($res1->social_media as $skill)
$content = $content . '<ul>' ;
{
$content = $content . '<li>' . $skill . '</li>';
}
$content = $content . '</ul>';
if($res1->marketing) { $content = $content . '<h4>Marketing</h4>';}
$content = $content . '<ul>' ;
foreach($res1->marketing as $skill)
{
$content = $content . '<li>' . $skill . '</li>';
}
$content = $content . '</ul>';
if($res1->communication) {$content = $content . '<h4>Communication</h4>';}
$content = $content . '<ul>' ;
foreach($res1->communication as $skill)
{
$content = $content . '<li>' . $skill . '</li>';
}
$content = $content . '</ul>';
if($res1->sales) {$content = $content . '<h4>Sales</h4>';}
$content = $content . '<ul>' ;
foreach($res1->sales as $skill)
{
$content = $content . '<li>' . $skill . '</li>';
}
$content = $content . '</ul>';
if($res1->financial) {$content = $content . '<h4>Financial</h4>';}
$content = $content . '<ul>' ;
foreach($res1->financial as $skill)
{
$content = $content . '<li>' . $skill . '</li>';
}
$content = $content . '</ul>';
if($res1->recruitment) {$content = $content . '<h4>Recruitment</h4>';}
$content = $content . '<ul>' ;
foreach($res1->recruitment as $skill)
{
$content = $content . '<li>' . $skill . '</li>';
}
$content = $content . '</ul>';
if($res1->human_resource_mngmnt) {$content = $content . '<h4>Human Resource Management</h4>';}
$content = $content . '<ul>' ;
foreach($res1->human_resource_mngmnt as $skill)
{
$content = $content . '<li>' . $skill . '</li>';
}
$content = $content . '</ul>';
if($res1->tooling) {$content = $content . '<h4>Tooling</h4>';}
$content = $content . '<ul>' ;
foreach($res1->tooling as $skill)
{
$content = $content . '<li>' . $skill . '</li>';
}
$content = $content . '</ul>';
foreach($res1->reviews as $review)
{
$content = $content . '</div>
</div>
<h2 class="review-section-title">Over VA '. $res1->name .'</h2>
<div class="et_pb_module et_pb_testimonial et_pb_testimonial_0 clearfix et_pb_bg_layout_light et_pb_text_align_left" style="background-color: #f5f5f5;" property="review" typeof="Review">
<div class="et_pb_testimonial_portrait" style="background-image: url(http://vabusinessacademy.2citroenen.nl/wp-content/uploads/2018/04/Schermafbeelding-2018-04-27-om-00.17.58.png);">
</div>
<div class="et_pb_testimonial_description">
<div class="et_pb_testimonial_description_inner">
<div property="reviewRating" typeof="Rating">
<span property="ratingValue">' .$review->rating.'<span>
<span property="bestRating" style="display:none;">' .$review->rating_best.'</span>
<span property="worstRating" style="display:none;">' .$review->rating_worst.'</span>
</div>
<meta property="datePublished" content='.$review->Created_date.'><span style="display:none;">'.$review->Created_date.'</span>
<p property="reviewBody">' . $review->text . '</p>
<span property="publisher" typeof="Organization">
<meta property="name" content='.$review->name.'>
</span>
<span style="display: none;" property="name">'. $res1->name . ' review, door: ' . $review->name.'</span>
<strong class="et_pb_testimonial_author" property="author" typeof="Person"><span property="name"' . $review->name . '</span></strong>
<p class="et_pb_testimonial_meta">CEO, <a href="' . $review->website . '">' . $review->website . '</a></p>
</div> <!-- .et_pb_testimonial_description_inner -->
</div> <!-- .et_pb_testimonial_description -->
</div> <!-- .et_pb_testimonial -->';
}
$content = $content . '</div> <!-- .et_pb_column -->
</div> <!-- .et_pb_row -->
</div> <!-- .et_pb_section -->
</div> <!-- .entry-content --> </div> </div>';
return $content;
}
add_shortcode('add_va_profile_page','do_getVa');
?>