===============START OF THE SCRIPT================
// Make sure this opening tag is only present ONCE at the very top if adding to an existing file. If using Snippets plugin, you might not need it.
//php script for tasty automation & SEO meta API access
add_filter( 'https_local_ssl_verify', '__return_true' ); // May be needed in some local/dev environments, consider removing on live if SSL is standard.
// --- Request Timeouts ---
add_action('http_api_curl', 'sar_custom_curl_timeout', 9999, 1);
function sar_custom_curl_timeout( $handle ){
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 30 ); // 30 seconds connection timeout.
curl_setopt( $handle, CURLOPT_TIMEOUT, 30 ); // 30 seconds total timeout.
}
add_filter( 'http_request_timeout', 'sar_custom_http_request_timeout', 9999 );
function sar_custom_http_request_timeout( $timeout_value ) {
return 30; // 30 seconds.
}
add_filter('http_request_args', 'sar_custom_http_request_args', 9999, 1);
function sar_custom_http_request_args( $r ){
$r['timeout'] = 30; // 30 seconds.
return $r;
}
// --- Tasty Recipes REST API Integration ---
function register_tasty_recipe_post_type_for_rest() { // Renamed slightly for clarity
// Ensure Tasty Recipes plugin handles the core registration.
// This part focuses on making sure REST API support is enabled if not already.
$post_type_object = get_post_type_object('tasty_recipe');
if ($post_type_object && empty($post_type_object->show_in_rest)) {
// If Tasty Recipes itself didn't register with show_in_rest=true, attempt to re-register.
// Note: This might conflict if Tasty Recipes updates its registration method. Ideally, Tasty Recipes enables REST API support itself.
$args = array(
'label' => __('Recipes', 'tasty-recipes'), // Use existing label
'public' => true,
'show_ui' => true,
'show_in_rest' => true, // Explicitly enable REST API
'hierarchical' => false,
'rewrite' => array('slug' => 'tasty_recipe'), // Use existing slug
'supports' => array('title', 'editor', 'thumbnail', 'custom-fields'), // Use existing supports
// Inherit other args from Tasty Recipes if possible, or define necessary ones.
);
register_post_type('tasty_recipe', $args);
}
}
// Run later in init to potentially override/ensure REST support if Tasty doesn't add it early.
add_action('init', 'register_tasty_recipe_post_type_for_rest', 20);
function register_tasty_custom_meta_fields_for_rest() { // Renamed for clarity
// List of meta fields used by Tasty Recipes that we need accessible via REST API
$tasty_meta_fields = [ // Renamed variable
'author_name', '_thumbnail_id', 'description', 'ingredients', 'instructions',
'notes', 'keywords', 'nutrifox_id', 'video_url', 'prep_time',
'additional_time_label', 'additional_time_value', 'cook_time', 'total_time', 'yield',
'category', 'method', 'cuisine', 'diet', 'serving_size',
'calories', 'sugar', 'sodium', 'fat', 'saturated_fat',
'unsaturated_fat', 'trans_fat', 'carbohydrates', 'fiber', 'protein',
'cholesterol', '_tasty_recipe_parents'
];
foreach ($tasty_meta_fields as $field) {
register_post_meta('tasty_recipe', $field, [
'show_in_rest' => true,
'single' => true,
'type' => 'string', // Default to string, adjust if specific fields need array/integer types
'auth_callback' => function() { return current_user_can('edit_posts'); }, // Basic auth check
]);
}
}
// Run after post type is likely registered
add_action('init', 'register_tasty_custom_meta_fields_for_rest', 25);
// --- Yoast & Rank Math SEO Meta REST API Integration ---
function sar_register_seo_meta_for_rest() {
// Define which post types need SEO meta access via REST API
$target_post_types = [
'post', // Standard Posts
// 'page', // Uncomment if needed for Pages
'tasty_recipe', // Ensure SEO meta can be set for recipes too
// Add other Custom Post Type slugs here if necessary
];
// Define common meta keys for Yoast SEO
$yoast_seo_meta_keys = [
'_yoast_wpseo_title', // SEO Title
'_yoast_wpseo_metadesc', // Meta Description
'_yoast_wpseo_focuskw', // Focus Keyphrase
// Add other Yoast keys like _yoast_wpseo_canonical, etc. if needed
];
// Define common meta keys for Rank Math
$rank_math_seo_meta_keys = [
'rank_math_title', // SEO Title
'rank_math_description', // Meta Description
'rank_math_focus_keyword', // Focus Keyword(s) (comma-separated string)
// Add other Rank Math keys like rank_math_canonical_url, rank_math_robots, etc. if needed
];
$all_seo_keys = array_merge($yoast_seo_meta_keys, $rank_math_seo_meta_keys);
foreach ($target_post_types as $post_type) {
if (post_type_exists($post_type)) { // Check if post type is actually registered
foreach ($all_seo_keys as $meta_key) {
register_post_meta($post_type, $meta_key, [
'show_in_rest' => true,
'single' => true,
'type' => 'string', // Most SEO fields are strings
'auth_callback' => function() use ($post_type) {
// More robust capability check based on post type object
$post_type_obj = get_post_type_object($post_type);
if (!$post_type_obj) return false;
// Check if user can edit posts of this specific type
return current_user_can($post_type_obj->cap->edit_posts);
// Fallback / simpler check: return current_user_can('edit_posts');
}
]);
}
}
}
}
// Run after post types are registered
add_action( 'init', 'sar_register_seo_meta_for_rest', 30 );
=======END OF SCRIPT=======
If you’re in search of a hearty and comforting meal that’s sure to please, look no further than Hamburger Steaks with Onion Gravy.
Ingredients
Scale
1 lb ground beef
1 egg
1/3 cup bread crumbs
1/2 tsp black pepper
1 tsp salt
1/2 tsp onion powder
1 clove garlic, minced
1 tsp Worcestershire sauce
1 tbsp oil
1 1/2 cups thinly sliced onion
2 tbsp all-purpose flour
1 cup beef broth
1/2 tsp salt
Instructions
Prepare the Hamburger Steaks: In a large bowl, combine the ground beef, egg, bread crumbs, black pepper, 1 tsp salt, onion powder, minced garlic, and Worcestershire sauce. Mix until well combined. Divide the mixture into 4 equal portions and shape them into patties. Cook the Hamburger Steaks: In a large skillet, heat the oil over medium-high heat. Add the hamburger patties and cook for 4-5 minutes on each side, or until browned and cooked through. Remove the patties from the skillet and set aside. Prepare the Onion Gravy: In the same skillet, add the thinly sliced onions and cook over medium heat until they are softened and caramelized, about 5-7 minutes. Sprinkle the flour over the onions and stir to coat evenly. Cook for 1-2 minutes to remove the raw flour taste. Gradually add the beef broth, stirring constantly to prevent lumps. Add the remaining 1/2 tsp salt and continue to cook until the gravy thickens, about 3-4 minutes. Combine and Serve: Return the cooked hamburger steaks to the skillet, nestling them into the onion gravy. Simmer for an additional 5 minutes to heat through and allow the flavors to meld. Serve the hamburger steaks hot, topped with the onion gravy. Enjoy your savory hamburger steaks with onion gravy!