add_action( 'wp', 'generic_content' );
function generic_content() {
global $wp_query;
if ( $wp_query->is_404 ) {
status_header( 200 );
$post_title = 'change me';
$post_content = 'change me';
$post = new stdClass();
$post->ID = - 1;
$post->post_content = $post_content;
$post->post_status = 'publish';
$post->post_title = $post_title;
$post->post_type = 'generic';
$post->post_name = $post_title;
$post->comment_status = 'closed';
$post->ping_status = 'closed';
$post->post_password = '';
$wp_query->found_posts = 1;
$wp_query->is_404 = false;
$wp_query->is_posts_page = 1;
$wp_query->is_single = 1;
$wp_query->is_singular = true;
$wp_query->max_num_pages = 1;
$wp_query->page = false;
$wp_query->post = $post;
$wp_query->post_count = 1;
$wp_query->posts = array( $post );
$wp_query->queried_object = $post;
}
}
$rating1 = get_post_meta( get_the_ID(), '_rating1', true );
$rating2 = get_post_meta( get_the_ID(), '_rating2', true );
$rating3 = get_post_meta( get_the_ID(), '_rating3', true );
$rating4 = get_post_meta( get_the_ID(), '_rating4', true );
$rating5 = get_post_meta( get_the_ID(), '_rating5', true );
$rating_amount = $rating1 + $rating2 + $rating3 + $rating4 + $rating5;
$user_rating = ( 1 * $rating1 + 2 * $rating2 + 3 * $rating3 + 4 * $rating4 + 5 * $rating5 ) / $rating_amount;
require_once ABSPATH . 'wp-admin/includes/template.php';
wp_star_rating( [
'rating' => $user_rating,
'type' => 'rating',
'number' => 0,
] );
curl --user root:1234 -X DELETE http://pt.dev/wp-json/wp/v2/pages/2
add_action('rest_api_init', function () {
remove_filter('rest_pre_serve_request', 'rest_send_cors_headers');
add_filter('rest_pre_serve_request', function ($value) {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE');
header('Access-Control-Allow-Credentials: true');
return $value;
});
}, 15);
$class = '';
$tag_color = get_term_meta( $id, 'color', true );
switch ( $tag_color ) {
case 'red':
$class = 'red'
break;
case 'blue':
$class = 'blue'
break;
}
<a href="tag_link" class="<?php echo $class; ?>">tag name</a>
current_user_can( 'manage_options' )
{
_id: "bbca5d6a-2156-41c4-89da-0329e8c99a4f", // Meteor.userId()
username: "cool_kid_13", // unique name
emails: [
// each email address can only belong to one user.
{ address: "cool@example.com", verified: true },
{ address: "another@different.com", verified: false }
],
createdAt: Wed Aug 21 2013 15:16:52 GMT-0700 (PDT),
profile: {
// The profile is writable by the user by default.
name: "Joe Schmoe"
},
services: {
facebook: {
id: "709050", // facebook id
accessToken: "AAACCgdX7G2...AbV9AZDZD"
},
resume: {
loginTokens: [
{ token: "97e8c205-c7e4-47c9-9bea-8e2ccc0694cd",
when: 1349761684048 }
]
}
}
}
Meteor.user().profile.country
Meteor.user().profile.city
Meteor.user().location.country
Meteor.user().location.city