maybe_upgrade(); } /** * Add manual regeneration button in post editor sidebar */ public function add_regenerate_button() { global $post; if (!$post) { return; } // Check if this post type is supported if (!$this->is_post_type_supported($post->post_type)) { return; } $already_generated = get_post_meta($post->ID, '_afi_robolly_generated', true); $generated_time = get_post_meta($post->ID, '_afi_robolly_generated_time', true); $has_thumbnail = has_post_thumbnail($post->ID); ?>
true], 'names'); foreach ($post_types as $post_type) { if ($this->is_post_type_supported($post_type)) { add_meta_box( 'afi_robolly_regenerate', 'AFI Robolly - Featured Image', array($this, 'render_regenerate_meta_box'), $post_type, 'side', 'low' ); } } } /** * Render the regenerate meta box */ public function render_regenerate_meta_box($post) { $already_generated = get_post_meta($post->ID, '_afi_robolly_generated', true); $generated_time = get_post_meta($post->ID, '_afi_robolly_generated_time', true); $has_thumbnail = has_post_thumbnail($post->ID); ?>AFI Robolly: Featured image regenerated successfully!
Enter your Robolly API Key. This is required for the plugin to function.
'; } public function api_key_field_callback() { $options = get_option($this->plugin_options_key); $api_key = isset($options['api_key']) ? $options['api_key'] : ''; ?> Configure how image metadata should be generated from post title.'; } public function generate_alt_field_callback() { $options = get_option($this->plugin_options_key); $generate_alt = isset($options['generate_alt']) ? $options['generate_alt'] : true; ?>Recommended for SEO and accessibility.
plugin_options_key); $generate_title = isset($options['generate_title']) ? $options['generate_title'] : true; ?> plugin_options_key); $generate_description = isset($options['generate_description']) ? $options['generate_description'] : true; ?> Configure which post types should have auto-generated featured images and their respective template IDs using Robolly.'; echo 'Note: Template IDs are specific to your Robolly account. Make sure to use valid template IDs from an active account
'; echo 'Post Image Extraction: Enable per post-type to use the first image from post content in your Robolly template.
'; echo 'Plugin by RuhaniRabin.com(MIT license). Donate if this helped you out.
'; } public function post_type_field_callback($args) { $defaults = $this->get_default_settings(); $options = get_option($this->plugin_options_key, $defaults); $post_type = $args['post_type']; $options[$post_type] = wp_parse_args($options[$post_type], array( 'enabled' => false, 'template_id' => '', 'use_post_image' => false, 'image_param_name' => 'image', 'min_image_width' => 600, 'trigger_on' => 'publish' // New option: 'publish' or 'save' )); $enabled = $options[$post_type]['enabled']; $template_id = $options[$post_type]['template_id']; $use_post_image = $options[$post_type]['use_post_image']; $image_param_name = $options[$post_type]['image_param_name']; $min_image_width = $options[$post_type]['min_image_width']; $trigger_on = $options[$post_type]['trigger_on']; ?>Choose when to automatically generate featured images. "On any save/update" will generate on manual saves, but only once per post.
Extract and send the first suitable image from post content to Robolly