post_type ) ? $post->post_type : '' ); if ( !$post_type ) { return; } if ( !in_array( $post_type, $the_types ) ) { return; } } // User Roles $user_roles = ai_tts_get_option( 'user_roles' ); $user_roles_to_enable = ai_tts_get_option( 'user_roles_to_enable' ); if ( $user_roles == 'specific' && !empty( $user_roles_to_enable ) ) { $current_user = wp_get_current_user(); $current_user_roles = $current_user->roles; $intersect = array_intersect( $current_user_roles, $user_roles_to_enable ); if ( empty( $intersect ) ) { return; } } // Add to post type: post add_meta_box( 'ai-tts-meta-box', esc_html__( 'AI TTS', 'ai-text-to-speech' ), 'ai_tts_meta_box_callback', 'post', 'side', 'low' ); // Add to all other post types $post_types = get_post_types( array( 'public' => true, ) ); foreach ( $post_types as $post_type ) { add_meta_box( 'ai-tts-meta-box', esc_html__( 'AI TTS', 'ai-text-to-speech' ), 'ai_tts_meta_box_callback', $post_type, 'side', 'low' ); } } /* * Meta box display callback * * @param WP_Post $post Current post object. */ function ai_tts_meta_box_callback( $post ) { $api_key = get_option( 'ai_tts_api_key' ); if ( !$api_key ) { echo '
' . esc_html__( 'Please enter your API key in the settings page.', 'ai-text-to-speech' ) . ' ' . esc_html__( 'Go to Settings', 'ai-text-to-speech' ) . '
'; return; } // Add a nonce field for security wp_nonce_field( 'ai_tts_save_meta_box_data', 'ai_tts_meta_box_nonce' ); ?> ID, 'ai_tts_file_url', true ); $tts_location = get_post_meta( $post->ID, 'ai_tts_location', true ); $is_local_storage = $tts_location === 'local' || $tts_location === ''; if ( $is_local_storage && $tts_file_url && !file_exists( str_replace( content_url(), WP_CONTENT_DIR, $tts_file_url ) ) ) { $tts_file_url = ''; delete_post_meta( $post->ID, 'ai_tts_file_url' ); delete_post_meta( $post->ID, 'ai_tts_file_name' ); delete_post_meta( $post->ID, 'ai_tts_location' ); } ?>ID, 'ai_tts_file_url', true ) ) { echo 'style="display: none;"'; } ?>>
ID, 'ai_tts_file_url', true ) ) { echo 'style="display: none;"'; } ?>>
is_paying_or_trial() ) { ?>style="pointer-events: none; opacity: 0.5;"> ID, 'ai_tts_customise', true ), 'on' ); ?> />
ID, 'ai_tts_file_url', true ) ) {
echo 'style="display: none;"';
}
?> style="margin: 0;">